From 8ad68bc20e851289a4ecd62e12ca78c6b3900a01 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Thu, 13 Jun 2024 09:15:10 -0500 Subject: [PATCH 01/49] feat: add address to service --- x/services/keeper/genesis_test.go | 6 ++++++ x/services/keeper/grpc_query_test.go | 9 +++++++++ x/services/keeper/invariants_test.go | 5 +++++ x/services/keeper/msg_server.go | 5 +++++ x/services/keeper/msg_server_test.go | 11 +++++++++++ x/services/keeper/services_test.go | 11 +++++++++++ 6 files changed, 47 insertions(+) diff --git a/x/services/keeper/genesis_test.go b/x/services/keeper/genesis_test.go index b0f614241..1f3cfb750 100644 --- a/x/services/keeper/genesis_test.go +++ b/x/services/keeper/genesis_test.go @@ -40,6 +40,7 @@ func (suite *KeeperTestSuite) TestKeeper_ExportGenesis() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), )) suite.k.SaveService(ctx, types.NewService( @@ -50,6 +51,7 @@ func (suite *KeeperTestSuite) TestKeeper_ExportGenesis() { "https://inertia.zone", "https://inertia.zone/logo.png", "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", + types.GetServiceAddress(2).String(), )) }, expGenesis: &types.GenesisState{ @@ -63,6 +65,7 @@ func (suite *KeeperTestSuite) TestKeeper_ExportGenesis() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), ), types.NewService( 2, @@ -72,6 +75,7 @@ func (suite *KeeperTestSuite) TestKeeper_ExportGenesis() { "https://inertia.zone", "https://inertia.zone/logo.png", "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", + types.GetServiceAddress(2).String(), ), }, Params: types.DefaultParams(), @@ -144,6 +148,7 @@ func (suite *KeeperTestSuite) TestKeeper_InitGenesis() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), ), }, types.DefaultParams(), @@ -164,6 +169,7 @@ func (suite *KeeperTestSuite) TestKeeper_InitGenesis() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), ), services[0]) }, }, diff --git a/x/services/keeper/grpc_query_test.go b/x/services/keeper/grpc_query_test.go index 2b83f1197..9e22b750d 100644 --- a/x/services/keeper/grpc_query_test.go +++ b/x/services/keeper/grpc_query_test.go @@ -27,6 +27,7 @@ func (suite *KeeperTestSuite) TestKeeper_Services() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), )) suite.Require().NoError(err) @@ -38,6 +39,7 @@ func (suite *KeeperTestSuite) TestKeeper_Services() { "https://inertia.zone", "https://inertia.zone/logo.png", "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", + types.GetServiceAddress(2).String(), )) suite.Require().NoError(err) }, @@ -52,6 +54,7 @@ func (suite *KeeperTestSuite) TestKeeper_Services() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), ), types.NewService( 2, @@ -61,6 +64,7 @@ func (suite *KeeperTestSuite) TestKeeper_Services() { "https://inertia.zone", "https://inertia.zone/logo.png", "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", + types.GetServiceAddress(2).String(), ), }, }, @@ -75,6 +79,7 @@ func (suite *KeeperTestSuite) TestKeeper_Services() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), )) suite.Require().NoError(err) @@ -86,6 +91,7 @@ func (suite *KeeperTestSuite) TestKeeper_Services() { "https://inertia.zone", "https://inertia.zone/logo.png", "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", + types.GetServiceAddress(2).String(), )) suite.Require().NoError(err) }, @@ -103,6 +109,7 @@ func (suite *KeeperTestSuite) TestKeeper_Services() { "https://inertia.zone", "https://inertia.zone/logo.png", "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", + types.GetServiceAddress(2).String(), ), }, }, @@ -156,6 +163,7 @@ func (suite *KeeperTestSuite) TestKeeper_Service() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), )) suite.Require().NoError(err) }, @@ -169,6 +177,7 @@ func (suite *KeeperTestSuite) TestKeeper_Service() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), ), }, } diff --git a/x/services/keeper/invariants_test.go b/x/services/keeper/invariants_test.go index f24a0017c..f2648171e 100644 --- a/x/services/keeper/invariants_test.go +++ b/x/services/keeper/invariants_test.go @@ -25,6 +25,7 @@ func (suite *KeeperTestSuite) TestValidServicesInvariant() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), )) }, expBroken: true, @@ -41,6 +42,7 @@ func (suite *KeeperTestSuite) TestValidServicesInvariant() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), )) }, expBroken: true, @@ -57,6 +59,7 @@ func (suite *KeeperTestSuite) TestValidServicesInvariant() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(2).String(), )) }, expBroken: true, @@ -73,6 +76,7 @@ func (suite *KeeperTestSuite) TestValidServicesInvariant() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), )) }, expBroken: true, @@ -89,6 +93,7 @@ func (suite *KeeperTestSuite) TestValidServicesInvariant() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), )) }, expBroken: false, diff --git a/x/services/keeper/msg_server.go b/x/services/keeper/msg_server.go index 6e3633f45..3b3348c1d 100644 --- a/x/services/keeper/msg_server.go +++ b/x/services/keeper/msg_server.go @@ -34,6 +34,10 @@ func (k msgServer) CreateService(goCtx context.Context, msg *types.MsgCreateServ return nil, err } + // Create the service account + serviceAddress := types.GetServiceAddress(serviceID) + k.createAccountIfNotExists(ctx, serviceAddress) + // Create the Service and validate it service := types.NewService( serviceID, @@ -43,6 +47,7 @@ func (k msgServer) CreateService(goCtx context.Context, msg *types.MsgCreateServ msg.Website, msg.PictureURL, msg.Sender, + serviceAddress.String(), ) // Validate the service before storing diff --git a/x/services/keeper/msg_server_test.go b/x/services/keeper/msg_server_test.go index 0fa9adc5f..bd04ea654 100644 --- a/x/services/keeper/msg_server_test.go +++ b/x/services/keeper/msg_server_test.go @@ -109,6 +109,7 @@ func (suite *KeeperTestSuite) TestMsgServer_CreateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), ), stored) // Make sure the service account has been created properly @@ -201,6 +202,7 @@ func (suite *KeeperTestSuite) TestMsgServer_UpdateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), )) }, msg: types.NewMsgUpdateService( @@ -224,6 +226,7 @@ func (suite *KeeperTestSuite) TestMsgServer_UpdateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), )) }, msg: types.NewMsgUpdateService( @@ -247,6 +250,7 @@ func (suite *KeeperTestSuite) TestMsgServer_UpdateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), )) }, msg: types.NewMsgUpdateService( @@ -277,6 +281,7 @@ func (suite *KeeperTestSuite) TestMsgServer_UpdateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), ), stored) }, }, @@ -346,6 +351,7 @@ func (suite *KeeperTestSuite) TestMsgServer_ActivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), )) }, msg: types.NewMsgActivateService( @@ -365,6 +371,7 @@ func (suite *KeeperTestSuite) TestMsgServer_ActivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), )) }, msg: types.NewMsgActivateService( @@ -384,6 +391,7 @@ func (suite *KeeperTestSuite) TestMsgServer_ActivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), )) }, msg: types.NewMsgActivateService( @@ -466,6 +474,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DeactivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), )) }, msg: types.NewMsgDeactivateService( @@ -485,6 +494,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DeactivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), )) }, msg: types.NewMsgDeactivateService( @@ -511,6 +521,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DeactivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), ), stored) }, }, diff --git a/x/services/keeper/services_test.go b/x/services/keeper/services_test.go index 658796c48..11236e30a 100644 --- a/x/services/keeper/services_test.go +++ b/x/services/keeper/services_test.go @@ -124,6 +124,7 @@ func (suite *KeeperTestSuite) TestKeeper_CreateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), ), shouldErr: true, }, @@ -147,6 +148,7 @@ func (suite *KeeperTestSuite) TestKeeper_CreateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), ), shouldErr: false, check: func(ctx sdk.Context) { @@ -176,6 +178,7 @@ func (suite *KeeperTestSuite) TestKeeper_CreateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), ), service) // Make sure the hook was called @@ -234,6 +237,7 @@ func (suite *KeeperTestSuite) TestKeeper_ActivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), )) }, serviceID: 1, @@ -250,6 +254,7 @@ func (suite *KeeperTestSuite) TestKeeper_ActivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), )) }, serviceID: 1, @@ -265,6 +270,7 @@ func (suite *KeeperTestSuite) TestKeeper_ActivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), ), service) // Make sure the hook was called @@ -323,6 +329,7 @@ func (suite *KeeperTestSuite) TestKeeper_DeactivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), )) }, serviceID: 1, @@ -339,6 +346,7 @@ func (suite *KeeperTestSuite) TestKeeper_DeactivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), )) }, serviceID: 1, @@ -354,6 +362,7 @@ func (suite *KeeperTestSuite) TestKeeper_DeactivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), ), service) // Make sure the hook was called @@ -411,6 +420,7 @@ func (suite *KeeperTestSuite) TestKeeper_GetService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), )) }, serviceID: 1, @@ -423,6 +433,7 @@ func (suite *KeeperTestSuite) TestKeeper_GetService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + types.GetServiceAddress(1).String(), ), }, } From b10d87d95291a44a99eabb0c490574b61d0e2ede Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Mon, 3 Jun 2024 04:55:17 -0500 Subject: [PATCH 02/49] chore: run code linting --- .../tokenfactory/v1/authorityMetadata.pulsar.go | 9 +++++---- api/milkyway/tokenfactory/v1/genesis.pulsar.go | 7 ++++--- api/milkyway/tokenfactory/v1/params.pulsar.go | 9 +++++---- api/milkyway/tokenfactory/v1/query.pulsar.go | 9 +++++---- api/milkyway/tokenfactory/v1/tx.pulsar.go | 9 +++++---- api/stride/epochs/genesis.pulsar.go | 7 ++++--- api/stride/epochs/query.pulsar.go | 9 +++++---- api/stride/icacallbacks/callback_data.pulsar.go | 7 ++++--- api/stride/icacallbacks/genesis.pulsar.go | 7 ++++--- api/stride/icacallbacks/packet.pulsar.go | 7 ++++--- api/stride/icacallbacks/params.pulsar.go | 7 ++++--- api/stride/icacallbacks/query.pulsar.go | 9 +++++---- api/stride/icacallbacks/tx.pulsar.go | 3 ++- api/stride/interchainquery/v1/genesis.pulsar.go | 7 ++++--- api/stride/interchainquery/v1/messages.pulsar.go | 9 +++++---- api/stride/interchainquery/v1/query.pulsar.go | 7 ++++--- api/stride/records/callbacks.pulsar.go | 7 ++++--- api/stride/records/genesis.pulsar.go | 7 ++++--- api/stride/records/params.pulsar.go | 7 ++++--- api/stride/records/query.pulsar.go | 9 +++++---- api/stride/records/records.pulsar.go | 9 +++++---- api/stride/stakeibc/address_unbonding.pulsar.go | 7 ++++--- api/stride/stakeibc/callbacks.pulsar.go | 12 +++++++----- api/stride/stakeibc/epoch_tracker.pulsar.go | 7 ++++--- api/stride/stakeibc/genesis.pulsar.go | 7 ++++--- api/stride/stakeibc/gov.pulsar.go | 7 ++++--- api/stride/stakeibc/host_zone.pulsar.go | 7 ++++--- api/stride/stakeibc/ica_account.pulsar.go | 7 ++++--- api/stride/stakeibc/packet.pulsar.go | 7 ++++--- api/stride/stakeibc/params.pulsar.go | 7 ++++--- api/stride/stakeibc/query.pulsar.go | 9 +++++---- api/stride/stakeibc/trade_route.pulsar.go | 9 +++++---- api/stride/stakeibc/tx.pulsar.go | 11 ++++++----- api/stride/stakeibc/validator.pulsar.go | 7 ++++--- 34 files changed, 150 insertions(+), 115 deletions(-) diff --git a/api/milkyway/tokenfactory/v1/authorityMetadata.pulsar.go b/api/milkyway/tokenfactory/v1/authorityMetadata.pulsar.go index 505676642..a009ba879 100644 --- a/api/milkyway/tokenfactory/v1/authorityMetadata.pulsar.go +++ b/api/milkyway/tokenfactory/v1/authorityMetadata.pulsar.go @@ -2,16 +2,17 @@ package tokenfactoryv1 import ( - _ "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + + _ "cosmossdk.io/api/cosmos/base/v1beta1" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/milkyway/tokenfactory/v1/genesis.pulsar.go b/api/milkyway/tokenfactory/v1/genesis.pulsar.go index f6d221ccc..560a3c478 100644 --- a/api/milkyway/tokenfactory/v1/genesis.pulsar.go +++ b/api/milkyway/tokenfactory/v1/genesis.pulsar.go @@ -3,14 +3,15 @@ package tokenfactoryv1 import ( fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var _ protoreflect.List = (*_GenesisState_2_list)(nil) diff --git a/api/milkyway/tokenfactory/v1/params.pulsar.go b/api/milkyway/tokenfactory/v1/params.pulsar.go index 9fb043cc9..25b473890 100644 --- a/api/milkyway/tokenfactory/v1/params.pulsar.go +++ b/api/milkyway/tokenfactory/v1/params.pulsar.go @@ -2,17 +2,18 @@ package tokenfactoryv1 import ( - v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var _ protoreflect.List = (*_Params_1_list)(nil) diff --git a/api/milkyway/tokenfactory/v1/query.pulsar.go b/api/milkyway/tokenfactory/v1/query.pulsar.go index 0c9eb68b5..825a7fa7a 100644 --- a/api/milkyway/tokenfactory/v1/query.pulsar.go +++ b/api/milkyway/tokenfactory/v1/query.pulsar.go @@ -2,17 +2,18 @@ package tokenfactoryv1 import ( - _ "cosmossdk.io/api/cosmos/base/query/v1beta1" fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + + _ "cosmossdk.io/api/cosmos/base/query/v1beta1" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/milkyway/tokenfactory/v1/tx.pulsar.go b/api/milkyway/tokenfactory/v1/tx.pulsar.go index d7b14ddf1..4e581e259 100644 --- a/api/milkyway/tokenfactory/v1/tx.pulsar.go +++ b/api/milkyway/tokenfactory/v1/tx.pulsar.go @@ -2,20 +2,21 @@ package tokenfactoryv1 import ( + fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + _ "cosmossdk.io/api/amino" v1beta11 "cosmossdk.io/api/cosmos/bank/v1beta1" v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" _ "cosmossdk.io/api/cosmos/msg/v1" - fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/stride/epochs/genesis.pulsar.go b/api/stride/epochs/genesis.pulsar.go index a98391993..a9a11b3c4 100644 --- a/api/stride/epochs/genesis.pulsar.go +++ b/api/stride/epochs/genesis.pulsar.go @@ -3,6 +3,10 @@ package epochs import ( fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -10,9 +14,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" durationpb "google.golang.org/protobuf/types/known/durationpb" timestamppb "google.golang.org/protobuf/types/known/timestamppb" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/stride/epochs/query.pulsar.go b/api/stride/epochs/query.pulsar.go index 77f055a53..6e0206d2b 100644 --- a/api/stride/epochs/query.pulsar.go +++ b/api/stride/epochs/query.pulsar.go @@ -2,17 +2,18 @@ package epochs import ( - v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + + v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/stride/icacallbacks/callback_data.pulsar.go b/api/stride/icacallbacks/callback_data.pulsar.go index 246763625..62fcf9509 100644 --- a/api/stride/icacallbacks/callback_data.pulsar.go +++ b/api/stride/icacallbacks/callback_data.pulsar.go @@ -3,13 +3,14 @@ package icacallbacks import ( fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + runtime "github.com/cosmos/cosmos-proto/runtime" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/stride/icacallbacks/genesis.pulsar.go b/api/stride/icacallbacks/genesis.pulsar.go index 8143181c5..e8a0b8d77 100644 --- a/api/stride/icacallbacks/genesis.pulsar.go +++ b/api/stride/icacallbacks/genesis.pulsar.go @@ -3,14 +3,15 @@ package icacallbacks import ( fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var _ protoreflect.List = (*_GenesisState_3_list)(nil) diff --git a/api/stride/icacallbacks/packet.pulsar.go b/api/stride/icacallbacks/packet.pulsar.go index dc77eb267..c223b438f 100644 --- a/api/stride/icacallbacks/packet.pulsar.go +++ b/api/stride/icacallbacks/packet.pulsar.go @@ -3,13 +3,14 @@ package icacallbacks import ( fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + runtime "github.com/cosmos/cosmos-proto/runtime" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/stride/icacallbacks/params.pulsar.go b/api/stride/icacallbacks/params.pulsar.go index e542245b7..83998d1e8 100644 --- a/api/stride/icacallbacks/params.pulsar.go +++ b/api/stride/icacallbacks/params.pulsar.go @@ -3,14 +3,15 @@ package icacallbacks import ( fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/stride/icacallbacks/query.pulsar.go b/api/stride/icacallbacks/query.pulsar.go index 7e5f369d8..a2d2e23fd 100644 --- a/api/stride/icacallbacks/query.pulsar.go +++ b/api/stride/icacallbacks/query.pulsar.go @@ -2,17 +2,18 @@ package icacallbacks import ( - v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + + v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/stride/icacallbacks/tx.pulsar.go b/api/stride/icacallbacks/tx.pulsar.go index 532e52e67..9965955d0 100644 --- a/api/stride/icacallbacks/tx.pulsar.go +++ b/api/stride/icacallbacks/tx.pulsar.go @@ -2,10 +2,11 @@ package icacallbacks import ( + reflect "reflect" + _ "cosmossdk.io/api/cosmos/msg/v1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" ) // Code generated by protoc-gen-go. DO NOT EDIT. diff --git a/api/stride/interchainquery/v1/genesis.pulsar.go b/api/stride/interchainquery/v1/genesis.pulsar.go index 092b7a51d..7371b4859 100644 --- a/api/stride/interchainquery/v1/genesis.pulsar.go +++ b/api/stride/interchainquery/v1/genesis.pulsar.go @@ -3,6 +3,10 @@ package interchainqueryv1 import ( fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" @@ -10,9 +14,6 @@ import ( protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" durationpb "google.golang.org/protobuf/types/known/durationpb" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/stride/interchainquery/v1/messages.pulsar.go b/api/stride/interchainquery/v1/messages.pulsar.go index 3ba0b9a9b..034408663 100644 --- a/api/stride/interchainquery/v1/messages.pulsar.go +++ b/api/stride/interchainquery/v1/messages.pulsar.go @@ -2,10 +2,14 @@ package interchainqueryv1 import ( + fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + _ "cosmossdk.io/api/amino" _ "cosmossdk.io/api/cosmos/msg/v1" crypto "cosmossdk.io/api/tendermint/crypto" - fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" @@ -13,9 +17,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/stride/interchainquery/v1/query.pulsar.go b/api/stride/interchainquery/v1/query.pulsar.go index 094c70795..58db67146 100644 --- a/api/stride/interchainquery/v1/query.pulsar.go +++ b/api/stride/interchainquery/v1/query.pulsar.go @@ -3,15 +3,16 @@ package interchainqueryv1 import ( fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/stride/records/callbacks.pulsar.go b/api/stride/records/callbacks.pulsar.go index 691cff99b..524ac9749 100644 --- a/api/stride/records/callbacks.pulsar.go +++ b/api/stride/records/callbacks.pulsar.go @@ -3,13 +3,14 @@ package records import ( fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + runtime "github.com/cosmos/cosmos-proto/runtime" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/stride/records/genesis.pulsar.go b/api/stride/records/genesis.pulsar.go index a34e9b821..842ebe4cb 100644 --- a/api/stride/records/genesis.pulsar.go +++ b/api/stride/records/genesis.pulsar.go @@ -3,14 +3,15 @@ package records import ( fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var _ protoreflect.List = (*_GenesisState_3_list)(nil) diff --git a/api/stride/records/params.pulsar.go b/api/stride/records/params.pulsar.go index 47d1a72a1..b1a3b5e84 100644 --- a/api/stride/records/params.pulsar.go +++ b/api/stride/records/params.pulsar.go @@ -3,13 +3,14 @@ package records import ( fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + runtime "github.com/cosmos/cosmos-proto/runtime" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/stride/records/query.pulsar.go b/api/stride/records/query.pulsar.go index 76ab4571d..dd1f49c8a 100644 --- a/api/stride/records/query.pulsar.go +++ b/api/stride/records/query.pulsar.go @@ -2,17 +2,18 @@ package records import ( - v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + + v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/stride/records/records.pulsar.go b/api/stride/records/records.pulsar.go index 20149c17e..ba73822f4 100644 --- a/api/stride/records/records.pulsar.go +++ b/api/stride/records/records.pulsar.go @@ -2,16 +2,17 @@ package records import ( - v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/stride/stakeibc/address_unbonding.pulsar.go b/api/stride/stakeibc/address_unbonding.pulsar.go index cd5057c2e..110ab9e14 100644 --- a/api/stride/stakeibc/address_unbonding.pulsar.go +++ b/api/stride/stakeibc/address_unbonding.pulsar.go @@ -3,14 +3,15 @@ package stakeibc import ( fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/stride/stakeibc/callbacks.pulsar.go b/api/stride/stakeibc/callbacks.pulsar.go index 61be3c8e9..a02d3ed57 100644 --- a/api/stride/stakeibc/callbacks.pulsar.go +++ b/api/stride/stakeibc/callbacks.pulsar.go @@ -2,17 +2,19 @@ package stakeibc import ( - v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" - records "github.com/milkyway-labs/milkyway/api/stride/records" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" + + records "github.com/milkyway-labs/milkyway/api/stride/records" ) var ( diff --git a/api/stride/stakeibc/epoch_tracker.pulsar.go b/api/stride/stakeibc/epoch_tracker.pulsar.go index da6961c6b..28f01c8d9 100644 --- a/api/stride/stakeibc/epoch_tracker.pulsar.go +++ b/api/stride/stakeibc/epoch_tracker.pulsar.go @@ -3,13 +3,14 @@ package stakeibc import ( fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + runtime "github.com/cosmos/cosmos-proto/runtime" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/stride/stakeibc/genesis.pulsar.go b/api/stride/stakeibc/genesis.pulsar.go index 29d5aecf8..c4c43d3b8 100644 --- a/api/stride/stakeibc/genesis.pulsar.go +++ b/api/stride/stakeibc/genesis.pulsar.go @@ -3,14 +3,15 @@ package stakeibc import ( fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var _ protoreflect.List = (*_GenesisState_5_list)(nil) diff --git a/api/stride/stakeibc/gov.pulsar.go b/api/stride/stakeibc/gov.pulsar.go index 1392138a4..3fe0b232d 100644 --- a/api/stride/stakeibc/gov.pulsar.go +++ b/api/stride/stakeibc/gov.pulsar.go @@ -3,14 +3,15 @@ package stakeibc import ( fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var _ protoreflect.List = (*_AddValidatorsProposal_4_list)(nil) diff --git a/api/stride/stakeibc/host_zone.pulsar.go b/api/stride/stakeibc/host_zone.pulsar.go index b28ec5b08..edbe6683e 100644 --- a/api/stride/stakeibc/host_zone.pulsar.go +++ b/api/stride/stakeibc/host_zone.pulsar.go @@ -3,15 +3,16 @@ package stakeibc import ( fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/stride/stakeibc/ica_account.pulsar.go b/api/stride/stakeibc/ica_account.pulsar.go index 238c790d6..7230dd817 100644 --- a/api/stride/stakeibc/ica_account.pulsar.go +++ b/api/stride/stakeibc/ica_account.pulsar.go @@ -3,13 +3,14 @@ package stakeibc import ( fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + runtime "github.com/cosmos/cosmos-proto/runtime" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/stride/stakeibc/packet.pulsar.go b/api/stride/stakeibc/packet.pulsar.go index e5b966a85..16132f276 100644 --- a/api/stride/stakeibc/packet.pulsar.go +++ b/api/stride/stakeibc/packet.pulsar.go @@ -3,13 +3,14 @@ package stakeibc import ( fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + runtime "github.com/cosmos/cosmos-proto/runtime" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/stride/stakeibc/params.pulsar.go b/api/stride/stakeibc/params.pulsar.go index 754db6f24..92d5c2c61 100644 --- a/api/stride/stakeibc/params.pulsar.go +++ b/api/stride/stakeibc/params.pulsar.go @@ -3,14 +3,15 @@ package stakeibc import ( fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/stride/stakeibc/query.pulsar.go b/api/stride/stakeibc/query.pulsar.go index fa8b7cf17..b3fdc6d46 100644 --- a/api/stride/stakeibc/query.pulsar.go +++ b/api/stride/stakeibc/query.pulsar.go @@ -2,17 +2,18 @@ package stakeibc import ( - v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + + v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( diff --git a/api/stride/stakeibc/trade_route.pulsar.go b/api/stride/stakeibc/trade_route.pulsar.go index b563d8f34..2dc4471e1 100644 --- a/api/stride/stakeibc/trade_route.pulsar.go +++ b/api/stride/stakeibc/trade_route.pulsar.go @@ -3,15 +3,16 @@ package stakeibc import ( fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( @@ -2010,7 +2011,7 @@ func (x *TradeConfig) GetMaxSwapAmount() string { // the swap. It makes the assumption that the reward token is always foreign to // the host so therefore the first two hops are to unwind the ibc denom enroute // to the trade chain and the last hop is the return so funds start/end in the -// withdrawl ICA on hostZone +// withdrawal ICA on hostZone // The structure is key'd on reward denom and host denom in their native forms // (i.e. reward_denom_on_reward_zone and host_denom_on_host_zone) type TradeRoute struct { diff --git a/api/stride/stakeibc/tx.pulsar.go b/api/stride/stakeibc/tx.pulsar.go index 21516c666..e653db619 100644 --- a/api/stride/stakeibc/tx.pulsar.go +++ b/api/stride/stakeibc/tx.pulsar.go @@ -2,19 +2,20 @@ package stakeibc import ( + fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + _ "cosmossdk.io/api/amino" v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" _ "cosmossdk.io/api/cosmos/msg/v1" - fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( @@ -23469,7 +23470,7 @@ type MsgSetCommunityPoolRebate struct { ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Rebate percentage represented as a decimal (e.g. 0.2 for 20%) RebateRate string `protobuf:"bytes,3,opt,name=rebate_rate,json=rebateRate,proto3" json:"rebate_rate,omitempty"` - // Number of stTokens recieved by the community pool after liquid staking + // Number of stTokens received by the community pool after liquid staking LiquidStakedStTokenAmount string `protobuf:"bytes,4,opt,name=liquid_staked_st_token_amount,json=liquidStakedStTokenAmount,proto3" json:"liquid_staked_st_token_amount,omitempty"` } diff --git a/api/stride/stakeibc/validator.pulsar.go b/api/stride/stakeibc/validator.pulsar.go index ea56baf1d..edd9caf60 100644 --- a/api/stride/stakeibc/validator.pulsar.go +++ b/api/stride/stakeibc/validator.pulsar.go @@ -3,15 +3,16 @@ package stakeibc import ( fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" ) var ( From 0eb02da6cd36da674af1e0eb99142756f79e7af5 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Mon, 3 Jun 2024 04:55:27 -0500 Subject: [PATCH 03/49] feat: add Proto files --- proto/milkyway/avs/v1/genesis.proto | 20 ++++++++++ proto/milkyway/avs/v1/models.proto | 15 ++++++++ proto/milkyway/avs/v1/params.proto | 21 ++++++++++ proto/milkyway/avs/v1/query.proto | 47 +++++++++++++++++++++++ proto/milkyway/avs/v1/tx.proto | 59 +++++++++++++++++++++++++++++ 5 files changed, 162 insertions(+) create mode 100644 proto/milkyway/avs/v1/genesis.proto create mode 100644 proto/milkyway/avs/v1/models.proto create mode 100644 proto/milkyway/avs/v1/params.proto create mode 100644 proto/milkyway/avs/v1/query.proto create mode 100644 proto/milkyway/avs/v1/tx.proto diff --git a/proto/milkyway/avs/v1/genesis.proto b/proto/milkyway/avs/v1/genesis.proto new file mode 100644 index 000000000..67d5f22ae --- /dev/null +++ b/proto/milkyway/avs/v1/genesis.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; +package milkyway.avs.v1; + +import "gogoproto/gogo.proto"; +import "milkyway/avs/v1/models.proto"; +import "milkyway/avs/v1/params.proto"; + +option go_package = "github.com/milkyway-labs/milkyway/x/avs/types"; + +// GenesisState defines the avs module's genesis state. +message GenesisState { + // Params defines the parameters of the module. + Params params = 1 [ (gogoproto.nullable) = false ]; + + // Services defines the list of actively validated services. + repeated AVS services = 2 [ + (gogoproto.moretags) = "yaml:\"services\"", + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/proto/milkyway/avs/v1/models.proto b/proto/milkyway/avs/v1/models.proto new file mode 100644 index 000000000..fe16d81fc --- /dev/null +++ b/proto/milkyway/avs/v1/models.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package milkyway.avs.v1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/milkyway-labs/milkyway/x/avs/types"; + +// AVS defines the fields of an AVS +message AVS { + // ID is the auto-generated unique identifier for the AVS + uint64 id = 1 [ (gogoproto.customname) = "ID" ]; + + // Name is the name of the AVS + string name = 2; +} diff --git a/proto/milkyway/avs/v1/params.proto b/proto/milkyway/avs/v1/params.proto new file mode 100644 index 000000000..b8b23d783 --- /dev/null +++ b/proto/milkyway/avs/v1/params.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; +package milkyway.avs.v1; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/milkyway-labs/milkyway/x/avs/types"; + +// Params defines the parameters for the avs module. +message Params { + + // AvsCreationFee defines the fee to register a new AVS. The fee is + // drawn from the MsgRegisterAVS creator's account, and transferred + // to the community pool. + repeated cosmos.base.v1beta1.Coin avs_registration_fee = 1 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"avs_registration_fee\"", + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/proto/milkyway/avs/v1/query.proto b/proto/milkyway/avs/v1/query.proto new file mode 100644 index 000000000..5624b026c --- /dev/null +++ b/proto/milkyway/avs/v1/query.proto @@ -0,0 +1,47 @@ +syntax = "proto3"; +package milkyway.avs.v1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "milkyway/avs/v1/models.proto"; +import "milkyway/avs/v1/params.proto"; + +option go_package = "github.com/milkyway-labs/milkyway/x/avs/types"; + +// Query defines the gRPC querier service. +service Query { + // Params defines a gRPC query method that returns the parameters of the + // module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/milkyway/avs/v1/params"; + } + + // Services defines a gRPC query method that returns the actively validates + // services currently registered in the module. + rpc Services(QueryServicesRequest) returns (QueryServicesResponse) { + option (google.api.http).get = "/milkyway/avs/v1/services"; + } +} + +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryParamsResponse { + Params params = 1 [ (gogoproto.nullable) = false ]; +} + +// QueryServicesRequest is the request type for the Query/Services RPC method. +message QueryServicesRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryServicesResponse is the response type for the Query/Services RPC method. +message QueryServicesResponse { + // AVS services defines the list of actively validates services + repeated AVS services = 1 [ (gogoproto.nullable) = false ]; + + // Pagination defines the pagination response + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} diff --git a/proto/milkyway/avs/v1/tx.proto b/proto/milkyway/avs/v1/tx.proto new file mode 100644 index 000000000..3bf398d93 --- /dev/null +++ b/proto/milkyway/avs/v1/tx.proto @@ -0,0 +1,59 @@ +syntax = "proto3"; +package milkyway.avs.v1; + +import "amino/amino.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/bank/v1beta1/bank.proto"; +import "cosmos/msg/v1/msg.proto"; +import "gogoproto/gogo.proto"; +import "milkyway/avs/v1/params.proto"; + +option go_package = "github.com/milkyway-labs/milkyway/x/avs/types"; + +// Msg defines the avs module's gRPC message service. +service Msg { + option (cosmos.msg.v1.service) = true; + + rpc RegisterAVS(MsgRegisterAVS) returns (MsgRegisterAVSResponse); + rpc DeregisterAVS(MsgDeregisterAVS) returns (MsgDeregisterAVSResponse); +} + +// MsgRegisterAVSResponse defines the message structure for the RegisterAVS +// gRPC service method. It allows an account to register a new AVS that later on +// operators can opt to validate. It requires a sender address as well as the +// details of the AVS to be register. +message MsgRegisterAVS { + option (cosmos.msg.v1.signer) = "sender"; + option (amino.name) = "avs/MsgRegisterAVS"; + + // Sender is the address of the user registering the AVS + string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + // Name is the name of the AVS + string name = 2 [ (gogoproto.moretags) = "yaml:\"name\"" ]; +} + +// MsgRegisterAVSResponse is the return value of MsgRegisterAVS. +// It returns the newly created AVS ID. +message MsgRegisterAVSResponse { + // NewAVSID is the ID of the newly registered AVS + uint64 new_avs_id = 1 [ (gogoproto.customname) = "NewAVSID" ]; +} + +// MsgDeregisterAVS defines the message structure for the DeregisterAVS gRPC +// service method. It allows the AVS owner to deregister their AVS so that +// operators know that they can safely stop validating it. +message MsgDeregisterAVS { + option (cosmos.msg.v1.signer) = "sender"; + option (amino.name) = "avs/MsgDeregisterAVS"; + + // Sender is the address of the user deregistering the AVS + string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + // AVSID is the ID of the AVS to be deregistered + uint64 avs_id = 2 [ (gogoproto.customname) = "AVSID" ]; +} + +// MsgDeregisterAVSResponse is the return value of MsgDeregisterAVS. +message MsgDeregisterAVSResponse {} \ No newline at end of file From 54a8e906039c3eb7df70ccc6e74c782093e3ee55 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Mon, 3 Jun 2024 08:44:19 -0500 Subject: [PATCH 04/49] chore: generate Proto implementations --- x/avs/types/genesis.pb.go | 388 ++++++++++++++ x/avs/types/models.pb.go | 355 +++++++++++++ x/avs/types/params.pb.go | 341 ++++++++++++ x/avs/types/query.pb.go | 1011 ++++++++++++++++++++++++++++++++++++ x/avs/types/query.pb.gw.go | 236 +++++++++ x/avs/types/tx.pb.go | 1005 +++++++++++++++++++++++++++++++++++ 6 files changed, 3336 insertions(+) create mode 100644 x/avs/types/genesis.pb.go create mode 100644 x/avs/types/models.pb.go create mode 100644 x/avs/types/params.pb.go create mode 100644 x/avs/types/query.pb.go create mode 100644 x/avs/types/query.pb.gw.go create mode 100644 x/avs/types/tx.pb.go diff --git a/x/avs/types/genesis.pb.go b/x/avs/types/genesis.pb.go new file mode 100644 index 000000000..23555b17f --- /dev/null +++ b/x/avs/types/genesis.pb.go @@ -0,0 +1,388 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: milkyway/avs/v1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/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 avs module's genesis state. +type GenesisState struct { + // Params defines the parameters of the module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + // Services defines the list of actively validated services. + Services []AVS `protobuf:"bytes,2,rep,name=services,proto3" json:"services" yaml:"services"` +} + +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_e9762187afdc6843, []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 (m *GenesisState) GetServices() []AVS { + if m != nil { + return m.Services + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "milkyway.avs.v1.GenesisState") +} + +func init() { proto.RegisterFile("milkyway/avs/v1/genesis.proto", fileDescriptor_e9762187afdc6843) } + +var fileDescriptor_e9762187afdc6843 = []byte{ + // 251 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcd, 0xcd, 0xcc, 0xc9, + 0xae, 0x2c, 0x4f, 0xac, 0xd4, 0x4f, 0x2c, 0x2b, 0xd6, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, + 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0x49, 0xeb, 0x25, 0x96, + 0x15, 0xeb, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xe5, 0xf4, 0x41, 0x2c, 0x88, + 0x32, 0x29, 0x19, 0x74, 0x53, 0x72, 0xf3, 0x53, 0x52, 0x73, 0x8a, 0x71, 0xc9, 0x16, 0x24, 0x16, + 0x25, 0xe6, 0x42, 0x65, 0x95, 0x26, 0x30, 0x72, 0xf1, 0xb8, 0x43, 0x2c, 0x0d, 0x2e, 0x49, 0x2c, + 0x49, 0x15, 0x32, 0xe5, 0x62, 0x83, 0x28, 0x90, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x36, 0x12, 0xd7, + 0x43, 0x73, 0x84, 0x5e, 0x00, 0x58, 0xda, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x62, + 0x21, 0x4f, 0x2e, 0x8e, 0xe2, 0xd4, 0xa2, 0xb2, 0xcc, 0xe4, 0xd4, 0x62, 0x09, 0x26, 0x05, 0x66, + 0x0d, 0x6e, 0x23, 0x11, 0x0c, 0x8d, 0x8e, 0x61, 0xc1, 0x4e, 0xe2, 0x20, 0x5d, 0x9f, 0xee, 0xc9, + 0xf3, 0x57, 0x26, 0xe6, 0xe6, 0x58, 0x29, 0xc1, 0xf4, 0x28, 0x05, 0xc1, 0xb5, 0x3b, 0xb9, 0x9f, + 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, 0x6e, 0x7a, 0x66, 0x49, 0x46, 0x69, + 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xcc, 0x70, 0xdd, 0x9c, 0xc4, 0xa4, 0x62, 0x38, 0x4f, 0xbf, + 0x02, 0xec, 0xcb, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x17, 0x8d, 0x01, 0x01, 0x00, + 0x00, 0xff, 0xff, 0x37, 0xb7, 0xfb, 0x2f, 0x66, 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 + if len(m.Services) > 0 { + for iNdEx := len(m.Services) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Services[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + { + 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)) + if len(m.Services) > 0 { + for _, e := range m.Services { + l = e.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 + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Services", 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 + } + m.Services = append(m.Services, AVS{}) + if err := m.Services[len(m.Services)-1].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/avs/types/models.pb.go b/x/avs/types/models.pb.go new file mode 100644 index 000000000..0422c13d0 --- /dev/null +++ b/x/avs/types/models.pb.go @@ -0,0 +1,355 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: milkyway/avs/v1/models.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/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 + +// AVS defines the fields of an AVS +type AVS struct { + // ID is the auto-generated unique identifier for the AVS + ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // Name is the name of the AVS + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` +} + +func (m *AVS) Reset() { *m = AVS{} } +func (m *AVS) String() string { return proto.CompactTextString(m) } +func (*AVS) ProtoMessage() {} +func (*AVS) Descriptor() ([]byte, []int) { + return fileDescriptor_85e2c65ca3819b2c, []int{0} +} +func (m *AVS) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AVS) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AVS.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 *AVS) XXX_Merge(src proto.Message) { + xxx_messageInfo_AVS.Merge(m, src) +} +func (m *AVS) XXX_Size() int { + return m.Size() +} +func (m *AVS) XXX_DiscardUnknown() { + xxx_messageInfo_AVS.DiscardUnknown(m) +} + +var xxx_messageInfo_AVS proto.InternalMessageInfo + +func (m *AVS) GetID() uint64 { + if m != nil { + return m.ID + } + return 0 +} + +func (m *AVS) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func init() { + proto.RegisterType((*AVS)(nil), "milkyway.avs.v1.AVS") +} + +func init() { proto.RegisterFile("milkyway/avs/v1/models.proto", fileDescriptor_85e2c65ca3819b2c) } + +var fileDescriptor_85e2c65ca3819b2c = []byte{ + // 189 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc9, 0xcd, 0xcc, 0xc9, + 0xae, 0x2c, 0x4f, 0xac, 0xd4, 0x4f, 0x2c, 0x2b, 0xd6, 0x2f, 0x33, 0xd4, 0xcf, 0xcd, 0x4f, 0x49, + 0xcd, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0xc9, 0xea, 0x25, 0x96, 0x15, + 0xeb, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xe5, 0xf4, 0x41, 0x2c, 0x88, 0x32, + 0x25, 0x43, 0x2e, 0x66, 0xc7, 0xb0, 0x60, 0x21, 0x31, 0x2e, 0xa6, 0xcc, 0x14, 0x09, 0x46, 0x05, + 0x46, 0x0d, 0x16, 0x27, 0xb6, 0x47, 0xf7, 0xe4, 0x99, 0x3c, 0x5d, 0x82, 0x98, 0x32, 0x53, 0x84, + 0x84, 0xb8, 0x58, 0xf2, 0x12, 0x73, 0x53, 0x25, 0x98, 0x14, 0x18, 0x35, 0x38, 0x83, 0xc0, 0x6c, + 0x27, 0xf7, 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, 0x4d, 0xcf, 0x2c, + 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x59, 0xaf, 0x9b, 0x93, 0x98, 0x54, 0x0c, + 0xe7, 0xe9, 0x57, 0x80, 0x1d, 0x5b, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x76, 0x82, 0x31, + 0x20, 0x00, 0x00, 0xff, 0xff, 0xd9, 0xe5, 0x4f, 0x6c, 0xc9, 0x00, 0x00, 0x00, +} + +func (m *AVS) 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 *AVS) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintModels(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if m.ID != 0 { + i = encodeVarintModels(dAtA, i, uint64(m.ID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintModels(dAtA []byte, offset int, v uint64) int { + offset -= sovModels(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *AVS) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ID != 0 { + n += 1 + sovModels(uint64(m.ID)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovModels(uint64(l)) + } + return n +} + +func sovModels(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozModels(x uint64) (n int) { + return sovModels(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *AVS) 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 ErrIntOverflowModels + } + 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: AVS: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AVS: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + 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 ErrInvalidLengthModels + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModels + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipModels(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthModels + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipModels(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, ErrIntOverflowModels + } + 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, ErrIntOverflowModels + } + 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, ErrIntOverflowModels + } + 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, ErrInvalidLengthModels + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupModels + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthModels + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthModels = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowModels = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupModels = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/avs/types/params.pb.go b/x/avs/types/params.pb.go new file mode 100644 index 000000000..3db84ca17 --- /dev/null +++ b/x/avs/types/params.pb.go @@ -0,0 +1,341 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: milkyway/avs/v1/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/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 avs module. +type Params struct { + // AvsCreationFee defines the fee to register a new AVS. The fee is + // drawn from the MsgRegisterAVS creator's account, and transferred + // to the community pool. + AvsRegistrationFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=avs_registration_fee,json=avsRegistrationFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"avs_registration_fee" yaml:"avs_registration_fee"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_1c4ad1ee400d0c19, []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 (m *Params) GetAvsRegistrationFee() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.AvsRegistrationFee + } + return nil +} + +func init() { + proto.RegisterType((*Params)(nil), "milkyway.avs.v1.Params") +} + +func init() { proto.RegisterFile("milkyway/avs/v1/params.proto", fileDescriptor_1c4ad1ee400d0c19) } + +var fileDescriptor_1c4ad1ee400d0c19 = []byte{ + // 284 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc9, 0xcd, 0xcc, 0xc9, + 0xae, 0x2c, 0x4f, 0xac, 0xd4, 0x4f, 0x2c, 0x2b, 0xd6, 0x2f, 0x33, 0xd4, 0x2f, 0x48, 0x2c, 0x4a, + 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0xc9, 0xea, 0x25, 0x96, 0x15, + 0xeb, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xe5, 0xf4, 0x41, 0x2c, 0x88, 0x32, + 0x29, 0xc9, 0xe4, 0xfc, 0xe2, 0xdc, 0xfc, 0xe2, 0x78, 0x88, 0x04, 0x84, 0x03, 0x95, 0x92, 0x83, + 0xf0, 0xf4, 0x93, 0x12, 0x8b, 0x53, 0xf5, 0xcb, 0x0c, 0x93, 0x52, 0x4b, 0x12, 0x0d, 0xf5, 0x93, + 0xf3, 0x33, 0xf3, 0x20, 0xf2, 0x4a, 0xcb, 0x19, 0xb9, 0xd8, 0x02, 0xc0, 0x56, 0x0a, 0xcd, 0x61, + 0xe4, 0x12, 0x49, 0x2c, 0x2b, 0x8e, 0x2f, 0x4a, 0x4d, 0xcf, 0x2c, 0x2e, 0x29, 0x4a, 0x2c, 0xc9, + 0xcc, 0xcf, 0x8b, 0x4f, 0x4b, 0x4d, 0x95, 0x60, 0x54, 0x60, 0xd6, 0xe0, 0x36, 0x92, 0xd4, 0x83, + 0x1a, 0x0c, 0x32, 0x4a, 0x0f, 0x6a, 0x94, 0x9e, 0x73, 0x7e, 0x66, 0x9e, 0x93, 0xff, 0x89, 0x7b, + 0xf2, 0x0c, 0x9f, 0xee, 0xc9, 0x4b, 0x57, 0x26, 0xe6, 0xe6, 0x58, 0x29, 0x61, 0x33, 0x44, 0x69, + 0xd5, 0x7d, 0x79, 0x8d, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xa8, 0x23, + 0xa1, 0x94, 0x6e, 0x71, 0x4a, 0xb6, 0x7e, 0x49, 0x65, 0x41, 0x6a, 0x31, 0xd8, 0xbc, 0xe2, 0x20, + 0xa1, 0xc4, 0xb2, 0xe2, 0x20, 0x24, 0x13, 0xdc, 0x52, 0x53, 0x9d, 0xdc, 0x4f, 0x3c, 0x92, 0x63, + 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, + 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x17, 0xc9, 0x5c, 0x58, 0x80, 0xe9, 0xe6, 0x24, 0x26, + 0x15, 0xc3, 0x79, 0xfa, 0x15, 0xe0, 0xe0, 0x05, 0x5b, 0x91, 0xc4, 0x06, 0xf6, 0xb9, 0x31, 0x20, + 0x00, 0x00, 0xff, 0xff, 0x37, 0xc8, 0x29, 0xe7, 0x7b, 0x01, 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 + if len(m.AvsRegistrationFee) > 0 { + for iNdEx := len(m.AvsRegistrationFee) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AvsRegistrationFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + 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 + if len(m.AvsRegistrationFee) > 0 { + for _, e := range m.AvsRegistrationFee { + l = e.Size() + n += 1 + l + sovParams(uint64(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 { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AvsRegistrationFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AvsRegistrationFee = append(m.AvsRegistrationFee, types.Coin{}) + if err := m.AvsRegistrationFee[len(m.AvsRegistrationFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + 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/avs/types/query.pb.go b/x/avs/types/query.pb.go new file mode 100644 index 000000000..227a9e679 --- /dev/null +++ b/x/avs/types/query.pb.go @@ -0,0 +1,1011 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: milkyway/avs/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + query "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is the request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_911f1b653a0f04ba, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is the response type for the Query/Params RPC method. +type QueryParamsResponse struct { + Params 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_911f1b653a0f04ba, []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{} +} + +// QueryServicesRequest is the request type for the Query/Services RPC method. +type QueryServicesRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryServicesRequest) Reset() { *m = QueryServicesRequest{} } +func (m *QueryServicesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryServicesRequest) ProtoMessage() {} +func (*QueryServicesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_911f1b653a0f04ba, []int{2} +} +func (m *QueryServicesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryServicesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryServicesRequest.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 *QueryServicesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryServicesRequest.Merge(m, src) +} +func (m *QueryServicesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryServicesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryServicesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryServicesRequest proto.InternalMessageInfo + +func (m *QueryServicesRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryServicesResponse is the response type for the Query/Services RPC method. +type QueryServicesResponse struct { + // AVS services defines the list of actively validates services + Services []AVS `protobuf:"bytes,1,rep,name=services,proto3" json:"services"` + // Pagination defines the pagination response + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryServicesResponse) Reset() { *m = QueryServicesResponse{} } +func (m *QueryServicesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryServicesResponse) ProtoMessage() {} +func (*QueryServicesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_911f1b653a0f04ba, []int{3} +} +func (m *QueryServicesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryServicesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryServicesResponse.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 *QueryServicesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryServicesResponse.Merge(m, src) +} +func (m *QueryServicesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryServicesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryServicesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryServicesResponse proto.InternalMessageInfo + +func (m *QueryServicesResponse) GetServices() []AVS { + if m != nil { + return m.Services + } + return nil +} + +func (m *QueryServicesResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "milkyway.avs.v1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "milkyway.avs.v1.QueryParamsResponse") + proto.RegisterType((*QueryServicesRequest)(nil), "milkyway.avs.v1.QueryServicesRequest") + proto.RegisterType((*QueryServicesResponse)(nil), "milkyway.avs.v1.QueryServicesResponse") +} + +func init() { proto.RegisterFile("milkyway/avs/v1/query.proto", fileDescriptor_911f1b653a0f04ba) } + +var fileDescriptor_911f1b653a0f04ba = []byte{ + // 435 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0x3f, 0x8f, 0xd3, 0x30, + 0x18, 0xc6, 0xe3, 0x03, 0xaa, 0x93, 0x6f, 0x40, 0x32, 0x41, 0x77, 0x97, 0x43, 0xb9, 0x23, 0xc0, + 0x71, 0x42, 0xaa, 0xad, 0x14, 0xc1, 0x4e, 0x07, 0xba, 0x30, 0x94, 0x56, 0x62, 0x60, 0x40, 0x72, + 0x8a, 0x15, 0x22, 0x92, 0x38, 0x8d, 0xdd, 0x40, 0x24, 0x26, 0x3e, 0x01, 0x12, 0x0b, 0x1f, 0xa9, + 0x63, 0x25, 0x16, 0x26, 0x84, 0x5a, 0xbe, 0x05, 0x0b, 0xaa, 0xed, 0xf4, 0x4f, 0x52, 0xe8, 0x16, + 0xf9, 0x7d, 0xde, 0xe7, 0xf9, 0xbd, 0xef, 0x1b, 0x78, 0x96, 0x44, 0xf1, 0xfb, 0xf2, 0x03, 0x2d, + 0x09, 0x2d, 0x04, 0x29, 0x7c, 0x32, 0x9e, 0xb0, 0xbc, 0xc4, 0x59, 0xce, 0x25, 0x47, 0x37, 0xab, + 0x22, 0xa6, 0x85, 0xc0, 0x85, 0xef, 0xd8, 0x21, 0x0f, 0xb9, 0xaa, 0x91, 0xe5, 0x97, 0x96, 0x39, + 0x77, 0x42, 0xce, 0xc3, 0x98, 0x11, 0x9a, 0x45, 0x84, 0xa6, 0x29, 0x97, 0x54, 0x46, 0x3c, 0x15, + 0xa6, 0xfa, 0x68, 0xc4, 0x45, 0xc2, 0x05, 0x09, 0xa8, 0x60, 0xda, 0x9d, 0x14, 0x7e, 0xc0, 0x24, + 0xf5, 0x49, 0x46, 0xc3, 0x28, 0x55, 0xe2, 0xca, 0xa9, 0x4e, 0x93, 0xf0, 0xb7, 0x2c, 0x16, 0xff, + 0xaa, 0x66, 0x34, 0xa7, 0x89, 0xa9, 0x7a, 0x36, 0x44, 0x2f, 0x97, 0xee, 0x7d, 0xf5, 0x38, 0x60, + 0xe3, 0x09, 0x13, 0xd2, 0x7b, 0x01, 0x6f, 0x6d, 0xbd, 0x8a, 0x8c, 0xa7, 0x82, 0xa1, 0x27, 0xb0, + 0xa5, 0x9b, 0x4f, 0xc0, 0x05, 0xb8, 0x3a, 0xea, 0x1c, 0xe3, 0xda, 0xa8, 0x58, 0x37, 0x74, 0xaf, + 0x4f, 0x7f, 0x9e, 0x5b, 0x03, 0x23, 0xf6, 0xde, 0x40, 0x5b, 0xb9, 0x0d, 0x59, 0x5e, 0x44, 0x23, + 0x56, 0xa5, 0xa0, 0xe7, 0x10, 0xae, 0x67, 0x31, 0x96, 0x97, 0x58, 0x0f, 0x8e, 0x97, 0x83, 0x63, + 0xbd, 0x56, 0x33, 0x38, 0xee, 0xd3, 0x90, 0x99, 0xde, 0xc1, 0x46, 0xa7, 0xf7, 0x0d, 0xc0, 0xdb, + 0xb5, 0x00, 0x03, 0xfc, 0x14, 0x1e, 0x0a, 0xf3, 0x76, 0x02, 0x2e, 0xae, 0x5d, 0x1d, 0x75, 0xec, + 0x06, 0xf2, 0xb3, 0x57, 0x43, 0xc3, 0xbb, 0xd2, 0xa2, 0xde, 0x16, 0xd9, 0x81, 0x22, 0x7b, 0xb8, + 0x97, 0x4c, 0x87, 0x6e, 0xa2, 0x75, 0xfe, 0x00, 0x78, 0x43, 0xa1, 0x21, 0x09, 0x5b, 0x7a, 0x39, + 0xe8, 0x5e, 0x03, 0xa1, 0x79, 0x01, 0xe7, 0xfe, 0xff, 0x45, 0x3a, 0xca, 0x3b, 0xff, 0xfc, 0xfd, + 0xf7, 0xd7, 0x83, 0x53, 0x74, 0x4c, 0x76, 0x1f, 0x19, 0x7d, 0x82, 0x87, 0xd5, 0x52, 0xd0, 0x83, + 0xdd, 0x96, 0xb5, 0xab, 0x38, 0x97, 0xfb, 0x64, 0x26, 0xfb, 0xae, 0xca, 0x3e, 0x43, 0xa7, 0x8d, + 0xec, 0x6a, 0x8d, 0xdd, 0xde, 0x74, 0xee, 0x82, 0xd9, 0xdc, 0x05, 0xbf, 0xe6, 0x2e, 0xf8, 0xb2, + 0x70, 0xad, 0xd9, 0xc2, 0xb5, 0x7e, 0x2c, 0x5c, 0xeb, 0x75, 0x3b, 0x8c, 0xe4, 0xbb, 0x49, 0x80, + 0x47, 0x3c, 0x59, 0xb5, 0xb7, 0x63, 0x1a, 0x88, 0xb5, 0xd9, 0x47, 0x65, 0x27, 0xcb, 0x8c, 0x89, + 0xa0, 0xa5, 0x7e, 0xd6, 0xc7, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x56, 0xe9, 0x60, 0xcc, 0x78, + 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 { + // Params defines a gRPC query method that returns the parameters of the + // module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Services defines a gRPC query method that returns the actively validates + // services currently registered in the module. + Services(ctx context.Context, in *QueryServicesRequest, opts ...grpc.CallOption) (*QueryServicesResponse, 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, "/milkyway.avs.v1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Services(ctx context.Context, in *QueryServicesRequest, opts ...grpc.CallOption) (*QueryServicesResponse, error) { + out := new(QueryServicesResponse) + err := c.cc.Invoke(ctx, "/milkyway.avs.v1.Query/Services", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Params defines a gRPC query method that returns the parameters of the + // module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // Services defines a gRPC query method that returns the actively validates + // services currently registered in the module. + Services(context.Context, *QueryServicesRequest) (*QueryServicesResponse, 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) Services(ctx context.Context, req *QueryServicesRequest) (*QueryServicesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Services 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: "/milkyway.avs.v1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Services_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryServicesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Services(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/milkyway.avs.v1.Query/Services", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Services(ctx, req.(*QueryServicesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "milkyway.avs.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "Services", + Handler: _Query_Services_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "milkyway/avs/v1/query.proto", +} + +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryServicesRequest) 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 *QueryServicesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryServicesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.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 *QueryServicesResponse) 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 *QueryServicesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryServicesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Services) > 0 { + for iNdEx := len(m.Services) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Services[iNdEx].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 *QueryServicesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryServicesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Services) > 0 { + for _, e := range m.Services { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.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 *QueryServicesRequest) 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: QueryServicesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryServicesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 *QueryServicesResponse) 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: QueryServicesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryServicesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Services", 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 + } + m.Services = append(m.Services, AVS{}) + if err := m.Services[len(m.Services)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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/avs/types/query.pb.gw.go b/x/avs/types/query.pb.gw.go new file mode 100644 index 000000000..ccea64048 --- /dev/null +++ b/x/avs/types/query.pb.gw.go @@ -0,0 +1,236 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: milkyway/avs/v1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_Services_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_Services_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryServicesRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Services_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Services(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Services_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryServicesRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Services_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Services(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_Services_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_Services_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_Services_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_Services_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_Services_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_Services_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{"milkyway", "avs", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Services_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"milkyway", "avs", "v1", "services"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_Services_0 = runtime.ForwardResponseMessage +) diff --git a/x/avs/types/tx.pb.go b/x/avs/types/tx.pb.go new file mode 100644 index 000000000..8c245b8e6 --- /dev/null +++ b/x/avs/types/tx.pb.go @@ -0,0 +1,1005 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: milkyway/avs/v1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/cosmos-sdk/x/bank/types" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/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 + +// MsgRegisterAVSResponse defines the message structure for the RegisterAVS +// gRPC service method. It allows an account to register a new AVS that later on +// operators can opt to validate. It requires a sender address as well as the +// details of the AVS to be register. +type MsgRegisterAVS struct { + // Sender is the address of the user registering the AVS + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + // Name is the name of the AVS + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` +} + +func (m *MsgRegisterAVS) Reset() { *m = MsgRegisterAVS{} } +func (m *MsgRegisterAVS) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterAVS) ProtoMessage() {} +func (*MsgRegisterAVS) Descriptor() ([]byte, []int) { + return fileDescriptor_01757aa274ae4cad, []int{0} +} +func (m *MsgRegisterAVS) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterAVS) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterAVS.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 *MsgRegisterAVS) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterAVS.Merge(m, src) +} +func (m *MsgRegisterAVS) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterAVS) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterAVS.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterAVS proto.InternalMessageInfo + +func (m *MsgRegisterAVS) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgRegisterAVS) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +// MsgRegisterAVSResponse is the return value of MsgRegisterAVS. +// It returns the newly created AVS ID. +type MsgRegisterAVSResponse struct { + // NewAVSID is the ID of the newly registered AVS + NewAVSID uint64 `protobuf:"varint,1,opt,name=new_avs_id,json=newAvsId,proto3" json:"new_avs_id,omitempty"` +} + +func (m *MsgRegisterAVSResponse) Reset() { *m = MsgRegisterAVSResponse{} } +func (m *MsgRegisterAVSResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterAVSResponse) ProtoMessage() {} +func (*MsgRegisterAVSResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_01757aa274ae4cad, []int{1} +} +func (m *MsgRegisterAVSResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterAVSResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterAVSResponse.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 *MsgRegisterAVSResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterAVSResponse.Merge(m, src) +} +func (m *MsgRegisterAVSResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterAVSResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterAVSResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterAVSResponse proto.InternalMessageInfo + +func (m *MsgRegisterAVSResponse) GetNewAVSID() uint64 { + if m != nil { + return m.NewAVSID + } + return 0 +} + +// MsgDeregisterAVS defines the message structure for the DeregisterAVS gRPC +// service method. It allows the AVS owner to deregister their AVS so that +// operators know that they can safely stop validating it. +type MsgDeregisterAVS struct { + // Sender is the address of the user deregistering the AVS + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + // AVSID is the ID of the AVS to be deregistered + AVSID uint64 `protobuf:"varint,2,opt,name=avs_id,json=avsId,proto3" json:"avs_id,omitempty"` +} + +func (m *MsgDeregisterAVS) Reset() { *m = MsgDeregisterAVS{} } +func (m *MsgDeregisterAVS) String() string { return proto.CompactTextString(m) } +func (*MsgDeregisterAVS) ProtoMessage() {} +func (*MsgDeregisterAVS) Descriptor() ([]byte, []int) { + return fileDescriptor_01757aa274ae4cad, []int{2} +} +func (m *MsgDeregisterAVS) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeregisterAVS) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeregisterAVS.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 *MsgDeregisterAVS) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeregisterAVS.Merge(m, src) +} +func (m *MsgDeregisterAVS) XXX_Size() int { + return m.Size() +} +func (m *MsgDeregisterAVS) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeregisterAVS.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeregisterAVS proto.InternalMessageInfo + +func (m *MsgDeregisterAVS) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgDeregisterAVS) GetAVSID() uint64 { + if m != nil { + return m.AVSID + } + return 0 +} + +// MsgDeregisterAVSResponse is the return value of MsgDeregisterAVS. +type MsgDeregisterAVSResponse struct { +} + +func (m *MsgDeregisterAVSResponse) Reset() { *m = MsgDeregisterAVSResponse{} } +func (m *MsgDeregisterAVSResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDeregisterAVSResponse) ProtoMessage() {} +func (*MsgDeregisterAVSResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_01757aa274ae4cad, []int{3} +} +func (m *MsgDeregisterAVSResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeregisterAVSResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeregisterAVSResponse.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 *MsgDeregisterAVSResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeregisterAVSResponse.Merge(m, src) +} +func (m *MsgDeregisterAVSResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgDeregisterAVSResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeregisterAVSResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeregisterAVSResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgRegisterAVS)(nil), "milkyway.avs.v1.MsgRegisterAVS") + proto.RegisterType((*MsgRegisterAVSResponse)(nil), "milkyway.avs.v1.MsgRegisterAVSResponse") + proto.RegisterType((*MsgDeregisterAVS)(nil), "milkyway.avs.v1.MsgDeregisterAVS") + proto.RegisterType((*MsgDeregisterAVSResponse)(nil), "milkyway.avs.v1.MsgDeregisterAVSResponse") +} + +func init() { proto.RegisterFile("milkyway/avs/v1/tx.proto", fileDescriptor_01757aa274ae4cad) } + +var fileDescriptor_01757aa274ae4cad = []byte{ + // 477 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x52, 0x41, 0x8b, 0xd3, 0x40, + 0x14, 0xde, 0x59, 0xb7, 0x65, 0x77, 0x56, 0x5d, 0x0d, 0x45, 0x63, 0x90, 0x74, 0x8d, 0x82, 0x5a, + 0x68, 0xc6, 0xea, 0xad, 0xb7, 0x96, 0x82, 0xec, 0xa1, 0x1e, 0x52, 0x58, 0x41, 0x90, 0x32, 0x69, + 0x86, 0x31, 0x6c, 0x67, 0xa6, 0xe4, 0xc5, 0x74, 0x7b, 0x13, 0x8f, 0xea, 0xc1, 0x9f, 0xd2, 0x83, + 0x3f, 0xc1, 0x83, 0xc7, 0xc5, 0x93, 0xa7, 0x22, 0xe9, 0xa1, 0x77, 0x7f, 0x81, 0x24, 0x99, 0x16, + 0x53, 0x85, 0x3d, 0x78, 0x09, 0xf9, 0xde, 0xf7, 0xcd, 0x7c, 0xef, 0x7b, 0xf3, 0xb0, 0x29, 0xc2, + 0xf1, 0xd9, 0x6c, 0x4a, 0x67, 0x84, 0x26, 0x40, 0x92, 0x16, 0x89, 0xcf, 0xdd, 0x49, 0xa4, 0x62, + 0x65, 0x1c, 0xad, 0x19, 0x97, 0x26, 0xe0, 0x26, 0x2d, 0xeb, 0x26, 0x15, 0xa1, 0x54, 0x24, 0xff, + 0x16, 0x1a, 0xeb, 0xce, 0x48, 0x81, 0x50, 0x30, 0xcc, 0x11, 0x29, 0x80, 0xa6, 0xec, 0x02, 0x11, + 0x9f, 0x02, 0x23, 0x49, 0xcb, 0x67, 0x31, 0x6d, 0x91, 0x91, 0x0a, 0xe5, 0x5f, 0xbc, 0x3c, 0xdb, + 0xf0, 0x19, 0xd0, 0xfc, 0x6d, 0xcd, 0x0b, 0xe0, 0x59, 0x5b, 0x02, 0xb8, 0x26, 0x6a, 0x5c, 0x71, + 0x55, 0x18, 0x66, 0x7f, 0xba, 0x7a, 0x77, 0x3b, 0xc7, 0x84, 0x46, 0x54, 0xe8, 0x66, 0x9c, 0x8f, + 0x08, 0x5f, 0xef, 0x03, 0xf7, 0x18, 0x0f, 0x21, 0x66, 0x51, 0xe7, 0x74, 0x60, 0x3c, 0xc1, 0x55, + 0x60, 0x32, 0x60, 0x91, 0x89, 0x8e, 0xd1, 0xa3, 0x83, 0xae, 0xf9, 0xfd, 0x4b, 0xb3, 0xa6, 0x13, + 0x74, 0x82, 0x20, 0x62, 0x00, 0x83, 0x38, 0x0a, 0x25, 0xf7, 0xb4, 0xce, 0xb8, 0x8f, 0xf7, 0x24, + 0x15, 0xcc, 0xdc, 0xcd, 0xf5, 0x47, 0xbf, 0x16, 0xf5, 0xc3, 0x19, 0x15, 0xe3, 0xb6, 0x93, 0x55, + 0x1d, 0x2f, 0x27, 0xdb, 0xce, 0xfb, 0xd5, 0xbc, 0xa1, 0x4f, 0x7c, 0x58, 0xcd, 0x1b, 0x46, 0xd6, + 0x4e, 0xd9, 0xda, 0xe9, 0xe1, 0x5b, 0xe5, 0x8a, 0xc7, 0x60, 0xa2, 0x24, 0x30, 0xa3, 0x81, 0xb1, + 0x64, 0xd3, 0x21, 0x4d, 0x60, 0x18, 0x06, 0x79, 0x63, 0x7b, 0xdd, 0xab, 0xe9, 0xa2, 0xbe, 0xff, + 0x82, 0x4d, 0x3b, 0xa7, 0x83, 0x93, 0x9e, 0xb7, 0x2f, 0xd9, 0xb4, 0x93, 0xc0, 0x49, 0xe0, 0x7c, + 0x42, 0xf8, 0x46, 0x1f, 0x78, 0x8f, 0x45, 0xff, 0x95, 0xea, 0x18, 0x57, 0xb5, 0xdd, 0x6e, 0x6e, + 0x77, 0x90, 0x2e, 0xea, 0x95, 0xc2, 0xab, 0x42, 0x33, 0xa3, 0xf6, 0x83, 0xad, 0x48, 0x35, 0x1d, + 0xa9, 0xe4, 0xec, 0x58, 0xd8, 0xdc, 0xae, 0xad, 0x63, 0x3d, 0xfd, 0x8a, 0xf0, 0x95, 0x3e, 0x70, + 0xe3, 0x25, 0x3e, 0xfc, 0xf3, 0x09, 0xea, 0xee, 0xd6, 0x8a, 0xb9, 0xe5, 0xb1, 0x58, 0x0f, 0x2f, + 0x11, 0x6c, 0xe6, 0xf6, 0x1a, 0x5f, 0x2b, 0xcf, 0xe1, 0xde, 0xbf, 0x4e, 0x96, 0x24, 0xd6, 0xe3, + 0x4b, 0x25, 0xeb, 0xeb, 0xad, 0xca, 0xbb, 0xd5, 0xbc, 0x81, 0xba, 0xcf, 0xbf, 0xa5, 0x36, 0xba, + 0x48, 0x6d, 0xf4, 0x33, 0xb5, 0xd1, 0xe7, 0xa5, 0xbd, 0x73, 0xb1, 0xb4, 0x77, 0x7e, 0x2c, 0xed, + 0x9d, 0x57, 0x4d, 0x1e, 0xc6, 0x6f, 0xde, 0xfa, 0xee, 0x48, 0x09, 0xb2, 0xbe, 0xb5, 0x39, 0xa6, + 0x3e, 0x6c, 0x10, 0x39, 0xcf, 0x17, 0x33, 0x9e, 0x4d, 0x18, 0xf8, 0xd5, 0x7c, 0x2b, 0x9f, 0xfd, + 0x0e, 0x00, 0x00, 0xff, 0xff, 0x84, 0x9e, 0x10, 0xaf, 0x7d, 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 + +// 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 { + RegisterAVS(ctx context.Context, in *MsgRegisterAVS, opts ...grpc.CallOption) (*MsgRegisterAVSResponse, error) + DeregisterAVS(ctx context.Context, in *MsgDeregisterAVS, opts ...grpc.CallOption) (*MsgDeregisterAVSResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) RegisterAVS(ctx context.Context, in *MsgRegisterAVS, opts ...grpc.CallOption) (*MsgRegisterAVSResponse, error) { + out := new(MsgRegisterAVSResponse) + err := c.cc.Invoke(ctx, "/milkyway.avs.v1.Msg/RegisterAVS", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) DeregisterAVS(ctx context.Context, in *MsgDeregisterAVS, opts ...grpc.CallOption) (*MsgDeregisterAVSResponse, error) { + out := new(MsgDeregisterAVSResponse) + err := c.cc.Invoke(ctx, "/milkyway.avs.v1.Msg/DeregisterAVS", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + RegisterAVS(context.Context, *MsgRegisterAVS) (*MsgRegisterAVSResponse, error) + DeregisterAVS(context.Context, *MsgDeregisterAVS) (*MsgDeregisterAVSResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) RegisterAVS(ctx context.Context, req *MsgRegisterAVS) (*MsgRegisterAVSResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterAVS not implemented") +} +func (*UnimplementedMsgServer) DeregisterAVS(ctx context.Context, req *MsgDeregisterAVS) (*MsgDeregisterAVSResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeregisterAVS not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_RegisterAVS_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRegisterAVS) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RegisterAVS(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/milkyway.avs.v1.Msg/RegisterAVS", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RegisterAVS(ctx, req.(*MsgRegisterAVS)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_DeregisterAVS_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDeregisterAVS) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).DeregisterAVS(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/milkyway.avs.v1.Msg/DeregisterAVS", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DeregisterAVS(ctx, req.(*MsgDeregisterAVS)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "milkyway.avs.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RegisterAVS", + Handler: _Msg_RegisterAVS_Handler, + }, + { + MethodName: "DeregisterAVS", + Handler: _Msg_DeregisterAVS_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "milkyway/avs/v1/tx.proto", +} + +func (m *MsgRegisterAVS) 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 *MsgRegisterAVS) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterAVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintTx(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRegisterAVSResponse) 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 *MsgRegisterAVSResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterAVSResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.NewAVSID != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.NewAVSID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgDeregisterAVS) 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 *MsgDeregisterAVS) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeregisterAVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.AVSID != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.AVSID)) + i-- + dAtA[i] = 0x10 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgDeregisterAVSResponse) 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 *MsgDeregisterAVSResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeregisterAVSResponse) 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 *MsgRegisterAVS) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRegisterAVSResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.NewAVSID != 0 { + n += 1 + sovTx(uint64(m.NewAVSID)) + } + return n +} + +func (m *MsgDeregisterAVS) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.AVSID != 0 { + n += 1 + sovTx(uint64(m.AVSID)) + } + return n +} + +func (m *MsgDeregisterAVSResponse) 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 *MsgRegisterAVS) 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: MsgRegisterAVS: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterAVS: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", 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.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + 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 *MsgRegisterAVSResponse) 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: MsgRegisterAVSResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterAVSResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NewAVSID", wireType) + } + m.NewAVSID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NewAVSID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *MsgDeregisterAVS) 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: MsgDeregisterAVS: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeregisterAVS: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AVSID", wireType) + } + m.AVSID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AVSID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *MsgDeregisterAVSResponse) 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: MsgDeregisterAVSResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeregisterAVSResponse: 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") +) From 3d7ccc6a88ccb78208a9dcb58e3802a0f2a3f5c4 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Mon, 3 Jun 2024 08:47:11 -0500 Subject: [PATCH 05/49] chore: rename tx.proto to messages.proto --- .../avs/v1/{tx.proto => messages.proto} | 0 x/avs/types/{tx.pb.go => messages.pb.go} | 172 +++++++++--------- 2 files changed, 86 insertions(+), 86 deletions(-) rename proto/milkyway/avs/v1/{tx.proto => messages.proto} (100%) rename x/avs/types/{tx.pb.go => messages.pb.go} (80%) diff --git a/proto/milkyway/avs/v1/tx.proto b/proto/milkyway/avs/v1/messages.proto similarity index 100% rename from proto/milkyway/avs/v1/tx.proto rename to proto/milkyway/avs/v1/messages.proto diff --git a/x/avs/types/tx.pb.go b/x/avs/types/messages.pb.go similarity index 80% rename from x/avs/types/tx.pb.go rename to x/avs/types/messages.pb.go index 8c245b8e6..f069a97b8 100644 --- a/x/avs/types/tx.pb.go +++ b/x/avs/types/messages.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: milkyway/avs/v1/tx.proto +// source: milkyway/avs/v1/messages.proto package types @@ -48,7 +48,7 @@ func (m *MsgRegisterAVS) Reset() { *m = MsgRegisterAVS{} } func (m *MsgRegisterAVS) String() string { return proto.CompactTextString(m) } func (*MsgRegisterAVS) ProtoMessage() {} func (*MsgRegisterAVS) Descriptor() ([]byte, []int) { - return fileDescriptor_01757aa274ae4cad, []int{0} + return fileDescriptor_ee6728b943d8fd23, []int{0} } func (m *MsgRegisterAVS) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -102,7 +102,7 @@ func (m *MsgRegisterAVSResponse) Reset() { *m = MsgRegisterAVSResponse{} func (m *MsgRegisterAVSResponse) String() string { return proto.CompactTextString(m) } func (*MsgRegisterAVSResponse) ProtoMessage() {} func (*MsgRegisterAVSResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_01757aa274ae4cad, []int{1} + return fileDescriptor_ee6728b943d8fd23, []int{1} } func (m *MsgRegisterAVSResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -152,7 +152,7 @@ func (m *MsgDeregisterAVS) Reset() { *m = MsgDeregisterAVS{} } func (m *MsgDeregisterAVS) String() string { return proto.CompactTextString(m) } func (*MsgDeregisterAVS) ProtoMessage() {} func (*MsgDeregisterAVS) Descriptor() ([]byte, []int) { - return fileDescriptor_01757aa274ae4cad, []int{2} + return fileDescriptor_ee6728b943d8fd23, []int{2} } func (m *MsgDeregisterAVS) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -203,7 +203,7 @@ func (m *MsgDeregisterAVSResponse) Reset() { *m = MsgDeregisterAVSRespon func (m *MsgDeregisterAVSResponse) String() string { return proto.CompactTextString(m) } func (*MsgDeregisterAVSResponse) ProtoMessage() {} func (*MsgDeregisterAVSResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_01757aa274ae4cad, []int{3} + return fileDescriptor_ee6728b943d8fd23, []int{3} } func (m *MsgDeregisterAVSResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -239,40 +239,40 @@ func init() { proto.RegisterType((*MsgDeregisterAVSResponse)(nil), "milkyway.avs.v1.MsgDeregisterAVSResponse") } -func init() { proto.RegisterFile("milkyway/avs/v1/tx.proto", fileDescriptor_01757aa274ae4cad) } +func init() { proto.RegisterFile("milkyway/avs/v1/messages.proto", fileDescriptor_ee6728b943d8fd23) } -var fileDescriptor_01757aa274ae4cad = []byte{ - // 477 bytes of a gzipped FileDescriptorProto +var fileDescriptor_ee6728b943d8fd23 = []byte{ + // 479 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x52, 0x41, 0x8b, 0xd3, 0x40, - 0x14, 0xde, 0x59, 0xb7, 0x65, 0x77, 0x56, 0x5d, 0x0d, 0x45, 0x63, 0x90, 0x74, 0x8d, 0x82, 0x5a, - 0x68, 0xc6, 0xea, 0xad, 0xb7, 0x96, 0x82, 0xec, 0xa1, 0x1e, 0x52, 0x58, 0x41, 0x90, 0x32, 0x69, - 0x86, 0x31, 0x6c, 0x67, 0xa6, 0xe4, 0xc5, 0x74, 0x7b, 0x13, 0x8f, 0xea, 0xc1, 0x9f, 0xd2, 0x83, - 0x3f, 0xc1, 0x83, 0xc7, 0xc5, 0x93, 0xa7, 0x22, 0xe9, 0xa1, 0x77, 0x7f, 0x81, 0x24, 0x99, 0x16, - 0x53, 0x85, 0x3d, 0x78, 0x09, 0xf9, 0xde, 0xf7, 0xcd, 0x7c, 0xef, 0x7b, 0xf3, 0xb0, 0x29, 0xc2, - 0xf1, 0xd9, 0x6c, 0x4a, 0x67, 0x84, 0x26, 0x40, 0x92, 0x16, 0x89, 0xcf, 0xdd, 0x49, 0xa4, 0x62, - 0x65, 0x1c, 0xad, 0x19, 0x97, 0x26, 0xe0, 0x26, 0x2d, 0xeb, 0x26, 0x15, 0xa1, 0x54, 0x24, 0xff, - 0x16, 0x1a, 0xeb, 0xce, 0x48, 0x81, 0x50, 0x30, 0xcc, 0x11, 0x29, 0x80, 0xa6, 0xec, 0x02, 0x11, - 0x9f, 0x02, 0x23, 0x49, 0xcb, 0x67, 0x31, 0x6d, 0x91, 0x91, 0x0a, 0xe5, 0x5f, 0xbc, 0x3c, 0xdb, - 0xf0, 0x19, 0xd0, 0xfc, 0x6d, 0xcd, 0x0b, 0xe0, 0x59, 0x5b, 0x02, 0xb8, 0x26, 0x6a, 0x5c, 0x71, - 0x55, 0x18, 0x66, 0x7f, 0xba, 0x7a, 0x77, 0x3b, 0xc7, 0x84, 0x46, 0x54, 0xe8, 0x66, 0x9c, 0x8f, - 0x08, 0x5f, 0xef, 0x03, 0xf7, 0x18, 0x0f, 0x21, 0x66, 0x51, 0xe7, 0x74, 0x60, 0x3c, 0xc1, 0x55, - 0x60, 0x32, 0x60, 0x91, 0x89, 0x8e, 0xd1, 0xa3, 0x83, 0xae, 0xf9, 0xfd, 0x4b, 0xb3, 0xa6, 0x13, - 0x74, 0x82, 0x20, 0x62, 0x00, 0x83, 0x38, 0x0a, 0x25, 0xf7, 0xb4, 0xce, 0xb8, 0x8f, 0xf7, 0x24, - 0x15, 0xcc, 0xdc, 0xcd, 0xf5, 0x47, 0xbf, 0x16, 0xf5, 0xc3, 0x19, 0x15, 0xe3, 0xb6, 0x93, 0x55, - 0x1d, 0x2f, 0x27, 0xdb, 0xce, 0xfb, 0xd5, 0xbc, 0xa1, 0x4f, 0x7c, 0x58, 0xcd, 0x1b, 0x46, 0xd6, - 0x4e, 0xd9, 0xda, 0xe9, 0xe1, 0x5b, 0xe5, 0x8a, 0xc7, 0x60, 0xa2, 0x24, 0x30, 0xa3, 0x81, 0xb1, - 0x64, 0xd3, 0x21, 0x4d, 0x60, 0x18, 0x06, 0x79, 0x63, 0x7b, 0xdd, 0xab, 0xe9, 0xa2, 0xbe, 0xff, - 0x82, 0x4d, 0x3b, 0xa7, 0x83, 0x93, 0x9e, 0xb7, 0x2f, 0xd9, 0xb4, 0x93, 0xc0, 0x49, 0xe0, 0x7c, - 0x42, 0xf8, 0x46, 0x1f, 0x78, 0x8f, 0x45, 0xff, 0x95, 0xea, 0x18, 0x57, 0xb5, 0xdd, 0x6e, 0x6e, - 0x77, 0x90, 0x2e, 0xea, 0x95, 0xc2, 0xab, 0x42, 0x33, 0xa3, 0xf6, 0x83, 0xad, 0x48, 0x35, 0x1d, - 0xa9, 0xe4, 0xec, 0x58, 0xd8, 0xdc, 0xae, 0xad, 0x63, 0x3d, 0xfd, 0x8a, 0xf0, 0x95, 0x3e, 0x70, - 0xe3, 0x25, 0x3e, 0xfc, 0xf3, 0x09, 0xea, 0xee, 0xd6, 0x8a, 0xb9, 0xe5, 0xb1, 0x58, 0x0f, 0x2f, - 0x11, 0x6c, 0xe6, 0xf6, 0x1a, 0x5f, 0x2b, 0xcf, 0xe1, 0xde, 0xbf, 0x4e, 0x96, 0x24, 0xd6, 0xe3, - 0x4b, 0x25, 0xeb, 0xeb, 0xad, 0xca, 0xbb, 0xd5, 0xbc, 0x81, 0xba, 0xcf, 0xbf, 0xa5, 0x36, 0xba, - 0x48, 0x6d, 0xf4, 0x33, 0xb5, 0xd1, 0xe7, 0xa5, 0xbd, 0x73, 0xb1, 0xb4, 0x77, 0x7e, 0x2c, 0xed, - 0x9d, 0x57, 0x4d, 0x1e, 0xc6, 0x6f, 0xde, 0xfa, 0xee, 0x48, 0x09, 0xb2, 0xbe, 0xb5, 0x39, 0xa6, - 0x3e, 0x6c, 0x10, 0x39, 0xcf, 0x17, 0x33, 0x9e, 0x4d, 0x18, 0xf8, 0xd5, 0x7c, 0x2b, 0x9f, 0xfd, - 0x0e, 0x00, 0x00, 0xff, 0xff, 0x84, 0x9e, 0x10, 0xaf, 0x7d, 0x03, 0x00, 0x00, + 0x14, 0x6e, 0xd6, 0x6d, 0xd9, 0x9d, 0x55, 0x57, 0x43, 0xd1, 0x1a, 0x24, 0x5d, 0xa3, 0xa0, 0x16, + 0x9a, 0xb1, 0x7a, 0xeb, 0xad, 0xa5, 0x20, 0x7b, 0xa8, 0x87, 0x14, 0x56, 0x10, 0xa4, 0x4c, 0x9a, + 0x61, 0x0c, 0xdb, 0x99, 0x29, 0x79, 0x31, 0xb5, 0x37, 0xf1, 0xa8, 0x1e, 0xfc, 0x29, 0x3d, 0xf8, + 0x13, 0x3c, 0x78, 0x5c, 0x3c, 0x79, 0x2a, 0x92, 0x1e, 0x7a, 0xf7, 0x17, 0x48, 0x26, 0xd3, 0x62, + 0xaa, 0xd0, 0xc3, 0x5e, 0x42, 0xbe, 0xf7, 0x7d, 0x33, 0xdf, 0xfb, 0xde, 0x3c, 0x64, 0xf3, 0x70, + 0x7c, 0x3e, 0x9b, 0x92, 0x19, 0x26, 0x09, 0xe0, 0xa4, 0x85, 0x39, 0x05, 0x20, 0x8c, 0x82, 0x3b, + 0x89, 0x64, 0x2c, 0xcd, 0xe3, 0x35, 0xef, 0x92, 0x04, 0xdc, 0xa4, 0x65, 0xdd, 0x24, 0x3c, 0x14, + 0x12, 0xab, 0x6f, 0xae, 0xb1, 0xee, 0x8c, 0x24, 0x70, 0x09, 0x43, 0x85, 0x70, 0x0e, 0x34, 0x65, + 0xe7, 0x08, 0xfb, 0x04, 0x28, 0x4e, 0x5a, 0x3e, 0x8d, 0x49, 0x0b, 0x8f, 0x64, 0x28, 0xfe, 0xe1, + 0xc5, 0xf9, 0x86, 0xcf, 0x80, 0xe6, 0x6f, 0x6b, 0x9e, 0x03, 0x53, 0xcd, 0x01, 0xd3, 0x44, 0x95, + 0x49, 0x26, 0x73, 0xc3, 0xec, 0x4f, 0x57, 0xef, 0x6e, 0xa7, 0x99, 0x90, 0x88, 0x70, 0xdd, 0x8c, + 0xf3, 0xc9, 0x40, 0xd7, 0xfb, 0xc0, 0x3c, 0xca, 0x42, 0x88, 0x69, 0xd4, 0x39, 0x1b, 0x98, 0x4f, + 0x50, 0x05, 0xa8, 0x08, 0x68, 0x54, 0x33, 0x4e, 0x8c, 0x47, 0x87, 0xdd, 0xda, 0x8f, 0xaf, 0xcd, + 0xaa, 0x4e, 0xd0, 0x09, 0x82, 0x88, 0x02, 0x0c, 0xe2, 0x28, 0x14, 0xcc, 0xd3, 0x3a, 0xf3, 0x3e, + 0xda, 0x17, 0x84, 0xd3, 0xda, 0x9e, 0xd2, 0x1f, 0xff, 0x5e, 0xd4, 0x8f, 0x66, 0x84, 0x8f, 0xdb, + 0x4e, 0x56, 0x75, 0x3c, 0x45, 0xb6, 0x9d, 0x0f, 0xab, 0x79, 0x43, 0x9f, 0xf8, 0xb8, 0x9a, 0x37, + 0xcc, 0xac, 0x9d, 0xa2, 0xb5, 0xd3, 0x43, 0xb7, 0x8a, 0x15, 0x8f, 0xc2, 0x44, 0x0a, 0xa0, 0x66, + 0x03, 0x21, 0x41, 0xa7, 0x43, 0x92, 0xc0, 0x30, 0x0c, 0x54, 0x63, 0xfb, 0xdd, 0xab, 0xe9, 0xa2, + 0x7e, 0xf0, 0x82, 0x4e, 0x3b, 0x67, 0x83, 0xd3, 0x9e, 0x77, 0x20, 0xe8, 0xb4, 0x93, 0xc0, 0x69, + 0xe0, 0x7c, 0x36, 0xd0, 0x8d, 0x3e, 0xb0, 0x1e, 0x8d, 0x2e, 0x95, 0xea, 0x04, 0x55, 0xb4, 0xdd, + 0x9e, 0xb2, 0x3b, 0x4c, 0x17, 0xf5, 0x72, 0xee, 0x55, 0x26, 0x99, 0x51, 0xfb, 0xc1, 0x56, 0xa4, + 0xaa, 0x8e, 0x54, 0x70, 0x76, 0x2c, 0x54, 0xdb, 0xae, 0xad, 0x63, 0x3d, 0xfd, 0x66, 0xa0, 0x2b, + 0x7d, 0x60, 0xe6, 0x4b, 0x74, 0xf4, 0xf7, 0x13, 0xd4, 0xdd, 0xad, 0x15, 0x73, 0x8b, 0x63, 0xb1, + 0x1e, 0xee, 0x10, 0x6c, 0xe6, 0xf6, 0x1a, 0x5d, 0x2b, 0xce, 0xe1, 0xde, 0xff, 0x4e, 0x16, 0x24, + 0xd6, 0xe3, 0x9d, 0x92, 0xf5, 0xf5, 0x56, 0xf9, 0xfd, 0x6a, 0xde, 0x30, 0xba, 0xcf, 0xbf, 0xa7, + 0xb6, 0x71, 0x91, 0xda, 0xc6, 0xaf, 0xd4, 0x36, 0xbe, 0x2c, 0xed, 0xd2, 0xc5, 0xd2, 0x2e, 0xfd, + 0x5c, 0xda, 0xa5, 0x57, 0x4d, 0x16, 0xc6, 0x6f, 0xde, 0xfa, 0xee, 0x48, 0x72, 0xbc, 0xbe, 0xb5, + 0x39, 0x26, 0x3e, 0x6c, 0x10, 0x7e, 0xa7, 0x16, 0x33, 0x9e, 0x4d, 0x28, 0xf8, 0x15, 0xb5, 0x95, + 0xcf, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0xfc, 0xef, 0xf5, 0x4c, 0x83, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -388,7 +388,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "milkyway/avs/v1/tx.proto", + Metadata: "milkyway/avs/v1/messages.proto", } func (m *MsgRegisterAVS) Marshal() (dAtA []byte, err error) { @@ -414,14 +414,14 @@ func (m *MsgRegisterAVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.Name) > 0 { i -= len(m.Name) copy(dAtA[i:], m.Name) - i = encodeVarintTx(dAtA, i, uint64(len(m.Name))) + i = encodeVarintMessages(dAtA, i, uint64(len(m.Name))) i-- dAtA[i] = 0x12 } if len(m.Sender) > 0 { i -= len(m.Sender) copy(dAtA[i:], m.Sender) - i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i = encodeVarintMessages(dAtA, i, uint64(len(m.Sender))) i-- dAtA[i] = 0xa } @@ -449,7 +449,7 @@ func (m *MsgRegisterAVSResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) var l int _ = l if m.NewAVSID != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.NewAVSID)) + i = encodeVarintMessages(dAtA, i, uint64(m.NewAVSID)) i-- dAtA[i] = 0x8 } @@ -477,14 +477,14 @@ func (m *MsgDeregisterAVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if m.AVSID != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.AVSID)) + i = encodeVarintMessages(dAtA, i, uint64(m.AVSID)) i-- dAtA[i] = 0x10 } if len(m.Sender) > 0 { i -= len(m.Sender) copy(dAtA[i:], m.Sender) - i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i = encodeVarintMessages(dAtA, i, uint64(len(m.Sender))) i-- dAtA[i] = 0xa } @@ -514,8 +514,8 @@ func (m *MsgDeregisterAVSResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) +func encodeVarintMessages(dAtA []byte, offset int, v uint64) int { + offset -= sovMessages(v) base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -533,11 +533,11 @@ func (m *MsgRegisterAVS) Size() (n int) { _ = l l = len(m.Sender) if l > 0 { - n += 1 + l + sovTx(uint64(l)) + n += 1 + l + sovMessages(uint64(l)) } l = len(m.Name) if l > 0 { - n += 1 + l + sovTx(uint64(l)) + n += 1 + l + sovMessages(uint64(l)) } return n } @@ -549,7 +549,7 @@ func (m *MsgRegisterAVSResponse) Size() (n int) { var l int _ = l if m.NewAVSID != 0 { - n += 1 + sovTx(uint64(m.NewAVSID)) + n += 1 + sovMessages(uint64(m.NewAVSID)) } return n } @@ -562,10 +562,10 @@ func (m *MsgDeregisterAVS) Size() (n int) { _ = l l = len(m.Sender) if l > 0 { - n += 1 + l + sovTx(uint64(l)) + n += 1 + l + sovMessages(uint64(l)) } if m.AVSID != 0 { - n += 1 + sovTx(uint64(m.AVSID)) + n += 1 + sovMessages(uint64(m.AVSID)) } return n } @@ -579,11 +579,11 @@ func (m *MsgDeregisterAVSResponse) Size() (n int) { return n } -func sovTx(x uint64) (n int) { +func sovMessages(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 sozMessages(x uint64) (n int) { + return sovMessages(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } func (m *MsgRegisterAVS) Unmarshal(dAtA []byte) error { l := len(dAtA) @@ -593,7 +593,7 @@ func (m *MsgRegisterAVS) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowTx + return ErrIntOverflowMessages } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -621,7 +621,7 @@ func (m *MsgRegisterAVS) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowTx + return ErrIntOverflowMessages } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -635,11 +635,11 @@ func (m *MsgRegisterAVS) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthTx + return ErrInvalidLengthMessages } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthTx + return ErrInvalidLengthMessages } if postIndex > l { return io.ErrUnexpectedEOF @@ -653,7 +653,7 @@ func (m *MsgRegisterAVS) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowTx + return ErrIntOverflowMessages } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -667,11 +667,11 @@ func (m *MsgRegisterAVS) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthTx + return ErrInvalidLengthMessages } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthTx + return ErrInvalidLengthMessages } if postIndex > l { return io.ErrUnexpectedEOF @@ -680,12 +680,12 @@ func (m *MsgRegisterAVS) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) + skippy, err := skipMessages(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx + return ErrInvalidLengthMessages } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -707,7 +707,7 @@ func (m *MsgRegisterAVSResponse) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowTx + return ErrIntOverflowMessages } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -735,7 +735,7 @@ func (m *MsgRegisterAVSResponse) Unmarshal(dAtA []byte) error { m.NewAVSID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowTx + return ErrIntOverflowMessages } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -749,12 +749,12 @@ func (m *MsgRegisterAVSResponse) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) + skippy, err := skipMessages(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx + return ErrInvalidLengthMessages } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -776,7 +776,7 @@ func (m *MsgDeregisterAVS) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowTx + return ErrIntOverflowMessages } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -804,7 +804,7 @@ func (m *MsgDeregisterAVS) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowTx + return ErrIntOverflowMessages } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -818,11 +818,11 @@ func (m *MsgDeregisterAVS) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthTx + return ErrInvalidLengthMessages } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthTx + return ErrInvalidLengthMessages } if postIndex > l { return io.ErrUnexpectedEOF @@ -836,7 +836,7 @@ func (m *MsgDeregisterAVS) Unmarshal(dAtA []byte) error { m.AVSID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowTx + return ErrIntOverflowMessages } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -850,12 +850,12 @@ func (m *MsgDeregisterAVS) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) + skippy, err := skipMessages(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx + return ErrInvalidLengthMessages } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -877,7 +877,7 @@ func (m *MsgDeregisterAVSResponse) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowTx + return ErrIntOverflowMessages } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -900,12 +900,12 @@ func (m *MsgDeregisterAVSResponse) Unmarshal(dAtA []byte) error { switch fieldNum { default: iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) + skippy, err := skipMessages(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx + return ErrInvalidLengthMessages } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -919,7 +919,7 @@ func (m *MsgDeregisterAVSResponse) Unmarshal(dAtA []byte) error { } return nil } -func skipTx(dAtA []byte) (n int, err error) { +func skipMessages(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 depth := 0 @@ -927,7 +927,7 @@ func skipTx(dAtA []byte) (n int, err error) { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowTx + return 0, ErrIntOverflowMessages } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -944,7 +944,7 @@ func skipTx(dAtA []byte) (n int, err error) { case 0: for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowTx + return 0, ErrIntOverflowMessages } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -960,7 +960,7 @@ func skipTx(dAtA []byte) (n int, err error) { var length int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowTx + return 0, ErrIntOverflowMessages } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -973,14 +973,14 @@ func skipTx(dAtA []byte) (n int, err error) { } } if length < 0 { - return 0, ErrInvalidLengthTx + return 0, ErrInvalidLengthMessages } iNdEx += length case 3: depth++ case 4: if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTx + return 0, ErrUnexpectedEndOfGroupMessages } depth-- case 5: @@ -989,7 +989,7 @@ func skipTx(dAtA []byte) (n int, err error) { return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } if iNdEx < 0 { - return 0, ErrInvalidLengthTx + return 0, ErrInvalidLengthMessages } if depth == 0 { return iNdEx, nil @@ -999,7 +999,7 @@ func skipTx(dAtA []byte) (n int, err error) { } var ( - ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") + ErrInvalidLengthMessages = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowMessages = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupMessages = fmt.Errorf("proto: unexpected end of group") ) From 33595a63edd0933ac61e036038d11de71cba081c Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Mon, 3 Jun 2024 09:36:53 -0500 Subject: [PATCH 06/49] refactor: add missing fields from Proto definitions --- proto/milkyway/avs/v1/messages.proto | 4 +- proto/milkyway/avs/v1/models.proto | 4 ++ x/avs/types/messages.pb.go | 63 +++++++++++------------ x/avs/types/models.pb.go | 75 ++++++++++++++++++++++++---- 4 files changed, 104 insertions(+), 42 deletions(-) diff --git a/proto/milkyway/avs/v1/messages.proto b/proto/milkyway/avs/v1/messages.proto index 3bf398d93..b2b935f63 100644 --- a/proto/milkyway/avs/v1/messages.proto +++ b/proto/milkyway/avs/v1/messages.proto @@ -25,7 +25,7 @@ service Msg { // details of the AVS to be register. message MsgRegisterAVS { option (cosmos.msg.v1.signer) = "sender"; - option (amino.name) = "avs/MsgRegisterAVS"; + option (amino.name) = "milkyway/MsgRegisterAVS"; // Sender is the address of the user registering the AVS string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; @@ -46,7 +46,7 @@ message MsgRegisterAVSResponse { // operators know that they can safely stop validating it. message MsgDeregisterAVS { option (cosmos.msg.v1.signer) = "sender"; - option (amino.name) = "avs/MsgDeregisterAVS"; + option (amino.name) = "milkyway/MsgDeregisterAVS"; // Sender is the address of the user deregistering the AVS string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; diff --git a/proto/milkyway/avs/v1/models.proto b/proto/milkyway/avs/v1/models.proto index fe16d81fc..d5646b1a4 100644 --- a/proto/milkyway/avs/v1/models.proto +++ b/proto/milkyway/avs/v1/models.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package milkyway.avs.v1; import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; option go_package = "github.com/milkyway-labs/milkyway/x/avs/types"; @@ -12,4 +13,7 @@ message AVS { // Name is the name of the AVS string name = 2; + + // Admin is the address of the user that has registered the AVS + string admin = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; } diff --git a/x/avs/types/messages.pb.go b/x/avs/types/messages.pb.go index f069a97b8..fc6d2a5de 100644 --- a/x/avs/types/messages.pb.go +++ b/x/avs/types/messages.pb.go @@ -242,37 +242,38 @@ func init() { func init() { proto.RegisterFile("milkyway/avs/v1/messages.proto", fileDescriptor_ee6728b943d8fd23) } var fileDescriptor_ee6728b943d8fd23 = []byte{ - // 479 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x52, 0x41, 0x8b, 0xd3, 0x40, - 0x14, 0x6e, 0xd6, 0x6d, 0xd9, 0x9d, 0x55, 0x57, 0x43, 0xd1, 0x1a, 0x24, 0x5d, 0xa3, 0xa0, 0x16, - 0x9a, 0xb1, 0x7a, 0xeb, 0xad, 0xa5, 0x20, 0x7b, 0xa8, 0x87, 0x14, 0x56, 0x10, 0xa4, 0x4c, 0x9a, - 0x61, 0x0c, 0xdb, 0x99, 0x29, 0x79, 0x31, 0xb5, 0x37, 0xf1, 0xa8, 0x1e, 0xfc, 0x29, 0x3d, 0xf8, - 0x13, 0x3c, 0x78, 0x5c, 0x3c, 0x79, 0x2a, 0x92, 0x1e, 0x7a, 0xf7, 0x17, 0x48, 0x26, 0xd3, 0x62, - 0xaa, 0xd0, 0xc3, 0x5e, 0x42, 0xbe, 0xf7, 0x7d, 0x33, 0xdf, 0xfb, 0xde, 0x3c, 0x64, 0xf3, 0x70, - 0x7c, 0x3e, 0x9b, 0x92, 0x19, 0x26, 0x09, 0xe0, 0xa4, 0x85, 0x39, 0x05, 0x20, 0x8c, 0x82, 0x3b, - 0x89, 0x64, 0x2c, 0xcd, 0xe3, 0x35, 0xef, 0x92, 0x04, 0xdc, 0xa4, 0x65, 0xdd, 0x24, 0x3c, 0x14, - 0x12, 0xab, 0x6f, 0xae, 0xb1, 0xee, 0x8c, 0x24, 0x70, 0x09, 0x43, 0x85, 0x70, 0x0e, 0x34, 0x65, - 0xe7, 0x08, 0xfb, 0x04, 0x28, 0x4e, 0x5a, 0x3e, 0x8d, 0x49, 0x0b, 0x8f, 0x64, 0x28, 0xfe, 0xe1, - 0xc5, 0xf9, 0x86, 0xcf, 0x80, 0xe6, 0x6f, 0x6b, 0x9e, 0x03, 0x53, 0xcd, 0x01, 0xd3, 0x44, 0x95, - 0x49, 0x26, 0x73, 0xc3, 0xec, 0x4f, 0x57, 0xef, 0x6e, 0xa7, 0x99, 0x90, 0x88, 0x70, 0xdd, 0x8c, - 0xf3, 0xc9, 0x40, 0xd7, 0xfb, 0xc0, 0x3c, 0xca, 0x42, 0x88, 0x69, 0xd4, 0x39, 0x1b, 0x98, 0x4f, - 0x50, 0x05, 0xa8, 0x08, 0x68, 0x54, 0x33, 0x4e, 0x8c, 0x47, 0x87, 0xdd, 0xda, 0x8f, 0xaf, 0xcd, - 0xaa, 0x4e, 0xd0, 0x09, 0x82, 0x88, 0x02, 0x0c, 0xe2, 0x28, 0x14, 0xcc, 0xd3, 0x3a, 0xf3, 0x3e, - 0xda, 0x17, 0x84, 0xd3, 0xda, 0x9e, 0xd2, 0x1f, 0xff, 0x5e, 0xd4, 0x8f, 0x66, 0x84, 0x8f, 0xdb, - 0x4e, 0x56, 0x75, 0x3c, 0x45, 0xb6, 0x9d, 0x0f, 0xab, 0x79, 0x43, 0x9f, 0xf8, 0xb8, 0x9a, 0x37, - 0xcc, 0xac, 0x9d, 0xa2, 0xb5, 0xd3, 0x43, 0xb7, 0x8a, 0x15, 0x8f, 0xc2, 0x44, 0x0a, 0xa0, 0x66, - 0x03, 0x21, 0x41, 0xa7, 0x43, 0x92, 0xc0, 0x30, 0x0c, 0x54, 0x63, 0xfb, 0xdd, 0xab, 0xe9, 0xa2, - 0x7e, 0xf0, 0x82, 0x4e, 0x3b, 0x67, 0x83, 0xd3, 0x9e, 0x77, 0x20, 0xe8, 0xb4, 0x93, 0xc0, 0x69, - 0xe0, 0x7c, 0x36, 0xd0, 0x8d, 0x3e, 0xb0, 0x1e, 0x8d, 0x2e, 0x95, 0xea, 0x04, 0x55, 0xb4, 0xdd, - 0x9e, 0xb2, 0x3b, 0x4c, 0x17, 0xf5, 0x72, 0xee, 0x55, 0x26, 0x99, 0x51, 0xfb, 0xc1, 0x56, 0xa4, - 0xaa, 0x8e, 0x54, 0x70, 0x76, 0x2c, 0x54, 0xdb, 0xae, 0xad, 0x63, 0x3d, 0xfd, 0x66, 0xa0, 0x2b, - 0x7d, 0x60, 0xe6, 0x4b, 0x74, 0xf4, 0xf7, 0x13, 0xd4, 0xdd, 0xad, 0x15, 0x73, 0x8b, 0x63, 0xb1, - 0x1e, 0xee, 0x10, 0x6c, 0xe6, 0xf6, 0x1a, 0x5d, 0x2b, 0xce, 0xe1, 0xde, 0xff, 0x4e, 0x16, 0x24, - 0xd6, 0xe3, 0x9d, 0x92, 0xf5, 0xf5, 0x56, 0xf9, 0xfd, 0x6a, 0xde, 0x30, 0xba, 0xcf, 0xbf, 0xa7, - 0xb6, 0x71, 0x91, 0xda, 0xc6, 0xaf, 0xd4, 0x36, 0xbe, 0x2c, 0xed, 0xd2, 0xc5, 0xd2, 0x2e, 0xfd, - 0x5c, 0xda, 0xa5, 0x57, 0x4d, 0x16, 0xc6, 0x6f, 0xde, 0xfa, 0xee, 0x48, 0x72, 0xbc, 0xbe, 0xb5, - 0x39, 0x26, 0x3e, 0x6c, 0x10, 0x7e, 0xa7, 0x16, 0x33, 0x9e, 0x4d, 0x28, 0xf8, 0x15, 0xb5, 0x95, - 0xcf, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0xfc, 0xef, 0xf5, 0x4c, 0x83, 0x03, 0x00, 0x00, + // 481 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x52, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0xce, 0x95, 0x26, 0x6a, 0xaf, 0x40, 0x21, 0xaa, 0x68, 0x6a, 0x21, 0xa7, 0x98, 0xa1, 0x34, + 0x52, 0x7c, 0x04, 0xb6, 0x6c, 0x89, 0x22, 0xa1, 0x0e, 0x61, 0x70, 0xa4, 0x22, 0x21, 0xa1, 0xe8, + 0x1c, 0x9f, 0x0e, 0xab, 0xb9, 0xbb, 0xc8, 0xcf, 0x38, 0x64, 0x43, 0x8c, 0x4c, 0xe5, 0x9f, 0x64, + 0xe0, 0x27, 0x30, 0x30, 0x56, 0x4c, 0x4c, 0x11, 0x72, 0x86, 0xec, 0xfc, 0x02, 0x94, 0xf3, 0x25, + 0xaa, 0x03, 0x52, 0x87, 0x2e, 0x96, 0xbf, 0xf7, 0x7d, 0x77, 0xdf, 0xfb, 0xde, 0x3d, 0x6c, 0x8b, + 0x70, 0x78, 0x31, 0x19, 0xd3, 0x09, 0xa1, 0x09, 0x90, 0xa4, 0x41, 0x04, 0x03, 0xa0, 0x9c, 0x81, + 0x3b, 0x8a, 0x54, 0xac, 0xca, 0xfb, 0x2b, 0xde, 0xa5, 0x09, 0xb8, 0x49, 0xc3, 0x7a, 0x48, 0x45, + 0x28, 0x15, 0xd1, 0xdf, 0x4c, 0x63, 0x1d, 0x0d, 0x14, 0x08, 0x05, 0x7d, 0x8d, 0x48, 0x06, 0x0c, + 0x65, 0x67, 0x88, 0xf8, 0x14, 0x18, 0x49, 0x1a, 0x3e, 0x8b, 0x69, 0x83, 0x0c, 0x54, 0x28, 0xff, + 0xe1, 0xe5, 0xc5, 0x9a, 0x5f, 0x02, 0xc3, 0x1f, 0x1a, 0x5e, 0x00, 0xd7, 0xcd, 0x01, 0x37, 0xc4, + 0x01, 0x57, 0x5c, 0x65, 0x86, 0xcb, 0x3f, 0x53, 0x7d, 0xbc, 0x99, 0x66, 0x44, 0x23, 0x2a, 0x4c, + 0x33, 0xce, 0x25, 0xc2, 0xf7, 0xbb, 0xc0, 0x3d, 0xc6, 0x43, 0x88, 0x59, 0xd4, 0x3a, 0xef, 0x95, + 0x9f, 0xe3, 0x12, 0x30, 0x19, 0xb0, 0xa8, 0x82, 0x8e, 0xd1, 0xb3, 0xdd, 0x76, 0xe5, 0xe7, 0xb7, + 0xfa, 0x81, 0x49, 0xd0, 0x0a, 0x82, 0x88, 0x01, 0xf4, 0xe2, 0x28, 0x94, 0xdc, 0x33, 0xba, 0xf2, + 0x53, 0xbc, 0x2d, 0xa9, 0x60, 0x95, 0x2d, 0xad, 0xdf, 0xff, 0x33, 0xab, 0xee, 0x4d, 0xa8, 0x18, + 0x36, 0x9d, 0x65, 0xd5, 0xf1, 0x34, 0xd9, 0x3c, 0xf9, 0xbc, 0x98, 0xd6, 0xcc, 0x89, 0x2f, 0x8b, + 0x69, 0xed, 0x70, 0xdd, 0x57, 0xde, 0xdf, 0xe9, 0xe0, 0x47, 0xf9, 0x8a, 0xc7, 0x60, 0xa4, 0x24, + 0xb0, 0x72, 0x0d, 0x63, 0xc9, 0xc6, 0x7d, 0x9a, 0x40, 0x3f, 0x0c, 0x74, 0x77, 0xdb, 0xed, 0xbb, + 0xe9, 0xac, 0xba, 0xf3, 0x9a, 0x8d, 0x5b, 0xe7, 0xbd, 0xb3, 0x8e, 0xb7, 0x23, 0xd9, 0xb8, 0x95, + 0xc0, 0x59, 0xe0, 0x7c, 0x45, 0xf8, 0x41, 0x17, 0x78, 0x87, 0x45, 0xb7, 0x8a, 0x76, 0x8c, 0x4b, + 0xc6, 0x6e, 0x4b, 0xdb, 0xed, 0xa6, 0xb3, 0x6a, 0x31, 0xf3, 0x2a, 0xd2, 0xa5, 0x51, 0xf3, 0x74, + 0x23, 0xd7, 0xd1, 0xf5, 0x5c, 0x39, 0x7b, 0xc7, 0xc2, 0x95, 0xcd, 0xda, 0x2a, 0xdb, 0x8b, 0xef, + 0x08, 0xdf, 0xe9, 0x02, 0x2f, 0xbf, 0xc1, 0x7b, 0xd7, 0x1f, 0xa3, 0xea, 0x6e, 0x2c, 0x9b, 0x9b, + 0x9f, 0x8d, 0x75, 0x72, 0x83, 0x60, 0x3d, 0xbc, 0x77, 0xf8, 0x5e, 0x7e, 0x18, 0x4f, 0xfe, 0x77, + 0x32, 0x27, 0xb1, 0x4e, 0x6f, 0x94, 0xac, 0xae, 0xb7, 0x8a, 0x9f, 0x16, 0xd3, 0x1a, 0x6a, 0xbf, + 0xfa, 0x91, 0xda, 0xe8, 0x2a, 0xb5, 0xd1, 0xef, 0xd4, 0x46, 0x97, 0x73, 0xbb, 0x70, 0x35, 0xb7, + 0x0b, 0xbf, 0xe6, 0x76, 0xe1, 0x6d, 0x9d, 0x87, 0xf1, 0xfb, 0x0f, 0xbe, 0x3b, 0x50, 0x82, 0xac, + 0x6e, 0xad, 0x0f, 0xa9, 0x0f, 0x6b, 0x44, 0x3e, 0xea, 0x15, 0x8d, 0x27, 0x23, 0x06, 0x7e, 0x49, + 0xef, 0xe7, 0xcb, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb2, 0x53, 0x2f, 0xfb, 0x8d, 0x03, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/avs/types/models.pb.go b/x/avs/types/models.pb.go index 0422c13d0..384b90b79 100644 --- a/x/avs/types/models.pb.go +++ b/x/avs/types/models.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -29,6 +30,8 @@ type AVS struct { ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // Name is the name of the AVS Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + // Admin is the address of the user that has registered the AVS + Admin string `protobuf:"bytes,3,opt,name=admin,proto3" json:"admin,omitempty"` } func (m *AVS) Reset() { *m = AVS{} } @@ -78,6 +81,13 @@ func (m *AVS) GetName() string { return "" } +func (m *AVS) GetAdmin() string { + if m != nil { + return m.Admin + } + return "" +} + func init() { proto.RegisterType((*AVS)(nil), "milkyway.avs.v1.AVS") } @@ -85,19 +95,23 @@ func init() { func init() { proto.RegisterFile("milkyway/avs/v1/models.proto", fileDescriptor_85e2c65ca3819b2c) } var fileDescriptor_85e2c65ca3819b2c = []byte{ - // 189 bytes of a gzipped FileDescriptorProto + // 241 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc9, 0xcd, 0xcc, 0xc9, 0xae, 0x2c, 0x4f, 0xac, 0xd4, 0x4f, 0x2c, 0x2b, 0xd6, 0x2f, 0x33, 0xd4, 0xcf, 0xcd, 0x4f, 0x49, 0xcd, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0xc9, 0xea, 0x25, 0x96, 0x15, 0xeb, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xe5, 0xf4, 0x41, 0x2c, 0x88, 0x32, - 0x25, 0x43, 0x2e, 0x66, 0xc7, 0xb0, 0x60, 0x21, 0x31, 0x2e, 0xa6, 0xcc, 0x14, 0x09, 0x46, 0x05, - 0x46, 0x0d, 0x16, 0x27, 0xb6, 0x47, 0xf7, 0xe4, 0x99, 0x3c, 0x5d, 0x82, 0x98, 0x32, 0x53, 0x84, - 0x84, 0xb8, 0x58, 0xf2, 0x12, 0x73, 0x53, 0x25, 0x98, 0x14, 0x18, 0x35, 0x38, 0x83, 0xc0, 0x6c, - 0x27, 0xf7, 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, 0x4d, 0xcf, 0x2c, - 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x59, 0xaf, 0x9b, 0x93, 0x98, 0x54, 0x0c, - 0xe7, 0xe9, 0x57, 0x80, 0x1d, 0x5b, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x76, 0x82, 0x31, - 0x20, 0x00, 0x00, 0xff, 0xff, 0xd9, 0xe5, 0x4f, 0x6c, 0xc9, 0x00, 0x00, 0x00, + 0x29, 0xc9, 0xe4, 0xfc, 0xe2, 0xdc, 0xfc, 0xe2, 0x78, 0x88, 0x04, 0x84, 0x03, 0x91, 0x52, 0x4a, + 0xe4, 0x62, 0x76, 0x0c, 0x0b, 0x16, 0x12, 0xe3, 0x62, 0xca, 0x4c, 0x91, 0x60, 0x54, 0x60, 0xd4, + 0x60, 0x71, 0x62, 0x7b, 0x74, 0x4f, 0x9e, 0xc9, 0xd3, 0x25, 0x88, 0x29, 0x33, 0x45, 0x48, 0x88, + 0x8b, 0x25, 0x2f, 0x31, 0x37, 0x55, 0x82, 0x49, 0x81, 0x51, 0x83, 0x33, 0x08, 0xcc, 0x16, 0xd2, + 0xe3, 0x62, 0x4d, 0x4c, 0xc9, 0xcd, 0xcc, 0x93, 0x60, 0x06, 0x09, 0x3a, 0x49, 0x5c, 0xda, 0xa2, + 0x2b, 0x02, 0x35, 0xd3, 0x31, 0x25, 0xa5, 0x28, 0xb5, 0xb8, 0x38, 0xb8, 0xa4, 0x28, 0x33, 0x2f, + 0x3d, 0x08, 0xa2, 0xcc, 0xc9, 0xfd, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, + 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, + 0x74, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x61, 0x3e, 0xd1, 0xcd, + 0x49, 0x4c, 0x2a, 0x86, 0xf3, 0xf4, 0x2b, 0xc0, 0xfe, 0x2e, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, + 0x03, 0x3b, 0xd9, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x5e, 0xd9, 0xd9, 0xbb, 0x14, 0x01, 0x00, + 0x00, } func (m *AVS) Marshal() (dAtA []byte, err error) { @@ -120,6 +134,13 @@ func (m *AVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintModels(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0x1a + } if len(m.Name) > 0 { i -= len(m.Name) copy(dAtA[i:], m.Name) @@ -159,6 +180,10 @@ func (m *AVS) Size() (n int) { if l > 0 { n += 1 + l + sovModels(uint64(l)) } + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovModels(uint64(l)) + } return n } @@ -248,6 +273,38 @@ func (m *AVS) Unmarshal(dAtA []byte) error { } m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + 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 ErrInvalidLengthModels + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModels + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipModels(dAtA[iNdEx:]) From eaae8bd531170c2ab81beebed8fa2614ef3df3c2 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Mon, 3 Jun 2024 09:37:15 -0500 Subject: [PATCH 07/49] feat: add message and genesis implementations --- x/avs/types/codec.go | 40 ++++++++++++++++++++ x/avs/types/errors.go | 9 +++++ x/avs/types/events.go | 11 ++++++ x/avs/types/genesis.go | 52 ++++++++++++++++++++++++++ x/avs/types/keys.go | 8 ++++ x/avs/types/messages.go | 82 +++++++++++++++++++++++++++++++++++++++++ x/avs/types/models.go | 35 ++++++++++++++++++ x/avs/types/params.go | 30 +++++++++++++++ 8 files changed, 267 insertions(+) create mode 100644 x/avs/types/codec.go create mode 100644 x/avs/types/errors.go create mode 100644 x/avs/types/events.go create mode 100644 x/avs/types/genesis.go create mode 100644 x/avs/types/keys.go create mode 100644 x/avs/types/messages.go create mode 100644 x/avs/types/models.go create mode 100644 x/avs/types/params.go diff --git a/x/avs/types/codec.go b/x/avs/types/codec.go new file mode 100644 index 000000000..41a16733b --- /dev/null +++ b/x/avs/types/codec.go @@ -0,0 +1,40 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/legacy" + "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + legacy.RegisterAminoMsg(cdc, &MsgRegisterAVS{}, "milkyway/MsgRegisterAVS") + legacy.RegisterAminoMsg(cdc, &MsgDeregisterAVS{}, "milkyway/MsgDeregisterAVS") +} + +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgRegisterAVS{}, + &MsgDeregisterAVS{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + // AminoCdc references the global x/avs module codec. Note, the codec should + // ONLY be used in certain instances of tests and for JSON encoding as Amino is + // still used for that purpose. + // + // The actual codec used for serialization should be provided to x/avs and + // defined at the application level. + AminoCdc = codec.NewLegacyAmino() +) + +func init() { + RegisterLegacyAminoCodec(AminoCdc) + cryptocodec.RegisterCrypto(AminoCdc) + sdk.RegisterLegacyAminoCodec(AminoCdc) +} diff --git a/x/avs/types/errors.go b/x/avs/types/errors.go new file mode 100644 index 000000000..ab08baa2d --- /dev/null +++ b/x/avs/types/errors.go @@ -0,0 +1,9 @@ +package types + +import ( + "cosmossdk.io/errors" +) + +var ( + ErrInvalidGenesis = errors.Register(ModuleName, 1, "invalid genesis state") +) diff --git a/x/avs/types/events.go b/x/avs/types/events.go new file mode 100644 index 000000000..862b5bac3 --- /dev/null +++ b/x/avs/types/events.go @@ -0,0 +1,11 @@ +package types + +// DONTCOVER + +const ( + EventTypeRegisterAVS = "registered_avs" + EventTypeDeregisteredAVS = "deregistered_avs" + + AttributeKeyAVSID = "avs_id" + AttributeKeySender = "sender" +) diff --git a/x/avs/types/genesis.go b/x/avs/types/genesis.go new file mode 100644 index 000000000..cc94b800e --- /dev/null +++ b/x/avs/types/genesis.go @@ -0,0 +1,52 @@ +package types + +import ( + "fmt" + + "github.com/milkyway-labs/milkyway/utils" +) + +// NewGenesisState returns a new GenesisState instance +func NewGenesisState(services []AVS, params Params) *GenesisState { + return &GenesisState{ + Services: services, + Params: params, + } +} + +// DefaultGenesisState returns a default GenesisState +func DefaultGenesisState() *GenesisState { + return NewGenesisState(nil, DefaultParams()) +} + +// -------------------------------------------------------------------------------------------------------------------- + +// ValidateGenesis validates the given genesis state and returns an error if something is invalid +func ValidateGenesis(data *GenesisState) error { + // Check for duplicated services + if duplicate := findDuplicatedService(data.Services); duplicate != nil { + return fmt.Errorf("duplicated service: %d", duplicate.ID) + } + + // Validate services + for _, service := range data.Services { + if err := service.Validate(); err != nil { + return fmt.Errorf("invalid service with id %d: %s", service.ID, err) + } + } + + // Validate params + if err := data.Params.Validate(); err != nil { + return fmt.Errorf("invalid params: %s", err) + } + + return nil +} + +// findDuplicatedService returns the first duplicated service in the slice. +// If no duplicates are found, it returns nil instead. +func findDuplicatedService(services []AVS) *AVS { + return utils.FindDuplicate(services, func(a, b AVS) bool { + return a.ID == b.ID + }) +} diff --git a/x/avs/types/keys.go b/x/avs/types/keys.go new file mode 100644 index 000000000..3b241b9ef --- /dev/null +++ b/x/avs/types/keys.go @@ -0,0 +1,8 @@ +package types + +const ( + ModuleName = "avs" + RouterKey = ModuleName + StoreKey = ModuleName + QuerierRoute = ModuleName +) diff --git a/x/avs/types/messages.go b/x/avs/types/messages.go new file mode 100644 index 000000000..900249784 --- /dev/null +++ b/x/avs/types/messages.go @@ -0,0 +1,82 @@ +package types + +import ( + "strings" + + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +var ( + _ sdk.Msg = &MsgRegisterAVS{} + _ sdk.Msg = &MsgDeregisterAVS{} +) + +// NewMsgRegisterAVS returns a new MsgRegisterAVS instance +func NewMsgRegisterAVS(name string, sender string) *MsgRegisterAVS { + return &MsgRegisterAVS{ + Name: name, + Sender: sender, + } +} + +// ValidateBasic implements sdk.Msg +func (msg *MsgRegisterAVS) ValidateBasic() error { + if strings.TrimSpace(msg.Name) == "" { + return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid AVS name: %s", msg.Name) + } + + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address") + } + + return nil +} + +// GetSignBytes implements sdk.Msg +func (msg *MsgRegisterAVS) GetSignBytes() []byte { + return AminoCdc.MustMarshalJSON(msg) +} + +// GetSigners implements sdk.Msg +func (msg *MsgRegisterAVS) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(msg.Sender) + return []sdk.AccAddress{addr} +} + +// -------------------------------------------------------------------------------------------------------------------- + +// NewMsgDeregisterAVS returns a new MsgDeregisterAVS instance +func NewMsgDeregisterAVS(avsID uint64, sender string) *MsgDeregisterAVS { + return &MsgDeregisterAVS{ + AVSID: avsID, + Sender: sender, + } +} + +// ValidateBasic implements sdk.Msg +func (msg *MsgDeregisterAVS) ValidateBasic() error { + if msg.AVSID == 0 { + return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid id: %d", msg.AVSID) + } + + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address") + } + + return nil +} + +// GetSignBytes implements sdk.Msg +func (msg *MsgDeregisterAVS) GetSignBytes() []byte { + return AminoCdc.MustMarshalJSON(msg) +} + +// GetSigners implements sdk.Msg +func (msg *MsgDeregisterAVS) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(msg.Sender) + return []sdk.AccAddress{addr} +} diff --git a/x/avs/types/models.go b/x/avs/types/models.go new file mode 100644 index 000000000..667bba84f --- /dev/null +++ b/x/avs/types/models.go @@ -0,0 +1,35 @@ +package types + +import ( + "fmt" + "strings" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// NewAVS creates a new AVS instance +func NewAVS(id uint64, name string, admin string) AVS { + return AVS{ + ID: id, + Name: name, + Admin: admin, + } +} + +// Validate checks that the AVS has valid values. +func (a *AVS) Validate() error { + if a.ID == 0 { + return fmt.Errorf("invalid id: %d", a.ID) + } + + if strings.TrimSpace(a.Name) == "" { + return fmt.Errorf("invalid name: %s", a.Name) + } + + _, err := sdk.AccAddressFromBech32(a.Admin) + if err != nil { + return fmt.Errorf("invalid admin address") + } + + return nil +} diff --git a/x/avs/types/params.go b/x/avs/types/params.go new file mode 100644 index 000000000..1222104df --- /dev/null +++ b/x/avs/types/params.go @@ -0,0 +1,30 @@ +package types + +import ( + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// NewParams creates a new Params object +func NewParams(avsRegistrationFee sdk.Coins) Params { + return Params{ + AvsRegistrationFee: avsRegistrationFee, + } +} + +// DefaultParams returns a default set of parameters. +func DefaultParams() Params { + return Params{ + AvsRegistrationFee: sdk.NewCoins(), + } +} + +// Validate checks that the parameters have valid values. +func (p *Params) Validate() error { + if !p.AvsRegistrationFee.IsValid() { + return errors.Wrapf(sdkerrors.ErrInvalidCoins, "invalid AVS registration fee: %s", p.AvsRegistrationFee) + } + + return nil +} From 501e055c82f61ef86daae8e918887f2ae644eac8 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Mon, 3 Jun 2024 17:52:56 -0500 Subject: [PATCH 08/49] feat: add queries --- proto/milkyway/avs/v1/query.proto | 17 ++ x/avs/types/query.go | 24 ++ x/avs/types/query.pb.go | 431 ++++++++++++++++++++++++++++-- x/avs/types/query.pb.gw.go | 101 +++++++ 4 files changed, 544 insertions(+), 29 deletions(-) create mode 100644 x/avs/types/query.go diff --git a/proto/milkyway/avs/v1/query.proto b/proto/milkyway/avs/v1/query.proto index 5624b026c..4ecd2fbb9 100644 --- a/proto/milkyway/avs/v1/query.proto +++ b/proto/milkyway/avs/v1/query.proto @@ -22,6 +22,12 @@ service Query { rpc Services(QueryServicesRequest) returns (QueryServicesResponse) { option (google.api.http).get = "/milkyway/avs/v1/services"; } + + // Service defines a gRPC query method that returns the service by the given + // service id. + rpc Service(QueryServiceRequest) returns (QueryServiceResponse) { + option (google.api.http).get = "/milkyway/avs/v1/services/{service_id}"; + } } // QueryParamsRequest is the request type for the Query/Params RPC method. @@ -45,3 +51,14 @@ message QueryServicesResponse { // Pagination defines the pagination response cosmos.base.query.v1beta1.PageResponse pagination = 2; } + +// QueryServiceRequest is the request type for the Query/Service RPC method. +message QueryServiceRequest { + // ServiceID is the ID of the service to query + uint64 service_id = 1 [ (gogoproto.customname) = "ServiceID" ]; +} + +// QueryServiceResponse is the response type for the Query/Service RPC method. +message QueryServiceResponse { + AVS service = 1 [ (gogoproto.nullable) = false ]; +} \ No newline at end of file diff --git a/x/avs/types/query.go b/x/avs/types/query.go new file mode 100644 index 000000000..72d449f0e --- /dev/null +++ b/x/avs/types/query.go @@ -0,0 +1,24 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/types/query" +) + +// NewQueryParamsRequest creates a new QueryParamsRequest instance +func NewQueryParamsRequest() *QueryParamsRequest { + return &QueryParamsRequest{} +} + +// NewQueryServicesRequest creates a new QueryServiceRequest instance +func NewQueryServicesRequest(pagination *query.PageRequest) *QueryServicesRequest { + return &QueryServicesRequest{ + Pagination: pagination, + } +} + +// NewQueryServiceRequest creates a new QueryServiceRequest instance +func NewQueryServiceRequest(serviceID uint64) *QueryServiceRequest { + return &QueryServiceRequest{ + ServiceID: serviceID, + } +} diff --git a/x/avs/types/query.pb.go b/x/avs/types/query.pb.go index 227a9e679..494016f10 100644 --- a/x/avs/types/query.pb.go +++ b/x/avs/types/query.pb.go @@ -212,45 +212,142 @@ func (m *QueryServicesResponse) GetPagination() *query.PageResponse { return nil } +// QueryServiceRequest is the request type for the Query/Service RPC method. +type QueryServiceRequest struct { + // ServiceID is the ID of the service to query + ServiceID uint64 `protobuf:"varint,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` +} + +func (m *QueryServiceRequest) Reset() { *m = QueryServiceRequest{} } +func (m *QueryServiceRequest) String() string { return proto.CompactTextString(m) } +func (*QueryServiceRequest) ProtoMessage() {} +func (*QueryServiceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_911f1b653a0f04ba, []int{4} +} +func (m *QueryServiceRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryServiceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryServiceRequest.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 *QueryServiceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryServiceRequest.Merge(m, src) +} +func (m *QueryServiceRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryServiceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryServiceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryServiceRequest proto.InternalMessageInfo + +func (m *QueryServiceRequest) GetServiceID() uint64 { + if m != nil { + return m.ServiceID + } + return 0 +} + +// QueryServiceResponse is the response type for the Query/Service RPC method. +type QueryServiceResponse struct { + Service AVS `protobuf:"bytes,1,opt,name=service,proto3" json:"service"` +} + +func (m *QueryServiceResponse) Reset() { *m = QueryServiceResponse{} } +func (m *QueryServiceResponse) String() string { return proto.CompactTextString(m) } +func (*QueryServiceResponse) ProtoMessage() {} +func (*QueryServiceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_911f1b653a0f04ba, []int{5} +} +func (m *QueryServiceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryServiceResponse.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 *QueryServiceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryServiceResponse.Merge(m, src) +} +func (m *QueryServiceResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryServiceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryServiceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryServiceResponse proto.InternalMessageInfo + +func (m *QueryServiceResponse) GetService() AVS { + if m != nil { + return m.Service + } + return AVS{} +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "milkyway.avs.v1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "milkyway.avs.v1.QueryParamsResponse") proto.RegisterType((*QueryServicesRequest)(nil), "milkyway.avs.v1.QueryServicesRequest") proto.RegisterType((*QueryServicesResponse)(nil), "milkyway.avs.v1.QueryServicesResponse") + proto.RegisterType((*QueryServiceRequest)(nil), "milkyway.avs.v1.QueryServiceRequest") + proto.RegisterType((*QueryServiceResponse)(nil), "milkyway.avs.v1.QueryServiceResponse") } func init() { proto.RegisterFile("milkyway/avs/v1/query.proto", fileDescriptor_911f1b653a0f04ba) } var fileDescriptor_911f1b653a0f04ba = []byte{ - // 435 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0x3f, 0x8f, 0xd3, 0x30, - 0x18, 0xc6, 0xe3, 0x03, 0xaa, 0x93, 0x6f, 0x40, 0x32, 0x41, 0x77, 0x97, 0x43, 0xb9, 0x23, 0xc0, - 0x71, 0x42, 0xaa, 0xad, 0x14, 0xc1, 0x4e, 0x07, 0xba, 0x30, 0x94, 0x56, 0x62, 0x60, 0x40, 0x72, - 0x8a, 0x15, 0x22, 0x92, 0x38, 0x8d, 0xdd, 0x40, 0x24, 0x26, 0x3e, 0x01, 0x12, 0x0b, 0x1f, 0xa9, - 0x63, 0x25, 0x16, 0x26, 0x84, 0x5a, 0xbe, 0x05, 0x0b, 0xaa, 0xed, 0xf4, 0x4f, 0x52, 0xe8, 0x16, - 0xf9, 0x7d, 0xde, 0xe7, 0xf9, 0xbd, 0xef, 0x1b, 0x78, 0x96, 0x44, 0xf1, 0xfb, 0xf2, 0x03, 0x2d, - 0x09, 0x2d, 0x04, 0x29, 0x7c, 0x32, 0x9e, 0xb0, 0xbc, 0xc4, 0x59, 0xce, 0x25, 0x47, 0x37, 0xab, - 0x22, 0xa6, 0x85, 0xc0, 0x85, 0xef, 0xd8, 0x21, 0x0f, 0xb9, 0xaa, 0x91, 0xe5, 0x97, 0x96, 0x39, - 0x77, 0x42, 0xce, 0xc3, 0x98, 0x11, 0x9a, 0x45, 0x84, 0xa6, 0x29, 0x97, 0x54, 0x46, 0x3c, 0x15, - 0xa6, 0xfa, 0x68, 0xc4, 0x45, 0xc2, 0x05, 0x09, 0xa8, 0x60, 0xda, 0x9d, 0x14, 0x7e, 0xc0, 0x24, - 0xf5, 0x49, 0x46, 0xc3, 0x28, 0x55, 0xe2, 0xca, 0xa9, 0x4e, 0x93, 0xf0, 0xb7, 0x2c, 0x16, 0xff, - 0xaa, 0x66, 0x34, 0xa7, 0x89, 0xa9, 0x7a, 0x36, 0x44, 0x2f, 0x97, 0xee, 0x7d, 0xf5, 0x38, 0x60, - 0xe3, 0x09, 0x13, 0xd2, 0x7b, 0x01, 0x6f, 0x6d, 0xbd, 0x8a, 0x8c, 0xa7, 0x82, 0xa1, 0x27, 0xb0, - 0xa5, 0x9b, 0x4f, 0xc0, 0x05, 0xb8, 0x3a, 0xea, 0x1c, 0xe3, 0xda, 0xa8, 0x58, 0x37, 0x74, 0xaf, - 0x4f, 0x7f, 0x9e, 0x5b, 0x03, 0x23, 0xf6, 0xde, 0x40, 0x5b, 0xb9, 0x0d, 0x59, 0x5e, 0x44, 0x23, - 0x56, 0xa5, 0xa0, 0xe7, 0x10, 0xae, 0x67, 0x31, 0x96, 0x97, 0x58, 0x0f, 0x8e, 0x97, 0x83, 0x63, - 0xbd, 0x56, 0x33, 0x38, 0xee, 0xd3, 0x90, 0x99, 0xde, 0xc1, 0x46, 0xa7, 0xf7, 0x0d, 0xc0, 0xdb, - 0xb5, 0x00, 0x03, 0xfc, 0x14, 0x1e, 0x0a, 0xf3, 0x76, 0x02, 0x2e, 0xae, 0x5d, 0x1d, 0x75, 0xec, - 0x06, 0xf2, 0xb3, 0x57, 0x43, 0xc3, 0xbb, 0xd2, 0xa2, 0xde, 0x16, 0xd9, 0x81, 0x22, 0x7b, 0xb8, - 0x97, 0x4c, 0x87, 0x6e, 0xa2, 0x75, 0xfe, 0x00, 0x78, 0x43, 0xa1, 0x21, 0x09, 0x5b, 0x7a, 0x39, - 0xe8, 0x5e, 0x03, 0xa1, 0x79, 0x01, 0xe7, 0xfe, 0xff, 0x45, 0x3a, 0xca, 0x3b, 0xff, 0xfc, 0xfd, - 0xf7, 0xd7, 0x83, 0x53, 0x74, 0x4c, 0x76, 0x1f, 0x19, 0x7d, 0x82, 0x87, 0xd5, 0x52, 0xd0, 0x83, - 0xdd, 0x96, 0xb5, 0xab, 0x38, 0x97, 0xfb, 0x64, 0x26, 0xfb, 0xae, 0xca, 0x3e, 0x43, 0xa7, 0x8d, - 0xec, 0x6a, 0x8d, 0xdd, 0xde, 0x74, 0xee, 0x82, 0xd9, 0xdc, 0x05, 0xbf, 0xe6, 0x2e, 0xf8, 0xb2, - 0x70, 0xad, 0xd9, 0xc2, 0xb5, 0x7e, 0x2c, 0x5c, 0xeb, 0x75, 0x3b, 0x8c, 0xe4, 0xbb, 0x49, 0x80, - 0x47, 0x3c, 0x59, 0xb5, 0xb7, 0x63, 0x1a, 0x88, 0xb5, 0xd9, 0x47, 0x65, 0x27, 0xcb, 0x8c, 0x89, - 0xa0, 0xa5, 0x7e, 0xd6, 0xc7, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x56, 0xe9, 0x60, 0xcc, 0x78, - 0x03, 0x00, 0x00, + // 512 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x4f, 0x6b, 0x13, 0x41, + 0x14, 0xcf, 0xb6, 0x35, 0x6d, 0x5f, 0x11, 0x61, 0x8c, 0xb4, 0x4d, 0x65, 0x53, 0xd7, 0x36, 0x06, + 0xb1, 0x33, 0x24, 0xfe, 0xb9, 0x1b, 0xc5, 0x52, 0xe8, 0xa1, 0xa6, 0xe0, 0xc1, 0x83, 0x32, 0x9b, + 0x0c, 0xeb, 0x62, 0x76, 0x67, 0x9b, 0xd9, 0xac, 0x06, 0xf5, 0x22, 0xe2, 0x59, 0xf0, 0xe2, 0x47, + 0xea, 0xb1, 0xe0, 0xc5, 0x53, 0x91, 0xc4, 0x0f, 0x22, 0x99, 0x79, 0x9b, 0x34, 0xd9, 0x36, 0xb9, + 0x2d, 0xf3, 0x7e, 0xef, 0xf7, 0xe7, 0xbd, 0xb7, 0xb0, 0x15, 0xf8, 0xed, 0xf7, 0xbd, 0x0f, 0xbc, + 0xc7, 0x78, 0xa2, 0x58, 0x52, 0x65, 0x27, 0x5d, 0xd1, 0xe9, 0xd1, 0xa8, 0x23, 0x63, 0x49, 0x6e, + 0xa4, 0x45, 0xca, 0x13, 0x45, 0x93, 0x6a, 0xb1, 0xe0, 0x49, 0x4f, 0xea, 0x1a, 0x1b, 0x7e, 0x19, + 0x58, 0xf1, 0xb6, 0x27, 0xa5, 0xd7, 0x16, 0x8c, 0x47, 0x3e, 0xe3, 0x61, 0x28, 0x63, 0x1e, 0xfb, + 0x32, 0x54, 0x58, 0xbd, 0xdf, 0x94, 0x2a, 0x90, 0x8a, 0xb9, 0x5c, 0x09, 0xc3, 0xce, 0x92, 0xaa, + 0x2b, 0x62, 0x5e, 0x65, 0x11, 0xf7, 0xfc, 0x50, 0x83, 0x53, 0xa6, 0x69, 0x37, 0x81, 0x6c, 0x89, + 0xb6, 0xba, 0xaa, 0x1a, 0xf1, 0x0e, 0x0f, 0xb0, 0xea, 0x14, 0x80, 0xbc, 0x1c, 0xb2, 0x1f, 0xe9, + 0xc7, 0x86, 0x38, 0xe9, 0x0a, 0x15, 0x3b, 0x87, 0x70, 0x73, 0xe2, 0x55, 0x45, 0x32, 0x54, 0x82, + 0x3c, 0x86, 0xbc, 0x69, 0xde, 0xb0, 0xb6, 0xad, 0xca, 0x5a, 0x6d, 0x9d, 0x4e, 0x45, 0xa5, 0xa6, + 0xa1, 0xbe, 0x74, 0x7a, 0x5e, 0xca, 0x35, 0x10, 0xec, 0xbc, 0x81, 0x82, 0x66, 0x3b, 0x16, 0x9d, + 0xc4, 0x6f, 0x8a, 0x54, 0x85, 0xbc, 0x00, 0x18, 0x67, 0x41, 0xca, 0x32, 0x35, 0xc1, 0xe9, 0x30, + 0x38, 0x35, 0x63, 0xc5, 0xe0, 0xf4, 0x88, 0x7b, 0x02, 0x7b, 0x1b, 0x17, 0x3a, 0x9d, 0x5f, 0x16, + 0xdc, 0x9a, 0x12, 0x40, 0xc3, 0x4f, 0x60, 0x45, 0xe1, 0xdb, 0x86, 0xb5, 0xbd, 0x58, 0x59, 0xab, + 0x15, 0x32, 0x96, 0x9f, 0xbe, 0x3a, 0x46, 0xbf, 0x23, 0x2c, 0xd9, 0x9f, 0x70, 0xb6, 0xa0, 0x9d, + 0xdd, 0x9b, 0xeb, 0xcc, 0x88, 0x4e, 0x58, 0x7b, 0x86, 0x83, 0x44, 0x67, 0x69, 0xf2, 0x07, 0x00, + 0xa8, 0xf5, 0xd6, 0x6f, 0xe9, 0xe4, 0x4b, 0xf5, 0xeb, 0xfd, 0xf3, 0xd2, 0x2a, 0xe2, 0x0e, 0x9e, + 0x37, 0x56, 0x11, 0x70, 0xd0, 0x72, 0x0e, 0x27, 0xe7, 0x37, 0x4a, 0xf7, 0x08, 0x96, 0x11, 0x84, + 0xc3, 0x9b, 0x15, 0x2e, 0x85, 0xd6, 0xbe, 0x2d, 0xc2, 0x35, 0x4d, 0x47, 0x62, 0xc8, 0x9b, 0x7d, + 0x91, 0xbb, 0x99, 0xc6, 0xec, 0x51, 0x14, 0x77, 0x66, 0x83, 0x8c, 0x29, 0xa7, 0xf4, 0xf5, 0xf7, + 0xbf, 0x9f, 0x0b, 0x9b, 0x64, 0x9d, 0x5d, 0x7e, 0x77, 0xe4, 0x33, 0xac, 0xa4, 0x7b, 0x22, 0xbb, + 0x97, 0x53, 0x4e, 0x1d, 0x4a, 0xb1, 0x3c, 0x0f, 0x86, 0xda, 0x77, 0xb4, 0xf6, 0x16, 0xd9, 0xcc, + 0x68, 0x8f, 0x36, 0xfb, 0xdd, 0x82, 0x65, 0xec, 0x23, 0x3b, 0x33, 0x69, 0x53, 0xf1, 0xdd, 0x39, + 0x28, 0xd4, 0xa6, 0x5a, 0xbb, 0x42, 0xca, 0x57, 0x6a, 0xb3, 0x4f, 0xe3, 0x9d, 0x7f, 0xa9, 0xef, + 0x9f, 0xf6, 0x6d, 0xeb, 0xac, 0x6f, 0x5b, 0x7f, 0xfb, 0xb6, 0xf5, 0x63, 0x60, 0xe7, 0xce, 0x06, + 0x76, 0xee, 0xcf, 0xc0, 0xce, 0xbd, 0xde, 0xf3, 0xfc, 0xf8, 0x5d, 0xd7, 0xa5, 0x4d, 0x19, 0x8c, + 0xb8, 0xf6, 0xda, 0xdc, 0x55, 0x63, 0xe6, 0x8f, 0x9a, 0x3b, 0xee, 0x45, 0x42, 0xb9, 0x79, 0xfd, + 0x23, 0x3f, 0xfc, 0x1f, 0x00, 0x00, 0xff, 0xff, 0x6e, 0xde, 0xb0, 0xb4, 0x94, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -271,6 +368,9 @@ type QueryClient interface { // Services defines a gRPC query method that returns the actively validates // services currently registered in the module. Services(ctx context.Context, in *QueryServicesRequest, opts ...grpc.CallOption) (*QueryServicesResponse, error) + // Service defines a gRPC query method that returns the service by the given + // service id. + Service(ctx context.Context, in *QueryServiceRequest, opts ...grpc.CallOption) (*QueryServiceResponse, error) } type queryClient struct { @@ -299,6 +399,15 @@ func (c *queryClient) Services(ctx context.Context, in *QueryServicesRequest, op return out, nil } +func (c *queryClient) Service(ctx context.Context, in *QueryServiceRequest, opts ...grpc.CallOption) (*QueryServiceResponse, error) { + out := new(QueryServiceResponse) + err := c.cc.Invoke(ctx, "/milkyway.avs.v1.Query/Service", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Params defines a gRPC query method that returns the parameters of the @@ -307,6 +416,9 @@ type QueryServer interface { // Services defines a gRPC query method that returns the actively validates // services currently registered in the module. Services(context.Context, *QueryServicesRequest) (*QueryServicesResponse, error) + // Service defines a gRPC query method that returns the service by the given + // service id. + Service(context.Context, *QueryServiceRequest) (*QueryServiceResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -319,6 +431,9 @@ func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsReq func (*UnimplementedQueryServer) Services(ctx context.Context, req *QueryServicesRequest) (*QueryServicesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Services not implemented") } +func (*UnimplementedQueryServer) Service(ctx context.Context, req *QueryServiceRequest) (*QueryServiceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Service not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -360,6 +475,24 @@ func _Query_Services_Handler(srv interface{}, ctx context.Context, dec func(inte return interceptor(ctx, in, info, handler) } +func _Query_Service_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryServiceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Service(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/milkyway.avs.v1.Query/Service", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Service(ctx, req.(*QueryServiceRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "milkyway.avs.v1.Query", HandlerType: (*QueryServer)(nil), @@ -372,6 +505,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Services", Handler: _Query_Services_Handler, }, + { + MethodName: "Service", + Handler: _Query_Service_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "milkyway/avs/v1/query.proto", @@ -517,6 +654,67 @@ func (m *QueryServicesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryServiceRequest) 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 *QueryServiceRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryServiceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ServiceID != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ServiceID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryServiceResponse) 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 *QueryServiceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryServiceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Service.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 @@ -580,6 +778,29 @@ func (m *QueryServicesResponse) Size() (n int) { return n } +func (m *QueryServiceRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ServiceID != 0 { + n += 1 + sovQuery(uint64(m.ServiceID)) + } + return n +} + +func (m *QueryServiceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Service.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -925,6 +1146,158 @@ func (m *QueryServicesResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryServiceRequest) 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: QueryServiceRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryServiceRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ServiceID", wireType) + } + m.ServiceID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ServiceID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *QueryServiceResponse) 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: QueryServiceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryServiceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Service", 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.Service.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 diff --git a/x/avs/types/query.pb.gw.go b/x/avs/types/query.pb.gw.go index ccea64048..0d3541d93 100644 --- a/x/avs/types/query.pb.gw.go +++ b/x/avs/types/query.pb.gw.go @@ -87,6 +87,60 @@ func local_request_Query_Services_0(ctx context.Context, marshaler runtime.Marsh } +func request_Query_Service_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryServiceRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["service_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "service_id") + } + + protoReq.ServiceId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "service_id", err) + } + + msg, err := client.Service(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Service_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryServiceRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["service_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "service_id") + } + + protoReq.ServiceId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "service_id", err) + } + + msg, err := server.Service(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. @@ -139,6 +193,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_Service_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_Service_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_Service_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -220,6 +297,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_Service_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_Service_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_Service_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -227,10 +324,14 @@ var ( pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"milkyway", "avs", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_Services_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"milkyway", "avs", "v1", "services"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Service_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"milkyway", "avs", "v1", "services", "service_id"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_Params_0 = runtime.ForwardResponseMessage forward_Query_Services_0 = runtime.ForwardResponseMessage + + forward_Query_Service_0 = runtime.ForwardResponseMessage ) From af9a8b82a8417de3aea5f4c2c2051a63cc2f810d Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Mon, 3 Jun 2024 18:10:10 -0500 Subject: [PATCH 09/49] refactor: use uint32 for AVS IDs instead of uint64 --- proto/milkyway/avs/v1/messages.proto | 2 +- proto/milkyway/avs/v1/models.proto | 2 +- proto/milkyway/avs/v1/query.proto | 2 +- x/avs/types/messages.pb.go | 64 ++++++++++++++-------------- x/avs/types/models.go | 2 +- x/avs/types/models.pb.go | 10 ++--- x/avs/types/query.go | 2 +- x/avs/types/query.pb.go | 34 +++++++-------- x/avs/types/query.pb.gw.go | 4 +- 9 files changed, 61 insertions(+), 61 deletions(-) diff --git a/proto/milkyway/avs/v1/messages.proto b/proto/milkyway/avs/v1/messages.proto index b2b935f63..75f53839a 100644 --- a/proto/milkyway/avs/v1/messages.proto +++ b/proto/milkyway/avs/v1/messages.proto @@ -38,7 +38,7 @@ message MsgRegisterAVS { // It returns the newly created AVS ID. message MsgRegisterAVSResponse { // NewAVSID is the ID of the newly registered AVS - uint64 new_avs_id = 1 [ (gogoproto.customname) = "NewAVSID" ]; + uint32 new_avs_id = 1 [ (gogoproto.customname) = "NewAVSID" ]; } // MsgDeregisterAVS defines the message structure for the DeregisterAVS gRPC diff --git a/proto/milkyway/avs/v1/models.proto b/proto/milkyway/avs/v1/models.proto index d5646b1a4..93ae56930 100644 --- a/proto/milkyway/avs/v1/models.proto +++ b/proto/milkyway/avs/v1/models.proto @@ -9,7 +9,7 @@ option go_package = "github.com/milkyway-labs/milkyway/x/avs/types"; // AVS defines the fields of an AVS message AVS { // ID is the auto-generated unique identifier for the AVS - uint64 id = 1 [ (gogoproto.customname) = "ID" ]; + uint32 id = 1 [ (gogoproto.customname) = "ID" ]; // Name is the name of the AVS string name = 2; diff --git a/proto/milkyway/avs/v1/query.proto b/proto/milkyway/avs/v1/query.proto index 4ecd2fbb9..56f460915 100644 --- a/proto/milkyway/avs/v1/query.proto +++ b/proto/milkyway/avs/v1/query.proto @@ -55,7 +55,7 @@ message QueryServicesResponse { // QueryServiceRequest is the request type for the Query/Service RPC method. message QueryServiceRequest { // ServiceID is the ID of the service to query - uint64 service_id = 1 [ (gogoproto.customname) = "ServiceID" ]; + uint32 service_id = 1 [ (gogoproto.customname) = "ServiceID" ]; } // QueryServiceResponse is the response type for the Query/Service RPC method. diff --git a/x/avs/types/messages.pb.go b/x/avs/types/messages.pb.go index fc6d2a5de..b36c530bb 100644 --- a/x/avs/types/messages.pb.go +++ b/x/avs/types/messages.pb.go @@ -95,7 +95,7 @@ func (m *MsgRegisterAVS) GetName() string { // It returns the newly created AVS ID. type MsgRegisterAVSResponse struct { // NewAVSID is the ID of the newly registered AVS - NewAVSID uint64 `protobuf:"varint,1,opt,name=new_avs_id,json=newAvsId,proto3" json:"new_avs_id,omitempty"` + NewAVSID uint32 `protobuf:"varint,1,opt,name=new_avs_id,json=newAvsId,proto3" json:"new_avs_id,omitempty"` } func (m *MsgRegisterAVSResponse) Reset() { *m = MsgRegisterAVSResponse{} } @@ -131,7 +131,7 @@ func (m *MsgRegisterAVSResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRegisterAVSResponse proto.InternalMessageInfo -func (m *MsgRegisterAVSResponse) GetNewAVSID() uint64 { +func (m *MsgRegisterAVSResponse) GetNewAVSID() uint32 { if m != nil { return m.NewAVSID } @@ -242,38 +242,38 @@ func init() { func init() { proto.RegisterFile("milkyway/avs/v1/messages.proto", fileDescriptor_ee6728b943d8fd23) } var fileDescriptor_ee6728b943d8fd23 = []byte{ - // 481 bytes of a gzipped FileDescriptorProto + // 482 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x52, 0x31, 0x6f, 0xd3, 0x40, - 0x14, 0xce, 0x95, 0x26, 0x6a, 0xaf, 0x40, 0x21, 0xaa, 0x68, 0x6a, 0x21, 0xa7, 0x98, 0xa1, 0x34, + 0x14, 0xce, 0x41, 0x13, 0xb5, 0x57, 0x4a, 0xc1, 0xaa, 0x68, 0x6a, 0x21, 0xa7, 0x98, 0xa1, 0x34, 0x52, 0x7c, 0x04, 0xb6, 0x6c, 0x89, 0x22, 0xa1, 0x0e, 0x61, 0x70, 0xa4, 0x22, 0x21, 0xa1, 0xe8, 0x1c, 0x9f, 0x0e, 0xab, 0xb9, 0xbb, 0xc8, 0xcf, 0x38, 0x64, 0x43, 0x8c, 0x4c, 0xe5, 0x9f, 0x64, - 0xe0, 0x27, 0x30, 0x30, 0x56, 0x4c, 0x4c, 0x11, 0x72, 0x86, 0xec, 0xfc, 0x02, 0x94, 0xf3, 0x25, - 0xaa, 0x03, 0x52, 0x87, 0x2e, 0x96, 0xbf, 0xf7, 0x7d, 0x77, 0xdf, 0xfb, 0xde, 0x3d, 0x6c, 0x8b, - 0x70, 0x78, 0x31, 0x19, 0xd3, 0x09, 0xa1, 0x09, 0x90, 0xa4, 0x41, 0x04, 0x03, 0xa0, 0x9c, 0x81, - 0x3b, 0x8a, 0x54, 0xac, 0xca, 0xfb, 0x2b, 0xde, 0xa5, 0x09, 0xb8, 0x49, 0xc3, 0x7a, 0x48, 0x45, - 0x28, 0x15, 0xd1, 0xdf, 0x4c, 0x63, 0x1d, 0x0d, 0x14, 0x08, 0x05, 0x7d, 0x8d, 0x48, 0x06, 0x0c, - 0x65, 0x67, 0x88, 0xf8, 0x14, 0x18, 0x49, 0x1a, 0x3e, 0x8b, 0x69, 0x83, 0x0c, 0x54, 0x28, 0xff, - 0xe1, 0xe5, 0xc5, 0x9a, 0x5f, 0x02, 0xc3, 0x1f, 0x1a, 0x5e, 0x00, 0xd7, 0xcd, 0x01, 0x37, 0xc4, - 0x01, 0x57, 0x5c, 0x65, 0x86, 0xcb, 0x3f, 0x53, 0x7d, 0xbc, 0x99, 0x66, 0x44, 0x23, 0x2a, 0x4c, - 0x33, 0xce, 0x25, 0xc2, 0xf7, 0xbb, 0xc0, 0x3d, 0xc6, 0x43, 0x88, 0x59, 0xd4, 0x3a, 0xef, 0x95, - 0x9f, 0xe3, 0x12, 0x30, 0x19, 0xb0, 0xa8, 0x82, 0x8e, 0xd1, 0xb3, 0xdd, 0x76, 0xe5, 0xe7, 0xb7, - 0xfa, 0x81, 0x49, 0xd0, 0x0a, 0x82, 0x88, 0x01, 0xf4, 0xe2, 0x28, 0x94, 0xdc, 0x33, 0xba, 0xf2, - 0x53, 0xbc, 0x2d, 0xa9, 0x60, 0x95, 0x2d, 0xad, 0xdf, 0xff, 0x33, 0xab, 0xee, 0x4d, 0xa8, 0x18, - 0x36, 0x9d, 0x65, 0xd5, 0xf1, 0x34, 0xd9, 0x3c, 0xf9, 0xbc, 0x98, 0xd6, 0xcc, 0x89, 0x2f, 0x8b, - 0x69, 0xed, 0x70, 0xdd, 0x57, 0xde, 0xdf, 0xe9, 0xe0, 0x47, 0xf9, 0x8a, 0xc7, 0x60, 0xa4, 0x24, - 0xb0, 0x72, 0x0d, 0x63, 0xc9, 0xc6, 0x7d, 0x9a, 0x40, 0x3f, 0x0c, 0x74, 0x77, 0xdb, 0xed, 0xbb, - 0xe9, 0xac, 0xba, 0xf3, 0x9a, 0x8d, 0x5b, 0xe7, 0xbd, 0xb3, 0x8e, 0xb7, 0x23, 0xd9, 0xb8, 0x95, - 0xc0, 0x59, 0xe0, 0x7c, 0x45, 0xf8, 0x41, 0x17, 0x78, 0x87, 0x45, 0xb7, 0x8a, 0x76, 0x8c, 0x4b, - 0xc6, 0x6e, 0x4b, 0xdb, 0xed, 0xa6, 0xb3, 0x6a, 0x31, 0xf3, 0x2a, 0xd2, 0xa5, 0x51, 0xf3, 0x74, - 0x23, 0xd7, 0xd1, 0xf5, 0x5c, 0x39, 0x7b, 0xc7, 0xc2, 0x95, 0xcd, 0xda, 0x2a, 0xdb, 0x8b, 0xef, - 0x08, 0xdf, 0xe9, 0x02, 0x2f, 0xbf, 0xc1, 0x7b, 0xd7, 0x1f, 0xa3, 0xea, 0x6e, 0x2c, 0x9b, 0x9b, - 0x9f, 0x8d, 0x75, 0x72, 0x83, 0x60, 0x3d, 0xbc, 0x77, 0xf8, 0x5e, 0x7e, 0x18, 0x4f, 0xfe, 0x77, - 0x32, 0x27, 0xb1, 0x4e, 0x6f, 0x94, 0xac, 0xae, 0xb7, 0x8a, 0x9f, 0x16, 0xd3, 0x1a, 0x6a, 0xbf, - 0xfa, 0x91, 0xda, 0xe8, 0x2a, 0xb5, 0xd1, 0xef, 0xd4, 0x46, 0x97, 0x73, 0xbb, 0x70, 0x35, 0xb7, - 0x0b, 0xbf, 0xe6, 0x76, 0xe1, 0x6d, 0x9d, 0x87, 0xf1, 0xfb, 0x0f, 0xbe, 0x3b, 0x50, 0x82, 0xac, - 0x6e, 0xad, 0x0f, 0xa9, 0x0f, 0x6b, 0x44, 0x3e, 0xea, 0x15, 0x8d, 0x27, 0x23, 0x06, 0x7e, 0x49, - 0xef, 0xe7, 0xcb, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb2, 0x53, 0x2f, 0xfb, 0x8d, 0x03, 0x00, - 0x00, + 0xe0, 0x27, 0x30, 0x30, 0x56, 0x4c, 0x4c, 0x11, 0x72, 0x86, 0xec, 0xfc, 0x02, 0x64, 0xfb, 0x12, + 0xd5, 0x01, 0xa9, 0x43, 0x17, 0xcb, 0xdf, 0xfb, 0xbe, 0xbb, 0xef, 0x7d, 0xef, 0x1e, 0xb6, 0x44, + 0x30, 0xba, 0x98, 0x4e, 0xe8, 0x94, 0xd0, 0x18, 0x48, 0xdc, 0x24, 0x82, 0x01, 0x50, 0xce, 0xc0, + 0x19, 0x87, 0x2a, 0x52, 0xc6, 0xfe, 0x8a, 0x77, 0x68, 0x0c, 0x4e, 0xdc, 0x34, 0x1f, 0x52, 0x11, + 0x48, 0x45, 0xb2, 0x6f, 0xae, 0x31, 0x8f, 0x86, 0x0a, 0x84, 0x82, 0x41, 0x86, 0x48, 0x0e, 0x34, + 0x65, 0xe5, 0x88, 0x78, 0x14, 0x18, 0x89, 0x9b, 0x1e, 0x8b, 0x68, 0x93, 0x0c, 0x55, 0x20, 0xff, + 0xe1, 0xe5, 0xc5, 0x9a, 0x4f, 0x81, 0xe6, 0x0f, 0x35, 0x2f, 0x80, 0x67, 0xcd, 0x01, 0xd7, 0xc4, + 0x01, 0x57, 0x5c, 0xe5, 0x86, 0xe9, 0x9f, 0xae, 0x3e, 0xde, 0x4c, 0x33, 0xa6, 0x21, 0x15, 0xba, + 0x19, 0xfb, 0x12, 0xe1, 0xfb, 0x3d, 0xe0, 0x2e, 0xe3, 0x01, 0x44, 0x2c, 0x6c, 0x9f, 0xf7, 0x8d, + 0xe7, 0xb8, 0x02, 0x4c, 0xfa, 0x2c, 0xac, 0xa2, 0x63, 0xf4, 0x6c, 0xa7, 0x53, 0xfd, 0xf9, 0xad, + 0x71, 0xa0, 0x13, 0xb4, 0x7d, 0x3f, 0x64, 0x00, 0xfd, 0x28, 0x0c, 0x24, 0x77, 0xb5, 0xce, 0x78, + 0x8a, 0xb7, 0x24, 0x15, 0xac, 0x7a, 0x27, 0xd3, 0xef, 0xff, 0x99, 0xd7, 0x76, 0xa7, 0x54, 0x8c, + 0x5a, 0x76, 0x5a, 0xb5, 0xdd, 0x8c, 0x6c, 0x9d, 0x7c, 0x5e, 0xce, 0xea, 0xfa, 0xc4, 0x97, 0xe5, + 0xac, 0x7e, 0xb8, 0xee, 0xab, 0xe8, 0x6f, 0x77, 0xf1, 0xa3, 0x62, 0xc5, 0x65, 0x30, 0x56, 0x12, + 0x98, 0x51, 0xc7, 0x58, 0xb2, 0xc9, 0x80, 0xc6, 0x30, 0x08, 0xfc, 0xac, 0xbb, 0xbd, 0xce, 0xbd, + 0x64, 0x5e, 0xdb, 0x7e, 0xcd, 0x26, 0xed, 0xf3, 0xfe, 0x59, 0xd7, 0xdd, 0x96, 0x6c, 0xd2, 0x8e, + 0xe1, 0xcc, 0xb7, 0xbf, 0x22, 0xfc, 0xa0, 0x07, 0xbc, 0xcb, 0xc2, 0x5b, 0x45, 0x3b, 0xc6, 0x15, + 0x6d, 0x97, 0x86, 0xdb, 0xea, 0xec, 0x24, 0xf3, 0x5a, 0x39, 0xf7, 0x2a, 0xd3, 0xd4, 0xa8, 0x75, + 0xba, 0x91, 0xeb, 0xe8, 0x7a, 0xae, 0x82, 0xbd, 0x6d, 0xe2, 0xea, 0x66, 0x6d, 0x95, 0xed, 0xc5, + 0x77, 0x84, 0xef, 0xf6, 0x80, 0x1b, 0x6f, 0xf0, 0xee, 0xf5, 0xc7, 0xa8, 0x39, 0x1b, 0xcb, 0xe6, + 0x14, 0x67, 0x63, 0x9e, 0xdc, 0x20, 0x58, 0x0f, 0xef, 0x1d, 0xde, 0x2b, 0x0e, 0xe3, 0xc9, 0xff, + 0x4e, 0x16, 0x24, 0xe6, 0xe9, 0x8d, 0x92, 0xd5, 0xf5, 0x66, 0xf9, 0xd3, 0x72, 0x56, 0x47, 0x9d, + 0x57, 0x3f, 0x12, 0x0b, 0x5d, 0x25, 0x16, 0xfa, 0x9d, 0x58, 0xe8, 0x72, 0x61, 0x95, 0xae, 0x16, + 0x56, 0xe9, 0xd7, 0xc2, 0x2a, 0xbd, 0x6d, 0xf0, 0x20, 0x7a, 0xff, 0xc1, 0x73, 0x86, 0x4a, 0x90, + 0xd5, 0xad, 0x8d, 0x11, 0xf5, 0x60, 0x8d, 0xc8, 0xc7, 0x6c, 0x45, 0xa3, 0xe9, 0x98, 0x81, 0x57, + 0xc9, 0xf6, 0xf3, 0xe5, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x30, 0x25, 0x2f, 0x06, 0x8d, 0x03, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -743,7 +743,7 @@ func (m *MsgRegisterAVSResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.NewAVSID |= uint64(b&0x7F) << shift + m.NewAVSID |= uint32(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/avs/types/models.go b/x/avs/types/models.go index 667bba84f..9912b34a5 100644 --- a/x/avs/types/models.go +++ b/x/avs/types/models.go @@ -8,7 +8,7 @@ import ( ) // NewAVS creates a new AVS instance -func NewAVS(id uint64, name string, admin string) AVS { +func NewAVS(id uint32, name string, admin string) AVS { return AVS{ ID: id, Name: name, diff --git a/x/avs/types/models.pb.go b/x/avs/types/models.pb.go index 384b90b79..40deb919f 100644 --- a/x/avs/types/models.pb.go +++ b/x/avs/types/models.pb.go @@ -27,7 +27,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // AVS defines the fields of an AVS type AVS struct { // ID is the auto-generated unique identifier for the AVS - ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + ID uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // Name is the name of the AVS Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // Admin is the address of the user that has registered the AVS @@ -67,7 +67,7 @@ func (m *AVS) XXX_DiscardUnknown() { var xxx_messageInfo_AVS proto.InternalMessageInfo -func (m *AVS) GetID() uint64 { +func (m *AVS) GetID() uint32 { if m != nil { return m.ID } @@ -102,7 +102,7 @@ var fileDescriptor_85e2c65ca3819b2c = []byte{ 0xeb, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xe5, 0xf4, 0x41, 0x2c, 0x88, 0x32, 0x29, 0xc9, 0xe4, 0xfc, 0xe2, 0xdc, 0xfc, 0xe2, 0x78, 0x88, 0x04, 0x84, 0x03, 0x91, 0x52, 0x4a, 0xe4, 0x62, 0x76, 0x0c, 0x0b, 0x16, 0x12, 0xe3, 0x62, 0xca, 0x4c, 0x91, 0x60, 0x54, 0x60, 0xd4, - 0x60, 0x71, 0x62, 0x7b, 0x74, 0x4f, 0x9e, 0xc9, 0xd3, 0x25, 0x88, 0x29, 0x33, 0x45, 0x48, 0x88, + 0xe0, 0x75, 0x62, 0x7b, 0x74, 0x4f, 0x9e, 0xc9, 0xd3, 0x25, 0x88, 0x29, 0x33, 0x45, 0x48, 0x88, 0x8b, 0x25, 0x2f, 0x31, 0x37, 0x55, 0x82, 0x49, 0x81, 0x51, 0x83, 0x33, 0x08, 0xcc, 0x16, 0xd2, 0xe3, 0x62, 0x4d, 0x4c, 0xc9, 0xcd, 0xcc, 0x93, 0x60, 0x06, 0x09, 0x3a, 0x49, 0x5c, 0xda, 0xa2, 0x2b, 0x02, 0x35, 0xd3, 0x31, 0x25, 0xa5, 0x28, 0xb5, 0xb8, 0x38, 0xb8, 0xa4, 0x28, 0x33, 0x2f, @@ -110,7 +110,7 @@ var fileDescriptor_85e2c65ca3819b2c = []byte{ 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x74, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x61, 0x3e, 0xd1, 0xcd, 0x49, 0x4c, 0x2a, 0x86, 0xf3, 0xf4, 0x2b, 0xc0, 0xfe, 0x2e, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, - 0x03, 0x3b, 0xd9, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x5e, 0xd9, 0xd9, 0xbb, 0x14, 0x01, 0x00, + 0x03, 0x3b, 0xd9, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x26, 0xf5, 0xc7, 0x42, 0x14, 0x01, 0x00, 0x00, } @@ -236,7 +236,7 @@ func (m *AVS) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ID |= uint64(b&0x7F) << shift + m.ID |= uint32(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/avs/types/query.go b/x/avs/types/query.go index 72d449f0e..d2033e4a5 100644 --- a/x/avs/types/query.go +++ b/x/avs/types/query.go @@ -17,7 +17,7 @@ func NewQueryServicesRequest(pagination *query.PageRequest) *QueryServicesReques } // NewQueryServiceRequest creates a new QueryServiceRequest instance -func NewQueryServiceRequest(serviceID uint64) *QueryServiceRequest { +func NewQueryServiceRequest(serviceID uint32) *QueryServiceRequest { return &QueryServiceRequest{ ServiceID: serviceID, } diff --git a/x/avs/types/query.pb.go b/x/avs/types/query.pb.go index 494016f10..8f5cf3a62 100644 --- a/x/avs/types/query.pb.go +++ b/x/avs/types/query.pb.go @@ -215,7 +215,7 @@ func (m *QueryServicesResponse) GetPagination() *query.PageResponse { // QueryServiceRequest is the request type for the Query/Service RPC method. type QueryServiceRequest struct { // ServiceID is the ID of the service to query - ServiceID uint64 `protobuf:"varint,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` + ServiceID uint32 `protobuf:"varint,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` } func (m *QueryServiceRequest) Reset() { *m = QueryServiceRequest{} } @@ -251,7 +251,7 @@ func (m *QueryServiceRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryServiceRequest proto.InternalMessageInfo -func (m *QueryServiceRequest) GetServiceID() uint64 { +func (m *QueryServiceRequest) GetServiceID() uint32 { if m != nil { return m.ServiceID } @@ -317,7 +317,7 @@ func init() { proto.RegisterFile("milkyway/avs/v1/query.proto", fileDescriptor_9 var fileDescriptor_911f1b653a0f04ba = []byte{ // 512 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x4f, 0x6b, 0x13, 0x41, - 0x14, 0xcf, 0xb6, 0x35, 0x6d, 0x5f, 0x11, 0x61, 0x8c, 0xb4, 0x4d, 0x65, 0x53, 0xd7, 0x36, 0x06, + 0x14, 0xcf, 0xb6, 0x9a, 0xb6, 0xaf, 0x14, 0x61, 0x8c, 0xb4, 0x4d, 0x65, 0x53, 0xd7, 0x36, 0x06, 0xb1, 0x33, 0x24, 0xfe, 0xb9, 0x1b, 0xc5, 0x52, 0xe8, 0xa1, 0xa6, 0xe0, 0xc1, 0x83, 0x32, 0x9b, 0x0c, 0xeb, 0x62, 0x76, 0x67, 0x9b, 0xd9, 0xac, 0x06, 0xf5, 0x22, 0xe2, 0x59, 0xf0, 0xe2, 0x47, 0xea, 0xb1, 0xe0, 0xc5, 0x53, 0x91, 0xc4, 0x0f, 0x22, 0x99, 0x79, 0x9b, 0x34, 0xd9, 0x36, 0xb9, @@ -329,25 +329,25 @@ var fileDescriptor_911f1b653a0f04ba = []byte{ 0x2b, 0x62, 0x5e, 0x65, 0x11, 0xf7, 0xfc, 0x50, 0x83, 0x53, 0xa6, 0x69, 0x37, 0x81, 0x6c, 0x89, 0xb6, 0xba, 0xaa, 0x1a, 0xf1, 0x0e, 0x0f, 0xb0, 0xea, 0x14, 0x80, 0xbc, 0x1c, 0xb2, 0x1f, 0xe9, 0xc7, 0x86, 0x38, 0xe9, 0x0a, 0x15, 0x3b, 0x87, 0x70, 0x73, 0xe2, 0x55, 0x45, 0x32, 0x54, 0x82, - 0x3c, 0x86, 0xbc, 0x69, 0xde, 0xb0, 0xb6, 0xad, 0xca, 0x5a, 0x6d, 0x9d, 0x4e, 0x45, 0xa5, 0xa6, - 0xa1, 0xbe, 0x74, 0x7a, 0x5e, 0xca, 0x35, 0x10, 0xec, 0xbc, 0x81, 0x82, 0x66, 0x3b, 0x16, 0x9d, - 0xc4, 0x6f, 0x8a, 0x54, 0x85, 0xbc, 0x00, 0x18, 0x67, 0x41, 0xca, 0x32, 0x35, 0xc1, 0xe9, 0x30, - 0x38, 0x35, 0x63, 0xc5, 0xe0, 0xf4, 0x88, 0x7b, 0x02, 0x7b, 0x1b, 0x17, 0x3a, 0x9d, 0x5f, 0x16, - 0xdc, 0x9a, 0x12, 0x40, 0xc3, 0x4f, 0x60, 0x45, 0xe1, 0xdb, 0x86, 0xb5, 0xbd, 0x58, 0x59, 0xab, - 0x15, 0x32, 0x96, 0x9f, 0xbe, 0x3a, 0x46, 0xbf, 0x23, 0x2c, 0xd9, 0x9f, 0x70, 0xb6, 0xa0, 0x9d, - 0xdd, 0x9b, 0xeb, 0xcc, 0x88, 0x4e, 0x58, 0x7b, 0x86, 0x83, 0x44, 0x67, 0x69, 0xf2, 0x07, 0x00, - 0xa8, 0xf5, 0xd6, 0x6f, 0xe9, 0xe4, 0x4b, 0xf5, 0xeb, 0xfd, 0xf3, 0xd2, 0x2a, 0xe2, 0x0e, 0x9e, - 0x37, 0x56, 0x11, 0x70, 0xd0, 0x72, 0x0e, 0x27, 0xe7, 0x37, 0x4a, 0xf7, 0x08, 0x96, 0x11, 0x84, - 0xc3, 0x9b, 0x15, 0x2e, 0x85, 0xd6, 0xbe, 0x2d, 0xc2, 0x35, 0x4d, 0x47, 0x62, 0xc8, 0x9b, 0x7d, + 0x3c, 0x86, 0xbc, 0x69, 0xde, 0xb0, 0xb6, 0xad, 0xca, 0x6a, 0x6d, 0x9d, 0x4e, 0x45, 0xa5, 0xa6, + 0xa1, 0x7e, 0xed, 0xf4, 0xbc, 0x94, 0x6b, 0x20, 0xd8, 0x79, 0x03, 0x05, 0xcd, 0x76, 0x2c, 0x3a, + 0x89, 0xdf, 0x14, 0xa9, 0x0a, 0x79, 0x01, 0x30, 0xce, 0x82, 0x94, 0x65, 0x6a, 0x82, 0xd3, 0x61, + 0x70, 0x6a, 0xc6, 0x8a, 0xc1, 0xe9, 0x11, 0xf7, 0x04, 0xf6, 0x36, 0x2e, 0x74, 0x3a, 0xbf, 0x2c, + 0xb8, 0x35, 0x25, 0x80, 0x86, 0x9f, 0xc0, 0xb2, 0xc2, 0xb7, 0x0d, 0x6b, 0x7b, 0xb1, 0xb2, 0x5a, + 0x2b, 0x64, 0x2c, 0x3f, 0x7d, 0x75, 0x8c, 0x7e, 0x47, 0x58, 0xb2, 0x3f, 0xe1, 0x6c, 0x41, 0x3b, + 0xbb, 0x37, 0xd7, 0x99, 0x11, 0x9d, 0xb0, 0xf6, 0x0c, 0x07, 0x89, 0xce, 0xd2, 0xe4, 0x0f, 0x00, + 0x50, 0xeb, 0xad, 0xdf, 0xd2, 0xc9, 0xd7, 0xea, 0x6b, 0xfd, 0xf3, 0xd2, 0x0a, 0xe2, 0x0e, 0x9e, + 0x37, 0x56, 0x10, 0x70, 0xd0, 0x72, 0x0e, 0x27, 0xe7, 0x37, 0x4a, 0xf7, 0x08, 0x96, 0x10, 0x84, + 0xc3, 0x9b, 0x15, 0x2e, 0x85, 0xd6, 0xbe, 0x2d, 0xc2, 0x75, 0x4d, 0x47, 0x62, 0xc8, 0x9b, 0x7d, 0x91, 0xbb, 0x99, 0xc6, 0xec, 0x51, 0x14, 0x77, 0x66, 0x83, 0x8c, 0x29, 0xa7, 0xf4, 0xf5, 0xf7, - 0xbf, 0x9f, 0x0b, 0x9b, 0x64, 0x9d, 0x5d, 0x7e, 0x77, 0xe4, 0x33, 0xac, 0xa4, 0x7b, 0x22, 0xbb, + 0xbf, 0x9f, 0x0b, 0x9b, 0x64, 0x9d, 0x5d, 0x7e, 0x77, 0xe4, 0x33, 0x2c, 0xa7, 0x7b, 0x22, 0xbb, 0x97, 0x53, 0x4e, 0x1d, 0x4a, 0xb1, 0x3c, 0x0f, 0x86, 0xda, 0x77, 0xb4, 0xf6, 0x16, 0xd9, 0xcc, - 0x68, 0x8f, 0x36, 0xfb, 0xdd, 0x82, 0x65, 0xec, 0x23, 0x3b, 0x33, 0x69, 0x53, 0xf1, 0xdd, 0x39, + 0x68, 0x8f, 0x36, 0xfb, 0xdd, 0x82, 0x25, 0xec, 0x23, 0x3b, 0x33, 0x69, 0x53, 0xf1, 0xdd, 0x39, 0x28, 0xd4, 0xa6, 0x5a, 0xbb, 0x42, 0xca, 0x57, 0x6a, 0xb3, 0x4f, 0xe3, 0x9d, 0x7f, 0xa9, 0xef, 0x9f, 0xf6, 0x6d, 0xeb, 0xac, 0x6f, 0x5b, 0x7f, 0xfb, 0xb6, 0xf5, 0x63, 0x60, 0xe7, 0xce, 0x06, 0x76, 0xee, 0xcf, 0xc0, 0xce, 0xbd, 0xde, 0xf3, 0xfc, 0xf8, 0x5d, 0xd7, 0xa5, 0x4d, 0x19, 0x8c, 0xb8, 0xf6, 0xda, 0xdc, 0x55, 0x63, 0xe6, 0x8f, 0x9a, 0x3b, 0xee, 0x45, 0x42, 0xb9, 0x79, 0xfd, - 0x23, 0x3f, 0xfc, 0x1f, 0x00, 0x00, 0xff, 0xff, 0x6e, 0xde, 0xb0, 0xb4, 0x94, 0x04, 0x00, 0x00, + 0x23, 0x3f, 0xfc, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xa6, 0xf1, 0x68, 0xae, 0x94, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1189,7 +1189,7 @@ func (m *QueryServiceRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ServiceID |= uint64(b&0x7F) << shift + m.ServiceID |= uint32(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/avs/types/query.pb.gw.go b/x/avs/types/query.pb.gw.go index 0d3541d93..50c76240f 100644 --- a/x/avs/types/query.pb.gw.go +++ b/x/avs/types/query.pb.gw.go @@ -103,7 +103,7 @@ func request_Query_Service_0(ctx context.Context, marshaler runtime.Marshaler, c return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "service_id") } - protoReq.ServiceId, err = runtime.Uint64(val) + protoReq.ServiceId, err = runtime.Uint32(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "service_id", err) @@ -130,7 +130,7 @@ func local_request_Query_Service_0(ctx context.Context, marshaler runtime.Marsha return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "service_id") } - protoReq.ServiceId, err = runtime.Uint64(val) + protoReq.ServiceId, err = runtime.Uint32(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "service_id", err) From 08ec13ec3baf02f1e139e20d0675904f6c89a029 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Mon, 3 Jun 2024 18:10:21 -0500 Subject: [PATCH 10/49] feat: add AVS-related keys --- x/avs/types/keys.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/x/avs/types/keys.go b/x/avs/types/keys.go index 3b241b9ef..b3dd0b1ef 100644 --- a/x/avs/types/keys.go +++ b/x/avs/types/keys.go @@ -1,8 +1,38 @@ package types +import ( + "encoding/binary" +) + const ( ModuleName = "avs" RouterKey = ModuleName StoreKey = ModuleName QuerierRoute = ModuleName ) + +var ( + AVSPrefix = []byte{0x02} +) + +// NextAVSIDKey returns the key for the next AVS ID +func NextAVSIDKey() []byte { + return []byte{0x01} +} + +// GetAVSIDBytes returns the byte representation of the AVS ID +func GetAVSIDBytes(avsID uint32) (avsIDBz []byte) { + avsIDBz = make([]byte, 4) + binary.BigEndian.PutUint32(avsIDBz, avsID) + return avsIDBz +} + +// GetAVSIDFromBytes returns the AVS ID from a byte array +func GetAVSIDFromBytes(bz []byte) (avsID uint32) { + return binary.BigEndian.Uint32(bz) +} + +// AVSStoreKey turns an AVS ID into a key used to store an AVS in the KVStore +func AVSStoreKey(avsID uint32) []byte { + return append(AVSPrefix, GetAVSIDBytes(avsID)...) +} From 5020c32e8b9788c93fadfa0cb5ad154fde2be8f7 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Mon, 3 Jun 2024 18:14:02 -0500 Subject: [PATCH 11/49] fix: query Proto definition --- proto/milkyway/avs/v1/query.proto | 2 +- x/avs/types/query.go | 2 +- x/avs/types/query.pb.go | 84 +++++++++++++++---------------- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/proto/milkyway/avs/v1/query.proto b/proto/milkyway/avs/v1/query.proto index 56f460915..93d328d3c 100644 --- a/proto/milkyway/avs/v1/query.proto +++ b/proto/milkyway/avs/v1/query.proto @@ -55,7 +55,7 @@ message QueryServicesResponse { // QueryServiceRequest is the request type for the Query/Service RPC method. message QueryServiceRequest { // ServiceID is the ID of the service to query - uint32 service_id = 1 [ (gogoproto.customname) = "ServiceID" ]; + uint32 service_id = 1; } // QueryServiceResponse is the response type for the Query/Service RPC method. diff --git a/x/avs/types/query.go b/x/avs/types/query.go index d2033e4a5..5a8c77330 100644 --- a/x/avs/types/query.go +++ b/x/avs/types/query.go @@ -19,6 +19,6 @@ func NewQueryServicesRequest(pagination *query.PageRequest) *QueryServicesReques // NewQueryServiceRequest creates a new QueryServiceRequest instance func NewQueryServiceRequest(serviceID uint32) *QueryServiceRequest { return &QueryServiceRequest{ - ServiceID: serviceID, + ServiceId: serviceID, } } diff --git a/x/avs/types/query.pb.go b/x/avs/types/query.pb.go index 8f5cf3a62..5cfa5c011 100644 --- a/x/avs/types/query.pb.go +++ b/x/avs/types/query.pb.go @@ -215,7 +215,7 @@ func (m *QueryServicesResponse) GetPagination() *query.PageResponse { // QueryServiceRequest is the request type for the Query/Service RPC method. type QueryServiceRequest struct { // ServiceID is the ID of the service to query - ServiceID uint32 `protobuf:"varint,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` + ServiceId uint32 `protobuf:"varint,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` } func (m *QueryServiceRequest) Reset() { *m = QueryServiceRequest{} } @@ -251,9 +251,9 @@ func (m *QueryServiceRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryServiceRequest proto.InternalMessageInfo -func (m *QueryServiceRequest) GetServiceID() uint32 { +func (m *QueryServiceRequest) GetServiceId() uint32 { if m != nil { - return m.ServiceID + return m.ServiceId } return 0 } @@ -315,39 +315,39 @@ func init() { func init() { proto.RegisterFile("milkyway/avs/v1/query.proto", fileDescriptor_911f1b653a0f04ba) } var fileDescriptor_911f1b653a0f04ba = []byte{ - // 512 bytes of a gzipped FileDescriptorProto + // 502 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x4f, 0x6b, 0x13, 0x41, - 0x14, 0xcf, 0xb6, 0x9a, 0xb6, 0xaf, 0x14, 0x61, 0x8c, 0xb4, 0x4d, 0x65, 0x53, 0xd7, 0x36, 0x06, - 0xb1, 0x33, 0x24, 0xfe, 0xb9, 0x1b, 0xc5, 0x52, 0xe8, 0xa1, 0xa6, 0xe0, 0xc1, 0x83, 0x32, 0x9b, - 0x0c, 0xeb, 0x62, 0x76, 0x67, 0x9b, 0xd9, 0xac, 0x06, 0xf5, 0x22, 0xe2, 0x59, 0xf0, 0xe2, 0x47, - 0xea, 0xb1, 0xe0, 0xc5, 0x53, 0x91, 0xc4, 0x0f, 0x22, 0x99, 0x79, 0x9b, 0x34, 0xd9, 0x36, 0xb9, - 0x2d, 0xf3, 0x7e, 0xef, 0xf7, 0xe7, 0xbd, 0xb7, 0xb0, 0x15, 0xf8, 0xed, 0xf7, 0xbd, 0x0f, 0xbc, - 0xc7, 0x78, 0xa2, 0x58, 0x52, 0x65, 0x27, 0x5d, 0xd1, 0xe9, 0xd1, 0xa8, 0x23, 0x63, 0x49, 0x6e, - 0xa4, 0x45, 0xca, 0x13, 0x45, 0x93, 0x6a, 0xb1, 0xe0, 0x49, 0x4f, 0xea, 0x1a, 0x1b, 0x7e, 0x19, - 0x58, 0xf1, 0xb6, 0x27, 0xa5, 0xd7, 0x16, 0x8c, 0x47, 0x3e, 0xe3, 0x61, 0x28, 0x63, 0x1e, 0xfb, - 0x32, 0x54, 0x58, 0xbd, 0xdf, 0x94, 0x2a, 0x90, 0x8a, 0xb9, 0x5c, 0x09, 0xc3, 0xce, 0x92, 0xaa, - 0x2b, 0x62, 0x5e, 0x65, 0x11, 0xf7, 0xfc, 0x50, 0x83, 0x53, 0xa6, 0x69, 0x37, 0x81, 0x6c, 0x89, - 0xb6, 0xba, 0xaa, 0x1a, 0xf1, 0x0e, 0x0f, 0xb0, 0xea, 0x14, 0x80, 0xbc, 0x1c, 0xb2, 0x1f, 0xe9, - 0xc7, 0x86, 0x38, 0xe9, 0x0a, 0x15, 0x3b, 0x87, 0x70, 0x73, 0xe2, 0x55, 0x45, 0x32, 0x54, 0x82, - 0x3c, 0x86, 0xbc, 0x69, 0xde, 0xb0, 0xb6, 0xad, 0xca, 0x6a, 0x6d, 0x9d, 0x4e, 0x45, 0xa5, 0xa6, - 0xa1, 0x7e, 0xed, 0xf4, 0xbc, 0x94, 0x6b, 0x20, 0xd8, 0x79, 0x03, 0x05, 0xcd, 0x76, 0x2c, 0x3a, - 0x89, 0xdf, 0x14, 0xa9, 0x0a, 0x79, 0x01, 0x30, 0xce, 0x82, 0x94, 0x65, 0x6a, 0x82, 0xd3, 0x61, - 0x70, 0x6a, 0xc6, 0x8a, 0xc1, 0xe9, 0x11, 0xf7, 0x04, 0xf6, 0x36, 0x2e, 0x74, 0x3a, 0xbf, 0x2c, - 0xb8, 0x35, 0x25, 0x80, 0x86, 0x9f, 0xc0, 0xb2, 0xc2, 0xb7, 0x0d, 0x6b, 0x7b, 0xb1, 0xb2, 0x5a, - 0x2b, 0x64, 0x2c, 0x3f, 0x7d, 0x75, 0x8c, 0x7e, 0x47, 0x58, 0xb2, 0x3f, 0xe1, 0x6c, 0x41, 0x3b, - 0xbb, 0x37, 0xd7, 0x99, 0x11, 0x9d, 0xb0, 0xf6, 0x0c, 0x07, 0x89, 0xce, 0xd2, 0xe4, 0x0f, 0x00, - 0x50, 0xeb, 0xad, 0xdf, 0xd2, 0xc9, 0xd7, 0xea, 0x6b, 0xfd, 0xf3, 0xd2, 0x0a, 0xe2, 0x0e, 0x9e, - 0x37, 0x56, 0x10, 0x70, 0xd0, 0x72, 0x0e, 0x27, 0xe7, 0x37, 0x4a, 0xf7, 0x08, 0x96, 0x10, 0x84, - 0xc3, 0x9b, 0x15, 0x2e, 0x85, 0xd6, 0xbe, 0x2d, 0xc2, 0x75, 0x4d, 0x47, 0x62, 0xc8, 0x9b, 0x7d, - 0x91, 0xbb, 0x99, 0xc6, 0xec, 0x51, 0x14, 0x77, 0x66, 0x83, 0x8c, 0x29, 0xa7, 0xf4, 0xf5, 0xf7, - 0xbf, 0x9f, 0x0b, 0x9b, 0x64, 0x9d, 0x5d, 0x7e, 0x77, 0xe4, 0x33, 0x2c, 0xa7, 0x7b, 0x22, 0xbb, - 0x97, 0x53, 0x4e, 0x1d, 0x4a, 0xb1, 0x3c, 0x0f, 0x86, 0xda, 0x77, 0xb4, 0xf6, 0x16, 0xd9, 0xcc, - 0x68, 0x8f, 0x36, 0xfb, 0xdd, 0x82, 0x25, 0xec, 0x23, 0x3b, 0x33, 0x69, 0x53, 0xf1, 0xdd, 0x39, - 0x28, 0xd4, 0xa6, 0x5a, 0xbb, 0x42, 0xca, 0x57, 0x6a, 0xb3, 0x4f, 0xe3, 0x9d, 0x7f, 0xa9, 0xef, - 0x9f, 0xf6, 0x6d, 0xeb, 0xac, 0x6f, 0x5b, 0x7f, 0xfb, 0xb6, 0xf5, 0x63, 0x60, 0xe7, 0xce, 0x06, - 0x76, 0xee, 0xcf, 0xc0, 0xce, 0xbd, 0xde, 0xf3, 0xfc, 0xf8, 0x5d, 0xd7, 0xa5, 0x4d, 0x19, 0x8c, - 0xb8, 0xf6, 0xda, 0xdc, 0x55, 0x63, 0xe6, 0x8f, 0x9a, 0x3b, 0xee, 0x45, 0x42, 0xb9, 0x79, 0xfd, - 0x23, 0x3f, 0xfc, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xa6, 0xf1, 0x68, 0xae, 0x94, 0x04, 0x00, 0x00, + 0x14, 0xcf, 0xb6, 0x9a, 0xd6, 0x57, 0x44, 0x18, 0x23, 0x6d, 0x53, 0xdd, 0xd6, 0xb5, 0x8d, 0x41, + 0xe8, 0x0c, 0x89, 0xd5, 0xbb, 0x3d, 0x58, 0x84, 0x1e, 0x6a, 0x0a, 0x1e, 0x3c, 0x28, 0xb3, 0xc9, + 0xb0, 0x2e, 0x66, 0x77, 0xb6, 0x99, 0xc9, 0x6a, 0x50, 0x2f, 0x22, 0x9e, 0x05, 0x2f, 0x7e, 0xa4, + 0x1e, 0x0b, 0x5e, 0x3c, 0x89, 0x24, 0x7e, 0x10, 0xc9, 0xcc, 0xdb, 0xc4, 0x64, 0x9b, 0xe4, 0xb6, + 0xbc, 0xf7, 0x7b, 0xbf, 0x3f, 0xef, 0xcd, 0xc2, 0x56, 0x14, 0xb6, 0xdf, 0xf6, 0xde, 0xf1, 0x1e, + 0xe3, 0xa9, 0x62, 0x69, 0x8d, 0x9d, 0x75, 0x45, 0xa7, 0x47, 0x93, 0x8e, 0xd4, 0x92, 0xdc, 0xc8, + 0x9a, 0x94, 0xa7, 0x8a, 0xa6, 0xb5, 0x72, 0x29, 0x90, 0x81, 0x34, 0x3d, 0x36, 0xfc, 0xb2, 0xb0, + 0xf2, 0xed, 0x40, 0xca, 0xa0, 0x2d, 0x18, 0x4f, 0x42, 0xc6, 0xe3, 0x58, 0x6a, 0xae, 0x43, 0x19, + 0x2b, 0xec, 0x3e, 0x68, 0x4a, 0x15, 0x49, 0xc5, 0x7c, 0xae, 0x84, 0x65, 0x67, 0x69, 0xcd, 0x17, + 0x9a, 0xd7, 0x58, 0xc2, 0x83, 0x30, 0x36, 0xe0, 0x8c, 0x69, 0xda, 0x4d, 0x24, 0x5b, 0xa2, 0xad, + 0x66, 0x75, 0x13, 0xde, 0xe1, 0x11, 0x76, 0xbd, 0x12, 0x90, 0xe7, 0x43, 0xf6, 0x13, 0x53, 0x6c, + 0x88, 0xb3, 0xae, 0x50, 0xda, 0x3b, 0x86, 0x9b, 0x13, 0x55, 0x95, 0xc8, 0x58, 0x09, 0xf2, 0x08, + 0x8a, 0x76, 0x78, 0xc3, 0xd9, 0x71, 0xaa, 0x6b, 0xf5, 0x75, 0x3a, 0x15, 0x95, 0xda, 0x81, 0xc3, + 0x2b, 0xe7, 0xbf, 0xb7, 0x0b, 0x0d, 0x04, 0x7b, 0xaf, 0xa0, 0x64, 0xd8, 0x4e, 0x45, 0x27, 0x0d, + 0x9b, 0x22, 0x53, 0x21, 0x4f, 0x01, 0xc6, 0x59, 0x90, 0xb2, 0x42, 0x6d, 0x70, 0x3a, 0x0c, 0x4e, + 0xed, 0x5a, 0x31, 0x38, 0x3d, 0xe1, 0x81, 0xc0, 0xd9, 0xc6, 0x7f, 0x93, 0xde, 0x0f, 0x07, 0x6e, + 0x4d, 0x09, 0xa0, 0xe1, 0xc7, 0xb0, 0xaa, 0xb0, 0xb6, 0xe1, 0xec, 0x2c, 0x57, 0xd7, 0xea, 0xa5, + 0x9c, 0xe5, 0x27, 0x2f, 0x4e, 0xd1, 0xef, 0x08, 0x4b, 0x8e, 0x26, 0x9c, 0x2d, 0x19, 0x67, 0xf7, + 0x17, 0x3a, 0xb3, 0xa2, 0x13, 0xd6, 0x0e, 0x70, 0x91, 0xe8, 0x2c, 0x4b, 0x7e, 0x07, 0x00, 0xb5, + 0x5e, 0x87, 0x2d, 0x93, 0xfc, 0x7a, 0xe3, 0x1a, 0x56, 0x9e, 0xb5, 0xbc, 0xe3, 0xc9, 0x85, 0x8d, + 0xe2, 0x1c, 0xc0, 0x0a, 0x82, 0x70, 0x5b, 0xf3, 0xd2, 0x64, 0xd0, 0xfa, 0x97, 0x65, 0xb8, 0x6a, + 0xe8, 0x88, 0x86, 0xa2, 0x3d, 0x10, 0xb9, 0x97, 0x1b, 0xcc, 0xbf, 0x82, 0xf2, 0xee, 0x7c, 0x90, + 0x35, 0xe5, 0x6d, 0x7f, 0xfe, 0xf9, 0xf7, 0xfb, 0xd2, 0x26, 0x59, 0x67, 0x97, 0x3f, 0x34, 0xf2, + 0x11, 0x56, 0xb3, 0xc3, 0x90, 0xbd, 0xcb, 0x29, 0xa7, 0x5e, 0x46, 0xb9, 0xb2, 0x08, 0x86, 0xda, + 0x77, 0x8d, 0xf6, 0x16, 0xd9, 0xcc, 0x69, 0x8f, 0x4e, 0xf9, 0xd5, 0x81, 0x15, 0x9c, 0x23, 0xbb, + 0x73, 0x69, 0x33, 0xf1, 0xbd, 0x05, 0x28, 0xd4, 0xa6, 0x46, 0xbb, 0x4a, 0x2a, 0x33, 0xb5, 0xd9, + 0x87, 0xf1, 0x91, 0x3f, 0x1d, 0x1e, 0x9d, 0xf7, 0x5d, 0xe7, 0xa2, 0xef, 0x3a, 0x7f, 0xfa, 0xae, + 0xf3, 0x6d, 0xe0, 0x16, 0x2e, 0x06, 0x6e, 0xe1, 0xd7, 0xc0, 0x2d, 0xbc, 0xdc, 0x0f, 0x42, 0xfd, + 0xa6, 0xeb, 0xd3, 0xa6, 0x8c, 0x46, 0x5c, 0xfb, 0x6d, 0xee, 0xab, 0x31, 0xf3, 0x7b, 0xc3, 0xad, + 0x7b, 0x89, 0x50, 0x7e, 0xd1, 0xfc, 0xb9, 0x0f, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x04, 0xce, + 0x72, 0x8e, 0x85, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -674,8 +674,8 @@ func (m *QueryServiceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.ServiceID != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ServiceID)) + if m.ServiceId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ServiceId)) i-- dAtA[i] = 0x8 } @@ -784,8 +784,8 @@ func (m *QueryServiceRequest) Size() (n int) { } var l int _ = l - if m.ServiceID != 0 { - n += 1 + sovQuery(uint64(m.ServiceID)) + if m.ServiceId != 0 { + n += 1 + sovQuery(uint64(m.ServiceId)) } return n } @@ -1177,9 +1177,9 @@ func (m *QueryServiceRequest) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ServiceID", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ServiceId", wireType) } - m.ServiceID = 0 + m.ServiceId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -1189,7 +1189,7 @@ func (m *QueryServiceRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ServiceID |= uint32(b&0x7F) << shift + m.ServiceId |= uint32(b&0x7F) << shift if b < 0x80 { break } From 9d7f08a9737754ef96698a5a08221fe2ed73e719 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Mon, 3 Jun 2024 18:16:12 -0500 Subject: [PATCH 12/49] feat: add AVS hooks --- x/avs/types/hooks.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 x/avs/types/hooks.go diff --git a/x/avs/types/hooks.go b/x/avs/types/hooks.go new file mode 100644 index 000000000..e968a97a0 --- /dev/null +++ b/x/avs/types/hooks.go @@ -0,0 +1,43 @@ +package types + +// DONTCOVER + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// Event Hooks +// These can be utilized to communicate between an avs keeper and another +// keeper which must take particular actions when AVSs change +// state. The second keeper must implement this interface, which then the +// avs keeper can call. + +// AVSHooks event hooks for avs objects (noalias) +type AVSHooks interface { + AfterAVSRegistered(ctx sdk.Context, avsID uint32) // Must be called after an AVS is registered + AfterAVSDeregistered(ctx sdk.Context, avsID uint32) // Must be called after an AVS is deregistered +} + +// -------------------------------------------------------------------------------------------------------------------- + +// MultiAVSHooks combines multiple avs hooks, all hook functions are run in array sequence +type MultiAVSHooks []AVSHooks + +// NewMultiAVSHooks creates a new MultiAVSHooks object +func NewMultiAVSHooks(hooks ...AVSHooks) MultiAVSHooks { + return hooks +} + +// AfterAVSRegistered implements AVSHooks +func (m MultiAVSHooks) AfterAVSRegistered(ctx sdk.Context, avsID uint32) { + for _, hook := range m { + hook.AfterAVSRegistered(ctx, avsID) + } +} + +// AfterAVSDeregistered implements AVSHooks +func (m MultiAVSHooks) AfterAVSDeregistered(ctx sdk.Context, avsID uint32) { + for _, hook := range m { + hook.AfterAVSDeregistered(ctx, avsID) + } +} From ff995df5689a798bf2f74a45faf0007ef15aa20b Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Mon, 3 Jun 2024 18:40:34 -0500 Subject: [PATCH 13/49] feat(tests): add tests for genesis, models and params --- x/avs/types/genesis_test.go | 81 +++++++++++++++++++++++++++++++++++++ x/avs/types/models_test.go | 50 +++++++++++++++++++++++ x/avs/types/params_test.go | 51 +++++++++++++++++++++++ 3 files changed, 182 insertions(+) create mode 100644 x/avs/types/genesis_test.go create mode 100644 x/avs/types/models_test.go create mode 100644 x/avs/types/params_test.go diff --git a/x/avs/types/genesis_test.go b/x/avs/types/genesis_test.go new file mode 100644 index 000000000..a6205f135 --- /dev/null +++ b/x/avs/types/genesis_test.go @@ -0,0 +1,81 @@ +package types_test + +import ( + "testing" + + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + "github.com/milkyway-labs/milkyway/x/avs/types" +) + +func TestValidateGenesis(t *testing.T) { + testCases := []struct { + name string + genesis *types.GenesisState + shouldErr bool + }{ + { + name: "duplicated service returns error", + genesis: &types.GenesisState{ + Services: []types.AVS{ + types.NewAVS(1, "MilkyWay", "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4"), + types.NewAVS(1, "MilkyWay", "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4"), + }, + Params: types.DefaultParams(), + }, + shouldErr: true, + }, + { + name: "invalid service returns error", + genesis: &types.GenesisState{ + Services: []types.AVS{ + types.NewAVS(1, "MilkyWay", "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4"), + types.NewAVS(2, "IBC Relaying", ""), + }, + Params: types.DefaultParams(), + }, + shouldErr: true, + }, + { + name: "invalid params returns error", + genesis: &types.GenesisState{ + Services: nil, + Params: types.Params{ + AvsRegistrationFee: sdk.Coins{sdk.Coin{Denom: "", Amount: sdkmath.NewInt(10)}}, + }, + }, + shouldErr: true, + }, + { + name: "default genesis is valid", + genesis: types.DefaultGenesisState(), + shouldErr: false, + }, + { + name: "valid genesis returns no error", + genesis: &types.GenesisState{ + Services: []types.AVS{ + types.NewAVS(1, "MilkyWay", "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4"), + types.NewAVS(2, "IBC Relaying", "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4"), + }, + Params: types.NewParams( + sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10))), + ), + }, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + err := types.ValidateGenesis(tc.genesis) + if tc.shouldErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/avs/types/models_test.go b/x/avs/types/models_test.go new file mode 100644 index 000000000..1d84dda5f --- /dev/null +++ b/x/avs/types/models_test.go @@ -0,0 +1,50 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/milkyway-labs/milkyway/x/avs/types" +) + +func TestAVS_Validate(t *testing.T) { + testCases := []struct { + name string + avs types.AVS + shouldErr bool + }{ + { + name: "invalid ID returns error", + avs: types.NewAVS(0, "MilkyWay", "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4"), + shouldErr: true, + }, + { + name: "invalid name returns error", + avs: types.NewAVS(1, "", "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4"), + shouldErr: true, + }, + { + name: "invalid address returns error", + avs: types.NewAVS(1, "MilkyWay", "invalid_address"), + shouldErr: true, + }, + { + name: "valid AVS returns no error", + avs: types.NewAVS(1, "MilkyWay", "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4"), + shouldErr: false, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + err := tc.avs.Validate() + if tc.shouldErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/avs/types/params_test.go b/x/avs/types/params_test.go new file mode 100644 index 000000000..0c3e667e3 --- /dev/null +++ b/x/avs/types/params_test.go @@ -0,0 +1,51 @@ +package types_test + +import ( + "testing" + + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + "github.com/milkyway-labs/milkyway/x/avs/types" +) + +func TestParams_Validate(t *testing.T) { + testCases := []struct { + name string + params types.Params + shouldErr bool + }{ + { + name: "invalid AVS registration fee returns error", + params: types.Params{ + AvsRegistrationFee: sdk.Coins{sdk.Coin{Denom: "", Amount: sdkmath.NewInt(100)}}, + }, + shouldErr: true, + }, + { + name: "default params returns no error", + params: types.DefaultParams(), + shouldErr: false, + }, + { + name: "valid params returns no error", + params: types.Params{ + AvsRegistrationFee: sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))), + }, + shouldErr: false, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + err := tc.params.Validate() + if tc.shouldErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} From 50fc5acb7ff16bfa4ec089b81ce3cf59bfef0033 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Mon, 3 Jun 2024 18:44:56 -0500 Subject: [PATCH 14/49] feat: add keeper --- x/avs/keeper/keeper.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 x/avs/keeper/keeper.go diff --git a/x/avs/keeper/keeper.go b/x/avs/keeper/keeper.go new file mode 100644 index 000000000..8b90b6095 --- /dev/null +++ b/x/avs/keeper/keeper.go @@ -0,0 +1,39 @@ +package keeper + +import ( + "cosmossdk.io/log" + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/milkyway-labs/milkyway/x/avs/types" +) + +type Keeper struct { + storeKey storetypes.StoreKey + cdc codec.BinaryCodec + hooks types.AVSHooks +} + +// NewKeeper creates a new keeper +func NewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey) Keeper { + return Keeper{ + storeKey: storeKey, + cdc: cdc, + } +} + +// Logger returns a module-specific logger. +func (k *Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", "x/"+types.ModuleName) +} + +// SetHooks allows to set the reactions hooks +func (k *Keeper) SetHooks(rs types.AVSHooks) *Keeper { + if k.hooks != nil { + panic("cannot set avs hooks twice") + } + + k.hooks = rs + return k +} From 16837354fde1c7d6b644dc8fab58106a069a95cd Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Mon, 3 Jun 2024 23:30:09 -0500 Subject: [PATCH 15/49] feat: add keeper methods to save AVS information --- proto/milkyway/avs/v1/messages.proto | 12 ++ proto/milkyway/avs/v1/models.proto | 33 ++- x/avs/keeper/avs.go | 67 ++++++ x/avs/keeper/hooks.go | 31 +++ x/avs/types/genesis_test.go | 43 +++- x/avs/types/hooks.go | 8 + x/avs/types/messages.go | 16 -- x/avs/types/messages.pb.go | 225 +++++++++++++++++--- x/avs/types/models.go | 24 ++- x/avs/types/models.pb.go | 299 ++++++++++++++++++++++++--- x/avs/types/models_test.go | 46 ++++- 11 files changed, 705 insertions(+), 99 deletions(-) create mode 100644 x/avs/keeper/avs.go create mode 100644 x/avs/keeper/hooks.go diff --git a/proto/milkyway/avs/v1/messages.proto b/proto/milkyway/avs/v1/messages.proto index 75f53839a..09a02acd4 100644 --- a/proto/milkyway/avs/v1/messages.proto +++ b/proto/milkyway/avs/v1/messages.proto @@ -32,6 +32,18 @@ message MsgRegisterAVS { // Name is the name of the AVS string name = 2 [ (gogoproto.moretags) = "yaml:\"name\"" ]; + + // Description is the description of the AVS (optional) + string description = 3 [ (gogoproto.moretags) = "yaml:\"description\"" ]; + + // Website is the website of the AVS (optional) + string website = 4 [ (gogoproto.moretags) = "yaml:\"website\"" ]; + + // PictureURL is the URL of the AVS picture (optional) + string picture_url = 5 [ + (gogoproto.customname) = "NewAVSID", + (gogoproto.moretags) = "yaml:\"picture_url\"" + ]; } // MsgRegisterAVSResponse is the return value of MsgRegisterAVS. diff --git a/proto/milkyway/avs/v1/models.proto b/proto/milkyway/avs/v1/models.proto index 93ae56930..cc847845a 100644 --- a/proto/milkyway/avs/v1/models.proto +++ b/proto/milkyway/avs/v1/models.proto @@ -6,14 +6,43 @@ import "cosmos_proto/cosmos.proto"; option go_package = "github.com/milkyway-labs/milkyway/x/avs/types"; +// AVSStatus defines the status of an AVS +enum AVSStatus { + option (gogoproto.goproto_enum_prefix) = false; + + // AVS_STATUS_UNSPECIFIED defines the AVS status is unspecified + AVS_STATUS_UNSPECIFIED = 0; + + // AVS_STATUS_CREATED defines the AVS status is created + AVS_STATUS_CREATED = 1; + + // AVS_STATUS_REGISTERED defines the AVS status is updated + AVS_STATUS_REGISTERED = 2; + + // AVS_STATUS_UNREGISTERED defines the AVS status is unregistered + AVS_STATUS_UNREGISTERED = 3; +} + // AVS defines the fields of an AVS message AVS { // ID is the auto-generated unique identifier for the AVS uint32 id = 1 [ (gogoproto.customname) = "ID" ]; - // Name is the name of the AVS - string name = 2; + // Status is the status of the AVS + AVSStatus status = 2; // Admin is the address of the user that has registered the AVS string admin = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + // Name is the name of the AVS + string name = 4; + + // Description is the description of the AVS (optional) + string description = 5; + + // Website is the website of the AVS (optional) + string website = 6; + + // PictureURL is the URL of the picture of the AVS (optional) + string pictureURL = 7; } diff --git a/x/avs/keeper/avs.go b/x/avs/keeper/avs.go new file mode 100644 index 000000000..e83effc77 --- /dev/null +++ b/x/avs/keeper/avs.go @@ -0,0 +1,67 @@ +package keeper + +import ( + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/milkyway-labs/milkyway/x/avs/types" +) + +// SetNextAVSID sets the next AVS ID to be used when registering a new AVS +func (k *Keeper) SetNextAVSID(ctx sdk.Context, avsID uint32) { + store := ctx.KVStore(k.storeKey) + store.Set(types.NextAVSIDKey(), types.GetAVSIDBytes(avsID)) +} + +// HasNextAVSID checks if the next AVS ID is set +func (k *Keeper) HasNextAVSID(ctx sdk.Context) bool { + store := ctx.KVStore(k.storeKey) + return store.Has(types.NextAVSIDKey()) +} + +// GetNextAVSID returns the next AVS ID to be used when registering a new AVS +func (k *Keeper) GetNextAVSID(ctx sdk.Context) (avsID uint32, err error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.NextAVSIDKey()) + if bz == nil { + return 0, errors.Wrapf(types.ErrInvalidGenesis, "initial avs id not set") + } + + avsID = types.GetAVSIDFromBytes(bz) + return avsID, nil +} + +// -------------------------------------------------------------------------------------------------------------------- + +// SaveAVS stores a new AVS in the KVStore +func (k *Keeper) SaveAVS(ctx sdk.Context, avs types.AVS) { + previous, existed := k.GetAVS(ctx, avs.ID) + + // Save the AVS data + store := ctx.KVStore(k.storeKey) + store.Set(types.AVSStoreKey(avs.ID), k.cdc.MustMarshal(&avs)) + k.Logger(ctx).Debug("saved avs", "id", avs.ID) + + // Call the hook based on the AVS status change + switch { + case !existed: + k.AfterAVSCreated(ctx, avs.ID) + case previous.Status == types.AVS_STATUS_CREATED && avs.Status == types.AVS_STATUS_REGISTERED: + k.AfterAVSRegistered(ctx, avs.ID) + case previous.Status == types.AVS_STATUS_REGISTERED && avs.Status == types.AVS_STATUS_UNREGISTERED: + k.AfterAVSDeregistered(ctx, avs.ID) + } +} + +// GetAVS returns an AVS from the KVStore +func (k *Keeper) GetAVS(ctx sdk.Context, avsID uint32) (avs types.AVS, found bool) { + store := ctx.KVStore(k.storeKey) + + bz := store.Get(types.AVSStoreKey(avsID)) + if bz == nil { + return avs, false + } + + k.cdc.MustUnmarshal(bz, &avs) + return avs, true +} diff --git a/x/avs/keeper/hooks.go b/x/avs/keeper/hooks.go new file mode 100644 index 000000000..c219ad516 --- /dev/null +++ b/x/avs/keeper/hooks.go @@ -0,0 +1,31 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/milkyway-labs/milkyway/x/avs/types" +) + +// Implement AVSHooks interface +var _ types.AVSHooks = &Keeper{} + +// AfterAVSCreated implements AVSHooks +func (k *Keeper) AfterAVSCreated(ctx sdk.Context, avsID uint32) { + if k.hooks != nil { + k.hooks.AfterAVSCreated(ctx, avsID) + } +} + +// AfterAVSRegistered implements AVSHooks +func (k *Keeper) AfterAVSRegistered(ctx sdk.Context, avsID uint32) { + if k.hooks != nil { + k.hooks.AfterAVSRegistered(ctx, avsID) + } +} + +// AfterAVSDeregistered implements AVSHooks +func (k *Keeper) AfterAVSDeregistered(ctx sdk.Context, avsID uint32) { + if k.hooks != nil { + k.hooks.AfterAVSDeregistered(ctx, avsID) + } +} diff --git a/x/avs/types/genesis_test.go b/x/avs/types/genesis_test.go index a6205f135..11cf518b9 100644 --- a/x/avs/types/genesis_test.go +++ b/x/avs/types/genesis_test.go @@ -20,9 +20,18 @@ func TestValidateGenesis(t *testing.T) { name: "duplicated service returns error", genesis: &types.GenesisState{ Services: []types.AVS{ - types.NewAVS(1, "MilkyWay", "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4"), - types.NewAVS(1, "MilkyWay", "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4"), - }, + { + ID: 1, + Status: types.AVS_STATUS_CREATED, + Admin: "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", + Name: "MilkyWay", + }, + { + ID: 1, + Status: types.AVS_STATUS_CREATED, + Admin: "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", + Name: "MilkyWay", + }}, Params: types.DefaultParams(), }, shouldErr: true, @@ -31,8 +40,18 @@ func TestValidateGenesis(t *testing.T) { name: "invalid service returns error", genesis: &types.GenesisState{ Services: []types.AVS{ - types.NewAVS(1, "MilkyWay", "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4"), - types.NewAVS(2, "IBC Relaying", ""), + { + ID: 1, + Status: types.AVS_STATUS_CREATED, + Admin: "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", + Name: "MilkyWay", + }, + { + ID: 2, + Status: types.AVS_STATUS_UNSPECIFIED, + Admin: "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", + Name: "IBC Relaying", + }, }, Params: types.DefaultParams(), }, @@ -57,8 +76,18 @@ func TestValidateGenesis(t *testing.T) { name: "valid genesis returns no error", genesis: &types.GenesisState{ Services: []types.AVS{ - types.NewAVS(1, "MilkyWay", "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4"), - types.NewAVS(2, "IBC Relaying", "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4"), + { + ID: 1, + Status: types.AVS_STATUS_CREATED, + Admin: "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", + Name: "MilkyWay", + }, + { + ID: 2, + Status: types.AVS_STATUS_REGISTERED, + Admin: "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", + Name: "IBC Relaying", + }, }, Params: types.NewParams( sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10))), diff --git a/x/avs/types/hooks.go b/x/avs/types/hooks.go index e968a97a0..fa3c5e852 100644 --- a/x/avs/types/hooks.go +++ b/x/avs/types/hooks.go @@ -14,6 +14,7 @@ import ( // AVSHooks event hooks for avs objects (noalias) type AVSHooks interface { + AfterAVSCreated(ctx sdk.Context, avsID uint32) // Must be called after an AVS is created AfterAVSRegistered(ctx sdk.Context, avsID uint32) // Must be called after an AVS is registered AfterAVSDeregistered(ctx sdk.Context, avsID uint32) // Must be called after an AVS is deregistered } @@ -28,6 +29,13 @@ func NewMultiAVSHooks(hooks ...AVSHooks) MultiAVSHooks { return hooks } +// AfterAVSCreated implements AVSHooks +func (m MultiAVSHooks) AfterAVSCreated(ctx sdk.Context, avsID uint32) { + for _, hook := range m { + hook.AfterAVSCreated(ctx, avsID) + } +} + // AfterAVSRegistered implements AVSHooks func (m MultiAVSHooks) AfterAVSRegistered(ctx sdk.Context, avsID uint32) { for _, hook := range m { diff --git a/x/avs/types/messages.go b/x/avs/types/messages.go index 900249784..18ed93226 100644 --- a/x/avs/types/messages.go +++ b/x/avs/types/messages.go @@ -13,14 +13,6 @@ var ( _ sdk.Msg = &MsgDeregisterAVS{} ) -// NewMsgRegisterAVS returns a new MsgRegisterAVS instance -func NewMsgRegisterAVS(name string, sender string) *MsgRegisterAVS { - return &MsgRegisterAVS{ - Name: name, - Sender: sender, - } -} - // ValidateBasic implements sdk.Msg func (msg *MsgRegisterAVS) ValidateBasic() error { if strings.TrimSpace(msg.Name) == "" { @@ -48,14 +40,6 @@ func (msg *MsgRegisterAVS) GetSigners() []sdk.AccAddress { // -------------------------------------------------------------------------------------------------------------------- -// NewMsgDeregisterAVS returns a new MsgDeregisterAVS instance -func NewMsgDeregisterAVS(avsID uint64, sender string) *MsgDeregisterAVS { - return &MsgDeregisterAVS{ - AVSID: avsID, - Sender: sender, - } -} - // ValidateBasic implements sdk.Msg func (msg *MsgDeregisterAVS) ValidateBasic() error { if msg.AVSID == 0 { diff --git a/x/avs/types/messages.pb.go b/x/avs/types/messages.pb.go index b36c530bb..dadf7d80a 100644 --- a/x/avs/types/messages.pb.go +++ b/x/avs/types/messages.pb.go @@ -42,6 +42,12 @@ type MsgRegisterAVS struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` // Name is the name of the AVS Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` + // Description is the description of the AVS (optional) + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` + // Website is the website of the AVS (optional) + Website string `protobuf:"bytes,4,opt,name=website,proto3" json:"website,omitempty" yaml:"website"` + // PictureURL is the URL of the AVS picture (optional) + NewAVSID string `protobuf:"bytes,5,opt,name=picture_url,json=pictureUrl,proto3" json:"picture_url,omitempty" yaml:"picture_url"` } func (m *MsgRegisterAVS) Reset() { *m = MsgRegisterAVS{} } @@ -91,6 +97,27 @@ func (m *MsgRegisterAVS) GetName() string { return "" } +func (m *MsgRegisterAVS) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *MsgRegisterAVS) GetWebsite() string { + if m != nil { + return m.Website + } + return "" +} + +func (m *MsgRegisterAVS) GetNewAVSID() string { + if m != nil { + return m.NewAVSID + } + return "" +} + // MsgRegisterAVSResponse is the return value of MsgRegisterAVS. // It returns the newly created AVS ID. type MsgRegisterAVSResponse struct { @@ -242,38 +269,43 @@ func init() { func init() { proto.RegisterFile("milkyway/avs/v1/messages.proto", fileDescriptor_ee6728b943d8fd23) } var fileDescriptor_ee6728b943d8fd23 = []byte{ - // 482 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x52, 0x31, 0x6f, 0xd3, 0x40, - 0x14, 0xce, 0x41, 0x13, 0xb5, 0x57, 0x4a, 0xc1, 0xaa, 0x68, 0x6a, 0x21, 0xa7, 0x98, 0xa1, 0x34, - 0x52, 0x7c, 0x04, 0xb6, 0x6c, 0x89, 0x22, 0xa1, 0x0e, 0x61, 0x70, 0xa4, 0x22, 0x21, 0xa1, 0xe8, - 0x1c, 0x9f, 0x0e, 0xab, 0xb9, 0xbb, 0xc8, 0xcf, 0x38, 0x64, 0x43, 0x8c, 0x4c, 0xe5, 0x9f, 0x64, - 0xe0, 0x27, 0x30, 0x30, 0x56, 0x4c, 0x4c, 0x11, 0x72, 0x86, 0xec, 0xfc, 0x02, 0x64, 0xfb, 0x12, - 0xd5, 0x01, 0xa9, 0x43, 0x17, 0xcb, 0xdf, 0xfb, 0xbe, 0xbb, 0xef, 0x7d, 0xef, 0x1e, 0xb6, 0x44, - 0x30, 0xba, 0x98, 0x4e, 0xe8, 0x94, 0xd0, 0x18, 0x48, 0xdc, 0x24, 0x82, 0x01, 0x50, 0xce, 0xc0, - 0x19, 0x87, 0x2a, 0x52, 0xc6, 0xfe, 0x8a, 0x77, 0x68, 0x0c, 0x4e, 0xdc, 0x34, 0x1f, 0x52, 0x11, - 0x48, 0x45, 0xb2, 0x6f, 0xae, 0x31, 0x8f, 0x86, 0x0a, 0x84, 0x82, 0x41, 0x86, 0x48, 0x0e, 0x34, - 0x65, 0xe5, 0x88, 0x78, 0x14, 0x18, 0x89, 0x9b, 0x1e, 0x8b, 0x68, 0x93, 0x0c, 0x55, 0x20, 0xff, - 0xe1, 0xe5, 0xc5, 0x9a, 0x4f, 0x81, 0xe6, 0x0f, 0x35, 0x2f, 0x80, 0x67, 0xcd, 0x01, 0xd7, 0xc4, - 0x01, 0x57, 0x5c, 0xe5, 0x86, 0xe9, 0x9f, 0xae, 0x3e, 0xde, 0x4c, 0x33, 0xa6, 0x21, 0x15, 0xba, - 0x19, 0xfb, 0x12, 0xe1, 0xfb, 0x3d, 0xe0, 0x2e, 0xe3, 0x01, 0x44, 0x2c, 0x6c, 0x9f, 0xf7, 0x8d, - 0xe7, 0xb8, 0x02, 0x4c, 0xfa, 0x2c, 0xac, 0xa2, 0x63, 0xf4, 0x6c, 0xa7, 0x53, 0xfd, 0xf9, 0xad, - 0x71, 0xa0, 0x13, 0xb4, 0x7d, 0x3f, 0x64, 0x00, 0xfd, 0x28, 0x0c, 0x24, 0x77, 0xb5, 0xce, 0x78, - 0x8a, 0xb7, 0x24, 0x15, 0xac, 0x7a, 0x27, 0xd3, 0xef, 0xff, 0x99, 0xd7, 0x76, 0xa7, 0x54, 0x8c, - 0x5a, 0x76, 0x5a, 0xb5, 0xdd, 0x8c, 0x6c, 0x9d, 0x7c, 0x5e, 0xce, 0xea, 0xfa, 0xc4, 0x97, 0xe5, - 0xac, 0x7e, 0xb8, 0xee, 0xab, 0xe8, 0x6f, 0x77, 0xf1, 0xa3, 0x62, 0xc5, 0x65, 0x30, 0x56, 0x12, - 0x98, 0x51, 0xc7, 0x58, 0xb2, 0xc9, 0x80, 0xc6, 0x30, 0x08, 0xfc, 0xac, 0xbb, 0xbd, 0xce, 0xbd, - 0x64, 0x5e, 0xdb, 0x7e, 0xcd, 0x26, 0xed, 0xf3, 0xfe, 0x59, 0xd7, 0xdd, 0x96, 0x6c, 0xd2, 0x8e, - 0xe1, 0xcc, 0xb7, 0xbf, 0x22, 0xfc, 0xa0, 0x07, 0xbc, 0xcb, 0xc2, 0x5b, 0x45, 0x3b, 0xc6, 0x15, - 0x6d, 0x97, 0x86, 0xdb, 0xea, 0xec, 0x24, 0xf3, 0x5a, 0x39, 0xf7, 0x2a, 0xd3, 0xd4, 0xa8, 0x75, - 0xba, 0x91, 0xeb, 0xe8, 0x7a, 0xae, 0x82, 0xbd, 0x6d, 0xe2, 0xea, 0x66, 0x6d, 0x95, 0xed, 0xc5, - 0x77, 0x84, 0xef, 0xf6, 0x80, 0x1b, 0x6f, 0xf0, 0xee, 0xf5, 0xc7, 0xa8, 0x39, 0x1b, 0xcb, 0xe6, - 0x14, 0x67, 0x63, 0x9e, 0xdc, 0x20, 0x58, 0x0f, 0xef, 0x1d, 0xde, 0x2b, 0x0e, 0xe3, 0xc9, 0xff, - 0x4e, 0x16, 0x24, 0xe6, 0xe9, 0x8d, 0x92, 0xd5, 0xf5, 0x66, 0xf9, 0xd3, 0x72, 0x56, 0x47, 0x9d, - 0x57, 0x3f, 0x12, 0x0b, 0x5d, 0x25, 0x16, 0xfa, 0x9d, 0x58, 0xe8, 0x72, 0x61, 0x95, 0xae, 0x16, - 0x56, 0xe9, 0xd7, 0xc2, 0x2a, 0xbd, 0x6d, 0xf0, 0x20, 0x7a, 0xff, 0xc1, 0x73, 0x86, 0x4a, 0x90, - 0xd5, 0xad, 0x8d, 0x11, 0xf5, 0x60, 0x8d, 0xc8, 0xc7, 0x6c, 0x45, 0xa3, 0xe9, 0x98, 0x81, 0x57, - 0xc9, 0xf6, 0xf3, 0xe5, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x30, 0x25, 0x2f, 0x06, 0x8d, 0x03, - 0x00, 0x00, + // 565 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0xb1, 0x6f, 0xd3, 0x4e, + 0x14, 0xae, 0xdb, 0x26, 0xbf, 0xf6, 0xf2, 0x6b, 0x0b, 0x56, 0xd5, 0xba, 0x16, 0xb2, 0x8b, 0x19, + 0x4a, 0x23, 0x62, 0x13, 0x58, 0x50, 0xb6, 0x84, 0x48, 0xa8, 0x43, 0x18, 0x1c, 0x51, 0x24, 0x24, + 0x14, 0x9d, 0xe3, 0x93, 0xb1, 0x1a, 0xfb, 0xac, 0x7b, 0x8e, 0x43, 0x36, 0xc4, 0xc8, 0x04, 0xff, + 0x49, 0x06, 0x56, 0x36, 0x06, 0xc6, 0x8a, 0x89, 0x29, 0x42, 0xc9, 0x90, 0x3d, 0x7f, 0x01, 0xca, + 0xf9, 0x12, 0xec, 0x80, 0xd4, 0x81, 0x25, 0xca, 0x7b, 0xdf, 0xf7, 0xee, 0xbb, 0xef, 0x3b, 0x3f, + 0xa4, 0x05, 0x7e, 0xef, 0x6a, 0x38, 0xc0, 0x43, 0x0b, 0x27, 0x60, 0x25, 0x55, 0x2b, 0x20, 0x00, + 0xd8, 0x23, 0x60, 0x46, 0x8c, 0xc6, 0x54, 0x3e, 0x58, 0xe2, 0x26, 0x4e, 0xc0, 0x4c, 0xaa, 0xea, + 0x6d, 0x1c, 0xf8, 0x21, 0xb5, 0xf8, 0x6f, 0xca, 0x51, 0x4f, 0xba, 0x14, 0x02, 0x0a, 0x1d, 0x5e, + 0x59, 0x69, 0x21, 0x20, 0x2d, 0xad, 0x2c, 0x07, 0x03, 0xb1, 0x92, 0xaa, 0x43, 0x62, 0x5c, 0xb5, + 0xba, 0xd4, 0x0f, 0xff, 0xc0, 0xc3, 0xab, 0x15, 0xbe, 0x28, 0x04, 0x7e, 0x2c, 0xf0, 0x00, 0x3c, + 0x7e, 0x39, 0xf0, 0x04, 0x70, 0xe8, 0x51, 0x8f, 0xa6, 0x82, 0x8b, 0x7f, 0xa2, 0x7b, 0x67, 0xdd, + 0x4d, 0x84, 0x19, 0x0e, 0xc4, 0x65, 0x8c, 0x2f, 0x9b, 0x68, 0xbf, 0x05, 0x9e, 0x4d, 0x3c, 0x1f, + 0x62, 0xc2, 0xea, 0x97, 0x6d, 0xf9, 0x21, 0x2a, 0x02, 0x09, 0x5d, 0xc2, 0x14, 0xe9, 0x54, 0xba, + 0xbf, 0xdb, 0x50, 0xbe, 0x7f, 0xae, 0x1c, 0x0a, 0x07, 0x75, 0xd7, 0x65, 0x04, 0xa0, 0x1d, 0x33, + 0x3f, 0xf4, 0x6c, 0xc1, 0x93, 0xef, 0xa1, 0xed, 0x10, 0x07, 0x44, 0xd9, 0xe4, 0xfc, 0x83, 0xf9, + 0x58, 0x2f, 0x0d, 0x71, 0xd0, 0xab, 0x19, 0x8b, 0xae, 0x61, 0x73, 0x50, 0x7e, 0x82, 0x4a, 0x2e, + 0x81, 0x2e, 0xf3, 0xa3, 0xd8, 0xa7, 0xa1, 0xb2, 0xc5, 0xb9, 0x47, 0xf3, 0xb1, 0x2e, 0xa7, 0xdc, + 0x0c, 0x68, 0xd8, 0x59, 0xaa, 0xfc, 0x00, 0xfd, 0x37, 0x20, 0x0e, 0xf8, 0x31, 0x51, 0xb6, 0xf9, + 0x94, 0x3c, 0x1f, 0xeb, 0xfb, 0xe9, 0x94, 0x00, 0x0c, 0x7b, 0x49, 0x91, 0x9f, 0xa2, 0x52, 0xe4, + 0x77, 0xe3, 0x3e, 0x23, 0x9d, 0x3e, 0xeb, 0x29, 0x05, 0x3e, 0x61, 0x4c, 0xc6, 0xfa, 0xce, 0x73, + 0x32, 0xa8, 0x5f, 0xb6, 0x2f, 0x9a, 0xbf, 0x35, 0x33, 0x44, 0xc3, 0x46, 0xa2, 0x7a, 0xc1, 0x7a, + 0xb5, 0xb3, 0xf7, 0xb3, 0x51, 0x59, 0xd8, 0xfb, 0x30, 0x1b, 0x95, 0x8f, 0x57, 0x21, 0xe6, 0xc3, + 0x32, 0x9a, 0xe8, 0x28, 0xdf, 0xb1, 0x09, 0x44, 0x34, 0x04, 0x22, 0x97, 0x11, 0x0a, 0xc9, 0xa0, + 0x83, 0x13, 0xe8, 0xf8, 0x2e, 0x8f, 0x72, 0xaf, 0xf1, 0x7f, 0xf6, 0x1a, 0xf6, 0x4e, 0x48, 0x06, + 0xf5, 0x04, 0x2e, 0x5c, 0xe3, 0x93, 0x84, 0x6e, 0xb5, 0xc0, 0x6b, 0x12, 0xf6, 0x4f, 0xef, 0x70, + 0x8a, 0x8a, 0x42, 0x6e, 0xf1, 0x12, 0xdb, 0x8d, 0xdd, 0xc9, 0x58, 0x2f, 0xa4, 0x5a, 0x05, 0xbc, + 0x10, 0xaa, 0x9d, 0xaf, 0xf9, 0x3a, 0xc9, 0xfa, 0xca, 0xc9, 0x1b, 0x2a, 0x52, 0xd6, 0x7b, 0x4b, + 0x6f, 0x8f, 0xbe, 0x4a, 0x68, 0xab, 0x05, 0x9e, 0xfc, 0x12, 0x95, 0xb2, 0x5f, 0x8e, 0x6e, 0xae, + 0x6d, 0x86, 0x99, 0xcf, 0x46, 0x3d, 0xbb, 0x81, 0xb0, 0x0a, 0xef, 0x35, 0xda, 0xcb, 0x87, 0x71, + 0xf7, 0x6f, 0x93, 0x39, 0x8a, 0x7a, 0x7e, 0x23, 0x65, 0x79, 0xbc, 0x5a, 0x78, 0x37, 0x1b, 0x95, + 0xa5, 0xc6, 0xb3, 0x6f, 0x13, 0x4d, 0xba, 0x9e, 0x68, 0xd2, 0xcf, 0x89, 0x26, 0x7d, 0x9c, 0x6a, + 0x1b, 0xd7, 0x53, 0x6d, 0xe3, 0xc7, 0x54, 0xdb, 0x78, 0x55, 0xf1, 0xfc, 0xf8, 0x4d, 0xdf, 0x31, + 0xbb, 0x34, 0xb0, 0x96, 0xa7, 0x56, 0x7a, 0xd8, 0x81, 0x55, 0x65, 0xbd, 0xe5, 0xfb, 0x14, 0x0f, + 0x23, 0x02, 0x4e, 0x91, 0x2f, 0xd3, 0xe3, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd4, 0x33, 0x12, + 0x05, 0x3a, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -412,6 +444,27 @@ func (m *MsgRegisterAVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.NewAVSID) > 0 { + i -= len(m.NewAVSID) + copy(dAtA[i:], m.NewAVSID) + i = encodeVarintMessages(dAtA, i, uint64(len(m.NewAVSID))) + i-- + dAtA[i] = 0x2a + } + if len(m.Website) > 0 { + i -= len(m.Website) + copy(dAtA[i:], m.Website) + i = encodeVarintMessages(dAtA, i, uint64(len(m.Website))) + i-- + dAtA[i] = 0x22 + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintMessages(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x1a + } if len(m.Name) > 0 { i -= len(m.Name) copy(dAtA[i:], m.Name) @@ -540,6 +593,18 @@ func (m *MsgRegisterAVS) Size() (n int) { if l > 0 { n += 1 + l + sovMessages(uint64(l)) } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovMessages(uint64(l)) + } + l = len(m.Website) + if l > 0 { + n += 1 + l + sovMessages(uint64(l)) + } + l = len(m.NewAVSID) + if l > 0 { + n += 1 + l + sovMessages(uint64(l)) + } return n } @@ -679,6 +744,102 @@ func (m *MsgRegisterAVS) Unmarshal(dAtA []byte) error { } m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + 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 ErrInvalidLengthMessages + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMessages + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Website", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + 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 ErrInvalidLengthMessages + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMessages + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Website = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewAVSID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + 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 ErrInvalidLengthMessages + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMessages + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NewAVSID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipMessages(dAtA[iNdEx:]) diff --git a/x/avs/types/models.go b/x/avs/types/models.go index 9912b34a5..7fa0b98ec 100644 --- a/x/avs/types/models.go +++ b/x/avs/types/models.go @@ -8,16 +8,32 @@ import ( ) // NewAVS creates a new AVS instance -func NewAVS(id uint32, name string, admin string) AVS { +func NewAVS( + id uint32, + status AVSStatus, + name string, + description string, + website string, + pictureURL string, + admin string, +) AVS { return AVS{ - ID: id, - Name: name, - Admin: admin, + ID: id, + Status: status, + Name: name, + Description: description, + Website: website, + PictureURL: pictureURL, + Admin: admin, } } // Validate checks that the AVS has valid values. func (a *AVS) Validate() error { + if a.Status == AVS_STATUS_UNSPECIFIED { + return fmt.Errorf("invalid status: %s", a.Status) + } + if a.ID == 0 { return fmt.Errorf("invalid id: %d", a.ID) } diff --git a/x/avs/types/models.pb.go b/x/avs/types/models.pb.go index 40deb919f..c53a8355e 100644 --- a/x/avs/types/models.pb.go +++ b/x/avs/types/models.pb.go @@ -24,14 +24,58 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// AVSStatus defines the status of an AVS +type AVSStatus int32 + +const ( + // AVS_STATUS_UNSPECIFIED defines the AVS status is unspecified + AVS_STATUS_UNSPECIFIED AVSStatus = 0 + // AVS_STATUS_CREATED defines the AVS status is created + AVS_STATUS_CREATED AVSStatus = 1 + // AVS_STATUS_REGISTERED defines the AVS status is updated + AVS_STATUS_REGISTERED AVSStatus = 2 + // AVS_STATUS_UNREGISTERED defines the AVS status is unregistered + AVS_STATUS_UNREGISTERED AVSStatus = 3 +) + +var AVSStatus_name = map[int32]string{ + 0: "AVS_STATUS_UNSPECIFIED", + 1: "AVS_STATUS_CREATED", + 2: "AVS_STATUS_REGISTERED", + 3: "AVS_STATUS_UNREGISTERED", +} + +var AVSStatus_value = map[string]int32{ + "AVS_STATUS_UNSPECIFIED": 0, + "AVS_STATUS_CREATED": 1, + "AVS_STATUS_REGISTERED": 2, + "AVS_STATUS_UNREGISTERED": 3, +} + +func (x AVSStatus) String() string { + return proto.EnumName(AVSStatus_name, int32(x)) +} + +func (AVSStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_85e2c65ca3819b2c, []int{0} +} + // AVS defines the fields of an AVS type AVS struct { // ID is the auto-generated unique identifier for the AVS ID uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // Name is the name of the AVS - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + // Status is the status of the AVS + Status AVSStatus `protobuf:"varint,2,opt,name=status,proto3,enum=milkyway.avs.v1.AVSStatus" json:"status,omitempty"` // Admin is the address of the user that has registered the AVS Admin string `protobuf:"bytes,3,opt,name=admin,proto3" json:"admin,omitempty"` + // Name is the name of the AVS + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + // Description is the description of the AVS (optional) + Description string `protobuf:"bytes,5,opt,name=description,proto3" json:"description,omitempty"` + // Website is the website of the AVS (optional) + Website string `protobuf:"bytes,6,opt,name=website,proto3" json:"website,omitempty"` + // PictureURL is the URL of the picture of the AVS (optional) + PictureURL string `protobuf:"bytes,7,opt,name=pictureURL,proto3" json:"pictureURL,omitempty"` } func (m *AVS) Reset() { *m = AVS{} } @@ -74,6 +118,20 @@ func (m *AVS) GetID() uint32 { return 0 } +func (m *AVS) GetStatus() AVSStatus { + if m != nil { + return m.Status + } + return AVS_STATUS_UNSPECIFIED +} + +func (m *AVS) GetAdmin() string { + if m != nil { + return m.Admin + } + return "" +} + func (m *AVS) GetName() string { if m != nil { return m.Name @@ -81,37 +139,62 @@ func (m *AVS) GetName() string { return "" } -func (m *AVS) GetAdmin() string { +func (m *AVS) GetDescription() string { if m != nil { - return m.Admin + return m.Description + } + return "" +} + +func (m *AVS) GetWebsite() string { + if m != nil { + return m.Website + } + return "" +} + +func (m *AVS) GetPictureURL() string { + if m != nil { + return m.PictureURL } return "" } func init() { + proto.RegisterEnum("milkyway.avs.v1.AVSStatus", AVSStatus_name, AVSStatus_value) proto.RegisterType((*AVS)(nil), "milkyway.avs.v1.AVS") } func init() { proto.RegisterFile("milkyway/avs/v1/models.proto", fileDescriptor_85e2c65ca3819b2c) } var fileDescriptor_85e2c65ca3819b2c = []byte{ - // 241 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc9, 0xcd, 0xcc, 0xc9, - 0xae, 0x2c, 0x4f, 0xac, 0xd4, 0x4f, 0x2c, 0x2b, 0xd6, 0x2f, 0x33, 0xd4, 0xcf, 0xcd, 0x4f, 0x49, - 0xcd, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0xc9, 0xea, 0x25, 0x96, 0x15, - 0xeb, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xe5, 0xf4, 0x41, 0x2c, 0x88, 0x32, - 0x29, 0xc9, 0xe4, 0xfc, 0xe2, 0xdc, 0xfc, 0xe2, 0x78, 0x88, 0x04, 0x84, 0x03, 0x91, 0x52, 0x4a, - 0xe4, 0x62, 0x76, 0x0c, 0x0b, 0x16, 0x12, 0xe3, 0x62, 0xca, 0x4c, 0x91, 0x60, 0x54, 0x60, 0xd4, - 0xe0, 0x75, 0x62, 0x7b, 0x74, 0x4f, 0x9e, 0xc9, 0xd3, 0x25, 0x88, 0x29, 0x33, 0x45, 0x48, 0x88, - 0x8b, 0x25, 0x2f, 0x31, 0x37, 0x55, 0x82, 0x49, 0x81, 0x51, 0x83, 0x33, 0x08, 0xcc, 0x16, 0xd2, - 0xe3, 0x62, 0x4d, 0x4c, 0xc9, 0xcd, 0xcc, 0x93, 0x60, 0x06, 0x09, 0x3a, 0x49, 0x5c, 0xda, 0xa2, - 0x2b, 0x02, 0x35, 0xd3, 0x31, 0x25, 0xa5, 0x28, 0xb5, 0xb8, 0x38, 0xb8, 0xa4, 0x28, 0x33, 0x2f, - 0x3d, 0x08, 0xa2, 0xcc, 0xc9, 0xfd, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, - 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, - 0x74, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x61, 0x3e, 0xd1, 0xcd, - 0x49, 0x4c, 0x2a, 0x86, 0xf3, 0xf4, 0x2b, 0xc0, 0xfe, 0x2e, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, - 0x03, 0x3b, 0xd9, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x26, 0xf5, 0xc7, 0x42, 0x14, 0x01, 0x00, - 0x00, + // 407 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0xcf, 0x6e, 0xd3, 0x30, + 0x1c, 0xc7, 0xe3, 0xb4, 0xeb, 0x34, 0x23, 0xa0, 0xb2, 0x46, 0xf1, 0x02, 0x32, 0x15, 0xa7, 0x0a, + 0xa9, 0x89, 0x36, 0x9e, 0x20, 0x5d, 0xc3, 0x54, 0x09, 0x21, 0x64, 0xb7, 0x3d, 0x70, 0xa9, 0xf2, + 0xc7, 0x0a, 0x16, 0x4d, 0x1c, 0xc5, 0x6e, 0x46, 0x0f, 0xdc, 0x39, 0xf2, 0x0e, 0xbc, 0x02, 0x0f, + 0xc1, 0x71, 0xe2, 0xc4, 0x09, 0xa1, 0xf4, 0x09, 0x78, 0x03, 0x34, 0x67, 0xad, 0x02, 0xb7, 0xdf, + 0xf7, 0xfb, 0xf9, 0x28, 0xbf, 0xc8, 0x36, 0x7c, 0x9a, 0x89, 0xf5, 0x87, 0xed, 0x75, 0xb8, 0xf5, + 0xc2, 0x4a, 0x79, 0xd5, 0xb9, 0x97, 0xc9, 0x84, 0xaf, 0x95, 0x5b, 0x94, 0x52, 0x4b, 0xf4, 0x70, + 0x4f, 0xdd, 0xb0, 0x52, 0x6e, 0x75, 0xee, 0x9c, 0xa6, 0x32, 0x95, 0x86, 0x79, 0xb7, 0x53, 0xa3, + 0x39, 0x67, 0xb1, 0x54, 0x99, 0x54, 0xab, 0x06, 0x34, 0xa1, 0x41, 0xcf, 0xff, 0x00, 0xd8, 0xf1, + 0x97, 0x0c, 0x0d, 0xa0, 0x2d, 0x12, 0x0c, 0x86, 0x60, 0x74, 0x7f, 0xd2, 0xab, 0x7f, 0x3d, 0xb3, + 0x67, 0x53, 0x6a, 0x8b, 0x04, 0x5d, 0xc0, 0x9e, 0xd2, 0xa1, 0xde, 0x28, 0x6c, 0x0f, 0xc1, 0xe8, + 0xc1, 0x85, 0xe3, 0xfe, 0xb7, 0xd2, 0xf5, 0x97, 0x8c, 0x19, 0x83, 0xde, 0x99, 0xc8, 0x85, 0x47, + 0x61, 0x92, 0x89, 0x1c, 0x77, 0x86, 0x60, 0x74, 0x32, 0xc1, 0x3f, 0xbe, 0x8d, 0x4f, 0xef, 0x96, + 0xfa, 0x49, 0x52, 0x72, 0xa5, 0x98, 0x2e, 0x45, 0x9e, 0xd2, 0x46, 0x43, 0x08, 0x76, 0xf3, 0x30, + 0xe3, 0xb8, 0x7b, 0xab, 0x53, 0x33, 0xa3, 0x21, 0xbc, 0x97, 0x70, 0x15, 0x97, 0xa2, 0xd0, 0x42, + 0xe6, 0xf8, 0xc8, 0xa0, 0x76, 0x85, 0x30, 0x3c, 0xbe, 0xe6, 0x91, 0x12, 0x9a, 0xe3, 0x9e, 0xa1, + 0xfb, 0x88, 0x08, 0x84, 0x85, 0x88, 0xf5, 0xa6, 0xe4, 0x0b, 0xfa, 0x1a, 0x1f, 0x1b, 0xd8, 0x6a, + 0x5e, 0x7c, 0x82, 0x27, 0x87, 0x9f, 0x46, 0x0e, 0x1c, 0xf8, 0x4b, 0xb6, 0x62, 0x73, 0x7f, 0xbe, + 0x60, 0xab, 0xc5, 0x1b, 0xf6, 0x36, 0xb8, 0x9c, 0xbd, 0x9a, 0x05, 0xd3, 0xbe, 0x85, 0x06, 0x10, + 0xb5, 0xd8, 0x25, 0x0d, 0xfc, 0x79, 0x30, 0xed, 0x03, 0x74, 0x06, 0x1f, 0xb5, 0x7a, 0x1a, 0x5c, + 0xcd, 0xd8, 0x3c, 0xa0, 0xc1, 0xb4, 0x6f, 0xa3, 0x27, 0xf0, 0xf1, 0x3f, 0x9f, 0x6b, 0xc1, 0x8e, + 0xd3, 0xfd, 0xfc, 0x95, 0x58, 0x93, 0xab, 0xef, 0x35, 0x01, 0x37, 0x35, 0x01, 0xbf, 0x6b, 0x02, + 0xbe, 0xec, 0x88, 0x75, 0xb3, 0x23, 0xd6, 0xcf, 0x1d, 0xb1, 0xde, 0x8d, 0x53, 0xa1, 0xdf, 0x6f, + 0x22, 0x37, 0x96, 0x99, 0xb7, 0x3f, 0xe6, 0xf1, 0x3a, 0x8c, 0xd4, 0x21, 0x79, 0x1f, 0xcd, 0x3b, + 0xd0, 0xdb, 0x82, 0xab, 0xa8, 0x67, 0xae, 0xf0, 0xe5, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x38, + 0x4f, 0x20, 0x19, 0x24, 0x02, 0x00, 0x00, } func (m *AVS) Marshal() (dAtA []byte, err error) { @@ -134,6 +217,34 @@ func (m *AVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.PictureURL) > 0 { + i -= len(m.PictureURL) + copy(dAtA[i:], m.PictureURL) + i = encodeVarintModels(dAtA, i, uint64(len(m.PictureURL))) + i-- + dAtA[i] = 0x3a + } + if len(m.Website) > 0 { + i -= len(m.Website) + copy(dAtA[i:], m.Website) + i = encodeVarintModels(dAtA, i, uint64(len(m.Website))) + i-- + dAtA[i] = 0x32 + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintModels(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x2a + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintModels(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x22 + } if len(m.Admin) > 0 { i -= len(m.Admin) copy(dAtA[i:], m.Admin) @@ -141,12 +252,10 @@ func (m *AVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintModels(dAtA, i, uint64(len(m.Name))) + if m.Status != 0 { + i = encodeVarintModels(dAtA, i, uint64(m.Status)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x10 } if m.ID != 0 { i = encodeVarintModels(dAtA, i, uint64(m.ID)) @@ -176,11 +285,26 @@ func (m *AVS) Size() (n int) { if m.ID != 0 { n += 1 + sovModels(uint64(m.ID)) } + if m.Status != 0 { + n += 1 + sovModels(uint64(m.Status)) + } + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovModels(uint64(l)) + } l = len(m.Name) if l > 0 { n += 1 + l + sovModels(uint64(l)) } - l = len(m.Admin) + l = len(m.Description) + if l > 0 { + n += 1 + l + sovModels(uint64(l)) + } + l = len(m.Website) + if l > 0 { + n += 1 + l + sovModels(uint64(l)) + } + l = len(m.PictureURL) if l > 0 { n += 1 + l + sovModels(uint64(l)) } @@ -242,6 +366,57 @@ func (m *AVS) Unmarshal(dAtA []byte) error { } } case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= AVSStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + 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 ErrInvalidLengthModels + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModels + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } @@ -273,9 +448,9 @@ func (m *AVS) Unmarshal(dAtA []byte) error { } m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -303,7 +478,71 @@ func (m *AVS) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Admin = string(dAtA[iNdEx:postIndex]) + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Website", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + 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 ErrInvalidLengthModels + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModels + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Website = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PictureURL", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + 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 ErrInvalidLengthModels + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModels + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PictureURL = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/avs/types/models_test.go b/x/avs/types/models_test.go index 1d84dda5f..4f39d6555 100644 --- a/x/avs/types/models_test.go +++ b/x/avs/types/models_test.go @@ -15,23 +15,53 @@ func TestAVS_Validate(t *testing.T) { shouldErr bool }{ { - name: "invalid ID returns error", - avs: types.NewAVS(0, "MilkyWay", "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4"), + name: "invalid status returns error", + avs: types.AVS{ + ID: 1, + Status: types.AVS_STATUS_UNSPECIFIED, + Admin: "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", + Name: "MilkyWay", + }, shouldErr: true, }, { - name: "invalid name returns error", - avs: types.NewAVS(1, "", "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4"), + name: "invalid ID returns error", + avs: types.AVS{ + ID: 0, + Status: types.AVS_STATUS_CREATED, + Admin: "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", + Name: "MilkyWay", + }, shouldErr: true, }, { - name: "invalid address returns error", - avs: types.NewAVS(1, "MilkyWay", "invalid_address"), + name: "invalid name returns error", + avs: types.AVS{ + ID: 1, + Status: types.AVS_STATUS_CREATED, + Admin: "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", + Name: "", + }, shouldErr: true, }, { - name: "valid AVS returns no error", - avs: types.NewAVS(1, "MilkyWay", "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4"), + name: "invalid address returns error", + avs: types.AVS{ + ID: 1, + Status: types.AVS_STATUS_CREATED, + Admin: "", + Name: "MilkyWay", + }, + shouldErr: true, + }, + { + name: "valid AVS returns no error", + avs: types.AVS{ + ID: 1, + Status: types.AVS_STATUS_CREATED, + Admin: "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", + Name: "MilkyWay", + }, shouldErr: false, }, } From 1c44cece371da25c10558e640240c502b3e52b79 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Tue, 4 Jun 2024 03:00:10 -0500 Subject: [PATCH 16/49] feat: add message update AVS --- proto/milkyway/avs/v1/messages.proto | 41 ++- x/avs/types/codec.go | 4 +- x/avs/types/keys.go | 2 + x/avs/types/messages.go | 28 +- x/avs/types/messages.pb.go | 454 ++++++++++++++++++++------- x/avs/types/models.go | 54 ++++ 6 files changed, 438 insertions(+), 145 deletions(-) diff --git a/proto/milkyway/avs/v1/messages.proto b/proto/milkyway/avs/v1/messages.proto index 09a02acd4..8e5d05ff3 100644 --- a/proto/milkyway/avs/v1/messages.proto +++ b/proto/milkyway/avs/v1/messages.proto @@ -16,7 +16,7 @@ service Msg { option (cosmos.msg.v1.service) = true; rpc RegisterAVS(MsgRegisterAVS) returns (MsgRegisterAVSResponse); - rpc DeregisterAVS(MsgDeregisterAVS) returns (MsgDeregisterAVSResponse); + rpc UpdateAVS(MsgUpdateAVS) returns (MsgUpdateAVSResponse); } // MsgRegisterAVSResponse defines the message structure for the RegisterAVS @@ -40,10 +40,7 @@ message MsgRegisterAVS { string website = 4 [ (gogoproto.moretags) = "yaml:\"website\"" ]; // PictureURL is the URL of the AVS picture (optional) - string picture_url = 5 [ - (gogoproto.customname) = "NewAVSID", - (gogoproto.moretags) = "yaml:\"picture_url\"" - ]; + string picture_url = 5 [ (gogoproto.moretags) = "yaml:\"picture_url\"" ]; } // MsgRegisterAVSResponse is the return value of MsgRegisterAVS. @@ -53,19 +50,35 @@ message MsgRegisterAVSResponse { uint32 new_avs_id = 1 [ (gogoproto.customname) = "NewAVSID" ]; } -// MsgDeregisterAVS defines the message structure for the DeregisterAVS gRPC -// service method. It allows the AVS owner to deregister their AVS so that -// operators know that they can safely stop validating it. -message MsgDeregisterAVS { +// MsgUpdateAVS defines the message structure for the UpdateAVS gRPC +// service method. It allows the AVS owner to update the details of +// an existing AVS. +message MsgUpdateAVS { option (cosmos.msg.v1.signer) = "sender"; - option (amino.name) = "milkyway/MsgDeregisterAVS"; + option (amino.name) = "milkyway/MsgUpdateAVS"; // Sender is the address of the user deregistering the AVS string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - // AVSID is the ID of the AVS to be deregistered - uint64 avs_id = 2 [ (gogoproto.customname) = "AVSID" ]; + // ID represents the ID of the AVS to be updated + uint64 id = 2 [ (gogoproto.customname) = "ID" ]; + + // Name is the new name of the AVS (optional). + // If it shouldn't be changed, use [do-not-modify] instead. + string name = 3 [ (gogoproto.moretags) = "yaml:\"name\"" ]; + + // Description is the new description of the AVS (optional) + // If it shouldn't be changed, use [do-not-modify] instead. + string description = 4 [ (gogoproto.moretags) = "yaml:\"description\"" ]; + + // Website is the new website of the AVS (optional) + // If it shouldn't be changed, use [do-not-modify] instead. + string website = 5 [ (gogoproto.moretags) = "yaml:\"website\"" ]; + + // PictureURL is the new URL of the AVS picture (optional) + // If it shouldn't be changed, use [do-not-modify] instead. + string picture_url = 6 [ (gogoproto.moretags) = "yaml:\"picture_url\"" ]; } -// MsgDeregisterAVSResponse is the return value of MsgDeregisterAVS. -message MsgDeregisterAVSResponse {} \ No newline at end of file +// MsgUpdateAVSResponse is the return value of MsgUpdateAVS. +message MsgUpdateAVSResponse {} \ No newline at end of file diff --git a/x/avs/types/codec.go b/x/avs/types/codec.go index 41a16733b..721286221 100644 --- a/x/avs/types/codec.go +++ b/x/avs/types/codec.go @@ -11,13 +11,13 @@ import ( func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { legacy.RegisterAminoMsg(cdc, &MsgRegisterAVS{}, "milkyway/MsgRegisterAVS") - legacy.RegisterAminoMsg(cdc, &MsgDeregisterAVS{}, "milkyway/MsgDeregisterAVS") + legacy.RegisterAminoMsg(cdc, &MsgUpdateAVS{}, "milkyway/MsgUpdateAVS") } func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgRegisterAVS{}, - &MsgDeregisterAVS{}, + &MsgUpdateAVS{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/avs/types/keys.go b/x/avs/types/keys.go index b3dd0b1ef..3f956f645 100644 --- a/x/avs/types/keys.go +++ b/x/avs/types/keys.go @@ -9,6 +9,8 @@ const ( RouterKey = ModuleName StoreKey = ModuleName QuerierRoute = ModuleName + + DoNotModify = "[do-not-modify]" ) var ( diff --git a/x/avs/types/messages.go b/x/avs/types/messages.go index 18ed93226..e24e0713e 100644 --- a/x/avs/types/messages.go +++ b/x/avs/types/messages.go @@ -10,13 +10,25 @@ import ( var ( _ sdk.Msg = &MsgRegisterAVS{} - _ sdk.Msg = &MsgDeregisterAVS{} + _ sdk.Msg = &MsgUpdateAVS{} ) // ValidateBasic implements sdk.Msg func (msg *MsgRegisterAVS) ValidateBasic() error { - if strings.TrimSpace(msg.Name) == "" { - return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid AVS name: %s", msg.Name) + if strings.TrimSpace(msg.Name) == "" || msg.Name == DoNotModify { + return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid name: %s", msg.Name) + } + + if msg.Description == DoNotModify { + return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid description") + } + + if msg.Website == DoNotModify { + return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid website") + } + + if msg.PictureUrl == DoNotModify { + return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid picture URL") } _, err := sdk.AccAddressFromBech32(msg.Sender) @@ -41,9 +53,9 @@ func (msg *MsgRegisterAVS) GetSigners() []sdk.AccAddress { // -------------------------------------------------------------------------------------------------------------------- // ValidateBasic implements sdk.Msg -func (msg *MsgDeregisterAVS) ValidateBasic() error { - if msg.AVSID == 0 { - return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid id: %d", msg.AVSID) +func (msg *MsgUpdateAVS) ValidateBasic() error { + if msg.ID == 0 { + return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid id: %d", msg.ID) } _, err := sdk.AccAddressFromBech32(msg.Sender) @@ -55,12 +67,12 @@ func (msg *MsgDeregisterAVS) ValidateBasic() error { } // GetSignBytes implements sdk.Msg -func (msg *MsgDeregisterAVS) GetSignBytes() []byte { +func (msg *MsgUpdateAVS) GetSignBytes() []byte { return AminoCdc.MustMarshalJSON(msg) } // GetSigners implements sdk.Msg -func (msg *MsgDeregisterAVS) GetSigners() []sdk.AccAddress { +func (msg *MsgUpdateAVS) GetSigners() []sdk.AccAddress { addr, _ := sdk.AccAddressFromBech32(msg.Sender) return []sdk.AccAddress{addr} } diff --git a/x/avs/types/messages.pb.go b/x/avs/types/messages.pb.go index dadf7d80a..e41b2fe8a 100644 --- a/x/avs/types/messages.pb.go +++ b/x/avs/types/messages.pb.go @@ -47,7 +47,7 @@ type MsgRegisterAVS struct { // Website is the website of the AVS (optional) Website string `protobuf:"bytes,4,opt,name=website,proto3" json:"website,omitempty" yaml:"website"` // PictureURL is the URL of the AVS picture (optional) - NewAVSID string `protobuf:"bytes,5,opt,name=picture_url,json=pictureUrl,proto3" json:"picture_url,omitempty" yaml:"picture_url"` + PictureUrl string `protobuf:"bytes,5,opt,name=picture_url,json=pictureUrl,proto3" json:"picture_url,omitempty" yaml:"picture_url"` } func (m *MsgRegisterAVS) Reset() { *m = MsgRegisterAVS{} } @@ -111,9 +111,9 @@ func (m *MsgRegisterAVS) GetWebsite() string { return "" } -func (m *MsgRegisterAVS) GetNewAVSID() string { +func (m *MsgRegisterAVS) GetPictureUrl() string { if m != nil { - return m.NewAVSID + return m.PictureUrl } return "" } @@ -165,28 +165,40 @@ func (m *MsgRegisterAVSResponse) GetNewAVSID() uint32 { return 0 } -// MsgDeregisterAVS defines the message structure for the DeregisterAVS gRPC -// service method. It allows the AVS owner to deregister their AVS so that -// operators know that they can safely stop validating it. -type MsgDeregisterAVS struct { +// MsgUpdateAVS defines the message structure for the UpdateAVS gRPC +// service method. It allows the AVS owner to update the details of +// an existing AVS. +type MsgUpdateAVS struct { // Sender is the address of the user deregistering the AVS Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - // AVSID is the ID of the AVS to be deregistered - AVSID uint64 `protobuf:"varint,2,opt,name=avs_id,json=avsId,proto3" json:"avs_id,omitempty"` + // ID represents the ID of the AVS to be updated + ID uint64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` + // Name is the new name of the AVS (optional). + // If it shouldn't be changed, use [do-not-modify] instead. + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` + // Description is the new description of the AVS (optional) + // If it shouldn't be changed, use [do-not-modify] instead. + Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` + // Website is the new website of the AVS (optional) + // If it shouldn't be changed, use [do-not-modify] instead. + Website string `protobuf:"bytes,5,opt,name=website,proto3" json:"website,omitempty" yaml:"website"` + // PictureURL is the new URL of the AVS picture (optional) + // If it shouldn't be changed, use [do-not-modify] instead. + PictureUrl string `protobuf:"bytes,6,opt,name=picture_url,json=pictureUrl,proto3" json:"picture_url,omitempty" yaml:"picture_url"` } -func (m *MsgDeregisterAVS) Reset() { *m = MsgDeregisterAVS{} } -func (m *MsgDeregisterAVS) String() string { return proto.CompactTextString(m) } -func (*MsgDeregisterAVS) ProtoMessage() {} -func (*MsgDeregisterAVS) Descriptor() ([]byte, []int) { +func (m *MsgUpdateAVS) Reset() { *m = MsgUpdateAVS{} } +func (m *MsgUpdateAVS) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateAVS) ProtoMessage() {} +func (*MsgUpdateAVS) Descriptor() ([]byte, []int) { return fileDescriptor_ee6728b943d8fd23, []int{2} } -func (m *MsgDeregisterAVS) XXX_Unmarshal(b []byte) error { +func (m *MsgUpdateAVS) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgDeregisterAVS) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgUpdateAVS) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgDeregisterAVS.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgUpdateAVS.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -196,48 +208,76 @@ func (m *MsgDeregisterAVS) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } -func (m *MsgDeregisterAVS) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgDeregisterAVS.Merge(m, src) +func (m *MsgUpdateAVS) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateAVS.Merge(m, src) } -func (m *MsgDeregisterAVS) XXX_Size() int { +func (m *MsgUpdateAVS) XXX_Size() int { return m.Size() } -func (m *MsgDeregisterAVS) XXX_DiscardUnknown() { - xxx_messageInfo_MsgDeregisterAVS.DiscardUnknown(m) +func (m *MsgUpdateAVS) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateAVS.DiscardUnknown(m) } -var xxx_messageInfo_MsgDeregisterAVS proto.InternalMessageInfo +var xxx_messageInfo_MsgUpdateAVS proto.InternalMessageInfo -func (m *MsgDeregisterAVS) GetSender() string { +func (m *MsgUpdateAVS) GetSender() string { if m != nil { return m.Sender } return "" } -func (m *MsgDeregisterAVS) GetAVSID() uint64 { +func (m *MsgUpdateAVS) GetID() uint64 { if m != nil { - return m.AVSID + return m.ID } return 0 } -// MsgDeregisterAVSResponse is the return value of MsgDeregisterAVS. -type MsgDeregisterAVSResponse struct { +func (m *MsgUpdateAVS) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *MsgUpdateAVS) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *MsgUpdateAVS) GetWebsite() string { + if m != nil { + return m.Website + } + return "" +} + +func (m *MsgUpdateAVS) GetPictureUrl() string { + if m != nil { + return m.PictureUrl + } + return "" +} + +// MsgUpdateAVSResponse is the return value of MsgUpdateAVS. +type MsgUpdateAVSResponse struct { } -func (m *MsgDeregisterAVSResponse) Reset() { *m = MsgDeregisterAVSResponse{} } -func (m *MsgDeregisterAVSResponse) String() string { return proto.CompactTextString(m) } -func (*MsgDeregisterAVSResponse) ProtoMessage() {} -func (*MsgDeregisterAVSResponse) Descriptor() ([]byte, []int) { +func (m *MsgUpdateAVSResponse) Reset() { *m = MsgUpdateAVSResponse{} } +func (m *MsgUpdateAVSResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateAVSResponse) ProtoMessage() {} +func (*MsgUpdateAVSResponse) Descriptor() ([]byte, []int) { return fileDescriptor_ee6728b943d8fd23, []int{3} } -func (m *MsgDeregisterAVSResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgUpdateAVSResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgDeregisterAVSResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgUpdateAVSResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgDeregisterAVSResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgUpdateAVSResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -247,65 +287,65 @@ func (m *MsgDeregisterAVSResponse) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } -func (m *MsgDeregisterAVSResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgDeregisterAVSResponse.Merge(m, src) +func (m *MsgUpdateAVSResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateAVSResponse.Merge(m, src) } -func (m *MsgDeregisterAVSResponse) XXX_Size() int { +func (m *MsgUpdateAVSResponse) XXX_Size() int { return m.Size() } -func (m *MsgDeregisterAVSResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgDeregisterAVSResponse.DiscardUnknown(m) +func (m *MsgUpdateAVSResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateAVSResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgDeregisterAVSResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgUpdateAVSResponse proto.InternalMessageInfo func init() { proto.RegisterType((*MsgRegisterAVS)(nil), "milkyway.avs.v1.MsgRegisterAVS") proto.RegisterType((*MsgRegisterAVSResponse)(nil), "milkyway.avs.v1.MsgRegisterAVSResponse") - proto.RegisterType((*MsgDeregisterAVS)(nil), "milkyway.avs.v1.MsgDeregisterAVS") - proto.RegisterType((*MsgDeregisterAVSResponse)(nil), "milkyway.avs.v1.MsgDeregisterAVSResponse") + proto.RegisterType((*MsgUpdateAVS)(nil), "milkyway.avs.v1.MsgUpdateAVS") + proto.RegisterType((*MsgUpdateAVSResponse)(nil), "milkyway.avs.v1.MsgUpdateAVSResponse") } func init() { proto.RegisterFile("milkyway/avs/v1/messages.proto", fileDescriptor_ee6728b943d8fd23) } var fileDescriptor_ee6728b943d8fd23 = []byte{ - // 565 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0xb1, 0x6f, 0xd3, 0x4e, - 0x14, 0xae, 0xdb, 0x26, 0xbf, 0xf6, 0xf2, 0x6b, 0x0b, 0x56, 0xd5, 0xba, 0x16, 0xb2, 0x8b, 0x19, - 0x4a, 0x23, 0x62, 0x13, 0x58, 0x50, 0xb6, 0x84, 0x48, 0xa8, 0x43, 0x18, 0x1c, 0x51, 0x24, 0x24, - 0x14, 0x9d, 0xe3, 0x93, 0xb1, 0x1a, 0xfb, 0xac, 0x7b, 0x8e, 0x43, 0x36, 0xc4, 0xc8, 0x04, 0xff, - 0x49, 0x06, 0x56, 0x36, 0x06, 0xc6, 0x8a, 0x89, 0x29, 0x42, 0xc9, 0x90, 0x3d, 0x7f, 0x01, 0xca, - 0xf9, 0x12, 0xec, 0x80, 0xd4, 0x81, 0x25, 0xca, 0x7b, 0xdf, 0xf7, 0xee, 0xbb, 0xef, 0x3b, 0x3f, - 0xa4, 0x05, 0x7e, 0xef, 0x6a, 0x38, 0xc0, 0x43, 0x0b, 0x27, 0x60, 0x25, 0x55, 0x2b, 0x20, 0x00, - 0xd8, 0x23, 0x60, 0x46, 0x8c, 0xc6, 0x54, 0x3e, 0x58, 0xe2, 0x26, 0x4e, 0xc0, 0x4c, 0xaa, 0xea, - 0x6d, 0x1c, 0xf8, 0x21, 0xb5, 0xf8, 0x6f, 0xca, 0x51, 0x4f, 0xba, 0x14, 0x02, 0x0a, 0x1d, 0x5e, - 0x59, 0x69, 0x21, 0x20, 0x2d, 0xad, 0x2c, 0x07, 0x03, 0xb1, 0x92, 0xaa, 0x43, 0x62, 0x5c, 0xb5, - 0xba, 0xd4, 0x0f, 0xff, 0xc0, 0xc3, 0xab, 0x15, 0xbe, 0x28, 0x04, 0x7e, 0x2c, 0xf0, 0x00, 0x3c, - 0x7e, 0x39, 0xf0, 0x04, 0x70, 0xe8, 0x51, 0x8f, 0xa6, 0x82, 0x8b, 0x7f, 0xa2, 0x7b, 0x67, 0xdd, - 0x4d, 0x84, 0x19, 0x0e, 0xc4, 0x65, 0x8c, 0x2f, 0x9b, 0x68, 0xbf, 0x05, 0x9e, 0x4d, 0x3c, 0x1f, - 0x62, 0xc2, 0xea, 0x97, 0x6d, 0xf9, 0x21, 0x2a, 0x02, 0x09, 0x5d, 0xc2, 0x14, 0xe9, 0x54, 0xba, - 0xbf, 0xdb, 0x50, 0xbe, 0x7f, 0xae, 0x1c, 0x0a, 0x07, 0x75, 0xd7, 0x65, 0x04, 0xa0, 0x1d, 0x33, - 0x3f, 0xf4, 0x6c, 0xc1, 0x93, 0xef, 0xa1, 0xed, 0x10, 0x07, 0x44, 0xd9, 0xe4, 0xfc, 0x83, 0xf9, - 0x58, 0x2f, 0x0d, 0x71, 0xd0, 0xab, 0x19, 0x8b, 0xae, 0x61, 0x73, 0x50, 0x7e, 0x82, 0x4a, 0x2e, - 0x81, 0x2e, 0xf3, 0xa3, 0xd8, 0xa7, 0xa1, 0xb2, 0xc5, 0xb9, 0x47, 0xf3, 0xb1, 0x2e, 0xa7, 0xdc, - 0x0c, 0x68, 0xd8, 0x59, 0xaa, 0xfc, 0x00, 0xfd, 0x37, 0x20, 0x0e, 0xf8, 0x31, 0x51, 0xb6, 0xf9, - 0x94, 0x3c, 0x1f, 0xeb, 0xfb, 0xe9, 0x94, 0x00, 0x0c, 0x7b, 0x49, 0x91, 0x9f, 0xa2, 0x52, 0xe4, - 0x77, 0xe3, 0x3e, 0x23, 0x9d, 0x3e, 0xeb, 0x29, 0x05, 0x3e, 0x61, 0x4c, 0xc6, 0xfa, 0xce, 0x73, - 0x32, 0xa8, 0x5f, 0xb6, 0x2f, 0x9a, 0xbf, 0x35, 0x33, 0x44, 0xc3, 0x46, 0xa2, 0x7a, 0xc1, 0x7a, - 0xb5, 0xb3, 0xf7, 0xb3, 0x51, 0x59, 0xd8, 0xfb, 0x30, 0x1b, 0x95, 0x8f, 0x57, 0x21, 0xe6, 0xc3, - 0x32, 0x9a, 0xe8, 0x28, 0xdf, 0xb1, 0x09, 0x44, 0x34, 0x04, 0x22, 0x97, 0x11, 0x0a, 0xc9, 0xa0, - 0x83, 0x13, 0xe8, 0xf8, 0x2e, 0x8f, 0x72, 0xaf, 0xf1, 0x7f, 0xf6, 0x1a, 0xf6, 0x4e, 0x48, 0x06, - 0xf5, 0x04, 0x2e, 0x5c, 0xe3, 0x93, 0x84, 0x6e, 0xb5, 0xc0, 0x6b, 0x12, 0xf6, 0x4f, 0xef, 0x70, - 0x8a, 0x8a, 0x42, 0x6e, 0xf1, 0x12, 0xdb, 0x8d, 0xdd, 0xc9, 0x58, 0x2f, 0xa4, 0x5a, 0x05, 0xbc, - 0x10, 0xaa, 0x9d, 0xaf, 0xf9, 0x3a, 0xc9, 0xfa, 0xca, 0xc9, 0x1b, 0x2a, 0x52, 0xd6, 0x7b, 0x4b, - 0x6f, 0x8f, 0xbe, 0x4a, 0x68, 0xab, 0x05, 0x9e, 0xfc, 0x12, 0x95, 0xb2, 0x5f, 0x8e, 0x6e, 0xae, - 0x6d, 0x86, 0x99, 0xcf, 0x46, 0x3d, 0xbb, 0x81, 0xb0, 0x0a, 0xef, 0x35, 0xda, 0xcb, 0x87, 0x71, - 0xf7, 0x6f, 0x93, 0x39, 0x8a, 0x7a, 0x7e, 0x23, 0x65, 0x79, 0xbc, 0x5a, 0x78, 0x37, 0x1b, 0x95, - 0xa5, 0xc6, 0xb3, 0x6f, 0x13, 0x4d, 0xba, 0x9e, 0x68, 0xd2, 0xcf, 0x89, 0x26, 0x7d, 0x9c, 0x6a, - 0x1b, 0xd7, 0x53, 0x6d, 0xe3, 0xc7, 0x54, 0xdb, 0x78, 0x55, 0xf1, 0xfc, 0xf8, 0x4d, 0xdf, 0x31, - 0xbb, 0x34, 0xb0, 0x96, 0xa7, 0x56, 0x7a, 0xd8, 0x81, 0x55, 0x65, 0xbd, 0xe5, 0xfb, 0x14, 0x0f, - 0x23, 0x02, 0x4e, 0x91, 0x2f, 0xd3, 0xe3, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd4, 0x33, 0x12, - 0x05, 0x3a, 0x04, 0x00, 0x00, + // 575 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x4d, 0x8f, 0xd2, 0x40, + 0x1c, 0xc6, 0x69, 0x79, 0x71, 0x77, 0x58, 0x77, 0x63, 0x83, 0x6c, 0x25, 0xda, 0x9a, 0x9a, 0xcd, + 0x1a, 0x22, 0xad, 0xe8, 0x41, 0xb3, 0x37, 0x08, 0x89, 0xe1, 0x80, 0x89, 0x25, 0xbb, 0x26, 0x5e, + 0xc8, 0x94, 0x4e, 0xea, 0x64, 0xe9, 0x4b, 0xfa, 0x2f, 0x45, 0x6e, 0xc6, 0xa3, 0x27, 0x3f, 0x0a, + 0x26, 0x1e, 0xfc, 0x02, 0x26, 0x1e, 0x37, 0x9e, 0x3c, 0x11, 0x03, 0x07, 0xee, 0x7c, 0x02, 0x43, + 0x3b, 0xd4, 0x82, 0x46, 0xdd, 0xbd, 0x10, 0x9e, 0xf9, 0x3d, 0xf3, 0xf6, 0x3c, 0x1d, 0x24, 0xd9, + 0x74, 0x70, 0x3e, 0x1e, 0xe1, 0xb1, 0x86, 0x43, 0xd0, 0xc2, 0xba, 0x66, 0x13, 0x00, 0x6c, 0x11, + 0x50, 0x3d, 0xdf, 0x0d, 0x5c, 0xe1, 0x60, 0xcd, 0x55, 0x1c, 0x82, 0x1a, 0xd6, 0x2b, 0x37, 0xb0, + 0x4d, 0x1d, 0x57, 0x8b, 0x7e, 0x63, 0x4f, 0xe5, 0x56, 0xdf, 0x05, 0xdb, 0x85, 0x5e, 0xa4, 0xb4, + 0x58, 0x30, 0x24, 0xc5, 0x4a, 0x33, 0x30, 0x10, 0x2d, 0xac, 0x1b, 0x24, 0xc0, 0x75, 0xad, 0xef, + 0x52, 0xe7, 0x37, 0xee, 0x9c, 0x27, 0x7c, 0x25, 0x18, 0x3f, 0x64, 0xdc, 0x06, 0x2b, 0x3a, 0x1c, + 0x58, 0x0c, 0x94, 0x2c, 0xd7, 0x72, 0xe3, 0x0d, 0x57, 0xff, 0xd8, 0xe8, 0xed, 0xed, 0xdb, 0x78, + 0xd8, 0xc7, 0x36, 0x3b, 0x8c, 0xf2, 0x91, 0x47, 0xfb, 0x1d, 0xb0, 0x74, 0x62, 0x51, 0x08, 0x88, + 0xdf, 0x38, 0xeb, 0x0a, 0x0f, 0x51, 0x01, 0x88, 0x63, 0x12, 0x5f, 0xe4, 0xee, 0x72, 0xf7, 0x77, + 0x9b, 0xe2, 0xb7, 0x4f, 0xb5, 0x12, 0xbb, 0x41, 0xc3, 0x34, 0x7d, 0x02, 0xd0, 0x0d, 0x7c, 0xea, + 0x58, 0x3a, 0xf3, 0x09, 0xf7, 0x50, 0xce, 0xc1, 0x36, 0x11, 0xf9, 0xc8, 0x7f, 0xb0, 0x9c, 0xca, + 0xc5, 0x31, 0xb6, 0x07, 0x27, 0xca, 0x6a, 0x54, 0xd1, 0x23, 0x28, 0x3c, 0x45, 0x45, 0x93, 0x40, + 0xdf, 0xa7, 0x5e, 0x40, 0x5d, 0x47, 0xcc, 0x46, 0xde, 0xf2, 0x72, 0x2a, 0x0b, 0xb1, 0x37, 0x05, + 0x15, 0x3d, 0x6d, 0x15, 0x1e, 0xa0, 0x6b, 0x23, 0x62, 0x00, 0x0d, 0x88, 0x98, 0x8b, 0x66, 0x09, + 0xcb, 0xa9, 0xbc, 0x1f, 0xcf, 0x62, 0x40, 0xd1, 0xd7, 0x16, 0xe1, 0x09, 0x2a, 0x7a, 0xb4, 0x1f, + 0x0c, 0x7d, 0xd2, 0x1b, 0xfa, 0x03, 0x31, 0xbf, 0xbd, 0x4f, 0x0a, 0x2a, 0x3a, 0x62, 0xea, 0xd4, + 0x1f, 0x9c, 0x1c, 0xbf, 0x5b, 0x4c, 0xaa, 0xec, 0x4a, 0xef, 0x17, 0x93, 0xea, 0x61, 0x12, 0xdc, + 0x66, 0x40, 0x4a, 0x0b, 0x95, 0x37, 0x47, 0x74, 0x02, 0x9e, 0xeb, 0x00, 0x11, 0xaa, 0x08, 0x39, + 0x64, 0xd4, 0xc3, 0x21, 0xf4, 0xa8, 0x19, 0xc5, 0x77, 0xbd, 0xb9, 0x37, 0x9b, 0xca, 0x3b, 0xcf, + 0xc9, 0xa8, 0x71, 0xd6, 0x6d, 0xb7, 0xf4, 0x1d, 0x87, 0x8c, 0x1a, 0x21, 0xb4, 0x4d, 0xe5, 0x0b, + 0x8f, 0xf6, 0x3a, 0x60, 0x9d, 0x7a, 0x26, 0x0e, 0xc8, 0xd5, 0x72, 0x2f, 0x23, 0x9e, 0x9a, 0x51, + 0xea, 0xb9, 0x66, 0x61, 0x36, 0x95, 0xf9, 0x76, 0x4b, 0xe7, 0xa9, 0x99, 0xf4, 0x91, 0xbd, 0x44, + 0x1f, 0xb9, 0x2b, 0xf5, 0x91, 0xbf, 0x74, 0x1f, 0x85, 0xff, 0xee, 0xe3, 0x68, 0xab, 0x8f, 0x9b, + 0xe9, 0x3e, 0x92, 0xd8, 0x94, 0x32, 0x2a, 0xa5, 0xf5, 0xba, 0x8b, 0x47, 0x9f, 0x39, 0x94, 0xed, + 0x80, 0x25, 0xbc, 0x44, 0xc5, 0xf4, 0xd7, 0x2d, 0xab, 0x5b, 0xaf, 0x57, 0xdd, 0xec, 0xb2, 0x72, + 0xfc, 0x0f, 0x43, 0x52, 0xf6, 0x0b, 0xb4, 0xfb, 0xab, 0xbc, 0x3b, 0x7f, 0x9a, 0x95, 0xe0, 0xca, + 0xd1, 0x5f, 0xf1, 0x7a, 0xc9, 0x4a, 0xfe, 0xed, 0x62, 0x52, 0xe5, 0x9a, 0xcf, 0xbe, 0xce, 0x24, + 0xee, 0x62, 0x26, 0x71, 0x3f, 0x66, 0x12, 0xf7, 0x61, 0x2e, 0x65, 0x2e, 0xe6, 0x52, 0xe6, 0xfb, + 0x5c, 0xca, 0xbc, 0xaa, 0x59, 0x34, 0x78, 0x3d, 0x34, 0xd4, 0xbe, 0x6b, 0x6b, 0xeb, 0x15, 0x6b, + 0x03, 0x6c, 0x40, 0xa2, 0xb4, 0x37, 0xd1, 0x3b, 0x0f, 0xc6, 0x1e, 0x01, 0xa3, 0x10, 0x3d, 0xf2, + 0xc7, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x33, 0x58, 0xed, 0x65, 0xd2, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -321,7 +361,7 @@ const _ = grpc.SupportPackageIsVersion4 // 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 { RegisterAVS(ctx context.Context, in *MsgRegisterAVS, opts ...grpc.CallOption) (*MsgRegisterAVSResponse, error) - DeregisterAVS(ctx context.Context, in *MsgDeregisterAVS, opts ...grpc.CallOption) (*MsgDeregisterAVSResponse, error) + UpdateAVS(ctx context.Context, in *MsgUpdateAVS, opts ...grpc.CallOption) (*MsgUpdateAVSResponse, error) } type msgClient struct { @@ -341,9 +381,9 @@ func (c *msgClient) RegisterAVS(ctx context.Context, in *MsgRegisterAVS, opts .. return out, nil } -func (c *msgClient) DeregisterAVS(ctx context.Context, in *MsgDeregisterAVS, opts ...grpc.CallOption) (*MsgDeregisterAVSResponse, error) { - out := new(MsgDeregisterAVSResponse) - err := c.cc.Invoke(ctx, "/milkyway.avs.v1.Msg/DeregisterAVS", in, out, opts...) +func (c *msgClient) UpdateAVS(ctx context.Context, in *MsgUpdateAVS, opts ...grpc.CallOption) (*MsgUpdateAVSResponse, error) { + out := new(MsgUpdateAVSResponse) + err := c.cc.Invoke(ctx, "/milkyway.avs.v1.Msg/UpdateAVS", in, out, opts...) if err != nil { return nil, err } @@ -353,7 +393,7 @@ func (c *msgClient) DeregisterAVS(ctx context.Context, in *MsgDeregisterAVS, opt // MsgServer is the server API for Msg service. type MsgServer interface { RegisterAVS(context.Context, *MsgRegisterAVS) (*MsgRegisterAVSResponse, error) - DeregisterAVS(context.Context, *MsgDeregisterAVS) (*MsgDeregisterAVSResponse, error) + UpdateAVS(context.Context, *MsgUpdateAVS) (*MsgUpdateAVSResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -363,8 +403,8 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) RegisterAVS(ctx context.Context, req *MsgRegisterAVS) (*MsgRegisterAVSResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RegisterAVS not implemented") } -func (*UnimplementedMsgServer) DeregisterAVS(ctx context.Context, req *MsgDeregisterAVS) (*MsgDeregisterAVSResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DeregisterAVS not implemented") +func (*UnimplementedMsgServer) UpdateAVS(ctx context.Context, req *MsgUpdateAVS) (*MsgUpdateAVSResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateAVS not implemented") } func RegisterMsgServer(s grpc1.Server, srv MsgServer) { @@ -389,20 +429,20 @@ func _Msg_RegisterAVS_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } -func _Msg_DeregisterAVS_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgDeregisterAVS) +func _Msg_UpdateAVS_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateAVS) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).DeregisterAVS(ctx, in) + return srv.(MsgServer).UpdateAVS(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/milkyway.avs.v1.Msg/DeregisterAVS", + FullMethod: "/milkyway.avs.v1.Msg/UpdateAVS", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).DeregisterAVS(ctx, req.(*MsgDeregisterAVS)) + return srv.(MsgServer).UpdateAVS(ctx, req.(*MsgUpdateAVS)) } return interceptor(ctx, in, info, handler) } @@ -416,8 +456,8 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Handler: _Msg_RegisterAVS_Handler, }, { - MethodName: "DeregisterAVS", - Handler: _Msg_DeregisterAVS_Handler, + MethodName: "UpdateAVS", + Handler: _Msg_UpdateAVS_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -444,10 +484,10 @@ func (m *MsgRegisterAVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.NewAVSID) > 0 { - i -= len(m.NewAVSID) - copy(dAtA[i:], m.NewAVSID) - i = encodeVarintMessages(dAtA, i, uint64(len(m.NewAVSID))) + if len(m.PictureUrl) > 0 { + i -= len(m.PictureUrl) + copy(dAtA[i:], m.PictureUrl) + i = encodeVarintMessages(dAtA, i, uint64(len(m.PictureUrl))) i-- dAtA[i] = 0x2a } @@ -510,7 +550,7 @@ func (m *MsgRegisterAVSResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *MsgDeregisterAVS) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateAVS) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -520,18 +560,46 @@ func (m *MsgDeregisterAVS) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgDeregisterAVS) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateAVS) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgDeregisterAVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateAVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.AVSID != 0 { - i = encodeVarintMessages(dAtA, i, uint64(m.AVSID)) + if len(m.PictureUrl) > 0 { + i -= len(m.PictureUrl) + copy(dAtA[i:], m.PictureUrl) + i = encodeVarintMessages(dAtA, i, uint64(len(m.PictureUrl))) + i-- + dAtA[i] = 0x32 + } + if len(m.Website) > 0 { + i -= len(m.Website) + copy(dAtA[i:], m.Website) + i = encodeVarintMessages(dAtA, i, uint64(len(m.Website))) + i-- + dAtA[i] = 0x2a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintMessages(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x22 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintMessages(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x1a + } + if m.ID != 0 { + i = encodeVarintMessages(dAtA, i, uint64(m.ID)) i-- dAtA[i] = 0x10 } @@ -545,7 +613,7 @@ func (m *MsgDeregisterAVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgDeregisterAVSResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateAVSResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -555,12 +623,12 @@ func (m *MsgDeregisterAVSResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgDeregisterAVSResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateAVSResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgDeregisterAVSResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateAVSResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -601,7 +669,7 @@ func (m *MsgRegisterAVS) Size() (n int) { if l > 0 { n += 1 + l + sovMessages(uint64(l)) } - l = len(m.NewAVSID) + l = len(m.PictureUrl) if l > 0 { n += 1 + l + sovMessages(uint64(l)) } @@ -620,7 +688,7 @@ func (m *MsgRegisterAVSResponse) Size() (n int) { return n } -func (m *MsgDeregisterAVS) Size() (n int) { +func (m *MsgUpdateAVS) Size() (n int) { if m == nil { return 0 } @@ -630,13 +698,29 @@ func (m *MsgDeregisterAVS) Size() (n int) { if l > 0 { n += 1 + l + sovMessages(uint64(l)) } - if m.AVSID != 0 { - n += 1 + sovMessages(uint64(m.AVSID)) + if m.ID != 0 { + n += 1 + sovMessages(uint64(m.ID)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovMessages(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovMessages(uint64(l)) + } + l = len(m.Website) + if l > 0 { + n += 1 + l + sovMessages(uint64(l)) + } + l = len(m.PictureUrl) + if l > 0 { + n += 1 + l + sovMessages(uint64(l)) } return n } -func (m *MsgDeregisterAVSResponse) Size() (n int) { +func (m *MsgUpdateAVSResponse) Size() (n int) { if m == nil { return 0 } @@ -810,7 +894,7 @@ func (m *MsgRegisterAVS) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NewAVSID", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PictureUrl", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -838,7 +922,7 @@ func (m *MsgRegisterAVS) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.NewAVSID = string(dAtA[iNdEx:postIndex]) + m.PictureUrl = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -930,7 +1014,7 @@ func (m *MsgRegisterAVSResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgDeregisterAVS) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateAVS) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -953,10 +1037,10 @@ func (m *MsgDeregisterAVS) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgDeregisterAVS: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateAVS: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgDeregisterAVS: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateAVS: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -993,9 +1077,92 @@ func (m *MsgDeregisterAVS) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AVSID", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + 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 ErrInvalidLengthMessages + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMessages + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + 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 ErrInvalidLengthMessages + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMessages + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Website", wireType) } - m.AVSID = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowMessages @@ -1005,11 +1172,56 @@ func (m *MsgDeregisterAVS) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.AVSID |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMessages + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMessages + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Website = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PictureUrl", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + 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 ErrInvalidLengthMessages + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMessages + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PictureUrl = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipMessages(dAtA[iNdEx:]) @@ -1031,7 +1243,7 @@ func (m *MsgDeregisterAVS) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgDeregisterAVSResponse) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateAVSResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1054,10 +1266,10 @@ func (m *MsgDeregisterAVSResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgDeregisterAVSResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateAVSResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgDeregisterAVSResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateAVSResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: diff --git a/x/avs/types/models.go b/x/avs/types/models.go index 7fa0b98ec..7bdcf2a47 100644 --- a/x/avs/types/models.go +++ b/x/avs/types/models.go @@ -49,3 +49,57 @@ func (a *AVS) Validate() error { return nil } + +// -------------------------------------------------------------------------------------------------------------------- + +// AVSUpdate defines the fields that can be updated in an AVS. +type AVSUpdate struct { + Name string + Description string + Website string + PictureURL string +} + +// NewAVSUpdate returns a new AVSUpdate instance. +func NewAVSUpdate( + name string, + description string, + website string, + pictureURL string, +) AVSUpdate { + return AVSUpdate{ + Name: name, + Description: description, + Website: website, + PictureURL: pictureURL, + } +} + +// Update returns a new AVS with updated fields. +func (a *AVS) Update(update AVSUpdate) AVS { + if update.Name == DoNotModify { + update.Name = a.Name + } + + if update.Description == DoNotModify { + update.Description = a.Description + } + + if update.Website == DoNotModify { + update.Website = a.Website + } + + if update.PictureURL == DoNotModify { + update.PictureURL = a.PictureURL + } + + return NewAVS( + a.ID, + a.Status, + update.Name, + update.Description, + update.Website, + update.PictureURL, + a.Admin, + ) +} From fffadad436e845edaf124d11b9b9952c6b0a4130 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Tue, 4 Jun 2024 09:37:32 -0500 Subject: [PATCH 17/49] refactor: improve genesis and messages definitions --- proto/milkyway/avs/v1/genesis.proto | 4 + proto/milkyway/avs/v1/messages.proto | 12 ++- x/avs/types/genesis.go | 14 ++- x/avs/types/genesis.pb.go | 56 +++++++++-- x/avs/types/genesis_test.go | 15 ++- x/avs/types/messages.go | 6 +- x/avs/types/messages.pb.go | 135 ++++++++++++++------------- 7 files changed, 156 insertions(+), 86 deletions(-) diff --git a/proto/milkyway/avs/v1/genesis.proto b/proto/milkyway/avs/v1/genesis.proto index 67d5f22ae..bcb7d81e3 100644 --- a/proto/milkyway/avs/v1/genesis.proto +++ b/proto/milkyway/avs/v1/genesis.proto @@ -17,4 +17,8 @@ message GenesisState { (gogoproto.moretags) = "yaml:\"services\"", (gogoproto.nullable) = false ]; + + // NextAVSId defines the ID that will be assigned to the next AVS that gets + // created. + uint32 next_avs_id = 3 [(gogoproto.customname) = "NextAVSID"]; } \ No newline at end of file diff --git a/proto/milkyway/avs/v1/messages.proto b/proto/milkyway/avs/v1/messages.proto index 8e5d05ff3..025a4ba82 100644 --- a/proto/milkyway/avs/v1/messages.proto +++ b/proto/milkyway/avs/v1/messages.proto @@ -40,7 +40,10 @@ message MsgRegisterAVS { string website = 4 [ (gogoproto.moretags) = "yaml:\"website\"" ]; // PictureURL is the URL of the AVS picture (optional) - string picture_url = 5 [ (gogoproto.moretags) = "yaml:\"picture_url\"" ]; + string picture_url = 5 [ + (gogoproto.moretags) = "yaml:\"picture_url\"", + (gogoproto.customname) = "PictureURL" + ]; } // MsgRegisterAVSResponse is the return value of MsgRegisterAVS. @@ -61,7 +64,7 @@ message MsgUpdateAVS { string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // ID represents the ID of the AVS to be updated - uint64 id = 2 [ (gogoproto.customname) = "ID" ]; + uint32 avs_id = 2 [ (gogoproto.customname) = "AVSID" ]; // Name is the new name of the AVS (optional). // If it shouldn't be changed, use [do-not-modify] instead. @@ -77,7 +80,10 @@ message MsgUpdateAVS { // PictureURL is the new URL of the AVS picture (optional) // If it shouldn't be changed, use [do-not-modify] instead. - string picture_url = 6 [ (gogoproto.moretags) = "yaml:\"picture_url\"" ]; + string picture_url = 6 [ + (gogoproto.moretags) = "yaml:\"picture_url\"", + (gogoproto.customname) = "PictureURL" + ]; } // MsgUpdateAVSResponse is the return value of MsgUpdateAVS. diff --git a/x/avs/types/genesis.go b/x/avs/types/genesis.go index cc94b800e..579c46ffa 100644 --- a/x/avs/types/genesis.go +++ b/x/avs/types/genesis.go @@ -7,22 +7,28 @@ import ( ) // NewGenesisState returns a new GenesisState instance -func NewGenesisState(services []AVS, params Params) *GenesisState { +func NewGenesisState(nextAVSID uint32, services []AVS, params Params) *GenesisState { return &GenesisState{ - Services: services, - Params: params, + NextAVSID: nextAVSID, + Services: services, + Params: params, } } // DefaultGenesisState returns a default GenesisState func DefaultGenesisState() *GenesisState { - return NewGenesisState(nil, DefaultParams()) + return NewGenesisState(1, nil, DefaultParams()) } // -------------------------------------------------------------------------------------------------------------------- // ValidateGenesis validates the given genesis state and returns an error if something is invalid func ValidateGenesis(data *GenesisState) error { + // Check for the next AVS ID + if data.NextAVSID == 0 { + return fmt.Errorf("invalid next AVS ID: %d", data.NextAVSID) + } + // Check for duplicated services if duplicate := findDuplicatedService(data.Services); duplicate != nil { return fmt.Errorf("duplicated service: %d", duplicate.ID) diff --git a/x/avs/types/genesis.pb.go b/x/avs/types/genesis.pb.go index 23555b17f..bd6193017 100644 --- a/x/avs/types/genesis.pb.go +++ b/x/avs/types/genesis.pb.go @@ -29,6 +29,9 @@ type GenesisState struct { Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` // Services defines the list of actively validated services. Services []AVS `protobuf:"bytes,2,rep,name=services,proto3" json:"services" yaml:"services"` + // NextAVSId defines the ID that will be assigned to the next AVS that gets + // created. + NextAVSID uint32 `protobuf:"varint,3,opt,name=next_avs_id,json=nextAvsId,proto3" json:"next_avs_id,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -78,6 +81,13 @@ func (m *GenesisState) GetServices() []AVS { return nil } +func (m *GenesisState) GetNextAVSID() uint32 { + if m != nil { + return m.NextAVSID + } + return 0 +} + func init() { proto.RegisterType((*GenesisState)(nil), "milkyway.avs.v1.GenesisState") } @@ -85,23 +95,26 @@ func init() { func init() { proto.RegisterFile("milkyway/avs/v1/genesis.proto", fileDescriptor_e9762187afdc6843) } var fileDescriptor_e9762187afdc6843 = []byte{ - // 251 bytes of a gzipped FileDescriptorProto + // 296 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcd, 0xcd, 0xcc, 0xc9, 0xae, 0x2c, 0x4f, 0xac, 0xd4, 0x4f, 0x2c, 0x2b, 0xd6, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0x49, 0xeb, 0x25, 0x96, 0x15, 0xeb, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xe5, 0xf4, 0x41, 0x2c, 0x88, 0x32, 0x29, 0x19, 0x74, 0x53, 0x72, 0xf3, 0x53, 0x52, 0x73, 0x8a, 0x71, 0xc9, 0x16, 0x24, 0x16, - 0x25, 0xe6, 0x42, 0x65, 0x95, 0x26, 0x30, 0x72, 0xf1, 0xb8, 0x43, 0x2c, 0x0d, 0x2e, 0x49, 0x2c, + 0x25, 0xe6, 0x42, 0x65, 0x95, 0xf6, 0x33, 0x72, 0xf1, 0xb8, 0x43, 0x2c, 0x0d, 0x2e, 0x49, 0x2c, 0x49, 0x15, 0x32, 0xe5, 0x62, 0x83, 0x28, 0x90, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x36, 0x12, 0xd7, 0x43, 0x73, 0x84, 0x5e, 0x00, 0x58, 0xda, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x62, 0x21, 0x4f, 0x2e, 0x8e, 0xe2, 0xd4, 0xa2, 0xb2, 0xcc, 0xe4, 0xd4, 0x62, 0x09, 0x26, 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x11, 0x0c, 0x8d, 0x8e, 0x61, 0xc1, 0x4e, 0xe2, 0x20, 0x5d, 0x9f, 0xee, 0xc9, - 0xf3, 0x57, 0x26, 0xe6, 0xe6, 0x58, 0x29, 0xc1, 0xf4, 0x28, 0x05, 0xc1, 0xb5, 0x3b, 0xb9, 0x9f, - 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, 0x6e, 0x7a, 0x66, 0x49, 0x46, 0x69, - 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xcc, 0x70, 0xdd, 0x9c, 0xc4, 0xa4, 0x62, 0x38, 0x4f, 0xbf, - 0x02, 0xec, 0xcb, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x17, 0x8d, 0x01, 0x01, 0x00, - 0x00, 0xff, 0xff, 0x37, 0xb7, 0xfb, 0x2f, 0x66, 0x01, 0x00, 0x00, + 0xf3, 0x57, 0x26, 0xe6, 0xe6, 0x58, 0x29, 0xc1, 0xf4, 0x28, 0x05, 0xc1, 0xb5, 0x0b, 0xe9, 0x72, + 0x71, 0xe7, 0xa5, 0x56, 0x94, 0xc4, 0x27, 0x96, 0x15, 0xc7, 0x67, 0xa6, 0x48, 0x30, 0x2b, 0x30, + 0x6a, 0xf0, 0x3a, 0xf1, 0x3e, 0xba, 0x27, 0xcf, 0xe9, 0x97, 0x5a, 0x51, 0xe2, 0x18, 0x16, 0xec, + 0xe9, 0x12, 0xc4, 0x09, 0x52, 0xe1, 0x58, 0x56, 0xec, 0x99, 0xe2, 0xe4, 0x7e, 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, 0xba, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, + 0xf9, 0xb9, 0xfa, 0x30, 0xb7, 0xe8, 0xe6, 0x24, 0x26, 0x15, 0xc3, 0x79, 0xfa, 0x15, 0xe0, 0x40, + 0x29, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x87, 0x88, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, + 0x04, 0xa4, 0xd5, 0x75, 0x95, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -124,6 +137,11 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.NextAVSID != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.NextAVSID)) + i-- + dAtA[i] = 0x18 + } if len(m.Services) > 0 { for iNdEx := len(m.Services) - 1; iNdEx >= 0; iNdEx-- { { @@ -176,6 +194,9 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if m.NextAVSID != 0 { + n += 1 + sovGenesis(uint64(m.NextAVSID)) + } return n } @@ -281,6 +302,25 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextAVSID", wireType) + } + m.NextAVSID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextAVSID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/avs/types/genesis_test.go b/x/avs/types/genesis_test.go index 11cf518b9..fd47343e4 100644 --- a/x/avs/types/genesis_test.go +++ b/x/avs/types/genesis_test.go @@ -16,9 +16,19 @@ func TestValidateGenesis(t *testing.T) { genesis *types.GenesisState shouldErr bool }{ + { + name: "invalid next AVS ID returns error", + genesis: &types.GenesisState{ + NextAVSID: 0, + Services: nil, + Params: types.DefaultParams(), + }, + shouldErr: true, + }, { name: "duplicated service returns error", genesis: &types.GenesisState{ + NextAVSID: 1, Services: []types.AVS{ { ID: 1, @@ -39,6 +49,7 @@ func TestValidateGenesis(t *testing.T) { { name: "invalid service returns error", genesis: &types.GenesisState{ + NextAVSID: 1, Services: []types.AVS{ { ID: 1, @@ -60,7 +71,8 @@ func TestValidateGenesis(t *testing.T) { { name: "invalid params returns error", genesis: &types.GenesisState{ - Services: nil, + NextAVSID: 1, + Services: nil, Params: types.Params{ AvsRegistrationFee: sdk.Coins{sdk.Coin{Denom: "", Amount: sdkmath.NewInt(10)}}, }, @@ -75,6 +87,7 @@ func TestValidateGenesis(t *testing.T) { { name: "valid genesis returns no error", genesis: &types.GenesisState{ + NextAVSID: 1, Services: []types.AVS{ { ID: 1, diff --git a/x/avs/types/messages.go b/x/avs/types/messages.go index e24e0713e..14a77376a 100644 --- a/x/avs/types/messages.go +++ b/x/avs/types/messages.go @@ -27,7 +27,7 @@ func (msg *MsgRegisterAVS) ValidateBasic() error { return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid website") } - if msg.PictureUrl == DoNotModify { + if msg.PictureURL == DoNotModify { return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid picture URL") } @@ -54,8 +54,8 @@ func (msg *MsgRegisterAVS) GetSigners() []sdk.AccAddress { // ValidateBasic implements sdk.Msg func (msg *MsgUpdateAVS) ValidateBasic() error { - if msg.ID == 0 { - return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid id: %d", msg.ID) + if msg.AVSID == 0 { + return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid avs id: %d", msg.AVSID) } _, err := sdk.AccAddressFromBech32(msg.Sender) diff --git a/x/avs/types/messages.pb.go b/x/avs/types/messages.pb.go index e41b2fe8a..0bc254fc6 100644 --- a/x/avs/types/messages.pb.go +++ b/x/avs/types/messages.pb.go @@ -47,7 +47,7 @@ type MsgRegisterAVS struct { // Website is the website of the AVS (optional) Website string `protobuf:"bytes,4,opt,name=website,proto3" json:"website,omitempty" yaml:"website"` // PictureURL is the URL of the AVS picture (optional) - PictureUrl string `protobuf:"bytes,5,opt,name=picture_url,json=pictureUrl,proto3" json:"picture_url,omitempty" yaml:"picture_url"` + PictureURL string `protobuf:"bytes,5,opt,name=picture_url,json=pictureUrl,proto3" json:"picture_url,omitempty" yaml:"picture_url"` } func (m *MsgRegisterAVS) Reset() { *m = MsgRegisterAVS{} } @@ -111,9 +111,9 @@ func (m *MsgRegisterAVS) GetWebsite() string { return "" } -func (m *MsgRegisterAVS) GetPictureUrl() string { +func (m *MsgRegisterAVS) GetPictureURL() string { if m != nil { - return m.PictureUrl + return m.PictureURL } return "" } @@ -172,7 +172,7 @@ type MsgUpdateAVS struct { // Sender is the address of the user deregistering the AVS Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` // ID represents the ID of the AVS to be updated - ID uint64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` + AVSID uint32 `protobuf:"varint,2,opt,name=avs_id,json=avsId,proto3" json:"avs_id,omitempty"` // Name is the new name of the AVS (optional). // If it shouldn't be changed, use [do-not-modify] instead. Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` @@ -184,7 +184,7 @@ type MsgUpdateAVS struct { Website string `protobuf:"bytes,5,opt,name=website,proto3" json:"website,omitempty" yaml:"website"` // PictureURL is the new URL of the AVS picture (optional) // If it shouldn't be changed, use [do-not-modify] instead. - PictureUrl string `protobuf:"bytes,6,opt,name=picture_url,json=pictureUrl,proto3" json:"picture_url,omitempty" yaml:"picture_url"` + PictureURL string `protobuf:"bytes,6,opt,name=picture_url,json=pictureUrl,proto3" json:"picture_url,omitempty" yaml:"picture_url"` } func (m *MsgUpdateAVS) Reset() { *m = MsgUpdateAVS{} } @@ -227,9 +227,9 @@ func (m *MsgUpdateAVS) GetSender() string { return "" } -func (m *MsgUpdateAVS) GetID() uint64 { +func (m *MsgUpdateAVS) GetAVSID() uint32 { if m != nil { - return m.ID + return m.AVSID } return 0 } @@ -255,9 +255,9 @@ func (m *MsgUpdateAVS) GetWebsite() string { return "" } -func (m *MsgUpdateAVS) GetPictureUrl() string { +func (m *MsgUpdateAVS) GetPictureURL() string { if m != nil { - return m.PictureUrl + return m.PictureURL } return "" } @@ -309,43 +309,44 @@ func init() { func init() { proto.RegisterFile("milkyway/avs/v1/messages.proto", fileDescriptor_ee6728b943d8fd23) } var fileDescriptor_ee6728b943d8fd23 = []byte{ - // 575 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x4d, 0x8f, 0xd2, 0x40, - 0x1c, 0xc6, 0x69, 0x79, 0x71, 0x77, 0x58, 0x77, 0x63, 0x83, 0x6c, 0x25, 0xda, 0x9a, 0x9a, 0xcd, - 0x1a, 0x22, 0xad, 0xe8, 0x41, 0xb3, 0x37, 0x08, 0x89, 0xe1, 0x80, 0x89, 0x25, 0xbb, 0x26, 0x5e, - 0xc8, 0x94, 0x4e, 0xea, 0x64, 0xe9, 0x4b, 0xfa, 0x2f, 0x45, 0x6e, 0xc6, 0xa3, 0x27, 0x3f, 0x0a, - 0x26, 0x1e, 0xfc, 0x02, 0x26, 0x1e, 0x37, 0x9e, 0x3c, 0x11, 0x03, 0x07, 0xee, 0x7c, 0x02, 0x43, - 0x3b, 0xd4, 0x82, 0x46, 0xdd, 0xbd, 0x10, 0x9e, 0xf9, 0x3d, 0xf3, 0xf6, 0x3c, 0x1d, 0x24, 0xd9, - 0x74, 0x70, 0x3e, 0x1e, 0xe1, 0xb1, 0x86, 0x43, 0xd0, 0xc2, 0xba, 0x66, 0x13, 0x00, 0x6c, 0x11, - 0x50, 0x3d, 0xdf, 0x0d, 0x5c, 0xe1, 0x60, 0xcd, 0x55, 0x1c, 0x82, 0x1a, 0xd6, 0x2b, 0x37, 0xb0, - 0x4d, 0x1d, 0x57, 0x8b, 0x7e, 0x63, 0x4f, 0xe5, 0x56, 0xdf, 0x05, 0xdb, 0x85, 0x5e, 0xa4, 0xb4, - 0x58, 0x30, 0x24, 0xc5, 0x4a, 0x33, 0x30, 0x10, 0x2d, 0xac, 0x1b, 0x24, 0xc0, 0x75, 0xad, 0xef, - 0x52, 0xe7, 0x37, 0xee, 0x9c, 0x27, 0x7c, 0x25, 0x18, 0x3f, 0x64, 0xdc, 0x06, 0x2b, 0x3a, 0x1c, - 0x58, 0x0c, 0x94, 0x2c, 0xd7, 0x72, 0xe3, 0x0d, 0x57, 0xff, 0xd8, 0xe8, 0xed, 0xed, 0xdb, 0x78, - 0xd8, 0xc7, 0x36, 0x3b, 0x8c, 0xf2, 0x91, 0x47, 0xfb, 0x1d, 0xb0, 0x74, 0x62, 0x51, 0x08, 0x88, - 0xdf, 0x38, 0xeb, 0x0a, 0x0f, 0x51, 0x01, 0x88, 0x63, 0x12, 0x5f, 0xe4, 0xee, 0x72, 0xf7, 0x77, - 0x9b, 0xe2, 0xb7, 0x4f, 0xb5, 0x12, 0xbb, 0x41, 0xc3, 0x34, 0x7d, 0x02, 0xd0, 0x0d, 0x7c, 0xea, - 0x58, 0x3a, 0xf3, 0x09, 0xf7, 0x50, 0xce, 0xc1, 0x36, 0x11, 0xf9, 0xc8, 0x7f, 0xb0, 0x9c, 0xca, - 0xc5, 0x31, 0xb6, 0x07, 0x27, 0xca, 0x6a, 0x54, 0xd1, 0x23, 0x28, 0x3c, 0x45, 0x45, 0x93, 0x40, - 0xdf, 0xa7, 0x5e, 0x40, 0x5d, 0x47, 0xcc, 0x46, 0xde, 0xf2, 0x72, 0x2a, 0x0b, 0xb1, 0x37, 0x05, - 0x15, 0x3d, 0x6d, 0x15, 0x1e, 0xa0, 0x6b, 0x23, 0x62, 0x00, 0x0d, 0x88, 0x98, 0x8b, 0x66, 0x09, - 0xcb, 0xa9, 0xbc, 0x1f, 0xcf, 0x62, 0x40, 0xd1, 0xd7, 0x16, 0xe1, 0x09, 0x2a, 0x7a, 0xb4, 0x1f, - 0x0c, 0x7d, 0xd2, 0x1b, 0xfa, 0x03, 0x31, 0xbf, 0xbd, 0x4f, 0x0a, 0x2a, 0x3a, 0x62, 0xea, 0xd4, - 0x1f, 0x9c, 0x1c, 0xbf, 0x5b, 0x4c, 0xaa, 0xec, 0x4a, 0xef, 0x17, 0x93, 0xea, 0x61, 0x12, 0xdc, - 0x66, 0x40, 0x4a, 0x0b, 0x95, 0x37, 0x47, 0x74, 0x02, 0x9e, 0xeb, 0x00, 0x11, 0xaa, 0x08, 0x39, - 0x64, 0xd4, 0xc3, 0x21, 0xf4, 0xa8, 0x19, 0xc5, 0x77, 0xbd, 0xb9, 0x37, 0x9b, 0xca, 0x3b, 0xcf, - 0xc9, 0xa8, 0x71, 0xd6, 0x6d, 0xb7, 0xf4, 0x1d, 0x87, 0x8c, 0x1a, 0x21, 0xb4, 0x4d, 0xe5, 0x0b, - 0x8f, 0xf6, 0x3a, 0x60, 0x9d, 0x7a, 0x26, 0x0e, 0xc8, 0xd5, 0x72, 0x2f, 0x23, 0x9e, 0x9a, 0x51, - 0xea, 0xb9, 0x66, 0x61, 0x36, 0x95, 0xf9, 0x76, 0x4b, 0xe7, 0xa9, 0x99, 0xf4, 0x91, 0xbd, 0x44, - 0x1f, 0xb9, 0x2b, 0xf5, 0x91, 0xbf, 0x74, 0x1f, 0x85, 0xff, 0xee, 0xe3, 0x68, 0xab, 0x8f, 0x9b, - 0xe9, 0x3e, 0x92, 0xd8, 0x94, 0x32, 0x2a, 0xa5, 0xf5, 0xba, 0x8b, 0x47, 0x9f, 0x39, 0x94, 0xed, - 0x80, 0x25, 0xbc, 0x44, 0xc5, 0xf4, 0xd7, 0x2d, 0xab, 0x5b, 0xaf, 0x57, 0xdd, 0xec, 0xb2, 0x72, - 0xfc, 0x0f, 0x43, 0x52, 0xf6, 0x0b, 0xb4, 0xfb, 0xab, 0xbc, 0x3b, 0x7f, 0x9a, 0x95, 0xe0, 0xca, - 0xd1, 0x5f, 0xf1, 0x7a, 0xc9, 0x4a, 0xfe, 0xed, 0x62, 0x52, 0xe5, 0x9a, 0xcf, 0xbe, 0xce, 0x24, - 0xee, 0x62, 0x26, 0x71, 0x3f, 0x66, 0x12, 0xf7, 0x61, 0x2e, 0x65, 0x2e, 0xe6, 0x52, 0xe6, 0xfb, - 0x5c, 0xca, 0xbc, 0xaa, 0x59, 0x34, 0x78, 0x3d, 0x34, 0xd4, 0xbe, 0x6b, 0x6b, 0xeb, 0x15, 0x6b, - 0x03, 0x6c, 0x40, 0xa2, 0xb4, 0x37, 0xd1, 0x3b, 0x0f, 0xc6, 0x1e, 0x01, 0xa3, 0x10, 0x3d, 0xf2, - 0xc7, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x33, 0x58, 0xed, 0x65, 0xd2, 0x04, 0x00, 0x00, + // 589 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xbf, 0x6f, 0xd3, 0x40, + 0x18, 0xad, 0xd3, 0x26, 0xb4, 0x97, 0xd2, 0x0a, 0xab, 0xa4, 0x26, 0x02, 0xbb, 0x32, 0x54, 0x45, + 0x11, 0xb1, 0x09, 0x2c, 0xa8, 0x5b, 0xa2, 0x22, 0x54, 0x89, 0x20, 0x70, 0x94, 0x22, 0xb1, 0x44, + 0xe7, 0xf8, 0x64, 0xac, 0xc6, 0x3f, 0xe4, 0xcf, 0x71, 0xc8, 0x86, 0x18, 0x99, 0xf8, 0x53, 0x32, + 0x30, 0xb0, 0xb1, 0x32, 0x56, 0x4c, 0x2c, 0x58, 0xc8, 0x19, 0xb2, 0xe7, 0x2f, 0x40, 0x39, 0x5f, + 0x5c, 0x27, 0x20, 0x50, 0xb3, 0x44, 0x79, 0xdf, 0x7b, 0xdf, 0xbd, 0xbb, 0xef, 0xf9, 0x0e, 0x89, + 0xb6, 0xd5, 0x3b, 0x1f, 0x0e, 0xf0, 0x50, 0xc5, 0x21, 0xa8, 0x61, 0x4d, 0xb5, 0x09, 0x00, 0x36, + 0x09, 0x28, 0x9e, 0xef, 0x06, 0x2e, 0xbf, 0x3b, 0xe7, 0x15, 0x1c, 0x82, 0x12, 0xd6, 0xca, 0x37, + 0xb0, 0x6d, 0x39, 0xae, 0x4a, 0x7f, 0x13, 0x4d, 0xf9, 0x56, 0xd7, 0x05, 0xdb, 0x85, 0x0e, 0x45, + 0x6a, 0x02, 0x18, 0x25, 0x26, 0x48, 0xd5, 0x31, 0x10, 0x35, 0xac, 0xe9, 0x24, 0xc0, 0x35, 0xb5, + 0xeb, 0x5a, 0xce, 0x1f, 0xbc, 0x73, 0x9e, 0xf2, 0x33, 0xc0, 0xf8, 0x7d, 0xc6, 0xdb, 0x60, 0xd2, + 0xcd, 0x81, 0xc9, 0x88, 0x3d, 0xd3, 0x35, 0xdd, 0xc4, 0x70, 0xf6, 0x8f, 0x55, 0x6f, 0x2f, 0x9f, + 0xc6, 0xc3, 0x3e, 0xb6, 0xd9, 0x66, 0xe4, 0xaf, 0x39, 0xb4, 0xd3, 0x04, 0x53, 0x23, 0xa6, 0x05, + 0x01, 0xf1, 0xeb, 0x67, 0x2d, 0xfe, 0x21, 0x2a, 0x00, 0x71, 0x0c, 0xe2, 0x0b, 0xdc, 0x01, 0x77, + 0x7f, 0xab, 0x21, 0x7c, 0xff, 0x5c, 0xdd, 0x63, 0x27, 0xa8, 0x1b, 0x86, 0x4f, 0x00, 0x5a, 0x81, + 0x6f, 0x39, 0xa6, 0xc6, 0x74, 0xfc, 0x5d, 0xb4, 0xe1, 0x60, 0x9b, 0x08, 0x39, 0xaa, 0xdf, 0x9d, + 0x46, 0x52, 0x71, 0x88, 0xed, 0xde, 0xb1, 0x3c, 0xab, 0xca, 0x1a, 0x25, 0xf9, 0x27, 0xa8, 0x68, + 0x10, 0xe8, 0xfa, 0x96, 0x17, 0x58, 0xae, 0x23, 0xac, 0x53, 0x6d, 0x69, 0x1a, 0x49, 0x7c, 0xa2, + 0xcd, 0x90, 0xb2, 0x96, 0x95, 0xf2, 0x0f, 0xd0, 0xb5, 0x01, 0xd1, 0xc1, 0x0a, 0x88, 0xb0, 0x41, + 0xbb, 0xf8, 0x69, 0x24, 0xed, 0x24, 0x5d, 0x8c, 0x90, 0xb5, 0xb9, 0x84, 0x7f, 0x8a, 0x8a, 0x9e, + 0xd5, 0x0d, 0xfa, 0x3e, 0xe9, 0xf4, 0xfd, 0x9e, 0x90, 0xa7, 0x1d, 0xf7, 0xe2, 0x48, 0x42, 0x2f, + 0x93, 0x72, 0x5b, 0x7b, 0x7e, 0xe9, 0x9a, 0x91, 0xca, 0x1a, 0x62, 0xa8, 0xed, 0xf7, 0x8e, 0x8f, + 0x3e, 0x4c, 0x46, 0x15, 0x76, 0xc0, 0x8f, 0x93, 0x51, 0x65, 0x3f, 0x1d, 0xe3, 0xe2, 0xb8, 0xe4, + 0x13, 0x54, 0x5a, 0xac, 0x68, 0x04, 0x3c, 0xd7, 0x01, 0xc2, 0x57, 0x10, 0x72, 0xc8, 0xa0, 0x83, + 0x43, 0xe8, 0x58, 0x06, 0x1d, 0xe6, 0xf5, 0xc6, 0x76, 0x1c, 0x49, 0x9b, 0x2f, 0xc8, 0xa0, 0x7e, + 0xd6, 0x3a, 0x3d, 0xd1, 0x36, 0x1d, 0x32, 0xa8, 0x87, 0x70, 0x6a, 0xc8, 0x3f, 0x73, 0x68, 0xbb, + 0x09, 0x66, 0xdb, 0x33, 0x70, 0x40, 0x56, 0x4b, 0xe1, 0x00, 0x15, 0x98, 0x55, 0x8e, 0x5a, 0x6d, + 0xc5, 0x91, 0x94, 0x4f, 0x7c, 0xf2, 0x78, 0x66, 0x92, 0xe6, 0xb4, 0x7e, 0x85, 0x9c, 0x36, 0x56, + 0xca, 0x29, 0x7f, 0xe5, 0x9c, 0x0a, 0x2b, 0xe6, 0x74, 0xb8, 0x94, 0xd3, 0xcd, 0x6c, 0x4e, 0xe9, + 0x38, 0xe5, 0x12, 0xda, 0xcb, 0xe2, 0x79, 0x46, 0x8f, 0xbe, 0x70, 0x68, 0xbd, 0x09, 0x26, 0xff, + 0x1a, 0x15, 0xb3, 0x77, 0x40, 0x52, 0x96, 0xee, 0xb8, 0xb2, 0x98, 0x71, 0xf9, 0xe8, 0x3f, 0x82, + 0xf4, 0x23, 0x78, 0x85, 0xb6, 0x2e, 0x43, 0xbd, 0xf3, 0xb7, 0xae, 0x94, 0x2e, 0x1f, 0xfe, 0x93, + 0x9e, 0x2f, 0x59, 0xce, 0xbf, 0x9f, 0x8c, 0x2a, 0x5c, 0xe3, 0xd9, 0xb7, 0x58, 0xe4, 0x2e, 0x62, + 0x91, 0xfb, 0x15, 0x8b, 0xdc, 0xa7, 0xb1, 0xb8, 0x76, 0x31, 0x16, 0xd7, 0x7e, 0x8c, 0xc5, 0xb5, + 0x37, 0x55, 0xd3, 0x0a, 0xde, 0xf6, 0x75, 0xa5, 0xeb, 0xda, 0xea, 0x7c, 0xc5, 0x6a, 0x0f, 0xeb, + 0x90, 0x22, 0xf5, 0x1d, 0x7d, 0x0d, 0x82, 0xa1, 0x47, 0x40, 0x2f, 0xd0, 0xa7, 0xe0, 0xf1, 0xef, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x3d, 0x91, 0xdb, 0x56, 0xf8, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -484,10 +485,10 @@ func (m *MsgRegisterAVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.PictureUrl) > 0 { - i -= len(m.PictureUrl) - copy(dAtA[i:], m.PictureUrl) - i = encodeVarintMessages(dAtA, i, uint64(len(m.PictureUrl))) + if len(m.PictureURL) > 0 { + i -= len(m.PictureURL) + copy(dAtA[i:], m.PictureURL) + i = encodeVarintMessages(dAtA, i, uint64(len(m.PictureURL))) i-- dAtA[i] = 0x2a } @@ -570,10 +571,10 @@ func (m *MsgUpdateAVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.PictureUrl) > 0 { - i -= len(m.PictureUrl) - copy(dAtA[i:], m.PictureUrl) - i = encodeVarintMessages(dAtA, i, uint64(len(m.PictureUrl))) + if len(m.PictureURL) > 0 { + i -= len(m.PictureURL) + copy(dAtA[i:], m.PictureURL) + i = encodeVarintMessages(dAtA, i, uint64(len(m.PictureURL))) i-- dAtA[i] = 0x32 } @@ -598,8 +599,8 @@ func (m *MsgUpdateAVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if m.ID != 0 { - i = encodeVarintMessages(dAtA, i, uint64(m.ID)) + if m.AVSID != 0 { + i = encodeVarintMessages(dAtA, i, uint64(m.AVSID)) i-- dAtA[i] = 0x10 } @@ -669,7 +670,7 @@ func (m *MsgRegisterAVS) Size() (n int) { if l > 0 { n += 1 + l + sovMessages(uint64(l)) } - l = len(m.PictureUrl) + l = len(m.PictureURL) if l > 0 { n += 1 + l + sovMessages(uint64(l)) } @@ -698,8 +699,8 @@ func (m *MsgUpdateAVS) Size() (n int) { if l > 0 { n += 1 + l + sovMessages(uint64(l)) } - if m.ID != 0 { - n += 1 + sovMessages(uint64(m.ID)) + if m.AVSID != 0 { + n += 1 + sovMessages(uint64(m.AVSID)) } l = len(m.Name) if l > 0 { @@ -713,7 +714,7 @@ func (m *MsgUpdateAVS) Size() (n int) { if l > 0 { n += 1 + l + sovMessages(uint64(l)) } - l = len(m.PictureUrl) + l = len(m.PictureURL) if l > 0 { n += 1 + l + sovMessages(uint64(l)) } @@ -894,7 +895,7 @@ func (m *MsgRegisterAVS) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PictureUrl", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PictureURL", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -922,7 +923,7 @@ func (m *MsgRegisterAVS) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.PictureUrl = string(dAtA[iNdEx:postIndex]) + m.PictureURL = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1077,9 +1078,9 @@ func (m *MsgUpdateAVS) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AVSID", wireType) } - m.ID = 0 + m.AVSID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowMessages @@ -1089,7 +1090,7 @@ func (m *MsgUpdateAVS) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ID |= uint64(b&0x7F) << shift + m.AVSID |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -1192,7 +1193,7 @@ func (m *MsgUpdateAVS) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PictureUrl", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PictureURL", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1220,7 +1221,7 @@ func (m *MsgUpdateAVS) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.PictureUrl = string(dAtA[iNdEx:postIndex]) + m.PictureURL = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex From 88d69287935f4510f0f4b5dabd1416f3722d8144 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Tue, 4 Jun 2024 09:38:19 -0500 Subject: [PATCH 18/49] feat: add msg server --- x/avs/keeper/msg_server.go | 93 ++++++++++++++++++++++++++++++++++++++ x/avs/types/events.go | 7 ++- x/avs/types/keys.go | 4 +- 3 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 x/avs/keeper/msg_server.go diff --git a/x/avs/keeper/msg_server.go b/x/avs/keeper/msg_server.go new file mode 100644 index 000000000..d1a769be4 --- /dev/null +++ b/x/avs/keeper/msg_server.go @@ -0,0 +1,93 @@ +package keeper + +import ( + "context" + "fmt" + + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/milkyway-labs/milkyway/x/avs/types" +) + +var ( + _ types.MsgServer = msgServer{} +) + +type msgServer struct { + Keeper +} + +// RegisterAVS defines the rpc method for Msg/RegisterAVS +func (k msgServer) RegisterAVS(goCtx context.Context, msg *types.MsgRegisterAVS) (*types.MsgRegisterAVSResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // Get the next reaction id + avsID, err := k.GetNextAVSID(ctx) + if err != nil { + return nil, err + } + + // Create the AVS and validate it + avs := types.NewAVS( + avsID, + types.AVS_STATUS_CREATED, + msg.Name, + msg.Description, + msg.Website, + msg.PictureURL, + msg.Sender, + ) + if err := avs.Validate(); err != nil { + return nil, errors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) + } + + // Store the AVS + k.SaveAVS(ctx, avs) + + // Update the ID for the next AVS + k.SetNextAVSID(ctx, avs.ID+1) + + // Emit the event + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeRegisteredAVS, + sdk.NewAttribute(types.AttributeKeyAVSID, fmt.Sprintf("%d", avs.ID)), + ), + }) + + return &types.MsgRegisterAVSResponse{ + NewAVSID: avs.ID, + }, nil +} + +// UpdateAVS defines the rpc method for Msg/UpdateAVS +func (k msgServer) UpdateAVS(goCtx context.Context, msg *types.MsgUpdateAVS) (*types.MsgUpdateAVSResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // Check if the AVS exists + avs, found := k.GetAVS(ctx, msg.AVSID) + if !found { + return nil, errors.Wrapf(sdkerrors.ErrInvalidRequest, "avs with id %d not found", msg.AVSID) + } + + // Update the AVS and validate it + updated := avs.Update(types.NewAVSUpdate(msg.Name, msg.Description, msg.Website, msg.PictureURL)) + if err := updated.Validate(); err != nil { + return nil, errors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) + } + + // Save the AVS + k.SaveAVS(ctx, updated) + + // Emit the event + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeUpdatedAVS, + sdk.NewAttribute(types.AttributeKeyAVSID, fmt.Sprintf("%d", msg.AVSID)), + ), + }) + + return &types.MsgUpdateAVSResponse{}, nil +} diff --git a/x/avs/types/events.go b/x/avs/types/events.go index 862b5bac3..37a65c9ed 100644 --- a/x/avs/types/events.go +++ b/x/avs/types/events.go @@ -3,9 +3,8 @@ package types // DONTCOVER const ( - EventTypeRegisterAVS = "registered_avs" - EventTypeDeregisteredAVS = "deregistered_avs" + EventTypeRegisteredAVS = "registered_avs" + EventTypeUpdatedAVS = "updated_avs" - AttributeKeyAVSID = "avs_id" - AttributeKeySender = "sender" + AttributeKeyAVSID = "avs_id" ) diff --git a/x/avs/types/keys.go b/x/avs/types/keys.go index 3f956f645..f00fa6d4a 100644 --- a/x/avs/types/keys.go +++ b/x/avs/types/keys.go @@ -14,7 +14,9 @@ const ( ) var ( - AVSPrefix = []byte{0x02} + AVSPrefix = []byte{0x01} + + ParamsKey = []byte{0x10} ) // NextAVSIDKey returns the key for the next AVS ID From 185f8edf1526ead188b2f5c528b4a7e63e726209 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Tue, 4 Jun 2024 09:38:27 -0500 Subject: [PATCH 19/49] feat: add genesis import/export --- x/avs/keeper/alias_functions.go | 24 ++++++++++++++++ x/avs/keeper/genesis.go | 51 +++++++++++++++++++++++++++++++++ x/avs/keeper/params.go | 25 ++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 x/avs/keeper/alias_functions.go create mode 100644 x/avs/keeper/genesis.go create mode 100644 x/avs/keeper/params.go diff --git a/x/avs/keeper/alias_functions.go b/x/avs/keeper/alias_functions.go new file mode 100644 index 000000000..72909fcf6 --- /dev/null +++ b/x/avs/keeper/alias_functions.go @@ -0,0 +1,24 @@ +package keeper + +import ( + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/milkyway-labs/milkyway/x/avs/types" +) + +// IterateServices iterates over the services in the store and performs a callback function +func (k *Keeper) IterateServices(ctx sdk.Context, cb func(service types.AVS) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iterator := storetypes.KVStorePrefixIterator(store, types.AVSPrefix) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var service types.AVS + k.cdc.MustUnmarshal(iterator.Value(), &service) + + if cb(service) { + break + } + } +} diff --git a/x/avs/keeper/genesis.go b/x/avs/keeper/genesis.go new file mode 100644 index 000000000..e5be1d95f --- /dev/null +++ b/x/avs/keeper/genesis.go @@ -0,0 +1,51 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/milkyway-labs/milkyway/x/avs/types" +) + +// ExportGenesis returns the GenesisState associated with the given context +func (k *Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + return types.NewGenesisState( + k.exportNextAVSID(ctx), + k.exportServices(ctx), + k.GetParams(ctx), + ) +} + +// exportNextAVSID returns the next AVS ID stored in the KVStore +func (k *Keeper) exportNextAVSID(ctx sdk.Context) uint32 { + nextAVSID, err := k.GetNextAVSID(ctx) + if err != nil { + panic(err) + } + return nextAVSID +} + +// exportServices returns the services stored in the KVStore +func (k *Keeper) exportServices(ctx sdk.Context) []types.AVS { + var services []types.AVS + k.IterateServices(ctx, func(service types.AVS) (stop bool) { + services = append(services, service) + return false + }) + return services +} + +// -------------------------------------------------------------------------------------------------------------------- + +// InitGenesis initializes the state from a GenesisState +func (k *Keeper) InitGenesis(ctx sdk.Context, state *types.GenesisState) { + // Set the next AVS ID + k.SetNextAVSID(ctx, state.NextAVSID) + + // Store the services + for _, service := range state.Services { + k.SaveAVS(ctx, service) + } + + // Store params + k.SetParams(ctx, state.Params) +} diff --git a/x/avs/keeper/params.go b/x/avs/keeper/params.go new file mode 100644 index 000000000..d9915bc60 --- /dev/null +++ b/x/avs/keeper/params.go @@ -0,0 +1,25 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/milkyway-labs/milkyway/x/avs/types" +) + +// SetParams sets module parameters +func (k *Keeper) SetParams(ctx sdk.Context, params types.Params) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(¶ms) + store.Set(types.ParamsKey, bz) +} + +// GetParams returns the module parameters +func (k *Keeper) GetParams(ctx sdk.Context) (p types.Params) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ParamsKey) + if bz == nil { + return p + } + k.cdc.MustUnmarshal(bz, &p) + return p +} From 9c972cfb8649ab6de4a76036f4ea06b3d3067e92 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Tue, 4 Jun 2024 09:58:12 -0500 Subject: [PATCH 20/49] feat: add gRPC query --- proto/milkyway/avs/v1/genesis.proto | 2 +- proto/milkyway/avs/v1/messages.proto | 38 +-- x/avs/keeper/grpc_query.go | 65 +++++ x/avs/keeper/msg_server.go | 26 +- x/avs/types/codec.go | 8 +- x/avs/types/events.go | 6 +- x/avs/types/messages.go | 20 +- x/avs/types/messages.pb.go | 386 +++++++++++++-------------- 8 files changed, 308 insertions(+), 243 deletions(-) create mode 100644 x/avs/keeper/grpc_query.go diff --git a/proto/milkyway/avs/v1/genesis.proto b/proto/milkyway/avs/v1/genesis.proto index bcb7d81e3..da82869cb 100644 --- a/proto/milkyway/avs/v1/genesis.proto +++ b/proto/milkyway/avs/v1/genesis.proto @@ -20,5 +20,5 @@ message GenesisState { // NextAVSId defines the ID that will be assigned to the next AVS that gets // created. - uint32 next_avs_id = 3 [(gogoproto.customname) = "NextAVSID"]; + uint32 next_avs_id = 3 [ (gogoproto.customname) = "NextAVSID" ]; } \ No newline at end of file diff --git a/proto/milkyway/avs/v1/messages.proto b/proto/milkyway/avs/v1/messages.proto index 025a4ba82..444ddd4c0 100644 --- a/proto/milkyway/avs/v1/messages.proto +++ b/proto/milkyway/avs/v1/messages.proto @@ -15,17 +15,17 @@ option go_package = "github.com/milkyway-labs/milkyway/x/avs/types"; service Msg { option (cosmos.msg.v1.service) = true; - rpc RegisterAVS(MsgRegisterAVS) returns (MsgRegisterAVSResponse); - rpc UpdateAVS(MsgUpdateAVS) returns (MsgUpdateAVSResponse); + rpc RegisterService(MsgRegisterService) returns (MsgRegisterServiceResponse); + rpc UpdateService(MsgUpdateService) returns (MsgUpdateServiceResponse); } -// MsgRegisterAVSResponse defines the message structure for the RegisterAVS -// gRPC service method. It allows an account to register a new AVS that later on -// operators can opt to validate. It requires a sender address as well as the -// details of the AVS to be register. -message MsgRegisterAVS { +// MsgRegisterServiceResponse defines the message structure for the +// RegisterService gRPC service method. It allows an account to register a new +// AVS that later on operators can opt to validate. It requires a sender address +// as well as the details of the AVS to be register. +message MsgRegisterService { option (cosmos.msg.v1.signer) = "sender"; - option (amino.name) = "milkyway/MsgRegisterAVS"; + option (amino.name) = "milkyway/MsgRegisterService"; // Sender is the address of the user registering the AVS string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; @@ -46,25 +46,25 @@ message MsgRegisterAVS { ]; } -// MsgRegisterAVSResponse is the return value of MsgRegisterAVS. +// MsgRegisterServiceResponse is the return value of MsgRegisterService. // It returns the newly created AVS ID. -message MsgRegisterAVSResponse { - // NewAVSID is the ID of the newly registered AVS - uint32 new_avs_id = 1 [ (gogoproto.customname) = "NewAVSID" ]; +message MsgRegisterServiceResponse { + // NewServiceID is the ID of the newly registered AVS + uint32 new_service_id = 1 [ (gogoproto.customname) = "NewServiceID" ]; } -// MsgUpdateAVS defines the message structure for the UpdateAVS gRPC +// MsgUpdateService defines the message structure for the UpdateService gRPC // service method. It allows the AVS owner to update the details of // an existing AVS. -message MsgUpdateAVS { +message MsgUpdateService { option (cosmos.msg.v1.signer) = "sender"; - option (amino.name) = "milkyway/MsgUpdateAVS"; + option (amino.name) = "milkyway/MsgUpdateService"; - // Sender is the address of the user deregistering the AVS + // Sender is the address of the user updating the AVS string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // ID represents the ID of the AVS to be updated - uint32 avs_id = 2 [ (gogoproto.customname) = "AVSID" ]; + uint32 service_id = 2 [ (gogoproto.customname) = "ServiceID" ]; // Name is the new name of the AVS (optional). // If it shouldn't be changed, use [do-not-modify] instead. @@ -86,5 +86,5 @@ message MsgUpdateAVS { ]; } -// MsgUpdateAVSResponse is the return value of MsgUpdateAVS. -message MsgUpdateAVSResponse {} \ No newline at end of file +// MsgUpdateServiceResponse is the return value of MsgUpdateService. +message MsgUpdateServiceResponse {} \ No newline at end of file diff --git a/x/avs/keeper/grpc_query.go b/x/avs/keeper/grpc_query.go new file mode 100644 index 000000000..992d4983f --- /dev/null +++ b/x/avs/keeper/grpc_query.go @@ -0,0 +1,65 @@ +package keeper + +import ( + "context" + + "cosmossdk.io/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/milkyway-labs/milkyway/x/avs/types" +) + +var _ types.QueryServer = &Keeper{} + +// Services implements the Query/Services gRPC method +func (k *Keeper) Services(ctx context.Context, request *types.QueryServicesRequest) (*types.QueryServicesResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + store := sdkCtx.KVStore(k.storeKey) + servicesStore := prefix.NewStore(store, types.AVSPrefix) + + var services []types.AVS + pageRes, err := query.Paginate(servicesStore, request.Pagination, func(key []byte, value []byte) error { + var service types.AVS + if err := k.cdc.Unmarshal(value, &service); err != nil { + return status.Error(codes.Internal, err.Error()) + } + + services = append(services, service) + return nil + }) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryServicesResponse{ + Services: services, + Pagination: pageRes, + }, nil +} + +// Service implements the Query/Service gRPC method +func (k *Keeper) Service(ctx context.Context, request *types.QueryServiceRequest) (*types.QueryServiceResponse, error) { + if request.ServiceId == 0 { + return nil, status.Error(codes.InvalidArgument, "invalid service ID") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + service, found := k.GetAVS(sdkCtx, request.ServiceId) + if !found { + return nil, status.Error(codes.NotFound, "service not found") + } + + return &types.QueryServiceResponse{Service: service}, nil +} + +// Params implements the Query/Params gRPC method +func (k *Keeper) Params(ctx context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + params := k.GetParams(sdkCtx) + return &types.QueryParamsResponse{Params: params}, nil +} diff --git a/x/avs/keeper/msg_server.go b/x/avs/keeper/msg_server.go index d1a769be4..df9f8e382 100644 --- a/x/avs/keeper/msg_server.go +++ b/x/avs/keeper/msg_server.go @@ -19,8 +19,8 @@ type msgServer struct { Keeper } -// RegisterAVS defines the rpc method for Msg/RegisterAVS -func (k msgServer) RegisterAVS(goCtx context.Context, msg *types.MsgRegisterAVS) (*types.MsgRegisterAVSResponse, error) { +// RegisterService defines the rpc method for Msg/RegisterService +func (k msgServer) RegisterService(goCtx context.Context, msg *types.MsgRegisterService) (*types.MsgRegisterServiceResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // Get the next reaction id @@ -52,24 +52,24 @@ func (k msgServer) RegisterAVS(goCtx context.Context, msg *types.MsgRegisterAVS) // Emit the event ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeRegisteredAVS, - sdk.NewAttribute(types.AttributeKeyAVSID, fmt.Sprintf("%d", avs.ID)), + types.EventTypeRegisteredService, + sdk.NewAttribute(types.AttributeKeyServiceID, fmt.Sprintf("%d", avs.ID)), ), }) - return &types.MsgRegisterAVSResponse{ - NewAVSID: avs.ID, + return &types.MsgRegisterServiceResponse{ + NewServiceID: avs.ID, }, nil } -// UpdateAVS defines the rpc method for Msg/UpdateAVS -func (k msgServer) UpdateAVS(goCtx context.Context, msg *types.MsgUpdateAVS) (*types.MsgUpdateAVSResponse, error) { +// UpdateService defines the rpc method for Msg/UpdateService +func (k msgServer) UpdateService(goCtx context.Context, msg *types.MsgUpdateService) (*types.MsgUpdateServiceResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // Check if the AVS exists - avs, found := k.GetAVS(ctx, msg.AVSID) + avs, found := k.GetAVS(ctx, msg.ServiceID) if !found { - return nil, errors.Wrapf(sdkerrors.ErrInvalidRequest, "avs with id %d not found", msg.AVSID) + return nil, errors.Wrapf(sdkerrors.ErrInvalidRequest, "avs with id %d not found", msg.ServiceID) } // Update the AVS and validate it @@ -84,10 +84,10 @@ func (k msgServer) UpdateAVS(goCtx context.Context, msg *types.MsgUpdateAVS) (*t // Emit the event ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeUpdatedAVS, - sdk.NewAttribute(types.AttributeKeyAVSID, fmt.Sprintf("%d", msg.AVSID)), + types.EventTypeUpdatedService, + sdk.NewAttribute(types.AttributeKeyServiceID, fmt.Sprintf("%d", msg.ServiceID)), ), }) - return &types.MsgUpdateAVSResponse{}, nil + return &types.MsgUpdateServiceResponse{}, nil } diff --git a/x/avs/types/codec.go b/x/avs/types/codec.go index 721286221..9297f8e7b 100644 --- a/x/avs/types/codec.go +++ b/x/avs/types/codec.go @@ -10,14 +10,14 @@ import ( ) func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - legacy.RegisterAminoMsg(cdc, &MsgRegisterAVS{}, "milkyway/MsgRegisterAVS") - legacy.RegisterAminoMsg(cdc, &MsgUpdateAVS{}, "milkyway/MsgUpdateAVS") + legacy.RegisterAminoMsg(cdc, &MsgRegisterService{}, "milkyway/MsgRegisterService") + legacy.RegisterAminoMsg(cdc, &MsgUpdateService{}, "milkyway/MsgUpdateService") } func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), - &MsgRegisterAVS{}, - &MsgUpdateAVS{}, + &MsgRegisterService{}, + &MsgUpdateService{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/avs/types/events.go b/x/avs/types/events.go index 37a65c9ed..b048ee8a8 100644 --- a/x/avs/types/events.go +++ b/x/avs/types/events.go @@ -3,8 +3,8 @@ package types // DONTCOVER const ( - EventTypeRegisteredAVS = "registered_avs" - EventTypeUpdatedAVS = "updated_avs" + EventTypeRegisteredService = "registered_service" + EventTypeUpdatedService = "updated_service" - AttributeKeyAVSID = "avs_id" + AttributeKeyServiceID = "avs_id" ) diff --git a/x/avs/types/messages.go b/x/avs/types/messages.go index 14a77376a..e0e9986ea 100644 --- a/x/avs/types/messages.go +++ b/x/avs/types/messages.go @@ -9,12 +9,12 @@ import ( ) var ( - _ sdk.Msg = &MsgRegisterAVS{} - _ sdk.Msg = &MsgUpdateAVS{} + _ sdk.Msg = &MsgRegisterService{} + _ sdk.Msg = &MsgUpdateService{} ) // ValidateBasic implements sdk.Msg -func (msg *MsgRegisterAVS) ValidateBasic() error { +func (msg *MsgRegisterService) ValidateBasic() error { if strings.TrimSpace(msg.Name) == "" || msg.Name == DoNotModify { return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid name: %s", msg.Name) } @@ -40,12 +40,12 @@ func (msg *MsgRegisterAVS) ValidateBasic() error { } // GetSignBytes implements sdk.Msg -func (msg *MsgRegisterAVS) GetSignBytes() []byte { +func (msg *MsgRegisterService) GetSignBytes() []byte { return AminoCdc.MustMarshalJSON(msg) } // GetSigners implements sdk.Msg -func (msg *MsgRegisterAVS) GetSigners() []sdk.AccAddress { +func (msg *MsgRegisterService) GetSigners() []sdk.AccAddress { addr, _ := sdk.AccAddressFromBech32(msg.Sender) return []sdk.AccAddress{addr} } @@ -53,9 +53,9 @@ func (msg *MsgRegisterAVS) GetSigners() []sdk.AccAddress { // -------------------------------------------------------------------------------------------------------------------- // ValidateBasic implements sdk.Msg -func (msg *MsgUpdateAVS) ValidateBasic() error { - if msg.AVSID == 0 { - return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid avs id: %d", msg.AVSID) +func (msg *MsgUpdateService) ValidateBasic() error { + if msg.ServiceID == 0 { + return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid service id: %d", msg.ServiceID) } _, err := sdk.AccAddressFromBech32(msg.Sender) @@ -67,12 +67,12 @@ func (msg *MsgUpdateAVS) ValidateBasic() error { } // GetSignBytes implements sdk.Msg -func (msg *MsgUpdateAVS) GetSignBytes() []byte { +func (msg *MsgUpdateService) GetSignBytes() []byte { return AminoCdc.MustMarshalJSON(msg) } // GetSigners implements sdk.Msg -func (msg *MsgUpdateAVS) GetSigners() []sdk.AccAddress { +func (msg *MsgUpdateService) GetSigners() []sdk.AccAddress { addr, _ := sdk.AccAddressFromBech32(msg.Sender) return []sdk.AccAddress{addr} } diff --git a/x/avs/types/messages.pb.go b/x/avs/types/messages.pb.go index 0bc254fc6..fa5eca119 100644 --- a/x/avs/types/messages.pb.go +++ b/x/avs/types/messages.pb.go @@ -33,11 +33,11 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgRegisterAVSResponse defines the message structure for the RegisterAVS -// gRPC service method. It allows an account to register a new AVS that later on -// operators can opt to validate. It requires a sender address as well as the -// details of the AVS to be register. -type MsgRegisterAVS struct { +// MsgRegisterServiceResponse defines the message structure for the +// RegisterService gRPC service method. It allows an account to register a new +// AVS that later on operators can opt to validate. It requires a sender address +// as well as the details of the AVS to be register. +type MsgRegisterService struct { // Sender is the address of the user registering the AVS Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` // Name is the name of the AVS @@ -50,18 +50,18 @@ type MsgRegisterAVS struct { PictureURL string `protobuf:"bytes,5,opt,name=picture_url,json=pictureUrl,proto3" json:"picture_url,omitempty" yaml:"picture_url"` } -func (m *MsgRegisterAVS) Reset() { *m = MsgRegisterAVS{} } -func (m *MsgRegisterAVS) String() string { return proto.CompactTextString(m) } -func (*MsgRegisterAVS) ProtoMessage() {} -func (*MsgRegisterAVS) Descriptor() ([]byte, []int) { +func (m *MsgRegisterService) Reset() { *m = MsgRegisterService{} } +func (m *MsgRegisterService) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterService) ProtoMessage() {} +func (*MsgRegisterService) Descriptor() ([]byte, []int) { return fileDescriptor_ee6728b943d8fd23, []int{0} } -func (m *MsgRegisterAVS) XXX_Unmarshal(b []byte) error { +func (m *MsgRegisterService) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgRegisterAVS) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgRegisterService) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgRegisterAVS.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgRegisterService.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -71,72 +71,72 @@ func (m *MsgRegisterAVS) XXX_Marshal(b []byte, deterministic bool) ([]byte, erro return b[:n], nil } } -func (m *MsgRegisterAVS) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRegisterAVS.Merge(m, src) +func (m *MsgRegisterService) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterService.Merge(m, src) } -func (m *MsgRegisterAVS) XXX_Size() int { +func (m *MsgRegisterService) XXX_Size() int { return m.Size() } -func (m *MsgRegisterAVS) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRegisterAVS.DiscardUnknown(m) +func (m *MsgRegisterService) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterService.DiscardUnknown(m) } -var xxx_messageInfo_MsgRegisterAVS proto.InternalMessageInfo +var xxx_messageInfo_MsgRegisterService proto.InternalMessageInfo -func (m *MsgRegisterAVS) GetSender() string { +func (m *MsgRegisterService) GetSender() string { if m != nil { return m.Sender } return "" } -func (m *MsgRegisterAVS) GetName() string { +func (m *MsgRegisterService) GetName() string { if m != nil { return m.Name } return "" } -func (m *MsgRegisterAVS) GetDescription() string { +func (m *MsgRegisterService) GetDescription() string { if m != nil { return m.Description } return "" } -func (m *MsgRegisterAVS) GetWebsite() string { +func (m *MsgRegisterService) GetWebsite() string { if m != nil { return m.Website } return "" } -func (m *MsgRegisterAVS) GetPictureURL() string { +func (m *MsgRegisterService) GetPictureURL() string { if m != nil { return m.PictureURL } return "" } -// MsgRegisterAVSResponse is the return value of MsgRegisterAVS. +// MsgRegisterServiceResponse is the return value of MsgRegisterService. // It returns the newly created AVS ID. -type MsgRegisterAVSResponse struct { - // NewAVSID is the ID of the newly registered AVS - NewAVSID uint32 `protobuf:"varint,1,opt,name=new_avs_id,json=newAvsId,proto3" json:"new_avs_id,omitempty"` +type MsgRegisterServiceResponse struct { + // NewServiceID is the ID of the newly registered AVS + NewServiceID uint32 `protobuf:"varint,1,opt,name=new_service_id,json=newServiceId,proto3" json:"new_service_id,omitempty"` } -func (m *MsgRegisterAVSResponse) Reset() { *m = MsgRegisterAVSResponse{} } -func (m *MsgRegisterAVSResponse) String() string { return proto.CompactTextString(m) } -func (*MsgRegisterAVSResponse) ProtoMessage() {} -func (*MsgRegisterAVSResponse) Descriptor() ([]byte, []int) { +func (m *MsgRegisterServiceResponse) Reset() { *m = MsgRegisterServiceResponse{} } +func (m *MsgRegisterServiceResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterServiceResponse) ProtoMessage() {} +func (*MsgRegisterServiceResponse) Descriptor() ([]byte, []int) { return fileDescriptor_ee6728b943d8fd23, []int{1} } -func (m *MsgRegisterAVSResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgRegisterServiceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgRegisterAVSResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgRegisterServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgRegisterAVSResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgRegisterServiceResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -146,33 +146,33 @@ func (m *MsgRegisterAVSResponse) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } -func (m *MsgRegisterAVSResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRegisterAVSResponse.Merge(m, src) +func (m *MsgRegisterServiceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterServiceResponse.Merge(m, src) } -func (m *MsgRegisterAVSResponse) XXX_Size() int { +func (m *MsgRegisterServiceResponse) XXX_Size() int { return m.Size() } -func (m *MsgRegisterAVSResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRegisterAVSResponse.DiscardUnknown(m) +func (m *MsgRegisterServiceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterServiceResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgRegisterAVSResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgRegisterServiceResponse proto.InternalMessageInfo -func (m *MsgRegisterAVSResponse) GetNewAVSID() uint32 { +func (m *MsgRegisterServiceResponse) GetNewServiceID() uint32 { if m != nil { - return m.NewAVSID + return m.NewServiceID } return 0 } -// MsgUpdateAVS defines the message structure for the UpdateAVS gRPC +// MsgUpdateService defines the message structure for the UpdateService gRPC // service method. It allows the AVS owner to update the details of // an existing AVS. -type MsgUpdateAVS struct { - // Sender is the address of the user deregistering the AVS +type MsgUpdateService struct { + // Sender is the address of the user updating the AVS Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` // ID represents the ID of the AVS to be updated - AVSID uint32 `protobuf:"varint,2,opt,name=avs_id,json=avsId,proto3" json:"avs_id,omitempty"` + ServiceID uint32 `protobuf:"varint,2,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` // Name is the new name of the AVS (optional). // If it shouldn't be changed, use [do-not-modify] instead. Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` @@ -187,18 +187,18 @@ type MsgUpdateAVS struct { PictureURL string `protobuf:"bytes,6,opt,name=picture_url,json=pictureUrl,proto3" json:"picture_url,omitempty" yaml:"picture_url"` } -func (m *MsgUpdateAVS) Reset() { *m = MsgUpdateAVS{} } -func (m *MsgUpdateAVS) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateAVS) ProtoMessage() {} -func (*MsgUpdateAVS) Descriptor() ([]byte, []int) { +func (m *MsgUpdateService) Reset() { *m = MsgUpdateService{} } +func (m *MsgUpdateService) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateService) ProtoMessage() {} +func (*MsgUpdateService) Descriptor() ([]byte, []int) { return fileDescriptor_ee6728b943d8fd23, []int{2} } -func (m *MsgUpdateAVS) XXX_Unmarshal(b []byte) error { +func (m *MsgUpdateService) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgUpdateAVS) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgUpdateService) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgUpdateAVS.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgUpdateService.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -208,76 +208,76 @@ func (m *MsgUpdateAVS) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (m *MsgUpdateAVS) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateAVS.Merge(m, src) +func (m *MsgUpdateService) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateService.Merge(m, src) } -func (m *MsgUpdateAVS) XXX_Size() int { +func (m *MsgUpdateService) XXX_Size() int { return m.Size() } -func (m *MsgUpdateAVS) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateAVS.DiscardUnknown(m) +func (m *MsgUpdateService) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateService.DiscardUnknown(m) } -var xxx_messageInfo_MsgUpdateAVS proto.InternalMessageInfo +var xxx_messageInfo_MsgUpdateService proto.InternalMessageInfo -func (m *MsgUpdateAVS) GetSender() string { +func (m *MsgUpdateService) GetSender() string { if m != nil { return m.Sender } return "" } -func (m *MsgUpdateAVS) GetAVSID() uint32 { +func (m *MsgUpdateService) GetServiceID() uint32 { if m != nil { - return m.AVSID + return m.ServiceID } return 0 } -func (m *MsgUpdateAVS) GetName() string { +func (m *MsgUpdateService) GetName() string { if m != nil { return m.Name } return "" } -func (m *MsgUpdateAVS) GetDescription() string { +func (m *MsgUpdateService) GetDescription() string { if m != nil { return m.Description } return "" } -func (m *MsgUpdateAVS) GetWebsite() string { +func (m *MsgUpdateService) GetWebsite() string { if m != nil { return m.Website } return "" } -func (m *MsgUpdateAVS) GetPictureURL() string { +func (m *MsgUpdateService) GetPictureURL() string { if m != nil { return m.PictureURL } return "" } -// MsgUpdateAVSResponse is the return value of MsgUpdateAVS. -type MsgUpdateAVSResponse struct { +// MsgUpdateServiceResponse is the return value of MsgUpdateService. +type MsgUpdateServiceResponse struct { } -func (m *MsgUpdateAVSResponse) Reset() { *m = MsgUpdateAVSResponse{} } -func (m *MsgUpdateAVSResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateAVSResponse) ProtoMessage() {} -func (*MsgUpdateAVSResponse) Descriptor() ([]byte, []int) { +func (m *MsgUpdateServiceResponse) Reset() { *m = MsgUpdateServiceResponse{} } +func (m *MsgUpdateServiceResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateServiceResponse) ProtoMessage() {} +func (*MsgUpdateServiceResponse) Descriptor() ([]byte, []int) { return fileDescriptor_ee6728b943d8fd23, []int{3} } -func (m *MsgUpdateAVSResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgUpdateServiceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgUpdateAVSResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgUpdateServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgUpdateAVSResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgUpdateServiceResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -287,66 +287,66 @@ func (m *MsgUpdateAVSResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte return b[:n], nil } } -func (m *MsgUpdateAVSResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateAVSResponse.Merge(m, src) +func (m *MsgUpdateServiceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateServiceResponse.Merge(m, src) } -func (m *MsgUpdateAVSResponse) XXX_Size() int { +func (m *MsgUpdateServiceResponse) XXX_Size() int { return m.Size() } -func (m *MsgUpdateAVSResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateAVSResponse.DiscardUnknown(m) +func (m *MsgUpdateServiceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateServiceResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgUpdateAVSResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgUpdateServiceResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgRegisterAVS)(nil), "milkyway.avs.v1.MsgRegisterAVS") - proto.RegisterType((*MsgRegisterAVSResponse)(nil), "milkyway.avs.v1.MsgRegisterAVSResponse") - proto.RegisterType((*MsgUpdateAVS)(nil), "milkyway.avs.v1.MsgUpdateAVS") - proto.RegisterType((*MsgUpdateAVSResponse)(nil), "milkyway.avs.v1.MsgUpdateAVSResponse") + proto.RegisterType((*MsgRegisterService)(nil), "milkyway.avs.v1.MsgRegisterService") + proto.RegisterType((*MsgRegisterServiceResponse)(nil), "milkyway.avs.v1.MsgRegisterServiceResponse") + proto.RegisterType((*MsgUpdateService)(nil), "milkyway.avs.v1.MsgUpdateService") + proto.RegisterType((*MsgUpdateServiceResponse)(nil), "milkyway.avs.v1.MsgUpdateServiceResponse") } func init() { proto.RegisterFile("milkyway/avs/v1/messages.proto", fileDescriptor_ee6728b943d8fd23) } var fileDescriptor_ee6728b943d8fd23 = []byte{ - // 589 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xbf, 0x6f, 0xd3, 0x40, - 0x18, 0xad, 0xd3, 0x26, 0xb4, 0x97, 0xd2, 0x0a, 0xab, 0xa4, 0x26, 0x02, 0xbb, 0x32, 0x54, 0x45, - 0x11, 0xb1, 0x09, 0x2c, 0xa8, 0x5b, 0xa2, 0x22, 0x54, 0x89, 0x20, 0x70, 0x94, 0x22, 0xb1, 0x44, - 0xe7, 0xf8, 0x64, 0xac, 0xc6, 0x3f, 0xe4, 0xcf, 0x71, 0xc8, 0x86, 0x18, 0x99, 0xf8, 0x53, 0x32, - 0x30, 0xb0, 0xb1, 0x32, 0x56, 0x4c, 0x2c, 0x58, 0xc8, 0x19, 0xb2, 0xe7, 0x2f, 0x40, 0x39, 0x5f, - 0x5c, 0x27, 0x20, 0x50, 0xb3, 0x44, 0x79, 0xdf, 0x7b, 0xdf, 0xbd, 0xbb, 0xef, 0xf9, 0x0e, 0x89, - 0xb6, 0xd5, 0x3b, 0x1f, 0x0e, 0xf0, 0x50, 0xc5, 0x21, 0xa8, 0x61, 0x4d, 0xb5, 0x09, 0x00, 0x36, - 0x09, 0x28, 0x9e, 0xef, 0x06, 0x2e, 0xbf, 0x3b, 0xe7, 0x15, 0x1c, 0x82, 0x12, 0xd6, 0xca, 0x37, - 0xb0, 0x6d, 0x39, 0xae, 0x4a, 0x7f, 0x13, 0x4d, 0xf9, 0x56, 0xd7, 0x05, 0xdb, 0x85, 0x0e, 0x45, - 0x6a, 0x02, 0x18, 0x25, 0x26, 0x48, 0xd5, 0x31, 0x10, 0x35, 0xac, 0xe9, 0x24, 0xc0, 0x35, 0xb5, - 0xeb, 0x5a, 0xce, 0x1f, 0xbc, 0x73, 0x9e, 0xf2, 0x33, 0xc0, 0xf8, 0x7d, 0xc6, 0xdb, 0x60, 0xd2, - 0xcd, 0x81, 0xc9, 0x88, 0x3d, 0xd3, 0x35, 0xdd, 0xc4, 0x70, 0xf6, 0x8f, 0x55, 0x6f, 0x2f, 0x9f, - 0xc6, 0xc3, 0x3e, 0xb6, 0xd9, 0x66, 0xe4, 0xaf, 0x39, 0xb4, 0xd3, 0x04, 0x53, 0x23, 0xa6, 0x05, - 0x01, 0xf1, 0xeb, 0x67, 0x2d, 0xfe, 0x21, 0x2a, 0x00, 0x71, 0x0c, 0xe2, 0x0b, 0xdc, 0x01, 0x77, - 0x7f, 0xab, 0x21, 0x7c, 0xff, 0x5c, 0xdd, 0x63, 0x27, 0xa8, 0x1b, 0x86, 0x4f, 0x00, 0x5a, 0x81, - 0x6f, 0x39, 0xa6, 0xc6, 0x74, 0xfc, 0x5d, 0xb4, 0xe1, 0x60, 0x9b, 0x08, 0x39, 0xaa, 0xdf, 0x9d, - 0x46, 0x52, 0x71, 0x88, 0xed, 0xde, 0xb1, 0x3c, 0xab, 0xca, 0x1a, 0x25, 0xf9, 0x27, 0xa8, 0x68, - 0x10, 0xe8, 0xfa, 0x96, 0x17, 0x58, 0xae, 0x23, 0xac, 0x53, 0x6d, 0x69, 0x1a, 0x49, 0x7c, 0xa2, - 0xcd, 0x90, 0xb2, 0x96, 0x95, 0xf2, 0x0f, 0xd0, 0xb5, 0x01, 0xd1, 0xc1, 0x0a, 0x88, 0xb0, 0x41, - 0xbb, 0xf8, 0x69, 0x24, 0xed, 0x24, 0x5d, 0x8c, 0x90, 0xb5, 0xb9, 0x84, 0x7f, 0x8a, 0x8a, 0x9e, - 0xd5, 0x0d, 0xfa, 0x3e, 0xe9, 0xf4, 0xfd, 0x9e, 0x90, 0xa7, 0x1d, 0xf7, 0xe2, 0x48, 0x42, 0x2f, - 0x93, 0x72, 0x5b, 0x7b, 0x7e, 0xe9, 0x9a, 0x91, 0xca, 0x1a, 0x62, 0xa8, 0xed, 0xf7, 0x8e, 0x8f, - 0x3e, 0x4c, 0x46, 0x15, 0x76, 0xc0, 0x8f, 0x93, 0x51, 0x65, 0x3f, 0x1d, 0xe3, 0xe2, 0xb8, 0xe4, - 0x13, 0x54, 0x5a, 0xac, 0x68, 0x04, 0x3c, 0xd7, 0x01, 0xc2, 0x57, 0x10, 0x72, 0xc8, 0xa0, 0x83, - 0x43, 0xe8, 0x58, 0x06, 0x1d, 0xe6, 0xf5, 0xc6, 0x76, 0x1c, 0x49, 0x9b, 0x2f, 0xc8, 0xa0, 0x7e, - 0xd6, 0x3a, 0x3d, 0xd1, 0x36, 0x1d, 0x32, 0xa8, 0x87, 0x70, 0x6a, 0xc8, 0x3f, 0x73, 0x68, 0xbb, - 0x09, 0x66, 0xdb, 0x33, 0x70, 0x40, 0x56, 0x4b, 0xe1, 0x00, 0x15, 0x98, 0x55, 0x8e, 0x5a, 0x6d, - 0xc5, 0x91, 0x94, 0x4f, 0x7c, 0xf2, 0x78, 0x66, 0x92, 0xe6, 0xb4, 0x7e, 0x85, 0x9c, 0x36, 0x56, - 0xca, 0x29, 0x7f, 0xe5, 0x9c, 0x0a, 0x2b, 0xe6, 0x74, 0xb8, 0x94, 0xd3, 0xcd, 0x6c, 0x4e, 0xe9, - 0x38, 0xe5, 0x12, 0xda, 0xcb, 0xe2, 0x79, 0x46, 0x8f, 0xbe, 0x70, 0x68, 0xbd, 0x09, 0x26, 0xff, - 0x1a, 0x15, 0xb3, 0x77, 0x40, 0x52, 0x96, 0xee, 0xb8, 0xb2, 0x98, 0x71, 0xf9, 0xe8, 0x3f, 0x82, - 0xf4, 0x23, 0x78, 0x85, 0xb6, 0x2e, 0x43, 0xbd, 0xf3, 0xb7, 0xae, 0x94, 0x2e, 0x1f, 0xfe, 0x93, - 0x9e, 0x2f, 0x59, 0xce, 0xbf, 0x9f, 0x8c, 0x2a, 0x5c, 0xe3, 0xd9, 0xb7, 0x58, 0xe4, 0x2e, 0x62, - 0x91, 0xfb, 0x15, 0x8b, 0xdc, 0xa7, 0xb1, 0xb8, 0x76, 0x31, 0x16, 0xd7, 0x7e, 0x8c, 0xc5, 0xb5, - 0x37, 0x55, 0xd3, 0x0a, 0xde, 0xf6, 0x75, 0xa5, 0xeb, 0xda, 0xea, 0x7c, 0xc5, 0x6a, 0x0f, 0xeb, - 0x90, 0x22, 0xf5, 0x1d, 0x7d, 0x0d, 0x82, 0xa1, 0x47, 0x40, 0x2f, 0xd0, 0xa7, 0xe0, 0xf1, 0xef, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x3d, 0x91, 0xdb, 0x56, 0xf8, 0x04, 0x00, 0x00, + // 587 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x3b, 0x8f, 0xd3, 0x4c, + 0x14, 0x5d, 0x67, 0x1f, 0x9f, 0x76, 0xf6, 0xf9, 0x59, 0x2b, 0xf0, 0x1a, 0x64, 0x83, 0x97, 0x82, + 0x7d, 0xc4, 0x26, 0x20, 0x21, 0xb4, 0x1d, 0x11, 0x08, 0x21, 0x11, 0x84, 0xbc, 0xa4, 0x41, 0x42, + 0xd1, 0xd8, 0x1e, 0x99, 0xd1, 0xc6, 0x0f, 0xf9, 0x3a, 0x0e, 0xe9, 0x10, 0x25, 0x15, 0x3f, 0x25, + 0x05, 0xff, 0x01, 0xca, 0x88, 0x8a, 0xca, 0x42, 0x4e, 0x91, 0x9a, 0xfc, 0x02, 0x94, 0xf1, 0x38, + 0x4f, 0x24, 0xd8, 0x34, 0x51, 0xce, 0x3d, 0xe7, 0xce, 0x99, 0xb9, 0x67, 0x3c, 0x48, 0xf1, 0x68, + 0xf3, 0xb2, 0xd3, 0xc6, 0x1d, 0x03, 0x27, 0x60, 0x24, 0x15, 0xc3, 0x23, 0x00, 0xd8, 0x25, 0xa0, + 0x87, 0x51, 0x10, 0x07, 0xe2, 0x5e, 0xc1, 0xeb, 0x38, 0x01, 0x3d, 0xa9, 0xc8, 0xff, 0x63, 0x8f, + 0xfa, 0x81, 0xc1, 0x7e, 0x73, 0x8d, 0x7c, 0x68, 0x07, 0xe0, 0x05, 0xd0, 0x60, 0xc8, 0xc8, 0x01, + 0xa7, 0x94, 0x1c, 0x19, 0x16, 0x06, 0x62, 0x24, 0x15, 0x8b, 0xc4, 0xb8, 0x62, 0xd8, 0x01, 0xf5, + 0x17, 0x78, 0xff, 0x72, 0xcc, 0x8f, 0x00, 0xe7, 0xaf, 0x73, 0xde, 0x03, 0x97, 0x6d, 0x0e, 0x5c, + 0x4e, 0x1c, 0xb8, 0x81, 0x1b, 0xe4, 0x86, 0xa3, 0x7f, 0xbc, 0x7a, 0x73, 0xfe, 0x34, 0x21, 0x8e, + 0xb0, 0xc7, 0x37, 0xa3, 0x7d, 0x2d, 0x21, 0xb1, 0x06, 0xae, 0x49, 0x5c, 0x0a, 0x31, 0x89, 0x2e, + 0x48, 0x94, 0x50, 0x9b, 0x88, 0xf7, 0xd0, 0x06, 0x10, 0xdf, 0x21, 0x91, 0x24, 0xdc, 0x12, 0xee, + 0x6e, 0x56, 0xa5, 0xef, 0x5f, 0xca, 0x07, 0xfc, 0x14, 0x8f, 0x1d, 0x27, 0x22, 0x00, 0x17, 0x71, + 0x44, 0x7d, 0xd7, 0xe4, 0x3a, 0xf1, 0x08, 0xad, 0xf9, 0xd8, 0x23, 0x52, 0x89, 0xe9, 0xf7, 0x86, + 0xa9, 0xba, 0xd5, 0xc1, 0x5e, 0xf3, 0x5c, 0x1b, 0x55, 0x35, 0x93, 0x91, 0xe2, 0x23, 0xb4, 0xe5, + 0x10, 0xb0, 0x23, 0x1a, 0xc6, 0x34, 0xf0, 0xa5, 0x55, 0xa6, 0xbd, 0x36, 0x4c, 0x55, 0x31, 0xd7, + 0x4e, 0x91, 0x9a, 0x39, 0x2d, 0x15, 0xcf, 0xd0, 0x7f, 0x6d, 0x62, 0x01, 0x8d, 0x89, 0xb4, 0xc6, + 0xba, 0xc4, 0x61, 0xaa, 0xee, 0xe6, 0x5d, 0x9c, 0xd0, 0xcc, 0x42, 0x22, 0x3e, 0x45, 0x5b, 0x21, + 0xb5, 0xe3, 0x56, 0x44, 0x1a, 0xad, 0xa8, 0x29, 0xad, 0xb3, 0x8e, 0x3b, 0x59, 0xaa, 0xa2, 0x57, + 0x79, 0xb9, 0x6e, 0xbe, 0x98, 0xb8, 0x4e, 0x49, 0x35, 0x13, 0x71, 0x54, 0x8f, 0x9a, 0xe7, 0xa7, + 0x1f, 0x07, 0xdd, 0x13, 0x7e, 0xc0, 0x4f, 0x83, 0xee, 0xc9, 0x8d, 0xf1, 0x28, 0x17, 0x47, 0xa6, + 0xbd, 0x46, 0xf2, 0x62, 0xd5, 0x24, 0x10, 0x06, 0x3e, 0x10, 0xf1, 0x21, 0xda, 0xf5, 0x49, 0xbb, + 0x01, 0x79, 0xb9, 0x41, 0x1d, 0x36, 0xd8, 0x9d, 0xea, 0x7e, 0x96, 0xaa, 0xdb, 0x2f, 0x49, 0x9b, + 0xeb, 0x9f, 0x3f, 0x31, 0xb7, 0xfd, 0x09, 0x72, 0xb4, 0x5f, 0x25, 0xb4, 0x5f, 0x03, 0xb7, 0x1e, + 0x3a, 0x38, 0x26, 0xcb, 0xa7, 0x73, 0x86, 0xd0, 0x94, 0x75, 0x89, 0x59, 0xef, 0x64, 0xa9, 0xba, + 0x39, 0xf1, 0xdd, 0x84, 0xc2, 0x74, 0x9c, 0xe5, 0xea, 0x15, 0xb2, 0x5c, 0x5b, 0x2a, 0xcb, 0xf5, + 0x2b, 0x67, 0xb9, 0xb1, 0x64, 0x96, 0xc7, 0x73, 0x59, 0x1e, 0x4e, 0x67, 0x39, 0x33, 0x5e, 0x4d, + 0x46, 0xd2, 0x7c, 0xad, 0xc8, 0xf1, 0x7e, 0x4f, 0x40, 0xab, 0x35, 0x70, 0x45, 0x1b, 0xed, 0xcd, + 0x7f, 0x33, 0x47, 0xfa, 0xdc, 0xbb, 0xa0, 0x2f, 0xde, 0x07, 0xf9, 0xf4, 0x1f, 0x44, 0xe3, 0x4b, + 0xf3, 0x16, 0xed, 0xcc, 0x06, 0x7f, 0xfb, 0x4f, 0xdd, 0x33, 0x12, 0xf9, 0xf8, 0xaf, 0x92, 0x62, + 0x79, 0x79, 0xfd, 0xc3, 0xa0, 0x7b, 0x22, 0x54, 0x9f, 0x7d, 0xcb, 0x14, 0xa1, 0x97, 0x29, 0xc2, + 0xcf, 0x4c, 0x11, 0x3e, 0xf7, 0x95, 0x95, 0x5e, 0x5f, 0x59, 0xf9, 0xd1, 0x57, 0x56, 0xde, 0x94, + 0x5d, 0x1a, 0xbf, 0x6b, 0x59, 0xba, 0x1d, 0x78, 0x46, 0xb1, 0x6a, 0xb9, 0x89, 0x2d, 0x18, 0x23, + 0xe3, 0x3d, 0x7b, 0x55, 0xe2, 0x4e, 0x48, 0xc0, 0xda, 0x60, 0x4f, 0xca, 0x83, 0xdf, 0x01, 0x00, + 0x00, 0xff, 0xff, 0x08, 0xe4, 0x2d, 0x1e, 0x40, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -361,8 +361,8 @@ const _ = grpc.SupportPackageIsVersion4 // // 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 { - RegisterAVS(ctx context.Context, in *MsgRegisterAVS, opts ...grpc.CallOption) (*MsgRegisterAVSResponse, error) - UpdateAVS(ctx context.Context, in *MsgUpdateAVS, opts ...grpc.CallOption) (*MsgUpdateAVSResponse, error) + RegisterService(ctx context.Context, in *MsgRegisterService, opts ...grpc.CallOption) (*MsgRegisterServiceResponse, error) + UpdateService(ctx context.Context, in *MsgUpdateService, opts ...grpc.CallOption) (*MsgUpdateServiceResponse, error) } type msgClient struct { @@ -373,18 +373,18 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) RegisterAVS(ctx context.Context, in *MsgRegisterAVS, opts ...grpc.CallOption) (*MsgRegisterAVSResponse, error) { - out := new(MsgRegisterAVSResponse) - err := c.cc.Invoke(ctx, "/milkyway.avs.v1.Msg/RegisterAVS", in, out, opts...) +func (c *msgClient) RegisterService(ctx context.Context, in *MsgRegisterService, opts ...grpc.CallOption) (*MsgRegisterServiceResponse, error) { + out := new(MsgRegisterServiceResponse) + err := c.cc.Invoke(ctx, "/milkyway.avs.v1.Msg/RegisterService", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *msgClient) UpdateAVS(ctx context.Context, in *MsgUpdateAVS, opts ...grpc.CallOption) (*MsgUpdateAVSResponse, error) { - out := new(MsgUpdateAVSResponse) - err := c.cc.Invoke(ctx, "/milkyway.avs.v1.Msg/UpdateAVS", in, out, opts...) +func (c *msgClient) UpdateService(ctx context.Context, in *MsgUpdateService, opts ...grpc.CallOption) (*MsgUpdateServiceResponse, error) { + out := new(MsgUpdateServiceResponse) + err := c.cc.Invoke(ctx, "/milkyway.avs.v1.Msg/UpdateService", in, out, opts...) if err != nil { return nil, err } @@ -393,57 +393,57 @@ func (c *msgClient) UpdateAVS(ctx context.Context, in *MsgUpdateAVS, opts ...grp // MsgServer is the server API for Msg service. type MsgServer interface { - RegisterAVS(context.Context, *MsgRegisterAVS) (*MsgRegisterAVSResponse, error) - UpdateAVS(context.Context, *MsgUpdateAVS) (*MsgUpdateAVSResponse, error) + RegisterService(context.Context, *MsgRegisterService) (*MsgRegisterServiceResponse, error) + UpdateService(context.Context, *MsgUpdateService) (*MsgUpdateServiceResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) RegisterAVS(ctx context.Context, req *MsgRegisterAVS) (*MsgRegisterAVSResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RegisterAVS not implemented") +func (*UnimplementedMsgServer) RegisterService(ctx context.Context, req *MsgRegisterService) (*MsgRegisterServiceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterService not implemented") } -func (*UnimplementedMsgServer) UpdateAVS(ctx context.Context, req *MsgUpdateAVS) (*MsgUpdateAVSResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateAVS not implemented") +func (*UnimplementedMsgServer) UpdateService(ctx context.Context, req *MsgUpdateService) (*MsgUpdateServiceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateService not implemented") } func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_RegisterAVS_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgRegisterAVS) +func _Msg_RegisterService_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRegisterService) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).RegisterAVS(ctx, in) + return srv.(MsgServer).RegisterService(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/milkyway.avs.v1.Msg/RegisterAVS", + FullMethod: "/milkyway.avs.v1.Msg/RegisterService", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).RegisterAVS(ctx, req.(*MsgRegisterAVS)) + return srv.(MsgServer).RegisterService(ctx, req.(*MsgRegisterService)) } return interceptor(ctx, in, info, handler) } -func _Msg_UpdateAVS_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateAVS) +func _Msg_UpdateService_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateService) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).UpdateAVS(ctx, in) + return srv.(MsgServer).UpdateService(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/milkyway.avs.v1.Msg/UpdateAVS", + FullMethod: "/milkyway.avs.v1.Msg/UpdateService", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateAVS(ctx, req.(*MsgUpdateAVS)) + return srv.(MsgServer).UpdateService(ctx, req.(*MsgUpdateService)) } return interceptor(ctx, in, info, handler) } @@ -453,19 +453,19 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "RegisterAVS", - Handler: _Msg_RegisterAVS_Handler, + MethodName: "RegisterService", + Handler: _Msg_RegisterService_Handler, }, { - MethodName: "UpdateAVS", - Handler: _Msg_UpdateAVS_Handler, + MethodName: "UpdateService", + Handler: _Msg_UpdateService_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "milkyway/avs/v1/messages.proto", } -func (m *MsgRegisterAVS) Marshal() (dAtA []byte, err error) { +func (m *MsgRegisterService) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -475,12 +475,12 @@ func (m *MsgRegisterAVS) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgRegisterAVS) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRegisterService) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgRegisterAVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRegisterService) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -523,7 +523,7 @@ func (m *MsgRegisterAVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgRegisterAVSResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgRegisterServiceResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -533,25 +533,25 @@ func (m *MsgRegisterAVSResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgRegisterAVSResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRegisterServiceResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgRegisterAVSResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRegisterServiceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.NewAVSID != 0 { - i = encodeVarintMessages(dAtA, i, uint64(m.NewAVSID)) + if m.NewServiceID != 0 { + i = encodeVarintMessages(dAtA, i, uint64(m.NewServiceID)) i-- dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func (m *MsgUpdateAVS) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateService) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -561,12 +561,12 @@ func (m *MsgUpdateAVS) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgUpdateAVS) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateService) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateAVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateService) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -599,8 +599,8 @@ func (m *MsgUpdateAVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if m.AVSID != 0 { - i = encodeVarintMessages(dAtA, i, uint64(m.AVSID)) + if m.ServiceID != 0 { + i = encodeVarintMessages(dAtA, i, uint64(m.ServiceID)) i-- dAtA[i] = 0x10 } @@ -614,7 +614,7 @@ func (m *MsgUpdateAVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgUpdateAVSResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateServiceResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -624,12 +624,12 @@ func (m *MsgUpdateAVSResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgUpdateAVSResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateServiceResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateAVSResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateServiceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -648,7 +648,7 @@ func encodeVarintMessages(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgRegisterAVS) Size() (n int) { +func (m *MsgRegisterService) Size() (n int) { if m == nil { return 0 } @@ -677,19 +677,19 @@ func (m *MsgRegisterAVS) Size() (n int) { return n } -func (m *MsgRegisterAVSResponse) Size() (n int) { +func (m *MsgRegisterServiceResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.NewAVSID != 0 { - n += 1 + sovMessages(uint64(m.NewAVSID)) + if m.NewServiceID != 0 { + n += 1 + sovMessages(uint64(m.NewServiceID)) } return n } -func (m *MsgUpdateAVS) Size() (n int) { +func (m *MsgUpdateService) Size() (n int) { if m == nil { return 0 } @@ -699,8 +699,8 @@ func (m *MsgUpdateAVS) Size() (n int) { if l > 0 { n += 1 + l + sovMessages(uint64(l)) } - if m.AVSID != 0 { - n += 1 + sovMessages(uint64(m.AVSID)) + if m.ServiceID != 0 { + n += 1 + sovMessages(uint64(m.ServiceID)) } l = len(m.Name) if l > 0 { @@ -721,7 +721,7 @@ func (m *MsgUpdateAVS) Size() (n int) { return n } -func (m *MsgUpdateAVSResponse) Size() (n int) { +func (m *MsgUpdateServiceResponse) Size() (n int) { if m == nil { return 0 } @@ -736,7 +736,7 @@ func sovMessages(x uint64) (n int) { func sozMessages(x uint64) (n int) { return sovMessages(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgRegisterAVS) Unmarshal(dAtA []byte) error { +func (m *MsgRegisterService) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -759,10 +759,10 @@ func (m *MsgRegisterAVS) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgRegisterAVS: wiretype end group for non-group") + return fmt.Errorf("proto: MsgRegisterService: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRegisterAVS: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgRegisterService: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -946,7 +946,7 @@ func (m *MsgRegisterAVS) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgRegisterAVSResponse) Unmarshal(dAtA []byte) error { +func (m *MsgRegisterServiceResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -969,17 +969,17 @@ func (m *MsgRegisterAVSResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgRegisterAVSResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgRegisterServiceResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRegisterAVSResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgRegisterServiceResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NewAVSID", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field NewServiceID", wireType) } - m.NewAVSID = 0 + m.NewServiceID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowMessages @@ -989,7 +989,7 @@ func (m *MsgRegisterAVSResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.NewAVSID |= uint32(b&0x7F) << shift + m.NewServiceID |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -1015,7 +1015,7 @@ func (m *MsgRegisterAVSResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateAVS) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateService) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1038,10 +1038,10 @@ func (m *MsgUpdateAVS) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateAVS: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateService: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateAVS: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateService: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1078,9 +1078,9 @@ func (m *MsgUpdateAVS) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AVSID", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ServiceID", wireType) } - m.AVSID = 0 + m.ServiceID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowMessages @@ -1090,7 +1090,7 @@ func (m *MsgUpdateAVS) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.AVSID |= uint32(b&0x7F) << shift + m.ServiceID |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -1244,7 +1244,7 @@ func (m *MsgUpdateAVS) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateAVSResponse) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateServiceResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1267,10 +1267,10 @@ func (m *MsgUpdateAVSResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateAVSResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateServiceResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateAVSResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateServiceResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: From dfa8bd7e0d5859649565795474ad1de167700ff8 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Tue, 4 Jun 2024 10:19:49 -0500 Subject: [PATCH 21/49] feat: add module definition --- x/avs/{keeper => }/genesis.go | 17 ++-- x/avs/keeper/alias_functions.go | 2 +- x/avs/keeper/avs.go | 10 +- x/avs/keeper/grpc_query.go | 6 +- x/avs/keeper/hooks.go | 6 +- x/avs/keeper/keeper.go | 2 +- x/avs/keeper/msg_server.go | 4 + x/avs/module.go | 161 ++++++++++++++++++++++++++++++++ x/avs/types/genesis.go | 8 +- x/avs/types/genesis_test.go | 4 +- 10 files changed, 192 insertions(+), 28 deletions(-) rename x/avs/{keeper => }/genesis.go (66%) create mode 100644 x/avs/module.go diff --git a/x/avs/keeper/genesis.go b/x/avs/genesis.go similarity index 66% rename from x/avs/keeper/genesis.go rename to x/avs/genesis.go index e5be1d95f..652019dde 100644 --- a/x/avs/keeper/genesis.go +++ b/x/avs/genesis.go @@ -1,22 +1,23 @@ -package keeper +package avs import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/milkyway-labs/milkyway/x/avs/keeper" "github.com/milkyway-labs/milkyway/x/avs/types" ) // ExportGenesis returns the GenesisState associated with the given context -func (k *Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { return types.NewGenesisState( - k.exportNextAVSID(ctx), - k.exportServices(ctx), + exportNextAVSID(ctx, k), + exportServices(ctx, k), k.GetParams(ctx), ) } // exportNextAVSID returns the next AVS ID stored in the KVStore -func (k *Keeper) exportNextAVSID(ctx sdk.Context) uint32 { +func exportNextAVSID(ctx sdk.Context, k keeper.Keeper) uint32 { nextAVSID, err := k.GetNextAVSID(ctx) if err != nil { panic(err) @@ -25,7 +26,7 @@ func (k *Keeper) exportNextAVSID(ctx sdk.Context) uint32 { } // exportServices returns the services stored in the KVStore -func (k *Keeper) exportServices(ctx sdk.Context) []types.AVS { +func exportServices(ctx sdk.Context, k keeper.Keeper) []types.AVS { var services []types.AVS k.IterateServices(ctx, func(service types.AVS) (stop bool) { services = append(services, service) @@ -34,10 +35,8 @@ func (k *Keeper) exportServices(ctx sdk.Context) []types.AVS { return services } -// -------------------------------------------------------------------------------------------------------------------- - // InitGenesis initializes the state from a GenesisState -func (k *Keeper) InitGenesis(ctx sdk.Context, state *types.GenesisState) { +func InitGenesis(ctx sdk.Context, k keeper.Keeper, state types.GenesisState) { // Set the next AVS ID k.SetNextAVSID(ctx, state.NextAVSID) diff --git a/x/avs/keeper/alias_functions.go b/x/avs/keeper/alias_functions.go index 72909fcf6..79f0d083e 100644 --- a/x/avs/keeper/alias_functions.go +++ b/x/avs/keeper/alias_functions.go @@ -8,7 +8,7 @@ import ( ) // IterateServices iterates over the services in the store and performs a callback function -func (k *Keeper) IterateServices(ctx sdk.Context, cb func(service types.AVS) (stop bool)) { +func (k Keeper) IterateServices(ctx sdk.Context, cb func(service types.AVS) (stop bool)) { store := ctx.KVStore(k.storeKey) iterator := storetypes.KVStorePrefixIterator(store, types.AVSPrefix) defer iterator.Close() diff --git a/x/avs/keeper/avs.go b/x/avs/keeper/avs.go index e83effc77..af03611bd 100644 --- a/x/avs/keeper/avs.go +++ b/x/avs/keeper/avs.go @@ -8,19 +8,19 @@ import ( ) // SetNextAVSID sets the next AVS ID to be used when registering a new AVS -func (k *Keeper) SetNextAVSID(ctx sdk.Context, avsID uint32) { +func (k Keeper) SetNextAVSID(ctx sdk.Context, avsID uint32) { store := ctx.KVStore(k.storeKey) store.Set(types.NextAVSIDKey(), types.GetAVSIDBytes(avsID)) } // HasNextAVSID checks if the next AVS ID is set -func (k *Keeper) HasNextAVSID(ctx sdk.Context) bool { +func (k Keeper) HasNextAVSID(ctx sdk.Context) bool { store := ctx.KVStore(k.storeKey) return store.Has(types.NextAVSIDKey()) } // GetNextAVSID returns the next AVS ID to be used when registering a new AVS -func (k *Keeper) GetNextAVSID(ctx sdk.Context) (avsID uint32, err error) { +func (k Keeper) GetNextAVSID(ctx sdk.Context) (avsID uint32, err error) { store := ctx.KVStore(k.storeKey) bz := store.Get(types.NextAVSIDKey()) if bz == nil { @@ -34,7 +34,7 @@ func (k *Keeper) GetNextAVSID(ctx sdk.Context) (avsID uint32, err error) { // -------------------------------------------------------------------------------------------------------------------- // SaveAVS stores a new AVS in the KVStore -func (k *Keeper) SaveAVS(ctx sdk.Context, avs types.AVS) { +func (k Keeper) SaveAVS(ctx sdk.Context, avs types.AVS) { previous, existed := k.GetAVS(ctx, avs.ID) // Save the AVS data @@ -54,7 +54,7 @@ func (k *Keeper) SaveAVS(ctx sdk.Context, avs types.AVS) { } // GetAVS returns an AVS from the KVStore -func (k *Keeper) GetAVS(ctx sdk.Context, avsID uint32) (avs types.AVS, found bool) { +func (k Keeper) GetAVS(ctx sdk.Context, avsID uint32) (avs types.AVS, found bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(types.AVSStoreKey(avsID)) diff --git a/x/avs/keeper/grpc_query.go b/x/avs/keeper/grpc_query.go index 992d4983f..029633557 100644 --- a/x/avs/keeper/grpc_query.go +++ b/x/avs/keeper/grpc_query.go @@ -15,7 +15,7 @@ import ( var _ types.QueryServer = &Keeper{} // Services implements the Query/Services gRPC method -func (k *Keeper) Services(ctx context.Context, request *types.QueryServicesRequest) (*types.QueryServicesResponse, error) { +func (k Keeper) Services(ctx context.Context, request *types.QueryServicesRequest) (*types.QueryServicesResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) store := sdkCtx.KVStore(k.storeKey) @@ -43,7 +43,7 @@ func (k *Keeper) Services(ctx context.Context, request *types.QueryServicesReque } // Service implements the Query/Service gRPC method -func (k *Keeper) Service(ctx context.Context, request *types.QueryServiceRequest) (*types.QueryServiceResponse, error) { +func (k Keeper) Service(ctx context.Context, request *types.QueryServiceRequest) (*types.QueryServiceResponse, error) { if request.ServiceId == 0 { return nil, status.Error(codes.InvalidArgument, "invalid service ID") } @@ -58,7 +58,7 @@ func (k *Keeper) Service(ctx context.Context, request *types.QueryServiceRequest } // Params implements the Query/Params gRPC method -func (k *Keeper) Params(ctx context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { +func (k Keeper) Params(ctx context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) params := k.GetParams(sdkCtx) return &types.QueryParamsResponse{Params: params}, nil diff --git a/x/avs/keeper/hooks.go b/x/avs/keeper/hooks.go index c219ad516..4109bd513 100644 --- a/x/avs/keeper/hooks.go +++ b/x/avs/keeper/hooks.go @@ -10,21 +10,21 @@ import ( var _ types.AVSHooks = &Keeper{} // AfterAVSCreated implements AVSHooks -func (k *Keeper) AfterAVSCreated(ctx sdk.Context, avsID uint32) { +func (k Keeper) AfterAVSCreated(ctx sdk.Context, avsID uint32) { if k.hooks != nil { k.hooks.AfterAVSCreated(ctx, avsID) } } // AfterAVSRegistered implements AVSHooks -func (k *Keeper) AfterAVSRegistered(ctx sdk.Context, avsID uint32) { +func (k Keeper) AfterAVSRegistered(ctx sdk.Context, avsID uint32) { if k.hooks != nil { k.hooks.AfterAVSRegistered(ctx, avsID) } } // AfterAVSDeregistered implements AVSHooks -func (k *Keeper) AfterAVSDeregistered(ctx sdk.Context, avsID uint32) { +func (k Keeper) AfterAVSDeregistered(ctx sdk.Context, avsID uint32) { if k.hooks != nil { k.hooks.AfterAVSDeregistered(ctx, avsID) } diff --git a/x/avs/keeper/keeper.go b/x/avs/keeper/keeper.go index 8b90b6095..1a022138a 100644 --- a/x/avs/keeper/keeper.go +++ b/x/avs/keeper/keeper.go @@ -24,7 +24,7 @@ func NewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey) Keeper { } // Logger returns a module-specific logger. -func (k *Keeper) Logger(ctx sdk.Context) log.Logger { +func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+types.ModuleName) } diff --git a/x/avs/keeper/msg_server.go b/x/avs/keeper/msg_server.go index df9f8e382..5ed971849 100644 --- a/x/avs/keeper/msg_server.go +++ b/x/avs/keeper/msg_server.go @@ -19,6 +19,10 @@ type msgServer struct { Keeper } +func NewMsgServer(k Keeper) types.MsgServer { + return &msgServer{Keeper: k} +} + // RegisterService defines the rpc method for Msg/RegisterService func (k msgServer) RegisterService(goCtx context.Context, msg *types.MsgRegisterService) (*types.MsgRegisterServiceResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) diff --git a/x/avs/module.go b/x/avs/module.go new file mode 100644 index 000000000..2e02fcfd5 --- /dev/null +++ b/x/avs/module.go @@ -0,0 +1,161 @@ +package avs + +import ( + "context" + "encoding/json" + "fmt" + + // this line is used by starport scaffolding # 1 + + "cosmossdk.io/core/appmodule" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/cometbft/cometbft/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/milkyway-labs/milkyway/x/avs/client/cli" + + "github.com/milkyway-labs/milkyway/x/avs/keeper" + "github.com/milkyway-labs/milkyway/x/avs/types" +) + +const ( + consensusVersion = 1 +) + +var ( + _ appmodule.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) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(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() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err != nil { + panic(err) + } +} + +// 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 +} + +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// Name returns the capability module's name. +func (am AppModule) Name() string { + return am.AppModuleBasic.Name() +} + +// RegisterServices registers a GRPC query service to respond to the module-specific GRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServer(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the capability module's invariants. +func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { + keeper.RegisterInvariants(ir, am.keeper) +} + +// 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 + 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 consensusVersion } + +// BeginBlock executes all ABCI BeginBlock logic respective to the capability module. +func (am AppModule) BeginBlock(ctx context.Context) error { + return nil +} + +// EndBlock executes all ABCI EndBlock logic respective to the capability module. It returns no validator updates. +func (am AppModule) EndBlock(ctx context.Context) error { + return nil +} + +func (am AppModule) IsOnePerModuleType() {} + +func (am AppModule) IsAppModule() {} diff --git a/x/avs/types/genesis.go b/x/avs/types/genesis.go index 579c46ffa..530a30e8b 100644 --- a/x/avs/types/genesis.go +++ b/x/avs/types/genesis.go @@ -15,15 +15,15 @@ func NewGenesisState(nextAVSID uint32, services []AVS, params Params) *GenesisSt } } -// DefaultGenesisState returns a default GenesisState -func DefaultGenesisState() *GenesisState { +// DefaultGenesis returns a default GenesisState +func DefaultGenesis() *GenesisState { return NewGenesisState(1, nil, DefaultParams()) } // -------------------------------------------------------------------------------------------------------------------- -// ValidateGenesis validates the given genesis state and returns an error if something is invalid -func ValidateGenesis(data *GenesisState) error { +// Validate validates the GenesisState and returns an error if it is invalid. +func (data *GenesisState) Validate() error { // Check for the next AVS ID if data.NextAVSID == 0 { return fmt.Errorf("invalid next AVS ID: %d", data.NextAVSID) diff --git a/x/avs/types/genesis_test.go b/x/avs/types/genesis_test.go index fd47343e4..d19f8991f 100644 --- a/x/avs/types/genesis_test.go +++ b/x/avs/types/genesis_test.go @@ -81,7 +81,7 @@ func TestValidateGenesis(t *testing.T) { }, { name: "default genesis is valid", - genesis: types.DefaultGenesisState(), + genesis: types.DefaultGenesis(), shouldErr: false, }, { @@ -112,7 +112,7 @@ func TestValidateGenesis(t *testing.T) { for _, tc := range testCases { tc := tc t.Run(tc.name, func(t *testing.T) { - err := types.ValidateGenesis(tc.genesis) + err := tc.genesis.Validate() if tc.shouldErr { require.Error(t, err) } else { From ba96f82d7736886429a5ecdcd9d661049ae7efd6 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Tue, 4 Jun 2024 10:23:03 -0500 Subject: [PATCH 22/49] chore: fix comments and variables name --- x/avs/module.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/x/avs/module.go b/x/avs/module.go index 2e02fcfd5..6548650a5 100644 --- a/x/avs/module.go +++ b/x/avs/module.go @@ -5,8 +5,6 @@ import ( "encoding/json" "fmt" - // this line is used by starport scaffolding # 1 - "cosmossdk.io/core/appmodule" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -147,12 +145,12 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw func (AppModule) ConsensusVersion() uint64 { return consensusVersion } // BeginBlock executes all ABCI BeginBlock logic respective to the capability module. -func (am AppModule) BeginBlock(ctx context.Context) error { +func (am AppModule) BeginBlock(_ context.Context) error { return nil } // EndBlock executes all ABCI EndBlock logic respective to the capability module. It returns no validator updates. -func (am AppModule) EndBlock(ctx context.Context) error { +func (am AppModule) EndBlock(_ context.Context) error { return nil } From 294ae0a9dd32db30e52adebcfa7d5fba9bc6a285 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Tue, 4 Jun 2024 10:24:52 -0500 Subject: [PATCH 23/49] chore: rename avs module to services --- x/avs/keeper/alias_functions.go | 24 - x/avs/keeper/grpc_query.go | 65 -- x/avs/keeper/hooks.go | 31 - x/avs/keeper/keeper.go | 39 - x/avs/keeper/msg_server.go | 97 -- x/avs/keeper/params.go | 25 - x/avs/module.go | 159 ---- x/avs/types/codec.go | 40 - x/avs/types/errors.go | 9 - x/avs/types/events.go | 10 - x/avs/types/genesis.go | 58 -- x/avs/types/genesis.pb.go | 428 --------- x/avs/types/genesis_test.go | 123 --- x/avs/types/hooks.go | 51 -- x/avs/types/keys.go | 42 - x/avs/types/messages.go | 78 -- x/avs/types/messages.pb.go | 1380 ---------------------------- x/avs/types/models.go | 105 --- x/avs/types/models.pb.go | 651 -------------- x/avs/types/models_test.go | 80 -- x/avs/types/params.go | 30 - x/avs/types/params.pb.go | 341 ------- x/avs/types/params_test.go | 51 -- x/avs/types/query.go | 24 - x/avs/types/query.pb.go | 1384 ----------------------------- x/avs/types/query.pb.gw.go | 337 ------- x/{avs => services}/genesis.go | 6 +- x/{avs => services}/keeper/avs.go | 2 +- 28 files changed, 4 insertions(+), 5666 deletions(-) delete mode 100644 x/avs/keeper/alias_functions.go delete mode 100644 x/avs/keeper/grpc_query.go delete mode 100644 x/avs/keeper/hooks.go delete mode 100644 x/avs/keeper/keeper.go delete mode 100644 x/avs/keeper/msg_server.go delete mode 100644 x/avs/keeper/params.go delete mode 100644 x/avs/module.go delete mode 100644 x/avs/types/codec.go delete mode 100644 x/avs/types/errors.go delete mode 100644 x/avs/types/events.go delete mode 100644 x/avs/types/genesis.go delete mode 100644 x/avs/types/genesis.pb.go delete mode 100644 x/avs/types/genesis_test.go delete mode 100644 x/avs/types/hooks.go delete mode 100644 x/avs/types/keys.go delete mode 100644 x/avs/types/messages.go delete mode 100644 x/avs/types/messages.pb.go delete mode 100644 x/avs/types/models.go delete mode 100644 x/avs/types/models.pb.go delete mode 100644 x/avs/types/models_test.go delete mode 100644 x/avs/types/params.go delete mode 100644 x/avs/types/params.pb.go delete mode 100644 x/avs/types/params_test.go delete mode 100644 x/avs/types/query.go delete mode 100644 x/avs/types/query.pb.go delete mode 100644 x/avs/types/query.pb.gw.go rename x/{avs => services}/genesis.go (90%) rename x/{avs => services}/keeper/avs.go (97%) diff --git a/x/avs/keeper/alias_functions.go b/x/avs/keeper/alias_functions.go deleted file mode 100644 index 79f0d083e..000000000 --- a/x/avs/keeper/alias_functions.go +++ /dev/null @@ -1,24 +0,0 @@ -package keeper - -import ( - storetypes "cosmossdk.io/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/milkyway-labs/milkyway/x/avs/types" -) - -// IterateServices iterates over the services in the store and performs a callback function -func (k Keeper) IterateServices(ctx sdk.Context, cb func(service types.AVS) (stop bool)) { - store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.AVSPrefix) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - var service types.AVS - k.cdc.MustUnmarshal(iterator.Value(), &service) - - if cb(service) { - break - } - } -} diff --git a/x/avs/keeper/grpc_query.go b/x/avs/keeper/grpc_query.go deleted file mode 100644 index 029633557..000000000 --- a/x/avs/keeper/grpc_query.go +++ /dev/null @@ -1,65 +0,0 @@ -package keeper - -import ( - "context" - - "cosmossdk.io/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/query" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - "github.com/milkyway-labs/milkyway/x/avs/types" -) - -var _ types.QueryServer = &Keeper{} - -// Services implements the Query/Services gRPC method -func (k Keeper) Services(ctx context.Context, request *types.QueryServicesRequest) (*types.QueryServicesResponse, error) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - - store := sdkCtx.KVStore(k.storeKey) - servicesStore := prefix.NewStore(store, types.AVSPrefix) - - var services []types.AVS - pageRes, err := query.Paginate(servicesStore, request.Pagination, func(key []byte, value []byte) error { - var service types.AVS - if err := k.cdc.Unmarshal(value, &service); err != nil { - return status.Error(codes.Internal, err.Error()) - } - - services = append(services, service) - return nil - }) - - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - - return &types.QueryServicesResponse{ - Services: services, - Pagination: pageRes, - }, nil -} - -// Service implements the Query/Service gRPC method -func (k Keeper) Service(ctx context.Context, request *types.QueryServiceRequest) (*types.QueryServiceResponse, error) { - if request.ServiceId == 0 { - return nil, status.Error(codes.InvalidArgument, "invalid service ID") - } - - sdkCtx := sdk.UnwrapSDKContext(ctx) - service, found := k.GetAVS(sdkCtx, request.ServiceId) - if !found { - return nil, status.Error(codes.NotFound, "service not found") - } - - return &types.QueryServiceResponse{Service: service}, nil -} - -// Params implements the Query/Params gRPC method -func (k Keeper) Params(ctx context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - params := k.GetParams(sdkCtx) - return &types.QueryParamsResponse{Params: params}, nil -} diff --git a/x/avs/keeper/hooks.go b/x/avs/keeper/hooks.go deleted file mode 100644 index 4109bd513..000000000 --- a/x/avs/keeper/hooks.go +++ /dev/null @@ -1,31 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/milkyway-labs/milkyway/x/avs/types" -) - -// Implement AVSHooks interface -var _ types.AVSHooks = &Keeper{} - -// AfterAVSCreated implements AVSHooks -func (k Keeper) AfterAVSCreated(ctx sdk.Context, avsID uint32) { - if k.hooks != nil { - k.hooks.AfterAVSCreated(ctx, avsID) - } -} - -// AfterAVSRegistered implements AVSHooks -func (k Keeper) AfterAVSRegistered(ctx sdk.Context, avsID uint32) { - if k.hooks != nil { - k.hooks.AfterAVSRegistered(ctx, avsID) - } -} - -// AfterAVSDeregistered implements AVSHooks -func (k Keeper) AfterAVSDeregistered(ctx sdk.Context, avsID uint32) { - if k.hooks != nil { - k.hooks.AfterAVSDeregistered(ctx, avsID) - } -} diff --git a/x/avs/keeper/keeper.go b/x/avs/keeper/keeper.go deleted file mode 100644 index 1a022138a..000000000 --- a/x/avs/keeper/keeper.go +++ /dev/null @@ -1,39 +0,0 @@ -package keeper - -import ( - "cosmossdk.io/log" - storetypes "cosmossdk.io/store/types" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/milkyway-labs/milkyway/x/avs/types" -) - -type Keeper struct { - storeKey storetypes.StoreKey - cdc codec.BinaryCodec - hooks types.AVSHooks -} - -// NewKeeper creates a new keeper -func NewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey) Keeper { - return Keeper{ - storeKey: storeKey, - cdc: cdc, - } -} - -// Logger returns a module-specific logger. -func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", "x/"+types.ModuleName) -} - -// SetHooks allows to set the reactions hooks -func (k *Keeper) SetHooks(rs types.AVSHooks) *Keeper { - if k.hooks != nil { - panic("cannot set avs hooks twice") - } - - k.hooks = rs - return k -} diff --git a/x/avs/keeper/msg_server.go b/x/avs/keeper/msg_server.go deleted file mode 100644 index 5ed971849..000000000 --- a/x/avs/keeper/msg_server.go +++ /dev/null @@ -1,97 +0,0 @@ -package keeper - -import ( - "context" - "fmt" - - "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/milkyway-labs/milkyway/x/avs/types" -) - -var ( - _ types.MsgServer = msgServer{} -) - -type msgServer struct { - Keeper -} - -func NewMsgServer(k Keeper) types.MsgServer { - return &msgServer{Keeper: k} -} - -// RegisterService defines the rpc method for Msg/RegisterService -func (k msgServer) RegisterService(goCtx context.Context, msg *types.MsgRegisterService) (*types.MsgRegisterServiceResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - // Get the next reaction id - avsID, err := k.GetNextAVSID(ctx) - if err != nil { - return nil, err - } - - // Create the AVS and validate it - avs := types.NewAVS( - avsID, - types.AVS_STATUS_CREATED, - msg.Name, - msg.Description, - msg.Website, - msg.PictureURL, - msg.Sender, - ) - if err := avs.Validate(); err != nil { - return nil, errors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) - } - - // Store the AVS - k.SaveAVS(ctx, avs) - - // Update the ID for the next AVS - k.SetNextAVSID(ctx, avs.ID+1) - - // Emit the event - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeRegisteredService, - sdk.NewAttribute(types.AttributeKeyServiceID, fmt.Sprintf("%d", avs.ID)), - ), - }) - - return &types.MsgRegisterServiceResponse{ - NewServiceID: avs.ID, - }, nil -} - -// UpdateService defines the rpc method for Msg/UpdateService -func (k msgServer) UpdateService(goCtx context.Context, msg *types.MsgUpdateService) (*types.MsgUpdateServiceResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - // Check if the AVS exists - avs, found := k.GetAVS(ctx, msg.ServiceID) - if !found { - return nil, errors.Wrapf(sdkerrors.ErrInvalidRequest, "avs with id %d not found", msg.ServiceID) - } - - // Update the AVS and validate it - updated := avs.Update(types.NewAVSUpdate(msg.Name, msg.Description, msg.Website, msg.PictureURL)) - if err := updated.Validate(); err != nil { - return nil, errors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) - } - - // Save the AVS - k.SaveAVS(ctx, updated) - - // Emit the event - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeUpdatedService, - sdk.NewAttribute(types.AttributeKeyServiceID, fmt.Sprintf("%d", msg.ServiceID)), - ), - }) - - return &types.MsgUpdateServiceResponse{}, nil -} diff --git a/x/avs/keeper/params.go b/x/avs/keeper/params.go deleted file mode 100644 index d9915bc60..000000000 --- a/x/avs/keeper/params.go +++ /dev/null @@ -1,25 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/milkyway-labs/milkyway/x/avs/types" -) - -// SetParams sets module parameters -func (k *Keeper) SetParams(ctx sdk.Context, params types.Params) { - store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshal(¶ms) - store.Set(types.ParamsKey, bz) -} - -// GetParams returns the module parameters -func (k *Keeper) GetParams(ctx sdk.Context) (p types.Params) { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.ParamsKey) - if bz == nil { - return p - } - k.cdc.MustUnmarshal(bz, &p) - return p -} diff --git a/x/avs/module.go b/x/avs/module.go deleted file mode 100644 index 6548650a5..000000000 --- a/x/avs/module.go +++ /dev/null @@ -1,159 +0,0 @@ -package avs - -import ( - "context" - "encoding/json" - "fmt" - - "cosmossdk.io/core/appmodule" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" - - abci "github.com/cometbft/cometbft/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/milkyway-labs/milkyway/x/avs/client/cli" - - "github.com/milkyway-labs/milkyway/x/avs/keeper" - "github.com/milkyway-labs/milkyway/x/avs/types" -) - -const ( - consensusVersion = 1 -) - -var ( - _ appmodule.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) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - types.RegisterLegacyAminoCodec(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() -} - -// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. -func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) - if err != nil { - panic(err) - } -} - -// 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 -} - -func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { - return AppModule{ - AppModuleBasic: NewAppModuleBasic(cdc), - keeper: keeper, - } -} - -// Name returns the capability module's name. -func (am AppModule) Name() string { - return am.AppModuleBasic.Name() -} - -// RegisterServices registers a GRPC query service to respond to the module-specific GRPC queries. -func (am AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServer(am.keeper)) - types.RegisterQueryServer(cfg.QueryServer(), am.keeper) -} - -// RegisterInvariants registers the capability module's invariants. -func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { - keeper.RegisterInvariants(ir, am.keeper) -} - -// 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 - 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 consensusVersion } - -// BeginBlock executes all ABCI BeginBlock logic respective to the capability module. -func (am AppModule) BeginBlock(_ context.Context) error { - return nil -} - -// EndBlock executes all ABCI EndBlock logic respective to the capability module. It returns no validator updates. -func (am AppModule) EndBlock(_ context.Context) error { - return nil -} - -func (am AppModule) IsOnePerModuleType() {} - -func (am AppModule) IsAppModule() {} diff --git a/x/avs/types/codec.go b/x/avs/types/codec.go deleted file mode 100644 index 9297f8e7b..000000000 --- a/x/avs/types/codec.go +++ /dev/null @@ -1,40 +0,0 @@ -package types - -import ( - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/legacy" - "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/msgservice" -) - -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - legacy.RegisterAminoMsg(cdc, &MsgRegisterService{}, "milkyway/MsgRegisterService") - legacy.RegisterAminoMsg(cdc, &MsgUpdateService{}, "milkyway/MsgUpdateService") -} - -func RegisterInterfaces(registry types.InterfaceRegistry) { - registry.RegisterImplementations((*sdk.Msg)(nil), - &MsgRegisterService{}, - &MsgUpdateService{}, - ) - - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) -} - -var ( - // AminoCdc references the global x/avs module codec. Note, the codec should - // ONLY be used in certain instances of tests and for JSON encoding as Amino is - // still used for that purpose. - // - // The actual codec used for serialization should be provided to x/avs and - // defined at the application level. - AminoCdc = codec.NewLegacyAmino() -) - -func init() { - RegisterLegacyAminoCodec(AminoCdc) - cryptocodec.RegisterCrypto(AminoCdc) - sdk.RegisterLegacyAminoCodec(AminoCdc) -} diff --git a/x/avs/types/errors.go b/x/avs/types/errors.go deleted file mode 100644 index ab08baa2d..000000000 --- a/x/avs/types/errors.go +++ /dev/null @@ -1,9 +0,0 @@ -package types - -import ( - "cosmossdk.io/errors" -) - -var ( - ErrInvalidGenesis = errors.Register(ModuleName, 1, "invalid genesis state") -) diff --git a/x/avs/types/events.go b/x/avs/types/events.go deleted file mode 100644 index b048ee8a8..000000000 --- a/x/avs/types/events.go +++ /dev/null @@ -1,10 +0,0 @@ -package types - -// DONTCOVER - -const ( - EventTypeRegisteredService = "registered_service" - EventTypeUpdatedService = "updated_service" - - AttributeKeyServiceID = "avs_id" -) diff --git a/x/avs/types/genesis.go b/x/avs/types/genesis.go deleted file mode 100644 index 530a30e8b..000000000 --- a/x/avs/types/genesis.go +++ /dev/null @@ -1,58 +0,0 @@ -package types - -import ( - "fmt" - - "github.com/milkyway-labs/milkyway/utils" -) - -// NewGenesisState returns a new GenesisState instance -func NewGenesisState(nextAVSID uint32, services []AVS, params Params) *GenesisState { - return &GenesisState{ - NextAVSID: nextAVSID, - Services: services, - Params: params, - } -} - -// DefaultGenesis returns a default GenesisState -func DefaultGenesis() *GenesisState { - return NewGenesisState(1, nil, DefaultParams()) -} - -// -------------------------------------------------------------------------------------------------------------------- - -// Validate validates the GenesisState and returns an error if it is invalid. -func (data *GenesisState) Validate() error { - // Check for the next AVS ID - if data.NextAVSID == 0 { - return fmt.Errorf("invalid next AVS ID: %d", data.NextAVSID) - } - - // Check for duplicated services - if duplicate := findDuplicatedService(data.Services); duplicate != nil { - return fmt.Errorf("duplicated service: %d", duplicate.ID) - } - - // Validate services - for _, service := range data.Services { - if err := service.Validate(); err != nil { - return fmt.Errorf("invalid service with id %d: %s", service.ID, err) - } - } - - // Validate params - if err := data.Params.Validate(); err != nil { - return fmt.Errorf("invalid params: %s", err) - } - - return nil -} - -// findDuplicatedService returns the first duplicated service in the slice. -// If no duplicates are found, it returns nil instead. -func findDuplicatedService(services []AVS) *AVS { - return utils.FindDuplicate(services, func(a, b AVS) bool { - return a.ID == b.ID - }) -} diff --git a/x/avs/types/genesis.pb.go b/x/avs/types/genesis.pb.go deleted file mode 100644 index bd6193017..000000000 --- a/x/avs/types/genesis.pb.go +++ /dev/null @@ -1,428 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: milkyway/avs/v1/genesis.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/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 avs module's genesis state. -type GenesisState struct { - // Params defines the parameters of the module. - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - // Services defines the list of actively validated services. - Services []AVS `protobuf:"bytes,2,rep,name=services,proto3" json:"services" yaml:"services"` - // NextAVSId defines the ID that will be assigned to the next AVS that gets - // created. - NextAVSID uint32 `protobuf:"varint,3,opt,name=next_avs_id,json=nextAvsId,proto3" json:"next_avs_id,omitempty"` -} - -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_e9762187afdc6843, []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 (m *GenesisState) GetServices() []AVS { - if m != nil { - return m.Services - } - return nil -} - -func (m *GenesisState) GetNextAVSID() uint32 { - if m != nil { - return m.NextAVSID - } - return 0 -} - -func init() { - proto.RegisterType((*GenesisState)(nil), "milkyway.avs.v1.GenesisState") -} - -func init() { proto.RegisterFile("milkyway/avs/v1/genesis.proto", fileDescriptor_e9762187afdc6843) } - -var fileDescriptor_e9762187afdc6843 = []byte{ - // 296 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcd, 0xcd, 0xcc, 0xc9, - 0xae, 0x2c, 0x4f, 0xac, 0xd4, 0x4f, 0x2c, 0x2b, 0xd6, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, - 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0x49, 0xeb, 0x25, 0x96, - 0x15, 0xeb, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xe5, 0xf4, 0x41, 0x2c, 0x88, - 0x32, 0x29, 0x19, 0x74, 0x53, 0x72, 0xf3, 0x53, 0x52, 0x73, 0x8a, 0x71, 0xc9, 0x16, 0x24, 0x16, - 0x25, 0xe6, 0x42, 0x65, 0x95, 0xf6, 0x33, 0x72, 0xf1, 0xb8, 0x43, 0x2c, 0x0d, 0x2e, 0x49, 0x2c, - 0x49, 0x15, 0x32, 0xe5, 0x62, 0x83, 0x28, 0x90, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x36, 0x12, 0xd7, - 0x43, 0x73, 0x84, 0x5e, 0x00, 0x58, 0xda, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x62, - 0x21, 0x4f, 0x2e, 0x8e, 0xe2, 0xd4, 0xa2, 0xb2, 0xcc, 0xe4, 0xd4, 0x62, 0x09, 0x26, 0x05, 0x66, - 0x0d, 0x6e, 0x23, 0x11, 0x0c, 0x8d, 0x8e, 0x61, 0xc1, 0x4e, 0xe2, 0x20, 0x5d, 0x9f, 0xee, 0xc9, - 0xf3, 0x57, 0x26, 0xe6, 0xe6, 0x58, 0x29, 0xc1, 0xf4, 0x28, 0x05, 0xc1, 0xb5, 0x0b, 0xe9, 0x72, - 0x71, 0xe7, 0xa5, 0x56, 0x94, 0xc4, 0x27, 0x96, 0x15, 0xc7, 0x67, 0xa6, 0x48, 0x30, 0x2b, 0x30, - 0x6a, 0xf0, 0x3a, 0xf1, 0x3e, 0xba, 0x27, 0xcf, 0xe9, 0x97, 0x5a, 0x51, 0xe2, 0x18, 0x16, 0xec, - 0xe9, 0x12, 0xc4, 0x09, 0x52, 0xe1, 0x58, 0x56, 0xec, 0x99, 0xe2, 0xe4, 0x7e, 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, 0xba, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, - 0xf9, 0xb9, 0xfa, 0x30, 0xb7, 0xe8, 0xe6, 0x24, 0x26, 0x15, 0xc3, 0x79, 0xfa, 0x15, 0xe0, 0x40, - 0x29, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x87, 0x88, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, - 0x04, 0xa4, 0xd5, 0x75, 0x95, 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 - if m.NextAVSID != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.NextAVSID)) - i-- - dAtA[i] = 0x18 - } - if len(m.Services) > 0 { - for iNdEx := len(m.Services) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Services[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - { - 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)) - if len(m.Services) > 0 { - for _, e := range m.Services { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if m.NextAVSID != 0 { - n += 1 + sovGenesis(uint64(m.NextAVSID)) - } - 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 - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Services", 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 - } - m.Services = append(m.Services, AVS{}) - if err := m.Services[len(m.Services)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NextAVSID", wireType) - } - m.NextAVSID = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.NextAVSID |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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/avs/types/genesis_test.go b/x/avs/types/genesis_test.go deleted file mode 100644 index d19f8991f..000000000 --- a/x/avs/types/genesis_test.go +++ /dev/null @@ -1,123 +0,0 @@ -package types_test - -import ( - "testing" - - sdkmath "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - - "github.com/milkyway-labs/milkyway/x/avs/types" -) - -func TestValidateGenesis(t *testing.T) { - testCases := []struct { - name string - genesis *types.GenesisState - shouldErr bool - }{ - { - name: "invalid next AVS ID returns error", - genesis: &types.GenesisState{ - NextAVSID: 0, - Services: nil, - Params: types.DefaultParams(), - }, - shouldErr: true, - }, - { - name: "duplicated service returns error", - genesis: &types.GenesisState{ - NextAVSID: 1, - Services: []types.AVS{ - { - ID: 1, - Status: types.AVS_STATUS_CREATED, - Admin: "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - Name: "MilkyWay", - }, - { - ID: 1, - Status: types.AVS_STATUS_CREATED, - Admin: "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - Name: "MilkyWay", - }}, - Params: types.DefaultParams(), - }, - shouldErr: true, - }, - { - name: "invalid service returns error", - genesis: &types.GenesisState{ - NextAVSID: 1, - Services: []types.AVS{ - { - ID: 1, - Status: types.AVS_STATUS_CREATED, - Admin: "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - Name: "MilkyWay", - }, - { - ID: 2, - Status: types.AVS_STATUS_UNSPECIFIED, - Admin: "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - Name: "IBC Relaying", - }, - }, - Params: types.DefaultParams(), - }, - shouldErr: true, - }, - { - name: "invalid params returns error", - genesis: &types.GenesisState{ - NextAVSID: 1, - Services: nil, - Params: types.Params{ - AvsRegistrationFee: sdk.Coins{sdk.Coin{Denom: "", Amount: sdkmath.NewInt(10)}}, - }, - }, - shouldErr: true, - }, - { - name: "default genesis is valid", - genesis: types.DefaultGenesis(), - shouldErr: false, - }, - { - name: "valid genesis returns no error", - genesis: &types.GenesisState{ - NextAVSID: 1, - Services: []types.AVS{ - { - ID: 1, - Status: types.AVS_STATUS_CREATED, - Admin: "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - Name: "MilkyWay", - }, - { - ID: 2, - Status: types.AVS_STATUS_REGISTERED, - Admin: "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - Name: "IBC Relaying", - }, - }, - Params: types.NewParams( - sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10))), - ), - }, - }, - } - - for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { - err := tc.genesis.Validate() - if tc.shouldErr { - require.Error(t, err) - } else { - require.NoError(t, err) - } - }) - } -} diff --git a/x/avs/types/hooks.go b/x/avs/types/hooks.go deleted file mode 100644 index fa3c5e852..000000000 --- a/x/avs/types/hooks.go +++ /dev/null @@ -1,51 +0,0 @@ -package types - -// DONTCOVER - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// Event Hooks -// These can be utilized to communicate between an avs keeper and another -// keeper which must take particular actions when AVSs change -// state. The second keeper must implement this interface, which then the -// avs keeper can call. - -// AVSHooks event hooks for avs objects (noalias) -type AVSHooks interface { - AfterAVSCreated(ctx sdk.Context, avsID uint32) // Must be called after an AVS is created - AfterAVSRegistered(ctx sdk.Context, avsID uint32) // Must be called after an AVS is registered - AfterAVSDeregistered(ctx sdk.Context, avsID uint32) // Must be called after an AVS is deregistered -} - -// -------------------------------------------------------------------------------------------------------------------- - -// MultiAVSHooks combines multiple avs hooks, all hook functions are run in array sequence -type MultiAVSHooks []AVSHooks - -// NewMultiAVSHooks creates a new MultiAVSHooks object -func NewMultiAVSHooks(hooks ...AVSHooks) MultiAVSHooks { - return hooks -} - -// AfterAVSCreated implements AVSHooks -func (m MultiAVSHooks) AfterAVSCreated(ctx sdk.Context, avsID uint32) { - for _, hook := range m { - hook.AfterAVSCreated(ctx, avsID) - } -} - -// AfterAVSRegistered implements AVSHooks -func (m MultiAVSHooks) AfterAVSRegistered(ctx sdk.Context, avsID uint32) { - for _, hook := range m { - hook.AfterAVSRegistered(ctx, avsID) - } -} - -// AfterAVSDeregistered implements AVSHooks -func (m MultiAVSHooks) AfterAVSDeregistered(ctx sdk.Context, avsID uint32) { - for _, hook := range m { - hook.AfterAVSDeregistered(ctx, avsID) - } -} diff --git a/x/avs/types/keys.go b/x/avs/types/keys.go deleted file mode 100644 index f00fa6d4a..000000000 --- a/x/avs/types/keys.go +++ /dev/null @@ -1,42 +0,0 @@ -package types - -import ( - "encoding/binary" -) - -const ( - ModuleName = "avs" - RouterKey = ModuleName - StoreKey = ModuleName - QuerierRoute = ModuleName - - DoNotModify = "[do-not-modify]" -) - -var ( - AVSPrefix = []byte{0x01} - - ParamsKey = []byte{0x10} -) - -// NextAVSIDKey returns the key for the next AVS ID -func NextAVSIDKey() []byte { - return []byte{0x01} -} - -// GetAVSIDBytes returns the byte representation of the AVS ID -func GetAVSIDBytes(avsID uint32) (avsIDBz []byte) { - avsIDBz = make([]byte, 4) - binary.BigEndian.PutUint32(avsIDBz, avsID) - return avsIDBz -} - -// GetAVSIDFromBytes returns the AVS ID from a byte array -func GetAVSIDFromBytes(bz []byte) (avsID uint32) { - return binary.BigEndian.Uint32(bz) -} - -// AVSStoreKey turns an AVS ID into a key used to store an AVS in the KVStore -func AVSStoreKey(avsID uint32) []byte { - return append(AVSPrefix, GetAVSIDBytes(avsID)...) -} diff --git a/x/avs/types/messages.go b/x/avs/types/messages.go deleted file mode 100644 index e0e9986ea..000000000 --- a/x/avs/types/messages.go +++ /dev/null @@ -1,78 +0,0 @@ -package types - -import ( - "strings" - - "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -var ( - _ sdk.Msg = &MsgRegisterService{} - _ sdk.Msg = &MsgUpdateService{} -) - -// ValidateBasic implements sdk.Msg -func (msg *MsgRegisterService) ValidateBasic() error { - if strings.TrimSpace(msg.Name) == "" || msg.Name == DoNotModify { - return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid name: %s", msg.Name) - } - - if msg.Description == DoNotModify { - return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid description") - } - - if msg.Website == DoNotModify { - return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid website") - } - - if msg.PictureURL == DoNotModify { - return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid picture URL") - } - - _, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address") - } - - return nil -} - -// GetSignBytes implements sdk.Msg -func (msg *MsgRegisterService) GetSignBytes() []byte { - return AminoCdc.MustMarshalJSON(msg) -} - -// GetSigners implements sdk.Msg -func (msg *MsgRegisterService) GetSigners() []sdk.AccAddress { - addr, _ := sdk.AccAddressFromBech32(msg.Sender) - return []sdk.AccAddress{addr} -} - -// -------------------------------------------------------------------------------------------------------------------- - -// ValidateBasic implements sdk.Msg -func (msg *MsgUpdateService) ValidateBasic() error { - if msg.ServiceID == 0 { - return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid service id: %d", msg.ServiceID) - } - - _, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address") - } - - return nil -} - -// GetSignBytes implements sdk.Msg -func (msg *MsgUpdateService) GetSignBytes() []byte { - return AminoCdc.MustMarshalJSON(msg) -} - -// GetSigners implements sdk.Msg -func (msg *MsgUpdateService) GetSigners() []sdk.AccAddress { - addr, _ := sdk.AccAddressFromBech32(msg.Sender) - return []sdk.AccAddress{addr} -} diff --git a/x/avs/types/messages.pb.go b/x/avs/types/messages.pb.go deleted file mode 100644 index fa5eca119..000000000 --- a/x/avs/types/messages.pb.go +++ /dev/null @@ -1,1380 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: milkyway/avs/v1/messages.proto - -package types - -import ( - context "context" - fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - _ "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/cosmos-sdk/types/msgservice" - _ "github.com/cosmos/cosmos-sdk/types/tx/amino" - _ "github.com/cosmos/cosmos-sdk/x/bank/types" - _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/cosmos/gogoproto/grpc" - proto "github.com/cosmos/gogoproto/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 - -// MsgRegisterServiceResponse defines the message structure for the -// RegisterService gRPC service method. It allows an account to register a new -// AVS that later on operators can opt to validate. It requires a sender address -// as well as the details of the AVS to be register. -type MsgRegisterService struct { - // Sender is the address of the user registering the AVS - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - // Name is the name of the AVS - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` - // Description is the description of the AVS (optional) - Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` - // Website is the website of the AVS (optional) - Website string `protobuf:"bytes,4,opt,name=website,proto3" json:"website,omitempty" yaml:"website"` - // PictureURL is the URL of the AVS picture (optional) - PictureURL string `protobuf:"bytes,5,opt,name=picture_url,json=pictureUrl,proto3" json:"picture_url,omitempty" yaml:"picture_url"` -} - -func (m *MsgRegisterService) Reset() { *m = MsgRegisterService{} } -func (m *MsgRegisterService) String() string { return proto.CompactTextString(m) } -func (*MsgRegisterService) ProtoMessage() {} -func (*MsgRegisterService) Descriptor() ([]byte, []int) { - return fileDescriptor_ee6728b943d8fd23, []int{0} -} -func (m *MsgRegisterService) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRegisterService) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRegisterService.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 *MsgRegisterService) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRegisterService.Merge(m, src) -} -func (m *MsgRegisterService) XXX_Size() int { - return m.Size() -} -func (m *MsgRegisterService) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRegisterService.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRegisterService proto.InternalMessageInfo - -func (m *MsgRegisterService) GetSender() string { - if m != nil { - return m.Sender - } - return "" -} - -func (m *MsgRegisterService) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *MsgRegisterService) GetDescription() string { - if m != nil { - return m.Description - } - return "" -} - -func (m *MsgRegisterService) GetWebsite() string { - if m != nil { - return m.Website - } - return "" -} - -func (m *MsgRegisterService) GetPictureURL() string { - if m != nil { - return m.PictureURL - } - return "" -} - -// MsgRegisterServiceResponse is the return value of MsgRegisterService. -// It returns the newly created AVS ID. -type MsgRegisterServiceResponse struct { - // NewServiceID is the ID of the newly registered AVS - NewServiceID uint32 `protobuf:"varint,1,opt,name=new_service_id,json=newServiceId,proto3" json:"new_service_id,omitempty"` -} - -func (m *MsgRegisterServiceResponse) Reset() { *m = MsgRegisterServiceResponse{} } -func (m *MsgRegisterServiceResponse) String() string { return proto.CompactTextString(m) } -func (*MsgRegisterServiceResponse) ProtoMessage() {} -func (*MsgRegisterServiceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ee6728b943d8fd23, []int{1} -} -func (m *MsgRegisterServiceResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRegisterServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRegisterServiceResponse.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 *MsgRegisterServiceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRegisterServiceResponse.Merge(m, src) -} -func (m *MsgRegisterServiceResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgRegisterServiceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRegisterServiceResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRegisterServiceResponse proto.InternalMessageInfo - -func (m *MsgRegisterServiceResponse) GetNewServiceID() uint32 { - if m != nil { - return m.NewServiceID - } - return 0 -} - -// MsgUpdateService defines the message structure for the UpdateService gRPC -// service method. It allows the AVS owner to update the details of -// an existing AVS. -type MsgUpdateService struct { - // Sender is the address of the user updating the AVS - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - // ID represents the ID of the AVS to be updated - ServiceID uint32 `protobuf:"varint,2,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` - // Name is the new name of the AVS (optional). - // If it shouldn't be changed, use [do-not-modify] instead. - Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` - // Description is the new description of the AVS (optional) - // If it shouldn't be changed, use [do-not-modify] instead. - Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` - // Website is the new website of the AVS (optional) - // If it shouldn't be changed, use [do-not-modify] instead. - Website string `protobuf:"bytes,5,opt,name=website,proto3" json:"website,omitempty" yaml:"website"` - // PictureURL is the new URL of the AVS picture (optional) - // If it shouldn't be changed, use [do-not-modify] instead. - PictureURL string `protobuf:"bytes,6,opt,name=picture_url,json=pictureUrl,proto3" json:"picture_url,omitempty" yaml:"picture_url"` -} - -func (m *MsgUpdateService) Reset() { *m = MsgUpdateService{} } -func (m *MsgUpdateService) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateService) ProtoMessage() {} -func (*MsgUpdateService) Descriptor() ([]byte, []int) { - return fileDescriptor_ee6728b943d8fd23, []int{2} -} -func (m *MsgUpdateService) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateService) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateService.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 *MsgUpdateService) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateService.Merge(m, src) -} -func (m *MsgUpdateService) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateService) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateService.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateService proto.InternalMessageInfo - -func (m *MsgUpdateService) GetSender() string { - if m != nil { - return m.Sender - } - return "" -} - -func (m *MsgUpdateService) GetServiceID() uint32 { - if m != nil { - return m.ServiceID - } - return 0 -} - -func (m *MsgUpdateService) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *MsgUpdateService) GetDescription() string { - if m != nil { - return m.Description - } - return "" -} - -func (m *MsgUpdateService) GetWebsite() string { - if m != nil { - return m.Website - } - return "" -} - -func (m *MsgUpdateService) GetPictureURL() string { - if m != nil { - return m.PictureURL - } - return "" -} - -// MsgUpdateServiceResponse is the return value of MsgUpdateService. -type MsgUpdateServiceResponse struct { -} - -func (m *MsgUpdateServiceResponse) Reset() { *m = MsgUpdateServiceResponse{} } -func (m *MsgUpdateServiceResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateServiceResponse) ProtoMessage() {} -func (*MsgUpdateServiceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ee6728b943d8fd23, []int{3} -} -func (m *MsgUpdateServiceResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateServiceResponse.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 *MsgUpdateServiceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateServiceResponse.Merge(m, src) -} -func (m *MsgUpdateServiceResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateServiceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateServiceResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateServiceResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*MsgRegisterService)(nil), "milkyway.avs.v1.MsgRegisterService") - proto.RegisterType((*MsgRegisterServiceResponse)(nil), "milkyway.avs.v1.MsgRegisterServiceResponse") - proto.RegisterType((*MsgUpdateService)(nil), "milkyway.avs.v1.MsgUpdateService") - proto.RegisterType((*MsgUpdateServiceResponse)(nil), "milkyway.avs.v1.MsgUpdateServiceResponse") -} - -func init() { proto.RegisterFile("milkyway/avs/v1/messages.proto", fileDescriptor_ee6728b943d8fd23) } - -var fileDescriptor_ee6728b943d8fd23 = []byte{ - // 587 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x3b, 0x8f, 0xd3, 0x4c, - 0x14, 0x5d, 0x67, 0x1f, 0x9f, 0x76, 0xf6, 0xf9, 0x59, 0x2b, 0xf0, 0x1a, 0x64, 0x83, 0x97, 0x82, - 0x7d, 0xc4, 0x26, 0x20, 0x21, 0xb4, 0x1d, 0x11, 0x08, 0x21, 0x11, 0x84, 0xbc, 0xa4, 0x41, 0x42, - 0xd1, 0xd8, 0x1e, 0x99, 0xd1, 0xc6, 0x0f, 0xf9, 0x3a, 0x0e, 0xe9, 0x10, 0x25, 0x15, 0x3f, 0x25, - 0x05, 0xff, 0x01, 0xca, 0x88, 0x8a, 0xca, 0x42, 0x4e, 0x91, 0x9a, 0xfc, 0x02, 0x94, 0xf1, 0x38, - 0x4f, 0x24, 0xd8, 0x34, 0x51, 0xce, 0x3d, 0xe7, 0xce, 0x99, 0xb9, 0x67, 0x3c, 0x48, 0xf1, 0x68, - 0xf3, 0xb2, 0xd3, 0xc6, 0x1d, 0x03, 0x27, 0x60, 0x24, 0x15, 0xc3, 0x23, 0x00, 0xd8, 0x25, 0xa0, - 0x87, 0x51, 0x10, 0x07, 0xe2, 0x5e, 0xc1, 0xeb, 0x38, 0x01, 0x3d, 0xa9, 0xc8, 0xff, 0x63, 0x8f, - 0xfa, 0x81, 0xc1, 0x7e, 0x73, 0x8d, 0x7c, 0x68, 0x07, 0xe0, 0x05, 0xd0, 0x60, 0xc8, 0xc8, 0x01, - 0xa7, 0x94, 0x1c, 0x19, 0x16, 0x06, 0x62, 0x24, 0x15, 0x8b, 0xc4, 0xb8, 0x62, 0xd8, 0x01, 0xf5, - 0x17, 0x78, 0xff, 0x72, 0xcc, 0x8f, 0x00, 0xe7, 0xaf, 0x73, 0xde, 0x03, 0x97, 0x6d, 0x0e, 0x5c, - 0x4e, 0x1c, 0xb8, 0x81, 0x1b, 0xe4, 0x86, 0xa3, 0x7f, 0xbc, 0x7a, 0x73, 0xfe, 0x34, 0x21, 0x8e, - 0xb0, 0xc7, 0x37, 0xa3, 0x7d, 0x2d, 0x21, 0xb1, 0x06, 0xae, 0x49, 0x5c, 0x0a, 0x31, 0x89, 0x2e, - 0x48, 0x94, 0x50, 0x9b, 0x88, 0xf7, 0xd0, 0x06, 0x10, 0xdf, 0x21, 0x91, 0x24, 0xdc, 0x12, 0xee, - 0x6e, 0x56, 0xa5, 0xef, 0x5f, 0xca, 0x07, 0xfc, 0x14, 0x8f, 0x1d, 0x27, 0x22, 0x00, 0x17, 0x71, - 0x44, 0x7d, 0xd7, 0xe4, 0x3a, 0xf1, 0x08, 0xad, 0xf9, 0xd8, 0x23, 0x52, 0x89, 0xe9, 0xf7, 0x86, - 0xa9, 0xba, 0xd5, 0xc1, 0x5e, 0xf3, 0x5c, 0x1b, 0x55, 0x35, 0x93, 0x91, 0xe2, 0x23, 0xb4, 0xe5, - 0x10, 0xb0, 0x23, 0x1a, 0xc6, 0x34, 0xf0, 0xa5, 0x55, 0xa6, 0xbd, 0x36, 0x4c, 0x55, 0x31, 0xd7, - 0x4e, 0x91, 0x9a, 0x39, 0x2d, 0x15, 0xcf, 0xd0, 0x7f, 0x6d, 0x62, 0x01, 0x8d, 0x89, 0xb4, 0xc6, - 0xba, 0xc4, 0x61, 0xaa, 0xee, 0xe6, 0x5d, 0x9c, 0xd0, 0xcc, 0x42, 0x22, 0x3e, 0x45, 0x5b, 0x21, - 0xb5, 0xe3, 0x56, 0x44, 0x1a, 0xad, 0xa8, 0x29, 0xad, 0xb3, 0x8e, 0x3b, 0x59, 0xaa, 0xa2, 0x57, - 0x79, 0xb9, 0x6e, 0xbe, 0x98, 0xb8, 0x4e, 0x49, 0x35, 0x13, 0x71, 0x54, 0x8f, 0x9a, 0xe7, 0xa7, - 0x1f, 0x07, 0xdd, 0x13, 0x7e, 0xc0, 0x4f, 0x83, 0xee, 0xc9, 0x8d, 0xf1, 0x28, 0x17, 0x47, 0xa6, - 0xbd, 0x46, 0xf2, 0x62, 0xd5, 0x24, 0x10, 0x06, 0x3e, 0x10, 0xf1, 0x21, 0xda, 0xf5, 0x49, 0xbb, - 0x01, 0x79, 0xb9, 0x41, 0x1d, 0x36, 0xd8, 0x9d, 0xea, 0x7e, 0x96, 0xaa, 0xdb, 0x2f, 0x49, 0x9b, - 0xeb, 0x9f, 0x3f, 0x31, 0xb7, 0xfd, 0x09, 0x72, 0xb4, 0x5f, 0x25, 0xb4, 0x5f, 0x03, 0xb7, 0x1e, - 0x3a, 0x38, 0x26, 0xcb, 0xa7, 0x73, 0x86, 0xd0, 0x94, 0x75, 0x89, 0x59, 0xef, 0x64, 0xa9, 0xba, - 0x39, 0xf1, 0xdd, 0x84, 0xc2, 0x74, 0x9c, 0xe5, 0xea, 0x15, 0xb2, 0x5c, 0x5b, 0x2a, 0xcb, 0xf5, - 0x2b, 0x67, 0xb9, 0xb1, 0x64, 0x96, 0xc7, 0x73, 0x59, 0x1e, 0x4e, 0x67, 0x39, 0x33, 0x5e, 0x4d, - 0x46, 0xd2, 0x7c, 0xad, 0xc8, 0xf1, 0x7e, 0x4f, 0x40, 0xab, 0x35, 0x70, 0x45, 0x1b, 0xed, 0xcd, - 0x7f, 0x33, 0x47, 0xfa, 0xdc, 0xbb, 0xa0, 0x2f, 0xde, 0x07, 0xf9, 0xf4, 0x1f, 0x44, 0xe3, 0x4b, - 0xf3, 0x16, 0xed, 0xcc, 0x06, 0x7f, 0xfb, 0x4f, 0xdd, 0x33, 0x12, 0xf9, 0xf8, 0xaf, 0x92, 0x62, - 0x79, 0x79, 0xfd, 0xc3, 0xa0, 0x7b, 0x22, 0x54, 0x9f, 0x7d, 0xcb, 0x14, 0xa1, 0x97, 0x29, 0xc2, - 0xcf, 0x4c, 0x11, 0x3e, 0xf7, 0x95, 0x95, 0x5e, 0x5f, 0x59, 0xf9, 0xd1, 0x57, 0x56, 0xde, 0x94, - 0x5d, 0x1a, 0xbf, 0x6b, 0x59, 0xba, 0x1d, 0x78, 0x46, 0xb1, 0x6a, 0xb9, 0x89, 0x2d, 0x18, 0x23, - 0xe3, 0x3d, 0x7b, 0x55, 0xe2, 0x4e, 0x48, 0xc0, 0xda, 0x60, 0x4f, 0xca, 0x83, 0xdf, 0x01, 0x00, - 0x00, 0xff, 0xff, 0x08, 0xe4, 0x2d, 0x1e, 0x40, 0x05, 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 { - RegisterService(ctx context.Context, in *MsgRegisterService, opts ...grpc.CallOption) (*MsgRegisterServiceResponse, error) - UpdateService(ctx context.Context, in *MsgUpdateService, opts ...grpc.CallOption) (*MsgUpdateServiceResponse, error) -} - -type msgClient struct { - cc grpc1.ClientConn -} - -func NewMsgClient(cc grpc1.ClientConn) MsgClient { - return &msgClient{cc} -} - -func (c *msgClient) RegisterService(ctx context.Context, in *MsgRegisterService, opts ...grpc.CallOption) (*MsgRegisterServiceResponse, error) { - out := new(MsgRegisterServiceResponse) - err := c.cc.Invoke(ctx, "/milkyway.avs.v1.Msg/RegisterService", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) UpdateService(ctx context.Context, in *MsgUpdateService, opts ...grpc.CallOption) (*MsgUpdateServiceResponse, error) { - out := new(MsgUpdateServiceResponse) - err := c.cc.Invoke(ctx, "/milkyway.avs.v1.Msg/UpdateService", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MsgServer is the server API for Msg service. -type MsgServer interface { - RegisterService(context.Context, *MsgRegisterService) (*MsgRegisterServiceResponse, error) - UpdateService(context.Context, *MsgUpdateService) (*MsgUpdateServiceResponse, error) -} - -// UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} - -func (*UnimplementedMsgServer) RegisterService(ctx context.Context, req *MsgRegisterService) (*MsgRegisterServiceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RegisterService not implemented") -} -func (*UnimplementedMsgServer) UpdateService(ctx context.Context, req *MsgUpdateService) (*MsgUpdateServiceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateService not implemented") -} - -func RegisterMsgServer(s grpc1.Server, srv MsgServer) { - s.RegisterService(&_Msg_serviceDesc, srv) -} - -func _Msg_RegisterService_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgRegisterService) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).RegisterService(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/milkyway.avs.v1.Msg/RegisterService", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).RegisterService(ctx, req.(*MsgRegisterService)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_UpdateService_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateService) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateService(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/milkyway.avs.v1.Msg/UpdateService", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateService(ctx, req.(*MsgUpdateService)) - } - return interceptor(ctx, in, info, handler) -} - -var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "milkyway.avs.v1.Msg", - HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "RegisterService", - Handler: _Msg_RegisterService_Handler, - }, - { - MethodName: "UpdateService", - Handler: _Msg_UpdateService_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "milkyway/avs/v1/messages.proto", -} - -func (m *MsgRegisterService) 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 *MsgRegisterService) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRegisterService) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.PictureURL) > 0 { - i -= len(m.PictureURL) - copy(dAtA[i:], m.PictureURL) - i = encodeVarintMessages(dAtA, i, uint64(len(m.PictureURL))) - i-- - dAtA[i] = 0x2a - } - if len(m.Website) > 0 { - i -= len(m.Website) - copy(dAtA[i:], m.Website) - i = encodeVarintMessages(dAtA, i, uint64(len(m.Website))) - i-- - dAtA[i] = 0x22 - } - if len(m.Description) > 0 { - i -= len(m.Description) - copy(dAtA[i:], m.Description) - i = encodeVarintMessages(dAtA, i, uint64(len(m.Description))) - i-- - dAtA[i] = 0x1a - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintMessages(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0x12 - } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintMessages(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgRegisterServiceResponse) 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 *MsgRegisterServiceResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRegisterServiceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.NewServiceID != 0 { - i = encodeVarintMessages(dAtA, i, uint64(m.NewServiceID)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *MsgUpdateService) 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 *MsgUpdateService) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateService) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.PictureURL) > 0 { - i -= len(m.PictureURL) - copy(dAtA[i:], m.PictureURL) - i = encodeVarintMessages(dAtA, i, uint64(len(m.PictureURL))) - i-- - dAtA[i] = 0x32 - } - if len(m.Website) > 0 { - i -= len(m.Website) - copy(dAtA[i:], m.Website) - i = encodeVarintMessages(dAtA, i, uint64(len(m.Website))) - i-- - dAtA[i] = 0x2a - } - if len(m.Description) > 0 { - i -= len(m.Description) - copy(dAtA[i:], m.Description) - i = encodeVarintMessages(dAtA, i, uint64(len(m.Description))) - i-- - dAtA[i] = 0x22 - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintMessages(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0x1a - } - if m.ServiceID != 0 { - i = encodeVarintMessages(dAtA, i, uint64(m.ServiceID)) - i-- - dAtA[i] = 0x10 - } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintMessages(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUpdateServiceResponse) 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 *MsgUpdateServiceResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateServiceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func encodeVarintMessages(dAtA []byte, offset int, v uint64) int { - offset -= sovMessages(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *MsgRegisterService) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovMessages(uint64(l)) - } - l = len(m.Name) - if l > 0 { - n += 1 + l + sovMessages(uint64(l)) - } - l = len(m.Description) - if l > 0 { - n += 1 + l + sovMessages(uint64(l)) - } - l = len(m.Website) - if l > 0 { - n += 1 + l + sovMessages(uint64(l)) - } - l = len(m.PictureURL) - if l > 0 { - n += 1 + l + sovMessages(uint64(l)) - } - return n -} - -func (m *MsgRegisterServiceResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.NewServiceID != 0 { - n += 1 + sovMessages(uint64(m.NewServiceID)) - } - return n -} - -func (m *MsgUpdateService) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovMessages(uint64(l)) - } - if m.ServiceID != 0 { - n += 1 + sovMessages(uint64(m.ServiceID)) - } - l = len(m.Name) - if l > 0 { - n += 1 + l + sovMessages(uint64(l)) - } - l = len(m.Description) - if l > 0 { - n += 1 + l + sovMessages(uint64(l)) - } - l = len(m.Website) - if l > 0 { - n += 1 + l + sovMessages(uint64(l)) - } - l = len(m.PictureURL) - if l > 0 { - n += 1 + l + sovMessages(uint64(l)) - } - return n -} - -func (m *MsgUpdateServiceResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func sovMessages(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozMessages(x uint64) (n int) { - return sovMessages(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *MsgRegisterService) 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 ErrIntOverflowMessages - } - 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: MsgRegisterService: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRegisterService: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessages - } - 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 ErrInvalidLengthMessages - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMessages - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Sender = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessages - } - 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 ErrInvalidLengthMessages - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMessages - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessages - } - 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 ErrInvalidLengthMessages - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMessages - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Description = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Website", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessages - } - 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 ErrInvalidLengthMessages - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMessages - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Website = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PictureURL", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessages - } - 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 ErrInvalidLengthMessages - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMessages - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PictureURL = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMessages(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMessages - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgRegisterServiceResponse) 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 ErrIntOverflowMessages - } - 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: MsgRegisterServiceResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRegisterServiceResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NewServiceID", wireType) - } - m.NewServiceID = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessages - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.NewServiceID |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipMessages(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMessages - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgUpdateService) 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 ErrIntOverflowMessages - } - 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: MsgUpdateService: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateService: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessages - } - 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 ErrInvalidLengthMessages - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMessages - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Sender = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ServiceID", wireType) - } - m.ServiceID = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessages - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ServiceID |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessages - } - 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 ErrInvalidLengthMessages - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMessages - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessages - } - 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 ErrInvalidLengthMessages - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMessages - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Description = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Website", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessages - } - 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 ErrInvalidLengthMessages - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMessages - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Website = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PictureURL", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessages - } - 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 ErrInvalidLengthMessages - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMessages - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PictureURL = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMessages(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMessages - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgUpdateServiceResponse) 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 ErrIntOverflowMessages - } - 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: MsgUpdateServiceResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateServiceResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipMessages(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMessages - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipMessages(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, ErrIntOverflowMessages - } - 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, ErrIntOverflowMessages - } - 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, ErrIntOverflowMessages - } - 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, ErrInvalidLengthMessages - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupMessages - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthMessages - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthMessages = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowMessages = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupMessages = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/avs/types/models.go b/x/avs/types/models.go deleted file mode 100644 index 7bdcf2a47..000000000 --- a/x/avs/types/models.go +++ /dev/null @@ -1,105 +0,0 @@ -package types - -import ( - "fmt" - "strings" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// NewAVS creates a new AVS instance -func NewAVS( - id uint32, - status AVSStatus, - name string, - description string, - website string, - pictureURL string, - admin string, -) AVS { - return AVS{ - ID: id, - Status: status, - Name: name, - Description: description, - Website: website, - PictureURL: pictureURL, - Admin: admin, - } -} - -// Validate checks that the AVS has valid values. -func (a *AVS) Validate() error { - if a.Status == AVS_STATUS_UNSPECIFIED { - return fmt.Errorf("invalid status: %s", a.Status) - } - - if a.ID == 0 { - return fmt.Errorf("invalid id: %d", a.ID) - } - - if strings.TrimSpace(a.Name) == "" { - return fmt.Errorf("invalid name: %s", a.Name) - } - - _, err := sdk.AccAddressFromBech32(a.Admin) - if err != nil { - return fmt.Errorf("invalid admin address") - } - - return nil -} - -// -------------------------------------------------------------------------------------------------------------------- - -// AVSUpdate defines the fields that can be updated in an AVS. -type AVSUpdate struct { - Name string - Description string - Website string - PictureURL string -} - -// NewAVSUpdate returns a new AVSUpdate instance. -func NewAVSUpdate( - name string, - description string, - website string, - pictureURL string, -) AVSUpdate { - return AVSUpdate{ - Name: name, - Description: description, - Website: website, - PictureURL: pictureURL, - } -} - -// Update returns a new AVS with updated fields. -func (a *AVS) Update(update AVSUpdate) AVS { - if update.Name == DoNotModify { - update.Name = a.Name - } - - if update.Description == DoNotModify { - update.Description = a.Description - } - - if update.Website == DoNotModify { - update.Website = a.Website - } - - if update.PictureURL == DoNotModify { - update.PictureURL = a.PictureURL - } - - return NewAVS( - a.ID, - a.Status, - update.Name, - update.Description, - update.Website, - update.PictureURL, - a.Admin, - ) -} diff --git a/x/avs/types/models.pb.go b/x/avs/types/models.pb.go deleted file mode 100644 index c53a8355e..000000000 --- a/x/avs/types/models.pb.go +++ /dev/null @@ -1,651 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: milkyway/avs/v1/models.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/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 - -// AVSStatus defines the status of an AVS -type AVSStatus int32 - -const ( - // AVS_STATUS_UNSPECIFIED defines the AVS status is unspecified - AVS_STATUS_UNSPECIFIED AVSStatus = 0 - // AVS_STATUS_CREATED defines the AVS status is created - AVS_STATUS_CREATED AVSStatus = 1 - // AVS_STATUS_REGISTERED defines the AVS status is updated - AVS_STATUS_REGISTERED AVSStatus = 2 - // AVS_STATUS_UNREGISTERED defines the AVS status is unregistered - AVS_STATUS_UNREGISTERED AVSStatus = 3 -) - -var AVSStatus_name = map[int32]string{ - 0: "AVS_STATUS_UNSPECIFIED", - 1: "AVS_STATUS_CREATED", - 2: "AVS_STATUS_REGISTERED", - 3: "AVS_STATUS_UNREGISTERED", -} - -var AVSStatus_value = map[string]int32{ - "AVS_STATUS_UNSPECIFIED": 0, - "AVS_STATUS_CREATED": 1, - "AVS_STATUS_REGISTERED": 2, - "AVS_STATUS_UNREGISTERED": 3, -} - -func (x AVSStatus) String() string { - return proto.EnumName(AVSStatus_name, int32(x)) -} - -func (AVSStatus) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_85e2c65ca3819b2c, []int{0} -} - -// AVS defines the fields of an AVS -type AVS struct { - // ID is the auto-generated unique identifier for the AVS - ID uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // Status is the status of the AVS - Status AVSStatus `protobuf:"varint,2,opt,name=status,proto3,enum=milkyway.avs.v1.AVSStatus" json:"status,omitempty"` - // Admin is the address of the user that has registered the AVS - Admin string `protobuf:"bytes,3,opt,name=admin,proto3" json:"admin,omitempty"` - // Name is the name of the AVS - Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` - // Description is the description of the AVS (optional) - Description string `protobuf:"bytes,5,opt,name=description,proto3" json:"description,omitempty"` - // Website is the website of the AVS (optional) - Website string `protobuf:"bytes,6,opt,name=website,proto3" json:"website,omitempty"` - // PictureURL is the URL of the picture of the AVS (optional) - PictureURL string `protobuf:"bytes,7,opt,name=pictureURL,proto3" json:"pictureURL,omitempty"` -} - -func (m *AVS) Reset() { *m = AVS{} } -func (m *AVS) String() string { return proto.CompactTextString(m) } -func (*AVS) ProtoMessage() {} -func (*AVS) Descriptor() ([]byte, []int) { - return fileDescriptor_85e2c65ca3819b2c, []int{0} -} -func (m *AVS) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *AVS) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_AVS.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 *AVS) XXX_Merge(src proto.Message) { - xxx_messageInfo_AVS.Merge(m, src) -} -func (m *AVS) XXX_Size() int { - return m.Size() -} -func (m *AVS) XXX_DiscardUnknown() { - xxx_messageInfo_AVS.DiscardUnknown(m) -} - -var xxx_messageInfo_AVS proto.InternalMessageInfo - -func (m *AVS) GetID() uint32 { - if m != nil { - return m.ID - } - return 0 -} - -func (m *AVS) GetStatus() AVSStatus { - if m != nil { - return m.Status - } - return AVS_STATUS_UNSPECIFIED -} - -func (m *AVS) GetAdmin() string { - if m != nil { - return m.Admin - } - return "" -} - -func (m *AVS) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *AVS) GetDescription() string { - if m != nil { - return m.Description - } - return "" -} - -func (m *AVS) GetWebsite() string { - if m != nil { - return m.Website - } - return "" -} - -func (m *AVS) GetPictureURL() string { - if m != nil { - return m.PictureURL - } - return "" -} - -func init() { - proto.RegisterEnum("milkyway.avs.v1.AVSStatus", AVSStatus_name, AVSStatus_value) - proto.RegisterType((*AVS)(nil), "milkyway.avs.v1.AVS") -} - -func init() { proto.RegisterFile("milkyway/avs/v1/models.proto", fileDescriptor_85e2c65ca3819b2c) } - -var fileDescriptor_85e2c65ca3819b2c = []byte{ - // 407 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0xcf, 0x6e, 0xd3, 0x30, - 0x1c, 0xc7, 0xe3, 0xb4, 0xeb, 0x34, 0x23, 0xa0, 0xb2, 0x46, 0xf1, 0x02, 0x32, 0x15, 0xa7, 0x0a, - 0xa9, 0x89, 0x36, 0x9e, 0x20, 0x5d, 0xc3, 0x54, 0x09, 0x21, 0x64, 0xb7, 0x3d, 0x70, 0xa9, 0xf2, - 0xc7, 0x0a, 0x16, 0x4d, 0x1c, 0xc5, 0x6e, 0x46, 0x0f, 0xdc, 0x39, 0xf2, 0x0e, 0xbc, 0x02, 0x0f, - 0xc1, 0x71, 0xe2, 0xc4, 0x09, 0xa1, 0xf4, 0x09, 0x78, 0x03, 0x34, 0x67, 0xad, 0x02, 0xb7, 0xdf, - 0xf7, 0xfb, 0xf9, 0x28, 0xbf, 0xc8, 0x36, 0x7c, 0x9a, 0x89, 0xf5, 0x87, 0xed, 0x75, 0xb8, 0xf5, - 0xc2, 0x4a, 0x79, 0xd5, 0xb9, 0x97, 0xc9, 0x84, 0xaf, 0x95, 0x5b, 0x94, 0x52, 0x4b, 0xf4, 0x70, - 0x4f, 0xdd, 0xb0, 0x52, 0x6e, 0x75, 0xee, 0x9c, 0xa6, 0x32, 0x95, 0x86, 0x79, 0xb7, 0x53, 0xa3, - 0x39, 0x67, 0xb1, 0x54, 0x99, 0x54, 0xab, 0x06, 0x34, 0xa1, 0x41, 0xcf, 0xff, 0x00, 0xd8, 0xf1, - 0x97, 0x0c, 0x0d, 0xa0, 0x2d, 0x12, 0x0c, 0x86, 0x60, 0x74, 0x7f, 0xd2, 0xab, 0x7f, 0x3d, 0xb3, - 0x67, 0x53, 0x6a, 0x8b, 0x04, 0x5d, 0xc0, 0x9e, 0xd2, 0xa1, 0xde, 0x28, 0x6c, 0x0f, 0xc1, 0xe8, - 0xc1, 0x85, 0xe3, 0xfe, 0xb7, 0xd2, 0xf5, 0x97, 0x8c, 0x19, 0x83, 0xde, 0x99, 0xc8, 0x85, 0x47, - 0x61, 0x92, 0x89, 0x1c, 0x77, 0x86, 0x60, 0x74, 0x32, 0xc1, 0x3f, 0xbe, 0x8d, 0x4f, 0xef, 0x96, - 0xfa, 0x49, 0x52, 0x72, 0xa5, 0x98, 0x2e, 0x45, 0x9e, 0xd2, 0x46, 0x43, 0x08, 0x76, 0xf3, 0x30, - 0xe3, 0xb8, 0x7b, 0xab, 0x53, 0x33, 0xa3, 0x21, 0xbc, 0x97, 0x70, 0x15, 0x97, 0xa2, 0xd0, 0x42, - 0xe6, 0xf8, 0xc8, 0xa0, 0x76, 0x85, 0x30, 0x3c, 0xbe, 0xe6, 0x91, 0x12, 0x9a, 0xe3, 0x9e, 0xa1, - 0xfb, 0x88, 0x08, 0x84, 0x85, 0x88, 0xf5, 0xa6, 0xe4, 0x0b, 0xfa, 0x1a, 0x1f, 0x1b, 0xd8, 0x6a, - 0x5e, 0x7c, 0x82, 0x27, 0x87, 0x9f, 0x46, 0x0e, 0x1c, 0xf8, 0x4b, 0xb6, 0x62, 0x73, 0x7f, 0xbe, - 0x60, 0xab, 0xc5, 0x1b, 0xf6, 0x36, 0xb8, 0x9c, 0xbd, 0x9a, 0x05, 0xd3, 0xbe, 0x85, 0x06, 0x10, - 0xb5, 0xd8, 0x25, 0x0d, 0xfc, 0x79, 0x30, 0xed, 0x03, 0x74, 0x06, 0x1f, 0xb5, 0x7a, 0x1a, 0x5c, - 0xcd, 0xd8, 0x3c, 0xa0, 0xc1, 0xb4, 0x6f, 0xa3, 0x27, 0xf0, 0xf1, 0x3f, 0x9f, 0x6b, 0xc1, 0x8e, - 0xd3, 0xfd, 0xfc, 0x95, 0x58, 0x93, 0xab, 0xef, 0x35, 0x01, 0x37, 0x35, 0x01, 0xbf, 0x6b, 0x02, - 0xbe, 0xec, 0x88, 0x75, 0xb3, 0x23, 0xd6, 0xcf, 0x1d, 0xb1, 0xde, 0x8d, 0x53, 0xa1, 0xdf, 0x6f, - 0x22, 0x37, 0x96, 0x99, 0xb7, 0x3f, 0xe6, 0xf1, 0x3a, 0x8c, 0xd4, 0x21, 0x79, 0x1f, 0xcd, 0x3b, - 0xd0, 0xdb, 0x82, 0xab, 0xa8, 0x67, 0xae, 0xf0, 0xe5, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x38, - 0x4f, 0x20, 0x19, 0x24, 0x02, 0x00, 0x00, -} - -func (m *AVS) 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 *AVS) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AVS) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.PictureURL) > 0 { - i -= len(m.PictureURL) - copy(dAtA[i:], m.PictureURL) - i = encodeVarintModels(dAtA, i, uint64(len(m.PictureURL))) - i-- - dAtA[i] = 0x3a - } - if len(m.Website) > 0 { - i -= len(m.Website) - copy(dAtA[i:], m.Website) - i = encodeVarintModels(dAtA, i, uint64(len(m.Website))) - i-- - dAtA[i] = 0x32 - } - if len(m.Description) > 0 { - i -= len(m.Description) - copy(dAtA[i:], m.Description) - i = encodeVarintModels(dAtA, i, uint64(len(m.Description))) - i-- - dAtA[i] = 0x2a - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintModels(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0x22 - } - if len(m.Admin) > 0 { - i -= len(m.Admin) - copy(dAtA[i:], m.Admin) - i = encodeVarintModels(dAtA, i, uint64(len(m.Admin))) - i-- - dAtA[i] = 0x1a - } - if m.Status != 0 { - i = encodeVarintModels(dAtA, i, uint64(m.Status)) - i-- - dAtA[i] = 0x10 - } - if m.ID != 0 { - i = encodeVarintModels(dAtA, i, uint64(m.ID)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintModels(dAtA []byte, offset int, v uint64) int { - offset -= sovModels(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *AVS) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ID != 0 { - n += 1 + sovModels(uint64(m.ID)) - } - if m.Status != 0 { - n += 1 + sovModels(uint64(m.Status)) - } - l = len(m.Admin) - if l > 0 { - n += 1 + l + sovModels(uint64(l)) - } - l = len(m.Name) - if l > 0 { - n += 1 + l + sovModels(uint64(l)) - } - l = len(m.Description) - if l > 0 { - n += 1 + l + sovModels(uint64(l)) - } - l = len(m.Website) - if l > 0 { - n += 1 + l + sovModels(uint64(l)) - } - l = len(m.PictureURL) - if l > 0 { - n += 1 + l + sovModels(uint64(l)) - } - return n -} - -func sovModels(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozModels(x uint64) (n int) { - return sovModels(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *AVS) 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 ErrIntOverflowModels - } - 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: AVS: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AVS: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) - } - m.ID = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ID |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - m.Status = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Status |= AVSStatus(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - 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 ErrInvalidLengthModels - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthModels - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Admin = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - 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 ErrInvalidLengthModels - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthModels - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - 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 ErrInvalidLengthModels - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthModels - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Description = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Website", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - 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 ErrInvalidLengthModels - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthModels - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Website = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PictureURL", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - 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 ErrInvalidLengthModels - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthModels - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PictureURL = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipModels(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthModels - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipModels(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, ErrIntOverflowModels - } - 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, ErrIntOverflowModels - } - 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, ErrIntOverflowModels - } - 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, ErrInvalidLengthModels - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupModels - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthModels - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthModels = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowModels = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupModels = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/avs/types/models_test.go b/x/avs/types/models_test.go deleted file mode 100644 index 4f39d6555..000000000 --- a/x/avs/types/models_test.go +++ /dev/null @@ -1,80 +0,0 @@ -package types_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/milkyway-labs/milkyway/x/avs/types" -) - -func TestAVS_Validate(t *testing.T) { - testCases := []struct { - name string - avs types.AVS - shouldErr bool - }{ - { - name: "invalid status returns error", - avs: types.AVS{ - ID: 1, - Status: types.AVS_STATUS_UNSPECIFIED, - Admin: "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - Name: "MilkyWay", - }, - shouldErr: true, - }, - { - name: "invalid ID returns error", - avs: types.AVS{ - ID: 0, - Status: types.AVS_STATUS_CREATED, - Admin: "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - Name: "MilkyWay", - }, - shouldErr: true, - }, - { - name: "invalid name returns error", - avs: types.AVS{ - ID: 1, - Status: types.AVS_STATUS_CREATED, - Admin: "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - Name: "", - }, - shouldErr: true, - }, - { - name: "invalid address returns error", - avs: types.AVS{ - ID: 1, - Status: types.AVS_STATUS_CREATED, - Admin: "", - Name: "MilkyWay", - }, - shouldErr: true, - }, - { - name: "valid AVS returns no error", - avs: types.AVS{ - ID: 1, - Status: types.AVS_STATUS_CREATED, - Admin: "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - Name: "MilkyWay", - }, - shouldErr: false, - }, - } - - for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { - err := tc.avs.Validate() - if tc.shouldErr { - require.Error(t, err) - } else { - require.NoError(t, err) - } - }) - } -} diff --git a/x/avs/types/params.go b/x/avs/types/params.go deleted file mode 100644 index 1222104df..000000000 --- a/x/avs/types/params.go +++ /dev/null @@ -1,30 +0,0 @@ -package types - -import ( - "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -// NewParams creates a new Params object -func NewParams(avsRegistrationFee sdk.Coins) Params { - return Params{ - AvsRegistrationFee: avsRegistrationFee, - } -} - -// DefaultParams returns a default set of parameters. -func DefaultParams() Params { - return Params{ - AvsRegistrationFee: sdk.NewCoins(), - } -} - -// Validate checks that the parameters have valid values. -func (p *Params) Validate() error { - if !p.AvsRegistrationFee.IsValid() { - return errors.Wrapf(sdkerrors.ErrInvalidCoins, "invalid AVS registration fee: %s", p.AvsRegistrationFee) - } - - return nil -} diff --git a/x/avs/types/params.pb.go b/x/avs/types/params.pb.go deleted file mode 100644 index 3db84ca17..000000000 --- a/x/avs/types/params.pb.go +++ /dev/null @@ -1,341 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: milkyway/avs/v1/params.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/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 avs module. -type Params struct { - // AvsCreationFee defines the fee to register a new AVS. The fee is - // drawn from the MsgRegisterAVS creator's account, and transferred - // to the community pool. - AvsRegistrationFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=avs_registration_fee,json=avsRegistrationFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"avs_registration_fee" yaml:"avs_registration_fee"` -} - -func (m *Params) Reset() { *m = Params{} } -func (m *Params) String() string { return proto.CompactTextString(m) } -func (*Params) ProtoMessage() {} -func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_1c4ad1ee400d0c19, []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 (m *Params) GetAvsRegistrationFee() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.AvsRegistrationFee - } - return nil -} - -func init() { - proto.RegisterType((*Params)(nil), "milkyway.avs.v1.Params") -} - -func init() { proto.RegisterFile("milkyway/avs/v1/params.proto", fileDescriptor_1c4ad1ee400d0c19) } - -var fileDescriptor_1c4ad1ee400d0c19 = []byte{ - // 284 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc9, 0xcd, 0xcc, 0xc9, - 0xae, 0x2c, 0x4f, 0xac, 0xd4, 0x4f, 0x2c, 0x2b, 0xd6, 0x2f, 0x33, 0xd4, 0x2f, 0x48, 0x2c, 0x4a, - 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0xc9, 0xea, 0x25, 0x96, 0x15, - 0xeb, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xe5, 0xf4, 0x41, 0x2c, 0x88, 0x32, - 0x29, 0xc9, 0xe4, 0xfc, 0xe2, 0xdc, 0xfc, 0xe2, 0x78, 0x88, 0x04, 0x84, 0x03, 0x95, 0x92, 0x83, - 0xf0, 0xf4, 0x93, 0x12, 0x8b, 0x53, 0xf5, 0xcb, 0x0c, 0x93, 0x52, 0x4b, 0x12, 0x0d, 0xf5, 0x93, - 0xf3, 0x33, 0xf3, 0x20, 0xf2, 0x4a, 0xcb, 0x19, 0xb9, 0xd8, 0x02, 0xc0, 0x56, 0x0a, 0xcd, 0x61, - 0xe4, 0x12, 0x49, 0x2c, 0x2b, 0x8e, 0x2f, 0x4a, 0x4d, 0xcf, 0x2c, 0x2e, 0x29, 0x4a, 0x2c, 0xc9, - 0xcc, 0xcf, 0x8b, 0x4f, 0x4b, 0x4d, 0x95, 0x60, 0x54, 0x60, 0xd6, 0xe0, 0x36, 0x92, 0xd4, 0x83, - 0x1a, 0x0c, 0x32, 0x4a, 0x0f, 0x6a, 0x94, 0x9e, 0x73, 0x7e, 0x66, 0x9e, 0x93, 0xff, 0x89, 0x7b, - 0xf2, 0x0c, 0x9f, 0xee, 0xc9, 0x4b, 0x57, 0x26, 0xe6, 0xe6, 0x58, 0x29, 0x61, 0x33, 0x44, 0x69, - 0xd5, 0x7d, 0x79, 0x8d, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xa8, 0x23, - 0xa1, 0x94, 0x6e, 0x71, 0x4a, 0xb6, 0x7e, 0x49, 0x65, 0x41, 0x6a, 0x31, 0xd8, 0xbc, 0xe2, 0x20, - 0xa1, 0xc4, 0xb2, 0xe2, 0x20, 0x24, 0x13, 0xdc, 0x52, 0x53, 0x9d, 0xdc, 0x4f, 0x3c, 0x92, 0x63, - 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, - 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x17, 0xc9, 0x5c, 0x58, 0x80, 0xe9, 0xe6, 0x24, 0x26, - 0x15, 0xc3, 0x79, 0xfa, 0x15, 0xe0, 0xe0, 0x05, 0x5b, 0x91, 0xc4, 0x06, 0xf6, 0xb9, 0x31, 0x20, - 0x00, 0x00, 0xff, 0xff, 0x37, 0xc8, 0x29, 0xe7, 0x7b, 0x01, 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 - if len(m.AvsRegistrationFee) > 0 { - for iNdEx := len(m.AvsRegistrationFee) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.AvsRegistrationFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - 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 - if len(m.AvsRegistrationFee) > 0 { - for _, e := range m.AvsRegistrationFee { - l = e.Size() - n += 1 + l + sovParams(uint64(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 { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AvsRegistrationFee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AvsRegistrationFee = append(m.AvsRegistrationFee, types.Coin{}) - if err := m.AvsRegistrationFee[len(m.AvsRegistrationFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - 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/avs/types/params_test.go b/x/avs/types/params_test.go deleted file mode 100644 index 0c3e667e3..000000000 --- a/x/avs/types/params_test.go +++ /dev/null @@ -1,51 +0,0 @@ -package types_test - -import ( - "testing" - - sdkmath "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - - "github.com/milkyway-labs/milkyway/x/avs/types" -) - -func TestParams_Validate(t *testing.T) { - testCases := []struct { - name string - params types.Params - shouldErr bool - }{ - { - name: "invalid AVS registration fee returns error", - params: types.Params{ - AvsRegistrationFee: sdk.Coins{sdk.Coin{Denom: "", Amount: sdkmath.NewInt(100)}}, - }, - shouldErr: true, - }, - { - name: "default params returns no error", - params: types.DefaultParams(), - shouldErr: false, - }, - { - name: "valid params returns no error", - params: types.Params{ - AvsRegistrationFee: sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))), - }, - shouldErr: false, - }, - } - - for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { - err := tc.params.Validate() - if tc.shouldErr { - require.Error(t, err) - } else { - require.NoError(t, err) - } - }) - } -} diff --git a/x/avs/types/query.go b/x/avs/types/query.go deleted file mode 100644 index 5a8c77330..000000000 --- a/x/avs/types/query.go +++ /dev/null @@ -1,24 +0,0 @@ -package types - -import ( - "github.com/cosmos/cosmos-sdk/types/query" -) - -// NewQueryParamsRequest creates a new QueryParamsRequest instance -func NewQueryParamsRequest() *QueryParamsRequest { - return &QueryParamsRequest{} -} - -// NewQueryServicesRequest creates a new QueryServiceRequest instance -func NewQueryServicesRequest(pagination *query.PageRequest) *QueryServicesRequest { - return &QueryServicesRequest{ - Pagination: pagination, - } -} - -// NewQueryServiceRequest creates a new QueryServiceRequest instance -func NewQueryServiceRequest(serviceID uint32) *QueryServiceRequest { - return &QueryServiceRequest{ - ServiceId: serviceID, - } -} diff --git a/x/avs/types/query.pb.go b/x/avs/types/query.pb.go deleted file mode 100644 index 5cfa5c011..000000000 --- a/x/avs/types/query.pb.go +++ /dev/null @@ -1,1384 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: milkyway/avs/v1/query.proto - -package types - -import ( - context "context" - fmt "fmt" - query "github.com/cosmos/cosmos-sdk/types/query" - _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/cosmos/gogoproto/grpc" - proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// QueryParamsRequest is the request type for the Query/Params RPC method. -type QueryParamsRequest struct { -} - -func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } -func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryParamsRequest) ProtoMessage() {} -func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_911f1b653a0f04ba, []int{0} -} -func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryParamsRequest.Merge(m, src) -} -func (m *QueryParamsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryParamsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo - -// QueryParamsResponse is the response type for the Query/Params RPC method. -type QueryParamsResponse struct { - Params 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_911f1b653a0f04ba, []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{} -} - -// QueryServicesRequest is the request type for the Query/Services RPC method. -type QueryServicesRequest struct { - Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` -} - -func (m *QueryServicesRequest) Reset() { *m = QueryServicesRequest{} } -func (m *QueryServicesRequest) String() string { return proto.CompactTextString(m) } -func (*QueryServicesRequest) ProtoMessage() {} -func (*QueryServicesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_911f1b653a0f04ba, []int{2} -} -func (m *QueryServicesRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryServicesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryServicesRequest.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 *QueryServicesRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryServicesRequest.Merge(m, src) -} -func (m *QueryServicesRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryServicesRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryServicesRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryServicesRequest proto.InternalMessageInfo - -func (m *QueryServicesRequest) GetPagination() *query.PageRequest { - if m != nil { - return m.Pagination - } - return nil -} - -// QueryServicesResponse is the response type for the Query/Services RPC method. -type QueryServicesResponse struct { - // AVS services defines the list of actively validates services - Services []AVS `protobuf:"bytes,1,rep,name=services,proto3" json:"services"` - // Pagination defines the pagination response - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` -} - -func (m *QueryServicesResponse) Reset() { *m = QueryServicesResponse{} } -func (m *QueryServicesResponse) String() string { return proto.CompactTextString(m) } -func (*QueryServicesResponse) ProtoMessage() {} -func (*QueryServicesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_911f1b653a0f04ba, []int{3} -} -func (m *QueryServicesResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryServicesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryServicesResponse.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 *QueryServicesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryServicesResponse.Merge(m, src) -} -func (m *QueryServicesResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryServicesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryServicesResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryServicesResponse proto.InternalMessageInfo - -func (m *QueryServicesResponse) GetServices() []AVS { - if m != nil { - return m.Services - } - return nil -} - -func (m *QueryServicesResponse) GetPagination() *query.PageResponse { - if m != nil { - return m.Pagination - } - return nil -} - -// QueryServiceRequest is the request type for the Query/Service RPC method. -type QueryServiceRequest struct { - // ServiceID is the ID of the service to query - ServiceId uint32 `protobuf:"varint,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` -} - -func (m *QueryServiceRequest) Reset() { *m = QueryServiceRequest{} } -func (m *QueryServiceRequest) String() string { return proto.CompactTextString(m) } -func (*QueryServiceRequest) ProtoMessage() {} -func (*QueryServiceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_911f1b653a0f04ba, []int{4} -} -func (m *QueryServiceRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryServiceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryServiceRequest.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 *QueryServiceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryServiceRequest.Merge(m, src) -} -func (m *QueryServiceRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryServiceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryServiceRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryServiceRequest proto.InternalMessageInfo - -func (m *QueryServiceRequest) GetServiceId() uint32 { - if m != nil { - return m.ServiceId - } - return 0 -} - -// QueryServiceResponse is the response type for the Query/Service RPC method. -type QueryServiceResponse struct { - Service AVS `protobuf:"bytes,1,opt,name=service,proto3" json:"service"` -} - -func (m *QueryServiceResponse) Reset() { *m = QueryServiceResponse{} } -func (m *QueryServiceResponse) String() string { return proto.CompactTextString(m) } -func (*QueryServiceResponse) ProtoMessage() {} -func (*QueryServiceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_911f1b653a0f04ba, []int{5} -} -func (m *QueryServiceResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryServiceResponse.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 *QueryServiceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryServiceResponse.Merge(m, src) -} -func (m *QueryServiceResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryServiceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryServiceResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryServiceResponse proto.InternalMessageInfo - -func (m *QueryServiceResponse) GetService() AVS { - if m != nil { - return m.Service - } - return AVS{} -} - -func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "milkyway.avs.v1.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "milkyway.avs.v1.QueryParamsResponse") - proto.RegisterType((*QueryServicesRequest)(nil), "milkyway.avs.v1.QueryServicesRequest") - proto.RegisterType((*QueryServicesResponse)(nil), "milkyway.avs.v1.QueryServicesResponse") - proto.RegisterType((*QueryServiceRequest)(nil), "milkyway.avs.v1.QueryServiceRequest") - proto.RegisterType((*QueryServiceResponse)(nil), "milkyway.avs.v1.QueryServiceResponse") -} - -func init() { proto.RegisterFile("milkyway/avs/v1/query.proto", fileDescriptor_911f1b653a0f04ba) } - -var fileDescriptor_911f1b653a0f04ba = []byte{ - // 502 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x4f, 0x6b, 0x13, 0x41, - 0x14, 0xcf, 0xb6, 0x9a, 0xd6, 0x57, 0x44, 0x18, 0x23, 0x6d, 0x53, 0xdd, 0xd6, 0xb5, 0x8d, 0x41, - 0xe8, 0x0c, 0x89, 0xd5, 0xbb, 0x3d, 0x58, 0x84, 0x1e, 0x6a, 0x0a, 0x1e, 0x3c, 0x28, 0xb3, 0xc9, - 0xb0, 0x2e, 0x66, 0x77, 0xb6, 0x99, 0xc9, 0x6a, 0x50, 0x2f, 0x22, 0x9e, 0x05, 0x2f, 0x7e, 0xa4, - 0x1e, 0x0b, 0x5e, 0x3c, 0x89, 0x24, 0x7e, 0x10, 0xc9, 0xcc, 0xdb, 0xc4, 0x64, 0x9b, 0xe4, 0xb6, - 0xbc, 0xf7, 0x7b, 0xbf, 0x3f, 0xef, 0xcd, 0xc2, 0x56, 0x14, 0xb6, 0xdf, 0xf6, 0xde, 0xf1, 0x1e, - 0xe3, 0xa9, 0x62, 0x69, 0x8d, 0x9d, 0x75, 0x45, 0xa7, 0x47, 0x93, 0x8e, 0xd4, 0x92, 0xdc, 0xc8, - 0x9a, 0x94, 0xa7, 0x8a, 0xa6, 0xb5, 0x72, 0x29, 0x90, 0x81, 0x34, 0x3d, 0x36, 0xfc, 0xb2, 0xb0, - 0xf2, 0xed, 0x40, 0xca, 0xa0, 0x2d, 0x18, 0x4f, 0x42, 0xc6, 0xe3, 0x58, 0x6a, 0xae, 0x43, 0x19, - 0x2b, 0xec, 0x3e, 0x68, 0x4a, 0x15, 0x49, 0xc5, 0x7c, 0xae, 0x84, 0x65, 0x67, 0x69, 0xcd, 0x17, - 0x9a, 0xd7, 0x58, 0xc2, 0x83, 0x30, 0x36, 0xe0, 0x8c, 0x69, 0xda, 0x4d, 0x24, 0x5b, 0xa2, 0xad, - 0x66, 0x75, 0x13, 0xde, 0xe1, 0x11, 0x76, 0xbd, 0x12, 0x90, 0xe7, 0x43, 0xf6, 0x13, 0x53, 0x6c, - 0x88, 0xb3, 0xae, 0x50, 0xda, 0x3b, 0x86, 0x9b, 0x13, 0x55, 0x95, 0xc8, 0x58, 0x09, 0xf2, 0x08, - 0x8a, 0x76, 0x78, 0xc3, 0xd9, 0x71, 0xaa, 0x6b, 0xf5, 0x75, 0x3a, 0x15, 0x95, 0xda, 0x81, 0xc3, - 0x2b, 0xe7, 0xbf, 0xb7, 0x0b, 0x0d, 0x04, 0x7b, 0xaf, 0xa0, 0x64, 0xd8, 0x4e, 0x45, 0x27, 0x0d, - 0x9b, 0x22, 0x53, 0x21, 0x4f, 0x01, 0xc6, 0x59, 0x90, 0xb2, 0x42, 0x6d, 0x70, 0x3a, 0x0c, 0x4e, - 0xed, 0x5a, 0x31, 0x38, 0x3d, 0xe1, 0x81, 0xc0, 0xd9, 0xc6, 0x7f, 0x93, 0xde, 0x0f, 0x07, 0x6e, - 0x4d, 0x09, 0xa0, 0xe1, 0xc7, 0xb0, 0xaa, 0xb0, 0xb6, 0xe1, 0xec, 0x2c, 0x57, 0xd7, 0xea, 0xa5, - 0x9c, 0xe5, 0x27, 0x2f, 0x4e, 0xd1, 0xef, 0x08, 0x4b, 0x8e, 0x26, 0x9c, 0x2d, 0x19, 0x67, 0xf7, - 0x17, 0x3a, 0xb3, 0xa2, 0x13, 0xd6, 0x0e, 0x70, 0x91, 0xe8, 0x2c, 0x4b, 0x7e, 0x07, 0x00, 0xb5, - 0x5e, 0x87, 0x2d, 0x93, 0xfc, 0x7a, 0xe3, 0x1a, 0x56, 0x9e, 0xb5, 0xbc, 0xe3, 0xc9, 0x85, 0x8d, - 0xe2, 0x1c, 0xc0, 0x0a, 0x82, 0x70, 0x5b, 0xf3, 0xd2, 0x64, 0xd0, 0xfa, 0x97, 0x65, 0xb8, 0x6a, - 0xe8, 0x88, 0x86, 0xa2, 0x3d, 0x10, 0xb9, 0x97, 0x1b, 0xcc, 0xbf, 0x82, 0xf2, 0xee, 0x7c, 0x90, - 0x35, 0xe5, 0x6d, 0x7f, 0xfe, 0xf9, 0xf7, 0xfb, 0xd2, 0x26, 0x59, 0x67, 0x97, 0x3f, 0x34, 0xf2, - 0x11, 0x56, 0xb3, 0xc3, 0x90, 0xbd, 0xcb, 0x29, 0xa7, 0x5e, 0x46, 0xb9, 0xb2, 0x08, 0x86, 0xda, - 0x77, 0x8d, 0xf6, 0x16, 0xd9, 0xcc, 0x69, 0x8f, 0x4e, 0xf9, 0xd5, 0x81, 0x15, 0x9c, 0x23, 0xbb, - 0x73, 0x69, 0x33, 0xf1, 0xbd, 0x05, 0x28, 0xd4, 0xa6, 0x46, 0xbb, 0x4a, 0x2a, 0x33, 0xb5, 0xd9, - 0x87, 0xf1, 0x91, 0x3f, 0x1d, 0x1e, 0x9d, 0xf7, 0x5d, 0xe7, 0xa2, 0xef, 0x3a, 0x7f, 0xfa, 0xae, - 0xf3, 0x6d, 0xe0, 0x16, 0x2e, 0x06, 0x6e, 0xe1, 0xd7, 0xc0, 0x2d, 0xbc, 0xdc, 0x0f, 0x42, 0xfd, - 0xa6, 0xeb, 0xd3, 0xa6, 0x8c, 0x46, 0x5c, 0xfb, 0x6d, 0xee, 0xab, 0x31, 0xf3, 0x7b, 0xc3, 0xad, - 0x7b, 0x89, 0x50, 0x7e, 0xd1, 0xfc, 0xb9, 0x0f, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x04, 0xce, - 0x72, 0x8e, 0x85, 0x04, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// QueryClient is the client API for Query service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type QueryClient interface { - // Params defines a gRPC query method that returns the parameters of the - // module. - Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) - // Services defines a gRPC query method that returns the actively validates - // services currently registered in the module. - Services(ctx context.Context, in *QueryServicesRequest, opts ...grpc.CallOption) (*QueryServicesResponse, error) - // Service defines a gRPC query method that returns the service by the given - // service id. - Service(ctx context.Context, in *QueryServiceRequest, opts ...grpc.CallOption) (*QueryServiceResponse, 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, "/milkyway.avs.v1.Query/Params", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) Services(ctx context.Context, in *QueryServicesRequest, opts ...grpc.CallOption) (*QueryServicesResponse, error) { - out := new(QueryServicesResponse) - err := c.cc.Invoke(ctx, "/milkyway.avs.v1.Query/Services", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) Service(ctx context.Context, in *QueryServiceRequest, opts ...grpc.CallOption) (*QueryServiceResponse, error) { - out := new(QueryServiceResponse) - err := c.cc.Invoke(ctx, "/milkyway.avs.v1.Query/Service", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// QueryServer is the server API for Query service. -type QueryServer interface { - // Params defines a gRPC query method that returns the parameters of the - // module. - Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) - // Services defines a gRPC query method that returns the actively validates - // services currently registered in the module. - Services(context.Context, *QueryServicesRequest) (*QueryServicesResponse, error) - // Service defines a gRPC query method that returns the service by the given - // service id. - Service(context.Context, *QueryServiceRequest) (*QueryServiceResponse, 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) Services(ctx context.Context, req *QueryServicesRequest) (*QueryServicesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Services not implemented") -} -func (*UnimplementedQueryServer) Service(ctx context.Context, req *QueryServiceRequest) (*QueryServiceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Service 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: "/milkyway.avs.v1.Query/Params", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_Services_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryServicesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Services(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/milkyway.avs.v1.Query/Services", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Services(ctx, req.(*QueryServicesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_Service_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryServiceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Service(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/milkyway.avs.v1.Query/Service", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Service(ctx, req.(*QueryServiceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "milkyway.avs.v1.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Params", - Handler: _Query_Params_Handler, - }, - { - MethodName: "Services", - Handler: _Query_Services_Handler, - }, - { - MethodName: "Service", - Handler: _Query_Service_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "milkyway/avs/v1/query.proto", -} - -func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *QueryServicesRequest) 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 *QueryServicesRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryServicesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.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 *QueryServicesResponse) 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 *QueryServicesResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryServicesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Services) > 0 { - for iNdEx := len(m.Services) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Services[iNdEx].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 *QueryServiceRequest) 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 *QueryServiceRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryServiceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.ServiceId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ServiceId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QueryServiceResponse) 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 *QueryServiceResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryServiceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Service.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 *QueryServicesRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryServicesResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Services) > 0 { - for _, e := range m.Services { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryServiceRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ServiceId != 0 { - n += 1 + sovQuery(uint64(m.ServiceId)) - } - return n -} - -func (m *QueryServiceResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Service.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 *QueryServicesRequest) 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: QueryServicesRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryServicesRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.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 *QueryServicesResponse) 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: QueryServicesResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryServicesResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Services", 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 - } - m.Services = append(m.Services, AVS{}) - if err := m.Services[len(m.Services)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.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 *QueryServiceRequest) 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: QueryServiceRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryServiceRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ServiceId", wireType) - } - m.ServiceId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ServiceId |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 *QueryServiceResponse) 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: QueryServiceResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryServiceResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Service", 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.Service.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/avs/types/query.pb.gw.go b/x/avs/types/query.pb.gw.go deleted file mode 100644 index 50c76240f..000000000 --- a/x/avs/types/query.pb.gw.go +++ /dev/null @@ -1,337 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: milkyway/avs/v1/query.proto - -/* -Package types is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package types - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryParamsRequest - var metadata runtime.ServerMetadata - - msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryParamsRequest - var metadata runtime.ServerMetadata - - msg, err := server.Params(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_Services_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_Services_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryServicesRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Services_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Services(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Services_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryServicesRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Services_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Services(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_Service_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryServiceRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["service_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "service_id") - } - - protoReq.ServiceId, err = runtime.Uint32(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "service_id", err) - } - - msg, err := client.Service(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Service_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryServiceRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["service_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "service_id") - } - - protoReq.ServiceId, err = runtime.Uint32(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "service_id", err) - } - - msg, err := server.Service(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_Services_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_Services_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_Services_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_Service_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_Service_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_Service_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_Services_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_Services_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_Services_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_Service_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_Service_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_Service_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{"milkyway", "avs", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_Services_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"milkyway", "avs", "v1", "services"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_Service_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"milkyway", "avs", "v1", "services", "service_id"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Params_0 = runtime.ForwardResponseMessage - - forward_Query_Services_0 = runtime.ForwardResponseMessage - - forward_Query_Service_0 = runtime.ForwardResponseMessage -) diff --git a/x/avs/genesis.go b/x/services/genesis.go similarity index 90% rename from x/avs/genesis.go rename to x/services/genesis.go index 652019dde..6b2671ce3 100644 --- a/x/avs/genesis.go +++ b/x/services/genesis.go @@ -1,10 +1,10 @@ -package avs +package services import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/milkyway-labs/milkyway/x/avs/keeper" - "github.com/milkyway-labs/milkyway/x/avs/types" + "github.com/milkyway-labs/milkyway/x/services/keeper" + "github.com/milkyway-labs/milkyway/x/services/types" ) // ExportGenesis returns the GenesisState associated with the given context diff --git a/x/avs/keeper/avs.go b/x/services/keeper/avs.go similarity index 97% rename from x/avs/keeper/avs.go rename to x/services/keeper/avs.go index af03611bd..f60beff11 100644 --- a/x/avs/keeper/avs.go +++ b/x/services/keeper/avs.go @@ -4,7 +4,7 @@ import ( "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/milkyway-labs/milkyway/x/avs/types" + "github.com/milkyway-labs/milkyway/x/services/types" ) // SetNextAVSID sets the next AVS ID to be used when registering a new AVS From 6f358f598c55811fda9e1df4203f9fd83c20139d Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Tue, 4 Jun 2024 10:31:01 -0500 Subject: [PATCH 24/49] chore: renamed AVS to Service --- proto/milkyway/avs/v1/genesis.proto | 2 +- proto/milkyway/avs/v1/models.proto | 26 +++++++++++++------------- proto/milkyway/avs/v1/query.proto | 20 ++++++++++---------- x/services/genesis.go | 10 +++++----- x/services/keeper/avs.go | 18 +++++++++--------- 5 files changed, 38 insertions(+), 38 deletions(-) diff --git a/proto/milkyway/avs/v1/genesis.proto b/proto/milkyway/avs/v1/genesis.proto index da82869cb..1dd386b10 100644 --- a/proto/milkyway/avs/v1/genesis.proto +++ b/proto/milkyway/avs/v1/genesis.proto @@ -13,7 +13,7 @@ message GenesisState { Params params = 1 [ (gogoproto.nullable) = false ]; // Services defines the list of actively validated services. - repeated AVS services = 2 [ + repeated Service services = 2 [ (gogoproto.moretags) = "yaml:\"services\"", (gogoproto.nullable) = false ]; diff --git a/proto/milkyway/avs/v1/models.proto b/proto/milkyway/avs/v1/models.proto index cc847845a..561ba5527 100644 --- a/proto/milkyway/avs/v1/models.proto +++ b/proto/milkyway/avs/v1/models.proto @@ -6,30 +6,30 @@ import "cosmos_proto/cosmos.proto"; option go_package = "github.com/milkyway-labs/milkyway/x/avs/types"; -// AVSStatus defines the status of an AVS -enum AVSStatus { +// ServiceStatus defines the status of an AVS +enum ServiceStatus { option (gogoproto.goproto_enum_prefix) = false; - // AVS_STATUS_UNSPECIFIED defines the AVS status is unspecified - AVS_STATUS_UNSPECIFIED = 0; + // SERVICE_STATUS_UNSPECIFIED defines the AVS status is unspecified + SERVICE_STATUS_UNSPECIFIED = 0; - // AVS_STATUS_CREATED defines the AVS status is created - AVS_STATUS_CREATED = 1; + // SERVICE_STATUS_CREATED defines the AVS status is created + SERVICE_STATUS_CREATED = 1; - // AVS_STATUS_REGISTERED defines the AVS status is updated - AVS_STATUS_REGISTERED = 2; + // SERVICE_STATUS_REGISTERED defines the AVS status is updated + SERVICE_STATUS_REGISTERED = 2; - // AVS_STATUS_UNREGISTERED defines the AVS status is unregistered - AVS_STATUS_UNREGISTERED = 3; + // SERVICE_STATUS_UNREGISTERED defines the AVS status is unregistered + SERVICE_STATUS_UNREGISTERED = 3; } -// AVS defines the fields of an AVS -message AVS { +// Service defines the fields of an AVS +message Service { // ID is the auto-generated unique identifier for the AVS uint32 id = 1 [ (gogoproto.customname) = "ID" ]; // Status is the status of the AVS - AVSStatus status = 2; + ServiceStatus status = 2; // Admin is the address of the user that has registered the AVS string admin = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; diff --git a/proto/milkyway/avs/v1/query.proto b/proto/milkyway/avs/v1/query.proto index 93d328d3c..ef84b334d 100644 --- a/proto/milkyway/avs/v1/query.proto +++ b/proto/milkyway/avs/v1/query.proto @@ -11,10 +11,10 @@ option go_package = "github.com/milkyway-labs/milkyway/x/avs/types"; // Query defines the gRPC querier service. service Query { - // Params defines a gRPC query method that returns the parameters of the - // module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/milkyway/avs/v1/params"; + // Service defines a gRPC query method that returns the service by the given + // service id. + rpc Service(QueryServiceRequest) returns (QueryServiceResponse) { + option (google.api.http).get = "/milkyway/avs/v1/services/{service_id}"; } // Services defines a gRPC query method that returns the actively validates @@ -23,10 +23,10 @@ service Query { option (google.api.http).get = "/milkyway/avs/v1/services"; } - // Service defines a gRPC query method that returns the service by the given - // service id. - rpc Service(QueryServiceRequest) returns (QueryServiceResponse) { - option (google.api.http).get = "/milkyway/avs/v1/services/{service_id}"; + // Params defines a gRPC query method that returns the parameters of the + // module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/milkyway/avs/v1/params"; } } @@ -46,7 +46,7 @@ message QueryServicesRequest { // QueryServicesResponse is the response type for the Query/Services RPC method. message QueryServicesResponse { // AVS services defines the list of actively validates services - repeated AVS services = 1 [ (gogoproto.nullable) = false ]; + repeated Service services = 1 [ (gogoproto.nullable) = false ]; // Pagination defines the pagination response cosmos.base.query.v1beta1.PageResponse pagination = 2; @@ -60,5 +60,5 @@ message QueryServiceRequest { // QueryServiceResponse is the response type for the Query/Service RPC method. message QueryServiceResponse { - AVS service = 1 [ (gogoproto.nullable) = false ]; + Service service = 1 [ (gogoproto.nullable) = false ]; } \ No newline at end of file diff --git a/x/services/genesis.go b/x/services/genesis.go index 6b2671ce3..9afe795be 100644 --- a/x/services/genesis.go +++ b/x/services/genesis.go @@ -16,7 +16,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { ) } -// exportNextAVSID returns the next AVS ID stored in the KVStore +// exportNextAVSID returns the next Service ID stored in the KVStore func exportNextAVSID(ctx sdk.Context, k keeper.Keeper) uint32 { nextAVSID, err := k.GetNextAVSID(ctx) if err != nil { @@ -26,9 +26,9 @@ func exportNextAVSID(ctx sdk.Context, k keeper.Keeper) uint32 { } // exportServices returns the services stored in the KVStore -func exportServices(ctx sdk.Context, k keeper.Keeper) []types.AVS { - var services []types.AVS - k.IterateServices(ctx, func(service types.AVS) (stop bool) { +func exportServices(ctx sdk.Context, k keeper.Keeper) []types.Service { + var services []types.Service + k.IterateServices(ctx, func(service types.Service) (stop bool) { services = append(services, service) return false }) @@ -37,7 +37,7 @@ func exportServices(ctx sdk.Context, k keeper.Keeper) []types.AVS { // InitGenesis initializes the state from a GenesisState func InitGenesis(ctx sdk.Context, k keeper.Keeper, state types.GenesisState) { - // Set the next AVS ID + // Set the next Service ID k.SetNextAVSID(ctx, state.NextAVSID) // Store the services diff --git a/x/services/keeper/avs.go b/x/services/keeper/avs.go index f60beff11..4a648d5e4 100644 --- a/x/services/keeper/avs.go +++ b/x/services/keeper/avs.go @@ -7,19 +7,19 @@ import ( "github.com/milkyway-labs/milkyway/x/services/types" ) -// SetNextAVSID sets the next AVS ID to be used when registering a new AVS +// SetNextAVSID sets the next Service ID to be used when registering a new Service func (k Keeper) SetNextAVSID(ctx sdk.Context, avsID uint32) { store := ctx.KVStore(k.storeKey) store.Set(types.NextAVSIDKey(), types.GetAVSIDBytes(avsID)) } -// HasNextAVSID checks if the next AVS ID is set +// HasNextAVSID checks if the next Service ID is set func (k Keeper) HasNextAVSID(ctx sdk.Context) bool { store := ctx.KVStore(k.storeKey) return store.Has(types.NextAVSIDKey()) } -// GetNextAVSID returns the next AVS ID to be used when registering a new AVS +// GetNextAVSID returns the next Service ID to be used when registering a new Service func (k Keeper) GetNextAVSID(ctx sdk.Context) (avsID uint32, err error) { store := ctx.KVStore(k.storeKey) bz := store.Get(types.NextAVSIDKey()) @@ -33,16 +33,16 @@ func (k Keeper) GetNextAVSID(ctx sdk.Context) (avsID uint32, err error) { // -------------------------------------------------------------------------------------------------------------------- -// SaveAVS stores a new AVS in the KVStore -func (k Keeper) SaveAVS(ctx sdk.Context, avs types.AVS) { +// SaveAVS stores a new Service in the KVStore +func (k Keeper) SaveAVS(ctx sdk.Context, avs types.Service) { previous, existed := k.GetAVS(ctx, avs.ID) - // Save the AVS data + // Save the Service data store := ctx.KVStore(k.storeKey) store.Set(types.AVSStoreKey(avs.ID), k.cdc.MustMarshal(&avs)) k.Logger(ctx).Debug("saved avs", "id", avs.ID) - // Call the hook based on the AVS status change + // Call the hook based on the Service status change switch { case !existed: k.AfterAVSCreated(ctx, avs.ID) @@ -53,8 +53,8 @@ func (k Keeper) SaveAVS(ctx sdk.Context, avs types.AVS) { } } -// GetAVS returns an AVS from the KVStore -func (k Keeper) GetAVS(ctx sdk.Context, avsID uint32) (avs types.AVS, found bool) { +// GetAVS returns an Service from the KVStore +func (k Keeper) GetAVS(ctx sdk.Context, avsID uint32) (avs types.Service, found bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(types.AVSStoreKey(avsID)) From 5e05ebb4c865585e7e460495bc078f389bf13bbf Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Tue, 4 Jun 2024 10:51:40 -0500 Subject: [PATCH 25/49] feat: add query command --- proto/milkyway/avs/v1/genesis.proto | 24 -------- proto/milkyway/avs/v1/messages.proto | 90 ---------------------------- proto/milkyway/avs/v1/models.proto | 48 --------------- proto/milkyway/avs/v1/params.proto | 21 ------- proto/milkyway/avs/v1/query.proto | 64 -------------------- 5 files changed, 247 deletions(-) delete mode 100644 proto/milkyway/avs/v1/genesis.proto delete mode 100644 proto/milkyway/avs/v1/messages.proto delete mode 100644 proto/milkyway/avs/v1/models.proto delete mode 100644 proto/milkyway/avs/v1/params.proto delete mode 100644 proto/milkyway/avs/v1/query.proto diff --git a/proto/milkyway/avs/v1/genesis.proto b/proto/milkyway/avs/v1/genesis.proto deleted file mode 100644 index 1dd386b10..000000000 --- a/proto/milkyway/avs/v1/genesis.proto +++ /dev/null @@ -1,24 +0,0 @@ -syntax = "proto3"; -package milkyway.avs.v1; - -import "gogoproto/gogo.proto"; -import "milkyway/avs/v1/models.proto"; -import "milkyway/avs/v1/params.proto"; - -option go_package = "github.com/milkyway-labs/milkyway/x/avs/types"; - -// GenesisState defines the avs module's genesis state. -message GenesisState { - // Params defines the parameters of the module. - Params params = 1 [ (gogoproto.nullable) = false ]; - - // Services defines the list of actively validated services. - repeated Service services = 2 [ - (gogoproto.moretags) = "yaml:\"services\"", - (gogoproto.nullable) = false - ]; - - // NextAVSId defines the ID that will be assigned to the next AVS that gets - // created. - uint32 next_avs_id = 3 [ (gogoproto.customname) = "NextAVSID" ]; -} \ No newline at end of file diff --git a/proto/milkyway/avs/v1/messages.proto b/proto/milkyway/avs/v1/messages.proto deleted file mode 100644 index 444ddd4c0..000000000 --- a/proto/milkyway/avs/v1/messages.proto +++ /dev/null @@ -1,90 +0,0 @@ -syntax = "proto3"; -package milkyway.avs.v1; - -import "amino/amino.proto"; -import "cosmos_proto/cosmos.proto"; -import "cosmos/base/v1beta1/coin.proto"; -import "cosmos/bank/v1beta1/bank.proto"; -import "cosmos/msg/v1/msg.proto"; -import "gogoproto/gogo.proto"; -import "milkyway/avs/v1/params.proto"; - -option go_package = "github.com/milkyway-labs/milkyway/x/avs/types"; - -// Msg defines the avs module's gRPC message service. -service Msg { - option (cosmos.msg.v1.service) = true; - - rpc RegisterService(MsgRegisterService) returns (MsgRegisterServiceResponse); - rpc UpdateService(MsgUpdateService) returns (MsgUpdateServiceResponse); -} - -// MsgRegisterServiceResponse defines the message structure for the -// RegisterService gRPC service method. It allows an account to register a new -// AVS that later on operators can opt to validate. It requires a sender address -// as well as the details of the AVS to be register. -message MsgRegisterService { - option (cosmos.msg.v1.signer) = "sender"; - option (amino.name) = "milkyway/MsgRegisterService"; - - // Sender is the address of the user registering the AVS - string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - - // Name is the name of the AVS - string name = 2 [ (gogoproto.moretags) = "yaml:\"name\"" ]; - - // Description is the description of the AVS (optional) - string description = 3 [ (gogoproto.moretags) = "yaml:\"description\"" ]; - - // Website is the website of the AVS (optional) - string website = 4 [ (gogoproto.moretags) = "yaml:\"website\"" ]; - - // PictureURL is the URL of the AVS picture (optional) - string picture_url = 5 [ - (gogoproto.moretags) = "yaml:\"picture_url\"", - (gogoproto.customname) = "PictureURL" - ]; -} - -// MsgRegisterServiceResponse is the return value of MsgRegisterService. -// It returns the newly created AVS ID. -message MsgRegisterServiceResponse { - // NewServiceID is the ID of the newly registered AVS - uint32 new_service_id = 1 [ (gogoproto.customname) = "NewServiceID" ]; -} - -// MsgUpdateService defines the message structure for the UpdateService gRPC -// service method. It allows the AVS owner to update the details of -// an existing AVS. -message MsgUpdateService { - option (cosmos.msg.v1.signer) = "sender"; - option (amino.name) = "milkyway/MsgUpdateService"; - - // Sender is the address of the user updating the AVS - string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - - // ID represents the ID of the AVS to be updated - uint32 service_id = 2 [ (gogoproto.customname) = "ServiceID" ]; - - // Name is the new name of the AVS (optional). - // If it shouldn't be changed, use [do-not-modify] instead. - string name = 3 [ (gogoproto.moretags) = "yaml:\"name\"" ]; - - // Description is the new description of the AVS (optional) - // If it shouldn't be changed, use [do-not-modify] instead. - string description = 4 [ (gogoproto.moretags) = "yaml:\"description\"" ]; - - // Website is the new website of the AVS (optional) - // If it shouldn't be changed, use [do-not-modify] instead. - string website = 5 [ (gogoproto.moretags) = "yaml:\"website\"" ]; - - // PictureURL is the new URL of the AVS picture (optional) - // If it shouldn't be changed, use [do-not-modify] instead. - string picture_url = 6 [ - (gogoproto.moretags) = "yaml:\"picture_url\"", - (gogoproto.customname) = "PictureURL" - ]; -} - -// MsgUpdateServiceResponse is the return value of MsgUpdateService. -message MsgUpdateServiceResponse {} \ No newline at end of file diff --git a/proto/milkyway/avs/v1/models.proto b/proto/milkyway/avs/v1/models.proto deleted file mode 100644 index 561ba5527..000000000 --- a/proto/milkyway/avs/v1/models.proto +++ /dev/null @@ -1,48 +0,0 @@ -syntax = "proto3"; -package milkyway.avs.v1; - -import "gogoproto/gogo.proto"; -import "cosmos_proto/cosmos.proto"; - -option go_package = "github.com/milkyway-labs/milkyway/x/avs/types"; - -// ServiceStatus defines the status of an AVS -enum ServiceStatus { - option (gogoproto.goproto_enum_prefix) = false; - - // SERVICE_STATUS_UNSPECIFIED defines the AVS status is unspecified - SERVICE_STATUS_UNSPECIFIED = 0; - - // SERVICE_STATUS_CREATED defines the AVS status is created - SERVICE_STATUS_CREATED = 1; - - // SERVICE_STATUS_REGISTERED defines the AVS status is updated - SERVICE_STATUS_REGISTERED = 2; - - // SERVICE_STATUS_UNREGISTERED defines the AVS status is unregistered - SERVICE_STATUS_UNREGISTERED = 3; -} - -// Service defines the fields of an AVS -message Service { - // ID is the auto-generated unique identifier for the AVS - uint32 id = 1 [ (gogoproto.customname) = "ID" ]; - - // Status is the status of the AVS - ServiceStatus status = 2; - - // Admin is the address of the user that has registered the AVS - string admin = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - - // Name is the name of the AVS - string name = 4; - - // Description is the description of the AVS (optional) - string description = 5; - - // Website is the website of the AVS (optional) - string website = 6; - - // PictureURL is the URL of the picture of the AVS (optional) - string pictureURL = 7; -} diff --git a/proto/milkyway/avs/v1/params.proto b/proto/milkyway/avs/v1/params.proto deleted file mode 100644 index b8b23d783..000000000 --- a/proto/milkyway/avs/v1/params.proto +++ /dev/null @@ -1,21 +0,0 @@ -syntax = "proto3"; -package milkyway.avs.v1; - -import "gogoproto/gogo.proto"; -import "cosmos_proto/cosmos.proto"; -import "cosmos/base/v1beta1/coin.proto"; - -option go_package = "github.com/milkyway-labs/milkyway/x/avs/types"; - -// Params defines the parameters for the avs module. -message Params { - - // AvsCreationFee defines the fee to register a new AVS. The fee is - // drawn from the MsgRegisterAVS creator's account, and transferred - // to the community pool. - repeated cosmos.base.v1beta1.Coin avs_registration_fee = 1 [ - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"avs_registration_fee\"", - (gogoproto.nullable) = false - ]; -} \ No newline at end of file diff --git a/proto/milkyway/avs/v1/query.proto b/proto/milkyway/avs/v1/query.proto deleted file mode 100644 index ef84b334d..000000000 --- a/proto/milkyway/avs/v1/query.proto +++ /dev/null @@ -1,64 +0,0 @@ -syntax = "proto3"; -package milkyway.avs.v1; - -import "gogoproto/gogo.proto"; -import "google/api/annotations.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; -import "milkyway/avs/v1/models.proto"; -import "milkyway/avs/v1/params.proto"; - -option go_package = "github.com/milkyway-labs/milkyway/x/avs/types"; - -// Query defines the gRPC querier service. -service Query { - // Service defines a gRPC query method that returns the service by the given - // service id. - rpc Service(QueryServiceRequest) returns (QueryServiceResponse) { - option (google.api.http).get = "/milkyway/avs/v1/services/{service_id}"; - } - - // Services defines a gRPC query method that returns the actively validates - // services currently registered in the module. - rpc Services(QueryServicesRequest) returns (QueryServicesResponse) { - option (google.api.http).get = "/milkyway/avs/v1/services"; - } - - // Params defines a gRPC query method that returns the parameters of the - // module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/milkyway/avs/v1/params"; - } -} - -// QueryParamsRequest is the request type for the Query/Params RPC method. -message QueryParamsRequest {} - -// QueryParamsResponse is the response type for the Query/Params RPC method. -message QueryParamsResponse { - Params params = 1 [ (gogoproto.nullable) = false ]; -} - -// QueryServicesRequest is the request type for the Query/Services RPC method. -message QueryServicesRequest { - cosmos.base.query.v1beta1.PageRequest pagination = 1; -} - -// QueryServicesResponse is the response type for the Query/Services RPC method. -message QueryServicesResponse { - // AVS services defines the list of actively validates services - repeated Service services = 1 [ (gogoproto.nullable) = false ]; - - // Pagination defines the pagination response - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -// QueryServiceRequest is the request type for the Query/Service RPC method. -message QueryServiceRequest { - // ServiceID is the ID of the service to query - uint32 service_id = 1; -} - -// QueryServiceResponse is the response type for the Query/Service RPC method. -message QueryServiceResponse { - Service service = 1 [ (gogoproto.nullable) = false ]; -} \ No newline at end of file From 1e1c14e8d85ce97ecaffe27cf5b34a7bad82b61b Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Tue, 4 Jun 2024 18:38:03 -0500 Subject: [PATCH 26/49] refactor: rename AVSs to Services --- x/services/genesis.go | 12 ++--- x/services/keeper/avs.go | 67 ------------------------ x/services/keeper/expected_interfaces.go | 11 ++++ 3 files changed, 17 insertions(+), 73 deletions(-) delete mode 100644 x/services/keeper/avs.go create mode 100644 x/services/keeper/expected_interfaces.go diff --git a/x/services/genesis.go b/x/services/genesis.go index 9afe795be..351a1e19e 100644 --- a/x/services/genesis.go +++ b/x/services/genesis.go @@ -10,15 +10,15 @@ import ( // ExportGenesis returns the GenesisState associated with the given context func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { return types.NewGenesisState( - exportNextAVSID(ctx, k), + exportNextServiceID(ctx, k), exportServices(ctx, k), k.GetParams(ctx), ) } -// exportNextAVSID returns the next Service ID stored in the KVStore -func exportNextAVSID(ctx sdk.Context, k keeper.Keeper) uint32 { - nextAVSID, err := k.GetNextAVSID(ctx) +// exportNextServiceID returns the next Service ID stored in the KVStore +func exportNextServiceID(ctx sdk.Context, k keeper.Keeper) uint32 { + nextAVSID, err := k.GetNextServiceID(ctx) if err != nil { panic(err) } @@ -38,11 +38,11 @@ func exportServices(ctx sdk.Context, k keeper.Keeper) []types.Service { // InitGenesis initializes the state from a GenesisState func InitGenesis(ctx sdk.Context, k keeper.Keeper, state types.GenesisState) { // Set the next Service ID - k.SetNextAVSID(ctx, state.NextAVSID) + k.SetNextServiceID(ctx, state.NextAVSID) // Store the services for _, service := range state.Services { - k.SaveAVS(ctx, service) + k.SaveService(ctx, service) } // Store params diff --git a/x/services/keeper/avs.go b/x/services/keeper/avs.go deleted file mode 100644 index 4a648d5e4..000000000 --- a/x/services/keeper/avs.go +++ /dev/null @@ -1,67 +0,0 @@ -package keeper - -import ( - "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/milkyway-labs/milkyway/x/services/types" -) - -// SetNextAVSID sets the next Service ID to be used when registering a new Service -func (k Keeper) SetNextAVSID(ctx sdk.Context, avsID uint32) { - store := ctx.KVStore(k.storeKey) - store.Set(types.NextAVSIDKey(), types.GetAVSIDBytes(avsID)) -} - -// HasNextAVSID checks if the next Service ID is set -func (k Keeper) HasNextAVSID(ctx sdk.Context) bool { - store := ctx.KVStore(k.storeKey) - return store.Has(types.NextAVSIDKey()) -} - -// GetNextAVSID returns the next Service ID to be used when registering a new Service -func (k Keeper) GetNextAVSID(ctx sdk.Context) (avsID uint32, err error) { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.NextAVSIDKey()) - if bz == nil { - return 0, errors.Wrapf(types.ErrInvalidGenesis, "initial avs id not set") - } - - avsID = types.GetAVSIDFromBytes(bz) - return avsID, nil -} - -// -------------------------------------------------------------------------------------------------------------------- - -// SaveAVS stores a new Service in the KVStore -func (k Keeper) SaveAVS(ctx sdk.Context, avs types.Service) { - previous, existed := k.GetAVS(ctx, avs.ID) - - // Save the Service data - store := ctx.KVStore(k.storeKey) - store.Set(types.AVSStoreKey(avs.ID), k.cdc.MustMarshal(&avs)) - k.Logger(ctx).Debug("saved avs", "id", avs.ID) - - // Call the hook based on the Service status change - switch { - case !existed: - k.AfterAVSCreated(ctx, avs.ID) - case previous.Status == types.AVS_STATUS_CREATED && avs.Status == types.AVS_STATUS_REGISTERED: - k.AfterAVSRegistered(ctx, avs.ID) - case previous.Status == types.AVS_STATUS_REGISTERED && avs.Status == types.AVS_STATUS_UNREGISTERED: - k.AfterAVSDeregistered(ctx, avs.ID) - } -} - -// GetAVS returns an Service from the KVStore -func (k Keeper) GetAVS(ctx sdk.Context, avsID uint32) (avs types.Service, found bool) { - store := ctx.KVStore(k.storeKey) - - bz := store.Get(types.AVSStoreKey(avsID)) - if bz == nil { - return avs, false - } - - k.cdc.MustUnmarshal(bz, &avs) - return avs, true -} diff --git a/x/services/keeper/expected_interfaces.go b/x/services/keeper/expected_interfaces.go new file mode 100644 index 000000000..716502d2f --- /dev/null +++ b/x/services/keeper/expected_interfaces.go @@ -0,0 +1,11 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type CommunityPoolKeeper interface { + FundCommunityPool(ctx context.Context, amount sdk.Coins, sender sdk.AccAddress) error +} From 93c368f737ef9665459fb863fd4c58d82fa980f1 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Tue, 4 Jun 2024 19:06:15 -0500 Subject: [PATCH 27/49] feat: add invariants --- x/services/genesis.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/x/services/genesis.go b/x/services/genesis.go index 351a1e19e..4f7b50118 100644 --- a/x/services/genesis.go +++ b/x/services/genesis.go @@ -8,7 +8,7 @@ import ( ) // ExportGenesis returns the GenesisState associated with the given context -func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { +func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) *types.GenesisState { return types.NewGenesisState( exportNextServiceID(ctx, k), exportServices(ctx, k), @@ -17,7 +17,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { } // exportNextServiceID returns the next Service ID stored in the KVStore -func exportNextServiceID(ctx sdk.Context, k keeper.Keeper) uint32 { +func exportNextServiceID(ctx sdk.Context, k *keeper.Keeper) uint32 { nextAVSID, err := k.GetNextServiceID(ctx) if err != nil { panic(err) @@ -26,7 +26,7 @@ func exportNextServiceID(ctx sdk.Context, k keeper.Keeper) uint32 { } // exportServices returns the services stored in the KVStore -func exportServices(ctx sdk.Context, k keeper.Keeper) []types.Service { +func exportServices(ctx sdk.Context, k *keeper.Keeper) []types.Service { var services []types.Service k.IterateServices(ctx, func(service types.Service) (stop bool) { services = append(services, service) @@ -36,9 +36,9 @@ func exportServices(ctx sdk.Context, k keeper.Keeper) []types.Service { } // InitGenesis initializes the state from a GenesisState -func InitGenesis(ctx sdk.Context, k keeper.Keeper, state types.GenesisState) { - // Set the next Service ID - k.SetNextServiceID(ctx, state.NextAVSID) +func InitGenesis(ctx sdk.Context, k *keeper.Keeper, state types.GenesisState) { + // Set the next service ID + k.SetNextServiceID(ctx, state.NextServiceID) // Store the services for _, service := range state.Services { From 072c2313e24ac1ba06b077e0d5560c3fb10f686b Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Wed, 5 Jun 2024 01:52:00 -0500 Subject: [PATCH 28/49] refactor: improve genesis usage --- x/services/genesis.go | 50 ------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 x/services/genesis.go diff --git a/x/services/genesis.go b/x/services/genesis.go deleted file mode 100644 index 4f7b50118..000000000 --- a/x/services/genesis.go +++ /dev/null @@ -1,50 +0,0 @@ -package services - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/milkyway-labs/milkyway/x/services/keeper" - "github.com/milkyway-labs/milkyway/x/services/types" -) - -// ExportGenesis returns the GenesisState associated with the given context -func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) *types.GenesisState { - return types.NewGenesisState( - exportNextServiceID(ctx, k), - exportServices(ctx, k), - k.GetParams(ctx), - ) -} - -// exportNextServiceID returns the next Service ID stored in the KVStore -func exportNextServiceID(ctx sdk.Context, k *keeper.Keeper) uint32 { - nextAVSID, err := k.GetNextServiceID(ctx) - if err != nil { - panic(err) - } - return nextAVSID -} - -// exportServices returns the services stored in the KVStore -func exportServices(ctx sdk.Context, k *keeper.Keeper) []types.Service { - var services []types.Service - k.IterateServices(ctx, func(service types.Service) (stop bool) { - services = append(services, service) - return false - }) - return services -} - -// InitGenesis initializes the state from a GenesisState -func InitGenesis(ctx sdk.Context, k *keeper.Keeper, state types.GenesisState) { - // Set the next service ID - k.SetNextServiceID(ctx, state.NextServiceID) - - // Store the services - for _, service := range state.Services { - k.SaveService(ctx, service) - } - - // Store params - k.SetParams(ctx, state.Params) -} From 6b724e812e7e78cca351f6b79280135fd4f44827 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Wed, 5 Jun 2024 02:01:17 -0500 Subject: [PATCH 29/49] refactor: improve msg server and gRPC querier --- x/services/keeper/genesis.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/services/keeper/genesis.go b/x/services/keeper/genesis.go index 7f4f39f6d..463aa4e82 100644 --- a/x/services/keeper/genesis.go +++ b/x/services/keeper/genesis.go @@ -33,7 +33,7 @@ func (k *Keeper) InitGenesis(ctx sdk.Context, state *types.GenesisState) { // Store the services for _, service := range state.Services { - k.SaveService(ctx, service) + k.storeService(ctx, service) } // Store params From db80558ecda20f0d5a1e42228a6bbbfa1a8fd855 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Wed, 5 Jun 2024 20:58:35 -0500 Subject: [PATCH 30/49] chore(tests): setup keeper tests --- Makefile | 9 +++++++++ .../{expected_interfaces.go => expected_keepers.go} | 0 2 files changed, 9 insertions(+) rename x/services/keeper/{expected_interfaces.go => expected_keepers.go} (100%) diff --git a/Makefile b/Makefile index 639475e9d..ae2496f55 100644 --- a/Makefile +++ b/Makefile @@ -227,6 +227,15 @@ mockgen: .PHONY: mocks +############################################################################### +### Mocks ### +############################################################################### + +mockgen: + @go install go.uber.org/mock/mockgen@latest + @./scripts/mockgen.sh +.PHONY: mocks + ############################################################################### ### Tests & Simulation ### ############################################################################### diff --git a/x/services/keeper/expected_interfaces.go b/x/services/keeper/expected_keepers.go similarity index 100% rename from x/services/keeper/expected_interfaces.go rename to x/services/keeper/expected_keepers.go From 17de184a38e37a14ac64f9defb11b1ecd329e394 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Thu, 6 Jun 2024 08:04:46 -0500 Subject: [PATCH 31/49] refactor: move expected keeper into types --- x/services/keeper/expected_keepers.go | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 x/services/keeper/expected_keepers.go diff --git a/x/services/keeper/expected_keepers.go b/x/services/keeper/expected_keepers.go deleted file mode 100644 index 716502d2f..000000000 --- a/x/services/keeper/expected_keepers.go +++ /dev/null @@ -1,11 +0,0 @@ -package keeper - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -type CommunityPoolKeeper interface { - FundCommunityPool(ctx context.Context, amount sdk.Coins, sender sdk.AccAddress) error -} From 76256f11c6274845db7a0756661dfa1aa85bfc6d Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Sun, 9 Jun 2024 23:30:08 -0500 Subject: [PATCH 32/49] refactor: improve msg service --- x/services/keeper/genesis.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/services/keeper/genesis.go b/x/services/keeper/genesis.go index 463aa4e82..7f4f39f6d 100644 --- a/x/services/keeper/genesis.go +++ b/x/services/keeper/genesis.go @@ -33,7 +33,7 @@ func (k *Keeper) InitGenesis(ctx sdk.Context, state *types.GenesisState) { // Store the services for _, service := range state.Services { - k.storeService(ctx, service) + k.SaveService(ctx, service) } // Store params From 05fe218e03d16e03e31f97f78a1bb1e505645bbf Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Thu, 13 Jun 2024 08:48:50 -0500 Subject: [PATCH 33/49] revert: api codebase formatting This reverts commit 7ef72fc833a60e70a113a3c22051f7d4c06ee9bb. --- .../tokenfactory/v1/authorityMetadata.pulsar.go | 9 ++++----- api/milkyway/tokenfactory/v1/genesis.pulsar.go | 7 +++---- api/milkyway/tokenfactory/v1/params.pulsar.go | 9 ++++----- api/milkyway/tokenfactory/v1/query.pulsar.go | 9 ++++----- api/milkyway/tokenfactory/v1/tx.pulsar.go | 9 ++++----- api/stride/epochs/genesis.pulsar.go | 7 +++---- api/stride/epochs/query.pulsar.go | 9 ++++----- api/stride/icacallbacks/callback_data.pulsar.go | 7 +++---- api/stride/icacallbacks/genesis.pulsar.go | 7 +++---- api/stride/icacallbacks/packet.pulsar.go | 7 +++---- api/stride/icacallbacks/params.pulsar.go | 7 +++---- api/stride/icacallbacks/query.pulsar.go | 9 ++++----- api/stride/icacallbacks/tx.pulsar.go | 3 +-- api/stride/interchainquery/v1/genesis.pulsar.go | 7 +++---- api/stride/interchainquery/v1/messages.pulsar.go | 9 ++++----- api/stride/interchainquery/v1/query.pulsar.go | 7 +++---- api/stride/records/callbacks.pulsar.go | 7 +++---- api/stride/records/genesis.pulsar.go | 7 +++---- api/stride/records/params.pulsar.go | 7 +++---- api/stride/records/query.pulsar.go | 9 ++++----- api/stride/records/records.pulsar.go | 9 ++++----- api/stride/stakeibc/address_unbonding.pulsar.go | 7 +++---- api/stride/stakeibc/callbacks.pulsar.go | 12 +++++------- api/stride/stakeibc/epoch_tracker.pulsar.go | 7 +++---- api/stride/stakeibc/genesis.pulsar.go | 7 +++---- api/stride/stakeibc/gov.pulsar.go | 7 +++---- api/stride/stakeibc/host_zone.pulsar.go | 7 +++---- api/stride/stakeibc/ica_account.pulsar.go | 7 +++---- api/stride/stakeibc/packet.pulsar.go | 7 +++---- api/stride/stakeibc/params.pulsar.go | 7 +++---- api/stride/stakeibc/query.pulsar.go | 9 ++++----- api/stride/stakeibc/trade_route.pulsar.go | 9 ++++----- api/stride/stakeibc/tx.pulsar.go | 11 +++++------ api/stride/stakeibc/validator.pulsar.go | 7 +++---- 34 files changed, 115 insertions(+), 150 deletions(-) diff --git a/api/milkyway/tokenfactory/v1/authorityMetadata.pulsar.go b/api/milkyway/tokenfactory/v1/authorityMetadata.pulsar.go index a009ba879..505676642 100644 --- a/api/milkyway/tokenfactory/v1/authorityMetadata.pulsar.go +++ b/api/milkyway/tokenfactory/v1/authorityMetadata.pulsar.go @@ -2,17 +2,16 @@ package tokenfactoryv1 import ( - fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - _ "cosmossdk.io/api/cosmos/base/v1beta1" + fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/milkyway/tokenfactory/v1/genesis.pulsar.go b/api/milkyway/tokenfactory/v1/genesis.pulsar.go index 560a3c478..f6d221ccc 100644 --- a/api/milkyway/tokenfactory/v1/genesis.pulsar.go +++ b/api/milkyway/tokenfactory/v1/genesis.pulsar.go @@ -3,15 +3,14 @@ package tokenfactoryv1 import ( fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var _ protoreflect.List = (*_GenesisState_2_list)(nil) diff --git a/api/milkyway/tokenfactory/v1/params.pulsar.go b/api/milkyway/tokenfactory/v1/params.pulsar.go index 25b473890..9fb043cc9 100644 --- a/api/milkyway/tokenfactory/v1/params.pulsar.go +++ b/api/milkyway/tokenfactory/v1/params.pulsar.go @@ -2,18 +2,17 @@ package tokenfactoryv1 import ( - fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" + fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var _ protoreflect.List = (*_Params_1_list)(nil) diff --git a/api/milkyway/tokenfactory/v1/query.pulsar.go b/api/milkyway/tokenfactory/v1/query.pulsar.go index 825a7fa7a..0c9eb68b5 100644 --- a/api/milkyway/tokenfactory/v1/query.pulsar.go +++ b/api/milkyway/tokenfactory/v1/query.pulsar.go @@ -2,18 +2,17 @@ package tokenfactoryv1 import ( - fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - _ "cosmossdk.io/api/cosmos/base/query/v1beta1" + fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/milkyway/tokenfactory/v1/tx.pulsar.go b/api/milkyway/tokenfactory/v1/tx.pulsar.go index 4e581e259..d7b14ddf1 100644 --- a/api/milkyway/tokenfactory/v1/tx.pulsar.go +++ b/api/milkyway/tokenfactory/v1/tx.pulsar.go @@ -2,21 +2,20 @@ package tokenfactoryv1 import ( - fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - _ "cosmossdk.io/api/amino" v1beta11 "cosmossdk.io/api/cosmos/bank/v1beta1" v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" _ "cosmossdk.io/api/cosmos/msg/v1" + fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/epochs/genesis.pulsar.go b/api/stride/epochs/genesis.pulsar.go index a9a11b3c4..a98391993 100644 --- a/api/stride/epochs/genesis.pulsar.go +++ b/api/stride/epochs/genesis.pulsar.go @@ -3,10 +3,6 @@ package epochs import ( fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -14,6 +10,9 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" durationpb "google.golang.org/protobuf/types/known/durationpb" timestamppb "google.golang.org/protobuf/types/known/timestamppb" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/epochs/query.pulsar.go b/api/stride/epochs/query.pulsar.go index 6e0206d2b..77f055a53 100644 --- a/api/stride/epochs/query.pulsar.go +++ b/api/stride/epochs/query.pulsar.go @@ -2,18 +2,17 @@ package epochs import ( - fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" + fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/icacallbacks/callback_data.pulsar.go b/api/stride/icacallbacks/callback_data.pulsar.go index 62fcf9509..246763625 100644 --- a/api/stride/icacallbacks/callback_data.pulsar.go +++ b/api/stride/icacallbacks/callback_data.pulsar.go @@ -3,14 +3,13 @@ package icacallbacks import ( fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - runtime "github.com/cosmos/cosmos-proto/runtime" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/icacallbacks/genesis.pulsar.go b/api/stride/icacallbacks/genesis.pulsar.go index e8a0b8d77..8143181c5 100644 --- a/api/stride/icacallbacks/genesis.pulsar.go +++ b/api/stride/icacallbacks/genesis.pulsar.go @@ -3,15 +3,14 @@ package icacallbacks import ( fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var _ protoreflect.List = (*_GenesisState_3_list)(nil) diff --git a/api/stride/icacallbacks/packet.pulsar.go b/api/stride/icacallbacks/packet.pulsar.go index c223b438f..dc77eb267 100644 --- a/api/stride/icacallbacks/packet.pulsar.go +++ b/api/stride/icacallbacks/packet.pulsar.go @@ -3,14 +3,13 @@ package icacallbacks import ( fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - runtime "github.com/cosmos/cosmos-proto/runtime" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/icacallbacks/params.pulsar.go b/api/stride/icacallbacks/params.pulsar.go index 83998d1e8..e542245b7 100644 --- a/api/stride/icacallbacks/params.pulsar.go +++ b/api/stride/icacallbacks/params.pulsar.go @@ -3,15 +3,14 @@ package icacallbacks import ( fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/icacallbacks/query.pulsar.go b/api/stride/icacallbacks/query.pulsar.go index a2d2e23fd..7e5f369d8 100644 --- a/api/stride/icacallbacks/query.pulsar.go +++ b/api/stride/icacallbacks/query.pulsar.go @@ -2,18 +2,17 @@ package icacallbacks import ( - fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" + fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/icacallbacks/tx.pulsar.go b/api/stride/icacallbacks/tx.pulsar.go index 9965955d0..532e52e67 100644 --- a/api/stride/icacallbacks/tx.pulsar.go +++ b/api/stride/icacallbacks/tx.pulsar.go @@ -2,11 +2,10 @@ package icacallbacks import ( - reflect "reflect" - _ "cosmossdk.io/api/cosmos/msg/v1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" ) // Code generated by protoc-gen-go. DO NOT EDIT. diff --git a/api/stride/interchainquery/v1/genesis.pulsar.go b/api/stride/interchainquery/v1/genesis.pulsar.go index 7371b4859..092b7a51d 100644 --- a/api/stride/interchainquery/v1/genesis.pulsar.go +++ b/api/stride/interchainquery/v1/genesis.pulsar.go @@ -3,10 +3,6 @@ package interchainqueryv1 import ( fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" @@ -14,6 +10,9 @@ import ( protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" durationpb "google.golang.org/protobuf/types/known/durationpb" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/interchainquery/v1/messages.pulsar.go b/api/stride/interchainquery/v1/messages.pulsar.go index 034408663..3ba0b9a9b 100644 --- a/api/stride/interchainquery/v1/messages.pulsar.go +++ b/api/stride/interchainquery/v1/messages.pulsar.go @@ -2,14 +2,10 @@ package interchainqueryv1 import ( - fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - _ "cosmossdk.io/api/amino" _ "cosmossdk.io/api/cosmos/msg/v1" crypto "cosmossdk.io/api/tendermint/crypto" + fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" @@ -17,6 +13,9 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/interchainquery/v1/query.pulsar.go b/api/stride/interchainquery/v1/query.pulsar.go index 58db67146..094c70795 100644 --- a/api/stride/interchainquery/v1/query.pulsar.go +++ b/api/stride/interchainquery/v1/query.pulsar.go @@ -3,16 +3,15 @@ package interchainqueryv1 import ( fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/records/callbacks.pulsar.go b/api/stride/records/callbacks.pulsar.go index 524ac9749..691cff99b 100644 --- a/api/stride/records/callbacks.pulsar.go +++ b/api/stride/records/callbacks.pulsar.go @@ -3,14 +3,13 @@ package records import ( fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - runtime "github.com/cosmos/cosmos-proto/runtime" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/records/genesis.pulsar.go b/api/stride/records/genesis.pulsar.go index 842ebe4cb..a34e9b821 100644 --- a/api/stride/records/genesis.pulsar.go +++ b/api/stride/records/genesis.pulsar.go @@ -3,15 +3,14 @@ package records import ( fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var _ protoreflect.List = (*_GenesisState_3_list)(nil) diff --git a/api/stride/records/params.pulsar.go b/api/stride/records/params.pulsar.go index b1a3b5e84..47d1a72a1 100644 --- a/api/stride/records/params.pulsar.go +++ b/api/stride/records/params.pulsar.go @@ -3,14 +3,13 @@ package records import ( fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - runtime "github.com/cosmos/cosmos-proto/runtime" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/records/query.pulsar.go b/api/stride/records/query.pulsar.go index dd1f49c8a..76ab4571d 100644 --- a/api/stride/records/query.pulsar.go +++ b/api/stride/records/query.pulsar.go @@ -2,18 +2,17 @@ package records import ( - fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" + fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/records/records.pulsar.go b/api/stride/records/records.pulsar.go index ba73822f4..20149c17e 100644 --- a/api/stride/records/records.pulsar.go +++ b/api/stride/records/records.pulsar.go @@ -2,17 +2,16 @@ package records import ( - fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" + fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/stakeibc/address_unbonding.pulsar.go b/api/stride/stakeibc/address_unbonding.pulsar.go index 110ab9e14..cd5057c2e 100644 --- a/api/stride/stakeibc/address_unbonding.pulsar.go +++ b/api/stride/stakeibc/address_unbonding.pulsar.go @@ -3,15 +3,14 @@ package stakeibc import ( fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/stakeibc/callbacks.pulsar.go b/api/stride/stakeibc/callbacks.pulsar.go index a02d3ed57..61be3c8e9 100644 --- a/api/stride/stakeibc/callbacks.pulsar.go +++ b/api/stride/stakeibc/callbacks.pulsar.go @@ -2,19 +2,17 @@ package stakeibc import ( - fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" + fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" + records "github.com/milkyway-labs/milkyway/api/stride/records" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - - records "github.com/milkyway-labs/milkyway/api/stride/records" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/stakeibc/epoch_tracker.pulsar.go b/api/stride/stakeibc/epoch_tracker.pulsar.go index 28f01c8d9..da6961c6b 100644 --- a/api/stride/stakeibc/epoch_tracker.pulsar.go +++ b/api/stride/stakeibc/epoch_tracker.pulsar.go @@ -3,14 +3,13 @@ package stakeibc import ( fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - runtime "github.com/cosmos/cosmos-proto/runtime" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/stakeibc/genesis.pulsar.go b/api/stride/stakeibc/genesis.pulsar.go index c4c43d3b8..29d5aecf8 100644 --- a/api/stride/stakeibc/genesis.pulsar.go +++ b/api/stride/stakeibc/genesis.pulsar.go @@ -3,15 +3,14 @@ package stakeibc import ( fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var _ protoreflect.List = (*_GenesisState_5_list)(nil) diff --git a/api/stride/stakeibc/gov.pulsar.go b/api/stride/stakeibc/gov.pulsar.go index 3fe0b232d..1392138a4 100644 --- a/api/stride/stakeibc/gov.pulsar.go +++ b/api/stride/stakeibc/gov.pulsar.go @@ -3,15 +3,14 @@ package stakeibc import ( fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var _ protoreflect.List = (*_AddValidatorsProposal_4_list)(nil) diff --git a/api/stride/stakeibc/host_zone.pulsar.go b/api/stride/stakeibc/host_zone.pulsar.go index edbe6683e..b28ec5b08 100644 --- a/api/stride/stakeibc/host_zone.pulsar.go +++ b/api/stride/stakeibc/host_zone.pulsar.go @@ -3,16 +3,15 @@ package stakeibc import ( fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/stakeibc/ica_account.pulsar.go b/api/stride/stakeibc/ica_account.pulsar.go index 7230dd817..238c790d6 100644 --- a/api/stride/stakeibc/ica_account.pulsar.go +++ b/api/stride/stakeibc/ica_account.pulsar.go @@ -3,14 +3,13 @@ package stakeibc import ( fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - runtime "github.com/cosmos/cosmos-proto/runtime" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/stakeibc/packet.pulsar.go b/api/stride/stakeibc/packet.pulsar.go index 16132f276..e5b966a85 100644 --- a/api/stride/stakeibc/packet.pulsar.go +++ b/api/stride/stakeibc/packet.pulsar.go @@ -3,14 +3,13 @@ package stakeibc import ( fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - runtime "github.com/cosmos/cosmos-proto/runtime" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/stakeibc/params.pulsar.go b/api/stride/stakeibc/params.pulsar.go index 92d5c2c61..754db6f24 100644 --- a/api/stride/stakeibc/params.pulsar.go +++ b/api/stride/stakeibc/params.pulsar.go @@ -3,15 +3,14 @@ package stakeibc import ( fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/stakeibc/query.pulsar.go b/api/stride/stakeibc/query.pulsar.go index b3fdc6d46..fa8b7cf17 100644 --- a/api/stride/stakeibc/query.pulsar.go +++ b/api/stride/stakeibc/query.pulsar.go @@ -2,18 +2,17 @@ package stakeibc import ( - fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" + fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( diff --git a/api/stride/stakeibc/trade_route.pulsar.go b/api/stride/stakeibc/trade_route.pulsar.go index 2dc4471e1..b563d8f34 100644 --- a/api/stride/stakeibc/trade_route.pulsar.go +++ b/api/stride/stakeibc/trade_route.pulsar.go @@ -3,16 +3,15 @@ package stakeibc import ( fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( @@ -2011,7 +2010,7 @@ func (x *TradeConfig) GetMaxSwapAmount() string { // the swap. It makes the assumption that the reward token is always foreign to // the host so therefore the first two hops are to unwind the ibc denom enroute // to the trade chain and the last hop is the return so funds start/end in the -// withdrawal ICA on hostZone +// withdrawl ICA on hostZone // The structure is key'd on reward denom and host denom in their native forms // (i.e. reward_denom_on_reward_zone and host_denom_on_host_zone) type TradeRoute struct { diff --git a/api/stride/stakeibc/tx.pulsar.go b/api/stride/stakeibc/tx.pulsar.go index e653db619..21516c666 100644 --- a/api/stride/stakeibc/tx.pulsar.go +++ b/api/stride/stakeibc/tx.pulsar.go @@ -2,20 +2,19 @@ package stakeibc import ( - fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - _ "cosmossdk.io/api/amino" v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" _ "cosmossdk.io/api/cosmos/msg/v1" + fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( @@ -23470,7 +23469,7 @@ type MsgSetCommunityPoolRebate struct { ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Rebate percentage represented as a decimal (e.g. 0.2 for 20%) RebateRate string `protobuf:"bytes,3,opt,name=rebate_rate,json=rebateRate,proto3" json:"rebate_rate,omitempty"` - // Number of stTokens received by the community pool after liquid staking + // Number of stTokens recieved by the community pool after liquid staking LiquidStakedStTokenAmount string `protobuf:"bytes,4,opt,name=liquid_staked_st_token_amount,json=liquidStakedStTokenAmount,proto3" json:"liquid_staked_st_token_amount,omitempty"` } diff --git a/api/stride/stakeibc/validator.pulsar.go b/api/stride/stakeibc/validator.pulsar.go index edd9caf60..ea56baf1d 100644 --- a/api/stride/stakeibc/validator.pulsar.go +++ b/api/stride/stakeibc/validator.pulsar.go @@ -3,16 +3,15 @@ package stakeibc import ( fmt "fmt" - io "io" - reflect "reflect" - sync "sync" - _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" ) var ( From 7b0c7706a8cccc040b7931dc48586e092fbdba7f Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Thu, 13 Jun 2024 09:45:45 -0500 Subject: [PATCH 34/49] refactor: store service account inside keeper --- x/services/keeper/genesis_test.go | 6 ------ x/services/keeper/grpc_query_test.go | 9 --------- x/services/keeper/invariants_test.go | 5 ----- x/services/keeper/msg_server.go | 5 ----- x/services/keeper/msg_server_test.go | 11 ----------- x/services/keeper/services_test.go | 11 ----------- 6 files changed, 47 deletions(-) diff --git a/x/services/keeper/genesis_test.go b/x/services/keeper/genesis_test.go index 1f3cfb750..b0f614241 100644 --- a/x/services/keeper/genesis_test.go +++ b/x/services/keeper/genesis_test.go @@ -40,7 +40,6 @@ func (suite *KeeperTestSuite) TestKeeper_ExportGenesis() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), )) suite.k.SaveService(ctx, types.NewService( @@ -51,7 +50,6 @@ func (suite *KeeperTestSuite) TestKeeper_ExportGenesis() { "https://inertia.zone", "https://inertia.zone/logo.png", "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", - types.GetServiceAddress(2).String(), )) }, expGenesis: &types.GenesisState{ @@ -65,7 +63,6 @@ func (suite *KeeperTestSuite) TestKeeper_ExportGenesis() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), ), types.NewService( 2, @@ -75,7 +72,6 @@ func (suite *KeeperTestSuite) TestKeeper_ExportGenesis() { "https://inertia.zone", "https://inertia.zone/logo.png", "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", - types.GetServiceAddress(2).String(), ), }, Params: types.DefaultParams(), @@ -148,7 +144,6 @@ func (suite *KeeperTestSuite) TestKeeper_InitGenesis() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), ), }, types.DefaultParams(), @@ -169,7 +164,6 @@ func (suite *KeeperTestSuite) TestKeeper_InitGenesis() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), ), services[0]) }, }, diff --git a/x/services/keeper/grpc_query_test.go b/x/services/keeper/grpc_query_test.go index 9e22b750d..2b83f1197 100644 --- a/x/services/keeper/grpc_query_test.go +++ b/x/services/keeper/grpc_query_test.go @@ -27,7 +27,6 @@ func (suite *KeeperTestSuite) TestKeeper_Services() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), )) suite.Require().NoError(err) @@ -39,7 +38,6 @@ func (suite *KeeperTestSuite) TestKeeper_Services() { "https://inertia.zone", "https://inertia.zone/logo.png", "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", - types.GetServiceAddress(2).String(), )) suite.Require().NoError(err) }, @@ -54,7 +52,6 @@ func (suite *KeeperTestSuite) TestKeeper_Services() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), ), types.NewService( 2, @@ -64,7 +61,6 @@ func (suite *KeeperTestSuite) TestKeeper_Services() { "https://inertia.zone", "https://inertia.zone/logo.png", "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", - types.GetServiceAddress(2).String(), ), }, }, @@ -79,7 +75,6 @@ func (suite *KeeperTestSuite) TestKeeper_Services() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), )) suite.Require().NoError(err) @@ -91,7 +86,6 @@ func (suite *KeeperTestSuite) TestKeeper_Services() { "https://inertia.zone", "https://inertia.zone/logo.png", "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", - types.GetServiceAddress(2).String(), )) suite.Require().NoError(err) }, @@ -109,7 +103,6 @@ func (suite *KeeperTestSuite) TestKeeper_Services() { "https://inertia.zone", "https://inertia.zone/logo.png", "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", - types.GetServiceAddress(2).String(), ), }, }, @@ -163,7 +156,6 @@ func (suite *KeeperTestSuite) TestKeeper_Service() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), )) suite.Require().NoError(err) }, @@ -177,7 +169,6 @@ func (suite *KeeperTestSuite) TestKeeper_Service() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), ), }, } diff --git a/x/services/keeper/invariants_test.go b/x/services/keeper/invariants_test.go index f2648171e..f24a0017c 100644 --- a/x/services/keeper/invariants_test.go +++ b/x/services/keeper/invariants_test.go @@ -25,7 +25,6 @@ func (suite *KeeperTestSuite) TestValidServicesInvariant() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), )) }, expBroken: true, @@ -42,7 +41,6 @@ func (suite *KeeperTestSuite) TestValidServicesInvariant() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), )) }, expBroken: true, @@ -59,7 +57,6 @@ func (suite *KeeperTestSuite) TestValidServicesInvariant() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(2).String(), )) }, expBroken: true, @@ -76,7 +73,6 @@ func (suite *KeeperTestSuite) TestValidServicesInvariant() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), )) }, expBroken: true, @@ -93,7 +89,6 @@ func (suite *KeeperTestSuite) TestValidServicesInvariant() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), )) }, expBroken: false, diff --git a/x/services/keeper/msg_server.go b/x/services/keeper/msg_server.go index 3b3348c1d..6e3633f45 100644 --- a/x/services/keeper/msg_server.go +++ b/x/services/keeper/msg_server.go @@ -34,10 +34,6 @@ func (k msgServer) CreateService(goCtx context.Context, msg *types.MsgCreateServ return nil, err } - // Create the service account - serviceAddress := types.GetServiceAddress(serviceID) - k.createAccountIfNotExists(ctx, serviceAddress) - // Create the Service and validate it service := types.NewService( serviceID, @@ -47,7 +43,6 @@ func (k msgServer) CreateService(goCtx context.Context, msg *types.MsgCreateServ msg.Website, msg.PictureURL, msg.Sender, - serviceAddress.String(), ) // Validate the service before storing diff --git a/x/services/keeper/msg_server_test.go b/x/services/keeper/msg_server_test.go index bd04ea654..0fa9adc5f 100644 --- a/x/services/keeper/msg_server_test.go +++ b/x/services/keeper/msg_server_test.go @@ -109,7 +109,6 @@ func (suite *KeeperTestSuite) TestMsgServer_CreateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), ), stored) // Make sure the service account has been created properly @@ -202,7 +201,6 @@ func (suite *KeeperTestSuite) TestMsgServer_UpdateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), )) }, msg: types.NewMsgUpdateService( @@ -226,7 +224,6 @@ func (suite *KeeperTestSuite) TestMsgServer_UpdateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), )) }, msg: types.NewMsgUpdateService( @@ -250,7 +247,6 @@ func (suite *KeeperTestSuite) TestMsgServer_UpdateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), )) }, msg: types.NewMsgUpdateService( @@ -281,7 +277,6 @@ func (suite *KeeperTestSuite) TestMsgServer_UpdateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), ), stored) }, }, @@ -351,7 +346,6 @@ func (suite *KeeperTestSuite) TestMsgServer_ActivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), )) }, msg: types.NewMsgActivateService( @@ -371,7 +365,6 @@ func (suite *KeeperTestSuite) TestMsgServer_ActivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), )) }, msg: types.NewMsgActivateService( @@ -391,7 +384,6 @@ func (suite *KeeperTestSuite) TestMsgServer_ActivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), )) }, msg: types.NewMsgActivateService( @@ -474,7 +466,6 @@ func (suite *KeeperTestSuite) TestMsgServer_DeactivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), )) }, msg: types.NewMsgDeactivateService( @@ -494,7 +485,6 @@ func (suite *KeeperTestSuite) TestMsgServer_DeactivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), )) }, msg: types.NewMsgDeactivateService( @@ -521,7 +511,6 @@ func (suite *KeeperTestSuite) TestMsgServer_DeactivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), ), stored) }, }, diff --git a/x/services/keeper/services_test.go b/x/services/keeper/services_test.go index 11236e30a..658796c48 100644 --- a/x/services/keeper/services_test.go +++ b/x/services/keeper/services_test.go @@ -124,7 +124,6 @@ func (suite *KeeperTestSuite) TestKeeper_CreateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), ), shouldErr: true, }, @@ -148,7 +147,6 @@ func (suite *KeeperTestSuite) TestKeeper_CreateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), ), shouldErr: false, check: func(ctx sdk.Context) { @@ -178,7 +176,6 @@ func (suite *KeeperTestSuite) TestKeeper_CreateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), ), service) // Make sure the hook was called @@ -237,7 +234,6 @@ func (suite *KeeperTestSuite) TestKeeper_ActivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), )) }, serviceID: 1, @@ -254,7 +250,6 @@ func (suite *KeeperTestSuite) TestKeeper_ActivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), )) }, serviceID: 1, @@ -270,7 +265,6 @@ func (suite *KeeperTestSuite) TestKeeper_ActivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), ), service) // Make sure the hook was called @@ -329,7 +323,6 @@ func (suite *KeeperTestSuite) TestKeeper_DeactivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), )) }, serviceID: 1, @@ -346,7 +339,6 @@ func (suite *KeeperTestSuite) TestKeeper_DeactivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), )) }, serviceID: 1, @@ -362,7 +354,6 @@ func (suite *KeeperTestSuite) TestKeeper_DeactivateService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), ), service) // Make sure the hook was called @@ -420,7 +411,6 @@ func (suite *KeeperTestSuite) TestKeeper_GetService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), )) }, serviceID: 1, @@ -433,7 +423,6 @@ func (suite *KeeperTestSuite) TestKeeper_GetService() { "https://milkyway.com", "https://milkyway.com/logo.png", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - types.GetServiceAddress(1).String(), ), }, } From 42b2a01653f3a2f3c8ede60580ab73588a688385 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Sat, 8 Jun 2024 12:03:43 -0500 Subject: [PATCH 35/49] feat: add keeper and types --- proto/milkyway/pools/v1/genesis.proto | 22 ++ proto/milkyway/pools/v1/models.proto | 16 ++ x/pools/keeper/alias_functions.go | 66 +++++ x/pools/keeper/keeper.go | 29 ++ x/pools/keeper/pools.go | 48 ++++ x/pools/types/errors.go | 9 + x/pools/types/genesis.go | 31 +++ x/pools/types/genesis.pb.go | 373 ++++++++++++++++++++++++++ x/pools/types/keys.go | 33 +++ x/pools/types/models.go | 28 ++ x/pools/types/models.pb.go | 357 ++++++++++++++++++++++++ 11 files changed, 1012 insertions(+) create mode 100644 proto/milkyway/pools/v1/genesis.proto create mode 100644 proto/milkyway/pools/v1/models.proto create mode 100644 x/pools/keeper/alias_functions.go create mode 100644 x/pools/keeper/keeper.go create mode 100644 x/pools/keeper/pools.go create mode 100644 x/pools/types/errors.go create mode 100644 x/pools/types/genesis.go create mode 100644 x/pools/types/genesis.pb.go create mode 100644 x/pools/types/keys.go create mode 100644 x/pools/types/models.go create mode 100644 x/pools/types/models.pb.go diff --git a/proto/milkyway/pools/v1/genesis.proto b/proto/milkyway/pools/v1/genesis.proto new file mode 100644 index 000000000..1a0cfa1af --- /dev/null +++ b/proto/milkyway/pools/v1/genesis.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; +package milkyway.pools.v1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; +import "milkyway/pools/v1/models.proto"; + +option go_package = "github.com/milkyway-labs/milkyway/x/pools/types"; + +// GenesisState defines the pools module's genesis state. +message GenesisState { + + // NextPoolID represents the id to be used when creating the next pool. + uint32 next_pool_id = 1 [ + (gogoproto.customname) = "NextPoolID", + (gogoproto.moretags) = "yaml:\"next_pool_id\"" + ]; + + // Operators defines the list of pools. + repeated Pool pools = 2 + [ (gogoproto.moretags) = "yaml:\"pools\"", (gogoproto.nullable) = false ]; +} \ No newline at end of file diff --git a/proto/milkyway/pools/v1/models.proto b/proto/milkyway/pools/v1/models.proto new file mode 100644 index 000000000..48d4b6074 --- /dev/null +++ b/proto/milkyway/pools/v1/models.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package milkyway.pools.v1; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/milkyway-labs/milkyway/x/pools/types"; + +// Pool defines the structure of a restaking pool +message Pool { + // ID is the auto-generated unique identifier for the pool + uint32 id = 1 [ (gogoproto.customname) = "ID" ]; + + // Denom represents the denomination of the tokens that are staked in the pool + string denom = 2; +} diff --git a/x/pools/keeper/alias_functions.go b/x/pools/keeper/alias_functions.go new file mode 100644 index 000000000..055e50a65 --- /dev/null +++ b/x/pools/keeper/alias_functions.go @@ -0,0 +1,66 @@ +package keeper + +import ( + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/milkyway-labs/milkyway/x/pools/types" +) + +// IteratePools iterates over the pools in the store and performs a callback function +func (k *Keeper) IteratePools(ctx sdk.Context, cb func(pool types.Pool) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iterator := storetypes.KVStorePrefixIterator(store, types.PooolPrefix) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var pool types.Pool + k.cdc.MustUnmarshal(iterator.Value(), &pool) + + if cb(pool) { + break + } + } +} + +// GetPoolForDenom returns the pool for the given denom if it exists. +// If the pool does not exist, false is returned instead +func (k *Keeper) GetPoolForDenom(ctx sdk.Context, denom string) (types.Pool, bool) { + store := ctx.KVStore(k.storeKey) + iterator := storetypes.KVStorePrefixIterator(store, types.PooolPrefix) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var pool types.Pool + k.cdc.MustUnmarshal(iterator.Value(), &pool) + + if pool.Denom == denom { + return pool, true + } + } + + return types.Pool{}, false +} + +// CreatePoolForDenomIfNotExists creates a new pool for the given denom if it does not exist +func (k *Keeper) CreatePoolForDenomIfNotExists(ctx sdk.Context, denom string) error { + // If the pool already exists, just return + if _, ok := k.GetPoolForDenom(ctx, denom); ok { + return nil + } + + // Get the pool id + poolID, err := k.GetNextPoolID(ctx) + if err != nil { + return nil + } + + // Create and store the pool + pool := types.NewPool(poolID, denom) + k.SavePool(ctx, pool) + + // Increment the pool id + k.SetNextPoolID(ctx, poolID+1) + + return nil +} diff --git a/x/pools/keeper/keeper.go b/x/pools/keeper/keeper.go new file mode 100644 index 000000000..58b5370c4 --- /dev/null +++ b/x/pools/keeper/keeper.go @@ -0,0 +1,29 @@ +package keeper + +import ( + "cosmossdk.io/log" + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/milkyway-labs/milkyway/x/operators/types" +) + +type Keeper struct { + storeKey storetypes.StoreKey + cdc codec.Codec + + authority string +} + +func NewKeeper(storeKey storetypes.StoreKey, authority string) *Keeper { + return &Keeper{ + storeKey: storeKey, + authority: authority, + } +} + +// Logger returns a module-specific logger. +func (k *Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", "x/"+types.ModuleName) +} diff --git a/x/pools/keeper/pools.go b/x/pools/keeper/pools.go new file mode 100644 index 000000000..fa57b801c --- /dev/null +++ b/x/pools/keeper/pools.go @@ -0,0 +1,48 @@ +package keeper + +import ( + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/milkyway-labs/milkyway/x/pools/types" +) + +// SetNextPoolID sets the next service ID to be used when registering a new Pool +func (k *Keeper) SetNextPoolID(ctx sdk.Context, serviceID uint32) { + store := ctx.KVStore(k.storeKey) + store.Set(types.NextPoolIDKey, types.GetPoolIDBytes(serviceID)) +} + +// GetNextPoolID returns the next service ID to be used when registering a new Pool +func (k *Keeper) GetNextPoolID(ctx sdk.Context) (serviceID uint32, err error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.NextPoolIDKey) + if bz == nil { + return 0, errors.Wrapf(types.ErrInvalidGenesis, "initial service id not set") + } + + serviceID = types.GetPoolIDFromBytes(bz) + return serviceID, nil +} + +// -------------------------------------------------------------------------------------------------------------------- + +// SavePool stores the given pool inside the store +func (k *Keeper) SavePool(ctx sdk.Context, pool types.Pool) { + store := ctx.KVStore(k.storeKey) + store.Set(types.GetPoolStoreKey(pool.ID), k.cdc.MustMarshal(&pool)) +} + +// GetPool retrieves the pool with the given ID from the store. +// If the pool does not exist, false is returned instead +func (k *Keeper) GetPool(ctx sdk.Context, id uint32) (types.Pool, bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.GetPoolStoreKey(id)) + if bz == nil { + return types.Pool{}, false + } + + var pool types.Pool + k.cdc.MustUnmarshal(bz, &pool) + return pool, true +} diff --git a/x/pools/types/errors.go b/x/pools/types/errors.go new file mode 100644 index 000000000..ab08baa2d --- /dev/null +++ b/x/pools/types/errors.go @@ -0,0 +1,9 @@ +package types + +import ( + "cosmossdk.io/errors" +) + +var ( + ErrInvalidGenesis = errors.Register(ModuleName, 1, "invalid genesis state") +) diff --git a/x/pools/types/genesis.go b/x/pools/types/genesis.go new file mode 100644 index 000000000..65d6efc70 --- /dev/null +++ b/x/pools/types/genesis.go @@ -0,0 +1,31 @@ +package types + +import ( + "fmt" +) + +// NewGenesis creates a new GenesisState instance +func NewGenesis(nextPoolID uint32, pools []Pool) GenesisState { + return GenesisState{ + NextPoolID: nextPoolID, + Pools: pools, + } +} + +// Validate checks if the GenesisState is valid +func (data *GenesisState) Validate() error { + // Validate the next pool ID + if data.NextPoolID == 0 { + return fmt.Errorf("invalid next pool id") + } + + // Validate the pools + for _, pool := range data.Pools { + err := pool.Validate() + if err != nil { + return fmt.Errorf("invalid pool with id %d: %w", pool.ID, err) + } + } + + return nil +} diff --git a/x/pools/types/genesis.pb.go b/x/pools/types/genesis.pb.go new file mode 100644 index 000000000..6514bf366 --- /dev/null +++ b/x/pools/types/genesis.pb.go @@ -0,0 +1,373 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: milkyway/pools/v1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/protobuf/types/known/timestamppb" + 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 pools module's genesis state. +type GenesisState struct { + // NextPoolID represents the id to be used when creating the next pool. + NextPoolID uint32 `protobuf:"varint,1,opt,name=next_pool_id,json=nextPoolId,proto3" json:"next_pool_id,omitempty" yaml:"next_pool_id"` + // Operators defines the list of pools. + Pools []Pool `protobuf:"bytes,2,rep,name=pools,proto3" json:"pools" yaml:"pools"` +} + +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_d15ae23e1a0ffba4, []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) GetNextPoolID() uint32 { + if m != nil { + return m.NextPoolID + } + return 0 +} + +func (m *GenesisState) GetPools() []Pool { + if m != nil { + return m.Pools + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "milkyway.pools.v1.GenesisState") +} + +func init() { proto.RegisterFile("milkyway/pools/v1/genesis.proto", fileDescriptor_d15ae23e1a0ffba4) } + +var fileDescriptor_d15ae23e1a0ffba4 = []byte{ + // 288 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcf, 0xcd, 0xcc, 0xc9, + 0xae, 0x2c, 0x4f, 0xac, 0xd4, 0x2f, 0xc8, 0xcf, 0xcf, 0x29, 0xd6, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, + 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x84, 0x29, 0xd0, + 0x03, 0x2b, 0xd0, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xea, 0x83, 0x58, + 0x10, 0x85, 0x52, 0xf2, 0xe9, 0xf9, 0xf9, 0xe9, 0x39, 0xa9, 0xfa, 0x60, 0x5e, 0x52, 0x69, 0x9a, + 0x7e, 0x49, 0x66, 0x6e, 0x6a, 0x71, 0x49, 0x62, 0x6e, 0x01, 0x54, 0x81, 0x1c, 0xa6, 0x55, 0xb9, + 0xf9, 0x29, 0xa9, 0x39, 0x50, 0x9b, 0x94, 0xe6, 0x30, 0x72, 0xf1, 0xb8, 0x43, 0xec, 0x0e, 0x2e, + 0x49, 0x2c, 0x49, 0x15, 0x72, 0xe7, 0xe2, 0xc9, 0x4b, 0xad, 0x28, 0x89, 0x07, 0x29, 0x8f, 0xcf, + 0x4c, 0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x75, 0x52, 0x7d, 0x74, 0x4f, 0x9e, 0xcb, 0x2f, 0xb5, + 0xa2, 0x24, 0x20, 0x3f, 0x3f, 0xc7, 0xd3, 0xe5, 0xd3, 0x3d, 0x79, 0xe1, 0xca, 0xc4, 0xdc, 0x1c, + 0x2b, 0x25, 0x64, 0xb5, 0x4a, 0x41, 0x5c, 0x79, 0x30, 0x25, 0x29, 0x42, 0xce, 0x5c, 0xac, 0x60, + 0x2b, 0x25, 0x98, 0x14, 0x98, 0x35, 0xb8, 0x8d, 0xc4, 0xf5, 0x30, 0xfc, 0xa4, 0x07, 0x52, 0xe9, + 0x24, 0x72, 0xe2, 0x9e, 0x3c, 0xc3, 0xa7, 0x7b, 0xf2, 0x3c, 0x10, 0x03, 0xc1, 0x92, 0x4a, 0x41, + 0x10, 0xbd, 0x4e, 0x9e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, + 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x9f, + 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0x33, 0x59, 0x37, 0x27, 0x31, + 0xa9, 0x18, 0xce, 0xd3, 0xaf, 0x80, 0xfa, 0xb9, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, + 0x61, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa6, 0x70, 0x7d, 0x2a, 0x7d, 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 + if len(m.Pools) > 0 { + for iNdEx := len(m.Pools) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Pools[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.NextPoolID != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.NextPoolID)) + i-- + dAtA[i] = 0x8 + } + 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 + if m.NextPoolID != 0 { + n += 1 + sovGenesis(uint64(m.NextPoolID)) + } + if len(m.Pools) > 0 { + for _, e := range m.Pools { + l = e.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 != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextPoolID", wireType) + } + m.NextPoolID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextPoolID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pools", 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 + } + m.Pools = append(m.Pools, Pool{}) + if err := m.Pools[len(m.Pools)-1].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/pools/types/keys.go b/x/pools/types/keys.go new file mode 100644 index 000000000..a28014b67 --- /dev/null +++ b/x/pools/types/keys.go @@ -0,0 +1,33 @@ +package types + +import ( + "encoding/binary" +) + +const ( + ModuleName = "pools" + StoreKey = ModuleName +) + +var ( + NextPoolIDKey = []byte{0x01} + + PooolPrefix = []byte{0xa1} +) + +// GetPoolIDBytes returns the byte representation of the pool ID +func GetPoolIDBytes(poolID uint32) (poolIDBz []byte) { + poolIDBz = make([]byte, 4) + binary.BigEndian.PutUint32(poolIDBz, poolID) + return poolIDBz +} + +// GetPoolIDFromBytes returns the pool ID from a byte array +func GetPoolIDFromBytes(bz []byte) (poolID uint32) { + return binary.BigEndian.Uint32(bz) +} + +// GetPoolStoreKey turns a pool ID into a key used to store a pool in the KVStore +func GetPoolStoreKey(poolID uint32) []byte { + return append(PooolPrefix, GetPoolIDBytes(poolID)...) +} diff --git a/x/pools/types/models.go b/x/pools/types/models.go new file mode 100644 index 000000000..63496ae57 --- /dev/null +++ b/x/pools/types/models.go @@ -0,0 +1,28 @@ +package types + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// NewPool creates a new Pool instance +func NewPool(id uint32, denom string) Pool { + return Pool{ + ID: id, + Denom: denom, + } +} + +// Validate checks if the pool is valid +func (p *Pool) Validate() error { + if p.ID == 0 { + return fmt.Errorf("invalid pool id") + } + + if sdk.ValidateDenom(p.Denom) != nil { + return fmt.Errorf("invalid pool denom") + } + + return nil +} diff --git a/x/pools/types/models.pb.go b/x/pools/types/models.pb.go new file mode 100644 index 000000000..1fa978842 --- /dev/null +++ b/x/pools/types/models.pb.go @@ -0,0 +1,357 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: milkyway/pools/v1/models.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/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 + +// Pool defines the structure of a restaking pool +type Pool struct { + // ID is the auto-generated unique identifier for the pool + ID uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // Denom represents the denomination of the tokens that are staked in the pool + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` +} + +func (m *Pool) Reset() { *m = Pool{} } +func (m *Pool) String() string { return proto.CompactTextString(m) } +func (*Pool) ProtoMessage() {} +func (*Pool) Descriptor() ([]byte, []int) { + return fileDescriptor_b29c6df2abe9a338, []int{0} +} +func (m *Pool) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Pool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Pool.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 *Pool) XXX_Merge(src proto.Message) { + xxx_messageInfo_Pool.Merge(m, src) +} +func (m *Pool) XXX_Size() int { + return m.Size() +} +func (m *Pool) XXX_DiscardUnknown() { + xxx_messageInfo_Pool.DiscardUnknown(m) +} + +var xxx_messageInfo_Pool proto.InternalMessageInfo + +func (m *Pool) GetID() uint32 { + if m != nil { + return m.ID + } + return 0 +} + +func (m *Pool) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func init() { + proto.RegisterType((*Pool)(nil), "milkyway.pools.v1.Pool") +} + +func init() { proto.RegisterFile("milkyway/pools/v1/models.proto", fileDescriptor_b29c6df2abe9a338) } + +var fileDescriptor_b29c6df2abe9a338 = []byte{ + // 207 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcb, 0xcd, 0xcc, 0xc9, + 0xae, 0x2c, 0x4f, 0xac, 0xd4, 0x2f, 0xc8, 0xcf, 0xcf, 0x29, 0xd6, 0x2f, 0x33, 0xd4, 0xcf, 0xcd, + 0x4f, 0x49, 0xcd, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x84, 0xc9, 0xeb, 0x81, + 0xe5, 0xf5, 0xca, 0x0c, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xb2, 0xfa, 0x20, 0x16, 0x44, + 0xa1, 0x94, 0x64, 0x72, 0x7e, 0x71, 0x6e, 0x7e, 0x71, 0x3c, 0x44, 0x02, 0xc2, 0x81, 0x48, 0x29, + 0x99, 0x70, 0xb1, 0x04, 0xe4, 0xe7, 0xe7, 0x08, 0x89, 0x71, 0x31, 0x65, 0xa6, 0x48, 0x30, 0x2a, + 0x30, 0x6a, 0xf0, 0x3a, 0xb1, 0x3d, 0xba, 0x27, 0xcf, 0xe4, 0xe9, 0x12, 0xc4, 0x94, 0x99, 0x22, + 0x24, 0xc2, 0xc5, 0x9a, 0x92, 0x9a, 0x97, 0x9f, 0x2b, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0x19, 0x04, + 0xe1, 0x38, 0x79, 0x9e, 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, 0x7e, 0x7a, + 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xcc, 0x79, 0xba, 0x39, 0x89, 0x49, + 0xc5, 0x70, 0x9e, 0x7e, 0x05, 0xd4, 0x3b, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x77, + 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x84, 0x7a, 0x82, 0x76, 0xed, 0x00, 0x00, 0x00, +} + +func (m *Pool) 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 *Pool) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintModels(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x12 + } + if m.ID != 0 { + i = encodeVarintModels(dAtA, i, uint64(m.ID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintModels(dAtA []byte, offset int, v uint64) int { + offset -= sovModels(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Pool) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ID != 0 { + n += 1 + sovModels(uint64(m.ID)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovModels(uint64(l)) + } + return n +} + +func sovModels(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozModels(x uint64) (n int) { + return sovModels(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Pool) 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 ErrIntOverflowModels + } + 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: Pool: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Pool: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + 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 ErrInvalidLengthModels + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModels + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipModels(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthModels + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipModels(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, ErrIntOverflowModels + } + 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, ErrIntOverflowModels + } + 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, ErrIntOverflowModels + } + 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, ErrInvalidLengthModels + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupModels + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthModels + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthModels = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowModels = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupModels = fmt.Errorf("proto: unexpected end of group") +) From c06c767fc74751fb65fa4cf9e1c6d4c2f3e22ffb Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Sun, 9 Jun 2024 03:46:31 -0500 Subject: [PATCH 36/49] feat(tests): add models tests --- x/pools/keeper/alias_functions.go | 11 +++++- x/pools/types/genesis.go | 5 +++ x/pools/types/genesis_test.go | 60 +++++++++++++++++++++++++++++++ x/pools/types/models_test.go | 44 +++++++++++++++++++++++ 4 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 x/pools/types/genesis_test.go create mode 100644 x/pools/types/models_test.go diff --git a/x/pools/keeper/alias_functions.go b/x/pools/keeper/alias_functions.go index 055e50a65..a5b9eb112 100644 --- a/x/pools/keeper/alias_functions.go +++ b/x/pools/keeper/alias_functions.go @@ -55,12 +55,21 @@ func (k *Keeper) CreatePoolForDenomIfNotExists(ctx sdk.Context, denom string) er return nil } - // Create and store the pool + // Create the pool and validate it pool := types.NewPool(poolID, denom) + err = pool.Validate() + if err != nil { + return err + } + + // Save the pool k.SavePool(ctx, pool) // Increment the pool id k.SetNextPoolID(ctx, poolID+1) + // Log the event + k.Logger(ctx).Debug("created pool", "id", poolID, "denom", denom) + return nil } diff --git a/x/pools/types/genesis.go b/x/pools/types/genesis.go index 65d6efc70..74dda93b3 100644 --- a/x/pools/types/genesis.go +++ b/x/pools/types/genesis.go @@ -12,6 +12,11 @@ func NewGenesis(nextPoolID uint32, pools []Pool) GenesisState { } } +// DefaultGenesis returns the default GenesisState +func DefaultGenesis() GenesisState { + return NewGenesis(1, nil) +} + // Validate checks if the GenesisState is valid func (data *GenesisState) Validate() error { // Validate the next pool ID diff --git a/x/pools/types/genesis_test.go b/x/pools/types/genesis_test.go new file mode 100644 index 000000000..a0ef891e7 --- /dev/null +++ b/x/pools/types/genesis_test.go @@ -0,0 +1,60 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/milkyway-labs/milkyway/x/pools/types" +) + +func TestGenesis_Validate(t *testing.T) { + testCases := []struct { + name string + genesis types.GenesisState + shouldErr bool + }{ + { + name: "invalid next pool id returns error", + genesis: types.NewGenesis(0, nil), + shouldErr: true, + }, + { + name: "invalid pool returns error", + genesis: types.NewGenesis( + 1, + []types.Pool{ + types.NewPool(0, "uatom"), + }, + ), + shouldErr: true, + }, + { + name: "default genesis does not return errors", + genesis: types.DefaultGenesis(), + shouldErr: false, + }, + { + name: "valid genesis does not return errors", + genesis: types.NewGenesis( + 1, + []types.Pool{ + types.NewPool(1, "uatom"), + }, + ), + shouldErr: false, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + err := tc.genesis.Validate() + if tc.shouldErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/pools/types/models_test.go b/x/pools/types/models_test.go new file mode 100644 index 000000000..cd7afff15 --- /dev/null +++ b/x/pools/types/models_test.go @@ -0,0 +1,44 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/milkyway-labs/milkyway/x/pools/types" +) + +func TestPool_Validate(t *testing.T) { + testCases := []struct { + name string + pool types.Pool + shouldErr bool + }{ + { + name: "invalid pool id returns error", + pool: types.NewPool(0, "uatom"), + shouldErr: true, + }, + { + name: "invalid pool denom returns error", + pool: types.NewPool(1, "uatom!"), + shouldErr: true, + }, + { + name: "valid pool does not return errors", + pool: types.NewPool(1, "uatom"), + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + err := tc.pool.Validate() + if tc.shouldErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} From 16531792b105bf7b9a1ec0769184918e200a9a00 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Sun, 9 Jun 2024 03:47:06 -0500 Subject: [PATCH 37/49] refactor: remove unused authority --- x/pools/keeper/keeper.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/x/pools/keeper/keeper.go b/x/pools/keeper/keeper.go index 58b5370c4..3154993f7 100644 --- a/x/pools/keeper/keeper.go +++ b/x/pools/keeper/keeper.go @@ -12,14 +12,11 @@ import ( type Keeper struct { storeKey storetypes.StoreKey cdc codec.Codec - - authority string } -func NewKeeper(storeKey storetypes.StoreKey, authority string) *Keeper { +func NewKeeper(storeKey storetypes.StoreKey) *Keeper { return &Keeper{ - storeKey: storeKey, - authority: authority, + storeKey: storeKey, } } From d6719f6c75cb3f4abfcbbd275567eb3a1fd1d7df Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Sun, 9 Jun 2024 04:09:20 -0500 Subject: [PATCH 38/49] feat(tests): add keeper tests --- x/pools/keeper/alias_functions.go | 16 +- x/pools/keeper/alias_functions_test.go | 137 +++++++++++++++++ x/pools/keeper/common_test.go | 95 ++++++++++++ x/pools/keeper/keeper.go | 3 +- x/pools/keeper/pools_test.go | 201 +++++++++++++++++++++++++ 5 files changed, 444 insertions(+), 8 deletions(-) create mode 100644 x/pools/keeper/alias_functions_test.go create mode 100644 x/pools/keeper/common_test.go create mode 100644 x/pools/keeper/pools_test.go diff --git a/x/pools/keeper/alias_functions.go b/x/pools/keeper/alias_functions.go index a5b9eb112..0764f00db 100644 --- a/x/pools/keeper/alias_functions.go +++ b/x/pools/keeper/alias_functions.go @@ -42,24 +42,26 @@ func (k *Keeper) GetPoolForDenom(ctx sdk.Context, denom string) (types.Pool, boo return types.Pool{}, false } -// CreatePoolForDenomIfNotExists creates a new pool for the given denom if it does not exist -func (k *Keeper) CreatePoolForDenomIfNotExists(ctx sdk.Context, denom string) error { +// CreateOrGetPoolByDenom creates a new pool for the given denom if it does not exist. +// If the pool already exists, no action is taken. +// In both cases, the pool is returned. +func (k *Keeper) CreateOrGetPoolByDenom(ctx sdk.Context, denom string) (types.Pool, error) { // If the pool already exists, just return - if _, ok := k.GetPoolForDenom(ctx, denom); ok { - return nil + if pool, found := k.GetPoolForDenom(ctx, denom); found { + return pool, nil } // Get the pool id poolID, err := k.GetNextPoolID(ctx) if err != nil { - return nil + return types.Pool{}, err } // Create the pool and validate it pool := types.NewPool(poolID, denom) err = pool.Validate() if err != nil { - return err + return types.Pool{}, err } // Save the pool @@ -71,5 +73,5 @@ func (k *Keeper) CreatePoolForDenomIfNotExists(ctx sdk.Context, denom string) er // Log the event k.Logger(ctx).Debug("created pool", "id", poolID, "denom", denom) - return nil + return pool, nil } diff --git a/x/pools/keeper/alias_functions_test.go b/x/pools/keeper/alias_functions_test.go new file mode 100644 index 000000000..8338df0cc --- /dev/null +++ b/x/pools/keeper/alias_functions_test.go @@ -0,0 +1,137 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/milkyway-labs/milkyway/x/pools/types" +) + +func (suite *KeeperTestSuite) TestKepeer_GetPoolForDenom() { + testCases := []struct { + name string + setup func() + store func(ctx sdk.Context) + denom string + expFound bool + expPool types.Pool + check func(ctx sdk.Context) + }{ + { + name: "non exiting pool returns error", + denom: "denom", + expFound: false, + }, + { + name: "existing pool is returned properly", + store: func(ctx sdk.Context) { + suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + }, + denom: "umilk", + expFound: true, + expPool: types.NewPool(1, "umilk"), + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.setup != nil { + tc.setup() + } + if tc.store != nil { + tc.store(ctx) + } + + pool, found := suite.k.GetPoolForDenom(ctx, tc.denom) + suite.Require().Equal(tc.expFound, found) + if tc.expFound { + suite.Require().Equal(tc.expPool, pool) + } + + if tc.check != nil { + tc.check(ctx) + } + }) + } +} + +func (suite *KeeperTestSuite) TestKeeper_CreateOrGetPoolByDenom() { + testCases := []struct { + name string + setup func() + store func(ctx sdk.Context) + denom string + shouldErr bool + expPool types.Pool + check func(ctx sdk.Context) + }{ + { + name: "invalid next pool id returns error", + denom: "umilk", + shouldErr: true, + }, + { + name: "invalid pool returns error", + store: func(ctx sdk.Context) { + suite.k.SetNextPoolID(ctx, 1) + }, + denom: "invalid!", + shouldErr: true, + }, + { + name: "existing pool is returned properly", + store: func(ctx sdk.Context) { + suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + }, + denom: "umilk", + shouldErr: false, + expPool: types.NewPool(1, "umilk"), + }, + { + name: "non existing pool is created properly", + store: func(ctx sdk.Context) { + suite.k.SetNextPoolID(ctx, 1) + }, + denom: "umilk", + shouldErr: false, + expPool: types.NewPool(1, "umilk"), + check: func(ctx sdk.Context) { + // Make sure the pool is stored properly + pool, found := suite.k.GetPoolForDenom(ctx, "umilk") + suite.Require().True(found) + suite.Require().Equal(types.NewPool(1, "umilk"), pool) + + // Make sure the next pool id has been incremented + nextPoolID, err := suite.k.GetNextPoolID(ctx) + suite.Require().NoError(err) + suite.Require().Equal(uint32(2), nextPoolID) + }, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.setup != nil { + tc.setup() + } + if tc.store != nil { + tc.store(ctx) + } + + pool, err := suite.k.CreateOrGetPoolByDenom(ctx, tc.denom) + if tc.shouldErr { + suite.Require().Error(err) + } else { + suite.Require().NoError(err) + suite.Require().Equal(tc.expPool, pool) + } + + if tc.check != nil { + tc.check(ctx) + } + }) + } +} diff --git a/x/pools/keeper/common_test.go b/x/pools/keeper/common_test.go new file mode 100644 index 000000000..0a0b91c35 --- /dev/null +++ b/x/pools/keeper/common_test.go @@ -0,0 +1,95 @@ +package keeper_test + +import ( + "testing" + + "cosmossdk.io/log" + "cosmossdk.io/store" + "cosmossdk.io/store/metrics" + "github.com/cosmos/cosmos-sdk/runtime" + authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + + "github.com/milkyway-labs/milkyway/app" + bankkeeper "github.com/milkyway-labs/milkyway/x/bank/keeper" + "github.com/milkyway-labs/milkyway/x/pools/keeper" + "github.com/milkyway-labs/milkyway/x/pools/types" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + + storetypes "cosmossdk.io/store/types" + db "github.com/cosmos/cosmos-db" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" +) + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} + +type KeeperTestSuite struct { + suite.Suite + + cdc codec.Codec + legacyAminoCdc *codec.LegacyAmino + ctx sdk.Context + + storeKey storetypes.StoreKey + + ak authkeeper.AccountKeeper + bk bankkeeper.Keeper + k *keeper.Keeper +} + +func (suite *KeeperTestSuite) SetupTest() { + // Define store keys + keys := storetypes.NewKVStoreKeys(types.StoreKey, authtypes.StoreKey, banktypes.StoreKey) + suite.storeKey = keys[types.StoreKey] + + // Create logger + logger := log.NewNopLogger() + + // Create an in-memory db + memDB := db.NewMemDB() + ms := store.NewCommitMultiStore(memDB, logger, metrics.NewNoOpMetrics()) + for _, key := range keys { + ms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, memDB) + } + + if err := ms.LoadLatestVersion(); err != nil { + panic(err) + } + + suite.ctx = sdk.NewContext(ms, tmproto.Header{ChainID: "test-chain"}, false, log.NewNopLogger()) + suite.cdc, suite.legacyAminoCdc = app.MakeCodecs() + + // Authority address + authorityAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String() + + // Build keepers + suite.ak = authkeeper.NewAccountKeeper( + suite.cdc, + runtime.NewKVStoreService(keys[authtypes.StoreKey]), + authtypes.ProtoBaseAccount, + app.GetMaccPerms(), + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), + sdk.GetConfig().GetBech32AccountAddrPrefix(), + authorityAddr, + ) + suite.bk = bankkeeper.NewKeeper( + suite.cdc, + runtime.NewKVStoreService(keys[banktypes.StoreKey]), + suite.ak, + nil, + authorityAddr, + logger, + ) + suite.k = keeper.NewKeeper( + suite.cdc, + suite.storeKey, + ) +} diff --git a/x/pools/keeper/keeper.go b/x/pools/keeper/keeper.go index 3154993f7..b959a1e5e 100644 --- a/x/pools/keeper/keeper.go +++ b/x/pools/keeper/keeper.go @@ -14,9 +14,10 @@ type Keeper struct { cdc codec.Codec } -func NewKeeper(storeKey storetypes.StoreKey) *Keeper { +func NewKeeper(cdc codec.Codec, storeKey storetypes.StoreKey) *Keeper { return &Keeper{ storeKey: storeKey, + cdc: cdc, } } diff --git a/x/pools/keeper/pools_test.go b/x/pools/keeper/pools_test.go new file mode 100644 index 000000000..866e6eb1a --- /dev/null +++ b/x/pools/keeper/pools_test.go @@ -0,0 +1,201 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/milkyway-labs/milkyway/x/pools/types" +) + +func (suite *KeeperTestSuite) TestKeeper_SetNextPoolID() { + testCases := []struct { + name string + store func(ctx sdk.Context) + id uint32 + check func(ctx sdk.Context) + }{ + { + name: "next pool id is saved correctly", + id: 1, + check: func(ctx sdk.Context) { + store := ctx.KVStore(suite.storeKey) + serviceIDBz := store.Get(types.NextPoolIDKey) + suite.Require().Equal(uint32(1), types.GetPoolIDFromBytes(serviceIDBz)) + }, + }, + { + name: "next pool id is overridden properly", + store: func(ctx sdk.Context) { + suite.k.SetNextPoolID(ctx, 1) + }, + id: 2, + check: func(ctx sdk.Context) { + store := ctx.KVStore(suite.storeKey) + serviceIDBz := store.Get(types.NextPoolIDKey) + suite.Require().Equal(uint32(2), types.GetPoolIDFromBytes(serviceIDBz)) + }, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + suite.k.SetNextPoolID(ctx, tc.id) + if tc.check != nil { + tc.check(ctx) + } + }) + } +} + +func (suite *KeeperTestSuite) TestKeeper_GetNextPoolID() { + testCases := []struct { + name string + store func(ctx sdk.Context) + shouldErr bool + expNext uint32 + }{ + { + name: "non existing next pool id returns error", + shouldErr: true, + }, + { + name: "exiting next pool id is returned properly", + store: func(ctx sdk.Context) { + suite.k.SetNextPoolID(ctx, 1) + }, + expNext: 1, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + next, err := suite.k.GetNextPoolID(ctx) + if tc.shouldErr { + suite.Require().Error(err) + } else { + suite.Require().NoError(err) + suite.Require().Equal(tc.expNext, next) + } + }) + } +} + +// -------------------------------------------------------------------------------------------------------------------- + +func (suite *KeeperTestSuite) TestKeeper_SavePool() { + testCases := []struct { + name string + setup func() + store func(ctx sdk.Context) + pool types.Pool + shouldErr bool + check func(ctx sdk.Context) + }{ + { + name: "non existing pool is saved properly", + store: func(ctx sdk.Context) { + suite.k.SetNextPoolID(ctx, 1) + }, + shouldErr: true, + pool: types.NewPool(1, "uatom"), + check: func(ctx sdk.Context) { + pool, found := suite.k.GetPool(ctx, 1) + suite.Require().True(found) + suite.Require().Equal(types.NewPool(1, "uatom"), pool) + }, + }, + { + name: "existing pool is overridden properly", + setup: func() { + suite.k.SetNextPoolID(suite.ctx, 1) + suite.k.SavePool(suite.ctx, types.NewPool(1, "uatom")) + }, + pool: types.NewPool(1, "usdt"), + check: func(ctx sdk.Context) { + pool, found := suite.k.GetPool(ctx, 1) + suite.Require().True(found) + suite.Require().Equal(types.NewPool(1, "usdt"), pool) + }, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.setup != nil { + tc.setup() + } + if tc.store != nil { + tc.store(ctx) + } + + suite.k.SavePool(ctx, tc.pool) + + if tc.check != nil { + tc.check(ctx) + } + }) + } +} + +func (suite *KeeperTestSuite) TestKeeper_GetPool() { + testCases := []struct { + name string + setup func() + store func(ctx sdk.Context) + poolID uint32 + expFound bool + expPool types.Pool + check func(ctx sdk.Context) + }{ + { + name: "not found pool returns error", + poolID: 1, + expFound: false, + }, + { + name: "found pool is returned properly", + store: func(ctx sdk.Context) { + suite.k.SavePool(ctx, types.NewPool(1, "uatom")) + }, + poolID: 1, + expFound: true, + expPool: types.NewPool(1, "uatom"), + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.setup != nil { + tc.setup() + } + if tc.store != nil { + tc.store(ctx) + } + + pool, found := suite.k.GetPool(ctx, tc.poolID) + suite.Require().Equal(tc.expFound, found) + if tc.expFound { + suite.Require().Equal(tc.expPool, pool) + } + + if tc.check != nil { + tc.check(ctx) + } + }) + } +} From 045c815a7158f4fb5f7e4ef4e66568935e41e15a Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Sun, 9 Jun 2024 04:30:10 -0500 Subject: [PATCH 39/49] feat: add gRPC query server --- proto/milkyway/pools/v1/query.proto | 61 ++ x/pools/keeper/alias_functions.go | 10 +- x/pools/keeper/alias_functions_test.go | 4 +- x/pools/keeper/grpc_query.go | 73 ++ x/pools/keeper/grpc_query_test.go | 109 ++ x/pools/keeper/keeper.go | 2 +- x/pools/types/keys.go | 4 +- x/pools/types/query.go | 26 + x/pools/types/query.pb.go | 1260 ++++++++++++++++++++++++ x/pools/types/query.pb.gw.go | 373 +++++++ 10 files changed, 1912 insertions(+), 10 deletions(-) create mode 100644 proto/milkyway/pools/v1/query.proto create mode 100644 x/pools/keeper/grpc_query.go create mode 100644 x/pools/keeper/grpc_query_test.go create mode 100644 x/pools/types/query.go create mode 100644 x/pools/types/query.pb.go create mode 100644 x/pools/types/query.pb.gw.go diff --git a/proto/milkyway/pools/v1/query.proto b/proto/milkyway/pools/v1/query.proto new file mode 100644 index 000000000..d2c1b7f0e --- /dev/null +++ b/proto/milkyway/pools/v1/query.proto @@ -0,0 +1,61 @@ +syntax = "proto3"; +package milkyway.pools.v1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "milkyway/pools/v1/models.proto"; + +option go_package = "github.com/milkyway-labs/milkyway/x/pools/types"; + +// Query defines the gRPC querier service. +service Query { + // PoolById defines a gRPC query method that returns the pool by the given ID. + rpc PoolById(QueryPoolByIdRequest) returns (QueryPoolResponse) { + option (google.api.http).get = "/milkyway/pool/v1/pool/{pool_id}"; + } + + // PoolByDenom defines a gRPC query method that returns the pool by the given + // denom. + rpc PoolByDenom(QueryPoolByDenomRequest) returns (QueryPoolResponse) { + option (google.api.http).get = "/milkyway/pool/v1/pool/denom/{denom}"; + } + + // Pools defines a gRPC query method that returns all pools. + rpc Pools(QueryPoolsRequest) returns (QueryPoolsResponse) { + option (google.api.http).get = "/milkyway/pool/v1/pools"; + } +} + +// QueryPoolByIdRequest is the request type for the Query/PoolById RPC method. +message QueryPoolByIdRequest { + // PoolID is the ID of the pool to query + uint32 pool_id = 1; +} + +// QueryPoolByDenomRequest is the request type for the Query/PollByDenom RPC method. +message QueryPoolByDenomRequest { + // Denom is the denom for which the pool is to be queried + string denom = 1; +} + +// QueryOperatorRPoolsesponse is the response type for the Query/PoolById and +// Query/PoolByDenom RPC methods. +message QueryPoolResponse { + // Pool is the queried pool + Pool pool = 1 [ (gogoproto.nullable) = false ]; +} + +// QueryPoolsRequest is the request type for the Query/Pools RPC method. +message QueryPoolsRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryPoolsResponse is the response type for the Query/Pools RPC method. +message QueryPoolsResponse { + // Pools is the list of pool + repeated Pool pools = 1 [ (gogoproto.nullable) = false ]; + + // Pagination defines the pagination response + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} \ No newline at end of file diff --git a/x/pools/keeper/alias_functions.go b/x/pools/keeper/alias_functions.go index 0764f00db..66fd20491 100644 --- a/x/pools/keeper/alias_functions.go +++ b/x/pools/keeper/alias_functions.go @@ -10,7 +10,7 @@ import ( // IteratePools iterates over the pools in the store and performs a callback function func (k *Keeper) IteratePools(ctx sdk.Context, cb func(pool types.Pool) (stop bool)) { store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.PooolPrefix) + iterator := storetypes.KVStorePrefixIterator(store, types.PoolPrefix) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -23,11 +23,11 @@ func (k *Keeper) IteratePools(ctx sdk.Context, cb func(pool types.Pool) (stop bo } } -// GetPoolForDenom returns the pool for the given denom if it exists. +// GetPoolByDenom returns the pool for the given denom if it exists. // If the pool does not exist, false is returned instead -func (k *Keeper) GetPoolForDenom(ctx sdk.Context, denom string) (types.Pool, bool) { +func (k *Keeper) GetPoolByDenom(ctx sdk.Context, denom string) (types.Pool, bool) { store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.PooolPrefix) + iterator := storetypes.KVStorePrefixIterator(store, types.PoolPrefix) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -47,7 +47,7 @@ func (k *Keeper) GetPoolForDenom(ctx sdk.Context, denom string) (types.Pool, boo // In both cases, the pool is returned. func (k *Keeper) CreateOrGetPoolByDenom(ctx sdk.Context, denom string) (types.Pool, error) { // If the pool already exists, just return - if pool, found := k.GetPoolForDenom(ctx, denom); found { + if pool, found := k.GetPoolByDenom(ctx, denom); found { return pool, nil } diff --git a/x/pools/keeper/alias_functions_test.go b/x/pools/keeper/alias_functions_test.go index 8338df0cc..e6286057f 100644 --- a/x/pools/keeper/alias_functions_test.go +++ b/x/pools/keeper/alias_functions_test.go @@ -43,7 +43,7 @@ func (suite *KeeperTestSuite) TestKepeer_GetPoolForDenom() { tc.store(ctx) } - pool, found := suite.k.GetPoolForDenom(ctx, tc.denom) + pool, found := suite.k.GetPoolByDenom(ctx, tc.denom) suite.Require().Equal(tc.expFound, found) if tc.expFound { suite.Require().Equal(tc.expPool, pool) @@ -98,7 +98,7 @@ func (suite *KeeperTestSuite) TestKeeper_CreateOrGetPoolByDenom() { expPool: types.NewPool(1, "umilk"), check: func(ctx sdk.Context) { // Make sure the pool is stored properly - pool, found := suite.k.GetPoolForDenom(ctx, "umilk") + pool, found := suite.k.GetPoolByDenom(ctx, "umilk") suite.Require().True(found) suite.Require().Equal(types.NewPool(1, "umilk"), pool) diff --git a/x/pools/keeper/grpc_query.go b/x/pools/keeper/grpc_query.go new file mode 100644 index 000000000..077c67b39 --- /dev/null +++ b/x/pools/keeper/grpc_query.go @@ -0,0 +1,73 @@ +package keeper + +import ( + "context" + + "cosmossdk.io/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/milkyway-labs/milkyway/x/pools/types" +) + +var _ types.QueryServer = &Keeper{} + +// PoolById implements the Query/PoolById gRPC method +func (k *Keeper) PoolById(ctx context.Context, request *types.QueryPoolByIdRequest) (*types.QueryPoolResponse, error) { + if request.PoolId == 0 { + return nil, status.Error(codes.InvalidArgument, "invalid pool id") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + pool, found := k.GetPool(sdkCtx, request.PoolId) + if !found { + return nil, status.Error(codes.NotFound, "pool not found") + } + + return &types.QueryPoolResponse{Pool: pool}, nil +} + +// PoolByDenom implements the Query/PoolByDenom gRPC method +func (k *Keeper) PoolByDenom(ctx context.Context, request *types.QueryPoolByDenomRequest) (*types.QueryPoolResponse, error) { + if err := sdk.ValidateDenom(request.Denom); err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid denom") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + pool, found := k.GetPoolByDenom(sdkCtx, request.Denom) + if !found { + return nil, status.Error(codes.NotFound, "pool not found") + } + + return &types.QueryPoolResponse{Pool: pool}, nil +} + +// Pools implements the Query/Pools gRPC method +func (k *Keeper) Pools(ctx context.Context, request *types.QueryPoolsRequest) (*types.QueryPoolsResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + store := sdkCtx.KVStore(k.storeKey) + poolsStore := prefix.NewStore(store, types.PoolPrefix) + + var pools []types.Pool + pageRes, err := query.Paginate(poolsStore, request.Pagination, func(key []byte, value []byte) error { + var pool types.Pool + if err := k.cdc.Unmarshal(value, &pool); err != nil { + return status.Error(codes.Internal, err.Error()) + } + + pools = append(pools, pool) + return nil + }) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryPoolsResponse{ + Pools: pools, + Pagination: pageRes, + }, nil +} diff --git a/x/pools/keeper/grpc_query_test.go b/x/pools/keeper/grpc_query_test.go new file mode 100644 index 000000000..4b3f77dd9 --- /dev/null +++ b/x/pools/keeper/grpc_query_test.go @@ -0,0 +1,109 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/milkyway-labs/milkyway/x/pools/types" +) + +func (suite *KeeperTestSuite) TestQueryServer_PoolById() { + testCases := []struct { + name string + setup func() + store func(ctx sdk.Context) + request *types.QueryPoolByIdRequest + shouldErr bool + expPool types.Pool + }{ + { + name: "not found pool returns error", + request: &types.QueryPoolByIdRequest{ + PoolId: 1, + }, + shouldErr: true, + }, + { + name: "found pool is returned properly", + store: func(ctx sdk.Context) { + suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + }, + request: &types.QueryPoolByIdRequest{ + PoolId: 1, + }, + shouldErr: false, + expPool: types.NewPool(1, "umilk"), + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.setup != nil { + tc.setup() + } + if tc.store != nil { + tc.store(ctx) + } + + res, err := suite.k.PoolById(ctx, tc.request) + if tc.shouldErr { + suite.Require().Error(err) + } else { + suite.Require().NoError(err) + suite.Require().Equal(tc.expPool, res.Pool) + } + }) + } +} + +func (suite *KeeperTestSuite) TestQueryServer_PoolByDenom() { + testCases := []struct { + name string + setup func() + store func(ctx sdk.Context) + request *types.QueryPoolByDenomRequest + shouldErr bool + expPool types.Pool + }{ + { + name: "not found pool returns error", + request: &types.QueryPoolByDenomRequest{ + Denom: "umilk", + }, + shouldErr: true, + }, + { + name: "found pool is returned properly", + store: func(ctx sdk.Context) { + suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + }, + request: &types.QueryPoolByDenomRequest{ + Denom: "umilk", + }, + shouldErr: false, + expPool: types.NewPool(1, "umilk"), + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.setup != nil { + tc.setup() + } + if tc.store != nil { + tc.store(ctx) + } + + res, err := suite.k.PoolByDenom(ctx, tc.request) + if tc.shouldErr { + suite.Require().Error(err) + } else { + suite.Require().NoError(err) + suite.Require().Equal(tc.expPool, res.Pool) + } + }) + } +} diff --git a/x/pools/keeper/keeper.go b/x/pools/keeper/keeper.go index b959a1e5e..41f473818 100644 --- a/x/pools/keeper/keeper.go +++ b/x/pools/keeper/keeper.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/milkyway-labs/milkyway/x/operators/types" + "github.com/milkyway-labs/milkyway/x/pools/types" ) type Keeper struct { diff --git a/x/pools/types/keys.go b/x/pools/types/keys.go index a28014b67..111570c6b 100644 --- a/x/pools/types/keys.go +++ b/x/pools/types/keys.go @@ -12,7 +12,7 @@ const ( var ( NextPoolIDKey = []byte{0x01} - PooolPrefix = []byte{0xa1} + PoolPrefix = []byte{0xa1} ) // GetPoolIDBytes returns the byte representation of the pool ID @@ -29,5 +29,5 @@ func GetPoolIDFromBytes(bz []byte) (poolID uint32) { // GetPoolStoreKey turns a pool ID into a key used to store a pool in the KVStore func GetPoolStoreKey(poolID uint32) []byte { - return append(PooolPrefix, GetPoolIDBytes(poolID)...) + return append(PoolPrefix, GetPoolIDBytes(poolID)...) } diff --git a/x/pools/types/query.go b/x/pools/types/query.go new file mode 100644 index 000000000..72afaace6 --- /dev/null +++ b/x/pools/types/query.go @@ -0,0 +1,26 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/types/query" +) + +// NewQueryPoolByIdRequest creates a new instance of QueryPoolByIdRequest +func NewQueryPoolByIdRequest(poolId uint32) *QueryPoolByIdRequest { + return &QueryPoolByIdRequest{ + PoolId: poolId, + } +} + +// NewQueryPoolByDenomRequest creates a new instance of QueryPoolByDenomRequest +func NewQueryPoolByDenomRequest(denom string) *QueryPoolByDenomRequest { + return &QueryPoolByDenomRequest{ + Denom: denom, + } +} + +// NewQueryPoolsRequest creates a new instance of QueryPoolsRequest +func NewQueryPoolsRequest(pagination *query.PageRequest) *QueryPoolsRequest { + return &QueryPoolsRequest{ + Pagination: pagination, + } +} diff --git a/x/pools/types/query.pb.go b/x/pools/types/query.pb.go new file mode 100644 index 000000000..42854e9a7 --- /dev/null +++ b/x/pools/types/query.pb.go @@ -0,0 +1,1260 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: milkyway/pools/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + query "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/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 + +// QueryPoolByIdRequest is the request type for the Query/PoolById RPC method. +type QueryPoolByIdRequest struct { + // PoolID is the ID of the pool to query + PoolId uint32 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` +} + +func (m *QueryPoolByIdRequest) Reset() { *m = QueryPoolByIdRequest{} } +func (m *QueryPoolByIdRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPoolByIdRequest) ProtoMessage() {} +func (*QueryPoolByIdRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7667236b657a7d, []int{0} +} +func (m *QueryPoolByIdRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPoolByIdRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPoolByIdRequest.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 *QueryPoolByIdRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPoolByIdRequest.Merge(m, src) +} +func (m *QueryPoolByIdRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPoolByIdRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPoolByIdRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPoolByIdRequest proto.InternalMessageInfo + +func (m *QueryPoolByIdRequest) GetPoolId() uint32 { + if m != nil { + return m.PoolId + } + return 0 +} + +// QueryPoolByDenomRequest is the request type for the Query/PollByDenom RPC method. +type QueryPoolByDenomRequest struct { + // Denom is the denom for which the pool is to be queried + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` +} + +func (m *QueryPoolByDenomRequest) Reset() { *m = QueryPoolByDenomRequest{} } +func (m *QueryPoolByDenomRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPoolByDenomRequest) ProtoMessage() {} +func (*QueryPoolByDenomRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7667236b657a7d, []int{1} +} +func (m *QueryPoolByDenomRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPoolByDenomRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPoolByDenomRequest.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 *QueryPoolByDenomRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPoolByDenomRequest.Merge(m, src) +} +func (m *QueryPoolByDenomRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPoolByDenomRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPoolByDenomRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPoolByDenomRequest proto.InternalMessageInfo + +func (m *QueryPoolByDenomRequest) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +// QueryOperatorRPoolsesponse is the response type for the Query/PoolById and +// Query/PoolByDenom RPC methods. +type QueryPoolResponse struct { + // Pool is the queried pool + Pool Pool `protobuf:"bytes,1,opt,name=pool,proto3" json:"pool"` +} + +func (m *QueryPoolResponse) Reset() { *m = QueryPoolResponse{} } +func (m *QueryPoolResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPoolResponse) ProtoMessage() {} +func (*QueryPoolResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7667236b657a7d, []int{2} +} +func (m *QueryPoolResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPoolResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPoolResponse.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 *QueryPoolResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPoolResponse.Merge(m, src) +} +func (m *QueryPoolResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPoolResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPoolResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPoolResponse proto.InternalMessageInfo + +func (m *QueryPoolResponse) GetPool() Pool { + if m != nil { + return m.Pool + } + return Pool{} +} + +// QueryPoolsRequest is the request type for the Query/Pools RPC method. +type QueryPoolsRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryPoolsRequest) Reset() { *m = QueryPoolsRequest{} } +func (m *QueryPoolsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPoolsRequest) ProtoMessage() {} +func (*QueryPoolsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7667236b657a7d, []int{3} +} +func (m *QueryPoolsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPoolsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPoolsRequest.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 *QueryPoolsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPoolsRequest.Merge(m, src) +} +func (m *QueryPoolsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPoolsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPoolsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPoolsRequest proto.InternalMessageInfo + +func (m *QueryPoolsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryPoolsResponse is the response type for the Query/Pools RPC method. +type QueryPoolsResponse struct { + // Pools is the list of pool + Pools []Pool `protobuf:"bytes,1,rep,name=pools,proto3" json:"pools"` + // Pagination defines the pagination response + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryPoolsResponse) Reset() { *m = QueryPoolsResponse{} } +func (m *QueryPoolsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPoolsResponse) ProtoMessage() {} +func (*QueryPoolsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7667236b657a7d, []int{4} +} +func (m *QueryPoolsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPoolsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPoolsResponse.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 *QueryPoolsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPoolsResponse.Merge(m, src) +} +func (m *QueryPoolsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPoolsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPoolsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPoolsResponse proto.InternalMessageInfo + +func (m *QueryPoolsResponse) GetPools() []Pool { + if m != nil { + return m.Pools + } + return nil +} + +func (m *QueryPoolsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +func init() { + proto.RegisterType((*QueryPoolByIdRequest)(nil), "milkyway.pools.v1.QueryPoolByIdRequest") + proto.RegisterType((*QueryPoolByDenomRequest)(nil), "milkyway.pools.v1.QueryPoolByDenomRequest") + proto.RegisterType((*QueryPoolResponse)(nil), "milkyway.pools.v1.QueryPoolResponse") + proto.RegisterType((*QueryPoolsRequest)(nil), "milkyway.pools.v1.QueryPoolsRequest") + proto.RegisterType((*QueryPoolsResponse)(nil), "milkyway.pools.v1.QueryPoolsResponse") +} + +func init() { proto.RegisterFile("milkyway/pools/v1/query.proto", fileDescriptor_bb7667236b657a7d) } + +var fileDescriptor_bb7667236b657a7d = []byte{ + // 487 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x41, 0x6f, 0xd3, 0x30, + 0x14, 0xc7, 0xeb, 0x6d, 0x1d, 0xe0, 0x89, 0xc3, 0xac, 0x4a, 0x1d, 0x15, 0x64, 0x55, 0x34, 0xb6, + 0x69, 0x02, 0x5b, 0xd9, 0xbe, 0xc1, 0x84, 0x86, 0x7a, 0x1b, 0x39, 0xc2, 0x01, 0x39, 0x8b, 0x15, + 0x22, 0x92, 0xbc, 0x6c, 0x4e, 0x0b, 0xd1, 0xb4, 0x0b, 0x9c, 0x91, 0x10, 0xf0, 0xa1, 0x76, 0x9c, + 0xc4, 0x85, 0x13, 0x42, 0x2d, 0x1f, 0x04, 0xf9, 0xc5, 0xd9, 0x32, 0xb5, 0xb4, 0x3b, 0xa5, 0xd6, + 0xfb, 0xff, 0xff, 0xfe, 0xf5, 0xbd, 0x67, 0xfa, 0x24, 0x8d, 0x93, 0xf7, 0xe5, 0x07, 0x59, 0x8a, + 0x1c, 0x20, 0xd1, 0x62, 0xe4, 0x89, 0xd3, 0xa1, 0x3a, 0x2b, 0x79, 0x7e, 0x06, 0x05, 0xb0, 0xf5, + 0xba, 0xcc, 0xb1, 0xcc, 0x47, 0x5e, 0xaf, 0x13, 0x41, 0x04, 0x58, 0x15, 0xe6, 0x57, 0x25, 0xec, + 0x3d, 0x8e, 0x00, 0xa2, 0x44, 0x09, 0x99, 0xc7, 0x42, 0x66, 0x19, 0x14, 0xb2, 0x88, 0x21, 0xd3, + 0xb6, 0xba, 0x77, 0x02, 0x3a, 0x05, 0x2d, 0x02, 0xa9, 0x55, 0x95, 0x2f, 0x46, 0x5e, 0xa0, 0x0a, + 0xe9, 0x89, 0x5c, 0x46, 0x71, 0x86, 0x62, 0xab, 0x75, 0xa6, 0x89, 0x52, 0x08, 0x55, 0x62, 0xb3, + 0x5c, 0x41, 0x3b, 0xaf, 0x4c, 0xc2, 0x31, 0x40, 0x72, 0x58, 0x0e, 0x42, 0x5f, 0x9d, 0x0e, 0x95, + 0x2e, 0x58, 0x97, 0xde, 0x33, 0x86, 0xb7, 0x71, 0xb8, 0x41, 0xfa, 0x64, 0xf7, 0xa1, 0xbf, 0x6a, + 0x8e, 0x83, 0xd0, 0x15, 0xb4, 0xdb, 0x30, 0xbc, 0x50, 0x19, 0xa4, 0xb5, 0xa7, 0x43, 0xdb, 0xa1, + 0x39, 0xa3, 0xe3, 0x81, 0x5f, 0x1d, 0xdc, 0x23, 0xba, 0x7e, 0x6d, 0xf0, 0x95, 0xce, 0x21, 0xd3, + 0x8a, 0x79, 0x74, 0xc5, 0xe4, 0xa1, 0x72, 0x6d, 0xbf, 0xcb, 0xa7, 0x1a, 0xc3, 0x31, 0x7f, 0xe5, + 0xf2, 0xf7, 0x66, 0xcb, 0x47, 0xa9, 0xfb, 0xa6, 0x91, 0xa3, 0xeb, 0x2b, 0x8f, 0x28, 0xbd, 0xf9, + 0xcb, 0x36, 0x6d, 0x9b, 0x57, 0xfd, 0xe1, 0xa6, 0x3f, 0xbc, 0xea, 0xbf, 0xed, 0x0f, 0x3f, 0x96, + 0x91, 0xb2, 0x5e, 0xbf, 0xe1, 0x74, 0xbf, 0x11, 0xca, 0x9a, 0xe9, 0x16, 0xf3, 0x80, 0xb6, 0x11, + 0x68, 0x83, 0xf4, 0x97, 0x17, 0x73, 0x56, 0x5a, 0xf6, 0xf2, 0x16, 0xd3, 0x12, 0x32, 0xed, 0x2c, + 0x64, 0xaa, 0x6e, 0x6c, 0x42, 0xed, 0xff, 0x58, 0xa6, 0x6d, 0x84, 0x62, 0x9f, 0x09, 0xbd, 0x5f, + 0x4f, 0x88, 0xed, 0xcc, 0xa0, 0x98, 0x35, 0xc3, 0xde, 0xd6, 0x3c, 0x61, 0x7d, 0xa3, 0xbb, 0xfb, + 0xe9, 0xe7, 0xdf, 0xef, 0x4b, 0x2e, 0xeb, 0x8b, 0x5b, 0xab, 0x62, 0x36, 0x05, 0xbf, 0xe7, 0x76, + 0x0f, 0x2e, 0xd8, 0x17, 0x42, 0xd7, 0x1a, 0x63, 0x67, 0x7b, 0xf3, 0x41, 0x9a, 0xbb, 0x71, 0x47, + 0x96, 0x67, 0xc8, 0xb2, 0xcd, 0xb6, 0xfe, 0xc3, 0x82, 0x1b, 0x25, 0xce, 0xf1, 0x73, 0xc1, 0x86, + 0xb4, 0x8d, 0xe3, 0x62, 0x73, 0xc3, 0xeb, 0x5d, 0xe9, 0x3d, 0x5d, 0xa0, 0xb2, 0x0c, 0x9b, 0xc8, + 0xf0, 0x88, 0x75, 0x67, 0x33, 0xe8, 0xc3, 0xc1, 0xe5, 0xd8, 0x21, 0x57, 0x63, 0x87, 0xfc, 0x19, + 0x3b, 0xe4, 0xeb, 0xc4, 0x69, 0x5d, 0x4d, 0x9c, 0xd6, 0xaf, 0x89, 0xd3, 0x7a, 0x2d, 0xa2, 0xb8, + 0x78, 0x37, 0x0c, 0xf8, 0x09, 0xa4, 0xd7, 0xe6, 0xe7, 0x89, 0x0c, 0xf4, 0x4d, 0xd4, 0x47, 0xfb, + 0x0e, 0x8b, 0x32, 0x57, 0x3a, 0x58, 0xc5, 0x47, 0x78, 0xf0, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x0b, + 0x98, 0x79, 0xe5, 0x38, 0x04, 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 { + // PoolById defines a gRPC query method that returns the pool by the given ID. + PoolById(ctx context.Context, in *QueryPoolByIdRequest, opts ...grpc.CallOption) (*QueryPoolResponse, error) + // PoolByDenom defines a gRPC query method that returns the pool by the given + // denom. + PoolByDenom(ctx context.Context, in *QueryPoolByDenomRequest, opts ...grpc.CallOption) (*QueryPoolResponse, error) + // Pools defines a gRPC query method that returns all pools. + Pools(ctx context.Context, in *QueryPoolsRequest, opts ...grpc.CallOption) (*QueryPoolsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) PoolById(ctx context.Context, in *QueryPoolByIdRequest, opts ...grpc.CallOption) (*QueryPoolResponse, error) { + out := new(QueryPoolResponse) + err := c.cc.Invoke(ctx, "/milkyway.pools.v1.Query/PoolById", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) PoolByDenom(ctx context.Context, in *QueryPoolByDenomRequest, opts ...grpc.CallOption) (*QueryPoolResponse, error) { + out := new(QueryPoolResponse) + err := c.cc.Invoke(ctx, "/milkyway.pools.v1.Query/PoolByDenom", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Pools(ctx context.Context, in *QueryPoolsRequest, opts ...grpc.CallOption) (*QueryPoolsResponse, error) { + out := new(QueryPoolsResponse) + err := c.cc.Invoke(ctx, "/milkyway.pools.v1.Query/Pools", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // PoolById defines a gRPC query method that returns the pool by the given ID. + PoolById(context.Context, *QueryPoolByIdRequest) (*QueryPoolResponse, error) + // PoolByDenom defines a gRPC query method that returns the pool by the given + // denom. + PoolByDenom(context.Context, *QueryPoolByDenomRequest) (*QueryPoolResponse, error) + // Pools defines a gRPC query method that returns all pools. + Pools(context.Context, *QueryPoolsRequest) (*QueryPoolsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) PoolById(ctx context.Context, req *QueryPoolByIdRequest) (*QueryPoolResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PoolById not implemented") +} +func (*UnimplementedQueryServer) PoolByDenom(ctx context.Context, req *QueryPoolByDenomRequest) (*QueryPoolResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PoolByDenom not implemented") +} +func (*UnimplementedQueryServer) Pools(ctx context.Context, req *QueryPoolsRequest) (*QueryPoolsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Pools not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_PoolById_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPoolByIdRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PoolById(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/milkyway.pools.v1.Query/PoolById", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PoolById(ctx, req.(*QueryPoolByIdRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_PoolByDenom_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPoolByDenomRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PoolByDenom(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/milkyway.pools.v1.Query/PoolByDenom", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PoolByDenom(ctx, req.(*QueryPoolByDenomRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Pools_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPoolsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Pools(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/milkyway.pools.v1.Query/Pools", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Pools(ctx, req.(*QueryPoolsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "milkyway.pools.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "PoolById", + Handler: _Query_PoolById_Handler, + }, + { + MethodName: "PoolByDenom", + Handler: _Query_PoolByDenom_Handler, + }, + { + MethodName: "Pools", + Handler: _Query_Pools_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "milkyway/pools/v1/query.proto", +} + +func (m *QueryPoolByIdRequest) 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 *QueryPoolByIdRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPoolByIdRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PoolId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryPoolByDenomRequest) 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 *QueryPoolByDenomRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPoolByDenomRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryPoolResponse) 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 *QueryPoolResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPoolResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Pool.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 *QueryPoolsRequest) 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 *QueryPoolsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPoolsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.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 *QueryPoolsResponse) 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 *QueryPoolsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPoolsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Pools) > 0 { + for iNdEx := len(m.Pools) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Pools[iNdEx].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 *QueryPoolByIdRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + return n +} + +func (m *QueryPoolByDenomRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryPoolResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Pool.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryPoolsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryPoolsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Pools) > 0 { + for _, e := range m.Pools { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.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 *QueryPoolByIdRequest) 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: QueryPoolByIdRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPoolByIdRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *QueryPoolByDenomRequest) 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: QueryPoolByDenomRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPoolByDenomRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", 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.Denom = 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 *QueryPoolResponse) 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: QueryPoolResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPoolResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pool", 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.Pool.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 *QueryPoolsRequest) 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: QueryPoolsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPoolsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 *QueryPoolsResponse) 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: QueryPoolsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPoolsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pools", 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 + } + m.Pools = append(m.Pools, Pool{}) + if err := m.Pools[len(m.Pools)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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/pools/types/query.pb.gw.go b/x/pools/types/query.pb.gw.go new file mode 100644 index 000000000..b9116fd2b --- /dev/null +++ b/x/pools/types/query.pb.gw.go @@ -0,0 +1,373 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: milkyway/pools/v1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_PoolById_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPoolByIdRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint32(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + msg, err := client.PoolById(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PoolById_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPoolByIdRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint32(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + msg, err := server.PoolById(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_PoolByDenom_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPoolByDenomRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + } + + protoReq.Denom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + } + + msg, err := client.PoolByDenom(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PoolByDenom_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPoolByDenomRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + } + + protoReq.Denom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + } + + msg, err := server.PoolByDenom(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_Pools_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_Pools_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPoolsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Pools_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Pools(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Pools_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPoolsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Pools_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Pools(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_PoolById_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_PoolById_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_PoolById_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_PoolByDenom_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_PoolByDenom_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_PoolByDenom_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Pools_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_Pools_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_Pools_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_PoolById_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_PoolById_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_PoolById_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_PoolByDenom_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_PoolByDenom_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_PoolByDenom_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Pools_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_Pools_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_Pools_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_PoolById_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1, 1, 0, 4, 1, 5, 3}, []string{"milkyway", "pool", "v1", "pool_id"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_PoolByDenom_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1, 2, 3, 1, 0, 4, 1, 5, 3}, []string{"milkyway", "pool", "v1", "denom"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Pools_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"milkyway", "pool", "v1", "pools"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_PoolById_0 = runtime.ForwardResponseMessage + + forward_Query_PoolByDenom_0 = runtime.ForwardResponseMessage + + forward_Query_Pools_0 = runtime.ForwardResponseMessage +) From 24473315c6872d0afb27327dc3cb75c742edd49d Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Sun, 9 Jun 2024 04:38:04 -0500 Subject: [PATCH 40/49] feat: add CLI commands --- x/pools/client/cli/query.go | 126 ++++++++++++++++++++++++++++++++++++ x/pools/types/models.go | 12 ++++ 2 files changed, 138 insertions(+) create mode 100644 x/pools/client/cli/query.go diff --git a/x/pools/client/cli/query.go b/x/pools/client/cli/query.go new file mode 100644 index 000000000..aa47d27b7 --- /dev/null +++ b/x/pools/client/cli/query.go @@ -0,0 +1,126 @@ +package cli + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/version" + "github.com/spf13/cobra" + + "github.com/milkyway-labs/milkyway/x/pools/types" +) + +// GetQueryCmd returns the command allowing to perform queries +func GetQueryCmd() *cobra.Command { + servicesQueryCmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + servicesQueryCmd.AddCommand( + getCmdQueryPoolByID(), + getCmdQueryPoolByDenom(), + getCmdQueryPools(), + ) + + return servicesQueryCmd +} + +// getCmdQueryPoolByID returns the command allowing to query a service +func getCmdQueryPoolByID() *cobra.Command { + cmd := &cobra.Command{ + Use: "pool [pool-id]", + Short: "Query the pool with the given id", + Example: fmt.Sprintf(`%s query %s pool 1`, version.AppName, types.ModuleName), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + poolID, err := types.ParsePoolID(args[0]) + if err != nil { + return err + } + + res, err := queryClient.PoolById(cmd.Context(), types.NewQueryPoolByIdRequest(poolID)) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// getCmdQueryPoolByDenom returns the command allowing to query services +func getCmdQueryPoolByDenom() *cobra.Command { + cmd := &cobra.Command{ + Use: "pool-by-denom [denom]", + Short: "Query the pool associated with the given denom", + Example: fmt.Sprintf(`%s query %s pool umilk`, version.AppName, types.ModuleName), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.PoolByDenom(cmd.Context(), types.NewQueryPoolByDenomRequest(args[0])) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// getCmdQueryPools returns the command to query the stored pools +func getCmdQueryPools() *cobra.Command { + cmd := &cobra.Command{ + Use: "pools", + Short: "Query the pools", + Example: fmt.Sprintf(`%s query %s pools --page=2 --limit=100`, version.AppName, types.ModuleName), + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + res, err := queryClient.Pools(cmd.Context(), types.NewQueryPoolsRequest(pageReq)) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "pools") + + return cmd +} diff --git a/x/pools/types/models.go b/x/pools/types/models.go index 63496ae57..b48ea5a43 100644 --- a/x/pools/types/models.go +++ b/x/pools/types/models.go @@ -2,10 +2,22 @@ package types import ( "fmt" + "strconv" sdk "github.com/cosmos/cosmos-sdk/types" ) +// ParsePoolID parses a pool id from a string +func ParsePoolID(value string) (uint32, error) { + parsed, err := strconv.ParseUint(value, 10, 32) + if err != nil { + return 0, fmt.Errorf("invalid pool id: %s", value) + } + return uint32(parsed), nil +} + +// -------------------------------------------------------------------------------------------------------------------- + // NewPool creates a new Pool instance func NewPool(id uint32, denom string) Pool { return Pool{ From 15d0dd8eae28fef113019b06127e14fd0280d065 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Sun, 9 Jun 2024 04:47:59 -0500 Subject: [PATCH 41/49] feat: add genesis export and initialization --- x/pools/keeper/alias_functions.go | 10 +++ x/pools/keeper/genesis.go | 37 ++++++++ x/pools/module.go | 143 ++++++++++++++++++++++++++++++ x/pools/types/genesis.go | 6 +- x/pools/types/genesis_test.go | 2 +- 5 files changed, 194 insertions(+), 4 deletions(-) create mode 100644 x/pools/keeper/genesis.go create mode 100644 x/pools/module.go diff --git a/x/pools/keeper/alias_functions.go b/x/pools/keeper/alias_functions.go index 66fd20491..e2131b48e 100644 --- a/x/pools/keeper/alias_functions.go +++ b/x/pools/keeper/alias_functions.go @@ -23,6 +23,16 @@ func (k *Keeper) IteratePools(ctx sdk.Context, cb func(pool types.Pool) (stop bo } } +// GetPools returns the list of stored pools +func (k *Keeper) GetPools(ctx sdk.Context) []types.Pool { + var pools []types.Pool + k.IteratePools(ctx, func(pool types.Pool) (stop bool) { + pools = append(pools, pool) + return false + }) + return pools +} + // GetPoolByDenom returns the pool for the given denom if it exists. // If the pool does not exist, false is returned instead func (k *Keeper) GetPoolByDenom(ctx sdk.Context, denom string) (types.Pool, bool) { diff --git a/x/pools/keeper/genesis.go b/x/pools/keeper/genesis.go new file mode 100644 index 000000000..41d94e5ff --- /dev/null +++ b/x/pools/keeper/genesis.go @@ -0,0 +1,37 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/milkyway-labs/milkyway/x/pools/types" +) + +// ExportGenesis returns a new GenesisState instance containing the information currently present inside the store +func (k *Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + return types.NewGenesis( + k.exportNextPoolID(ctx), + k.GetPools(ctx), + ) +} + +// exportNextPoolID exports the next pool id stored inside the store +func (k *Keeper) exportNextPoolID(ctx sdk.Context) uint32 { + nextPoolID, err := k.GetNextPoolID(ctx) + if err != nil { + panic(err) + } + return nextPoolID +} + +// -------------------------------------------------------------------------------------------------------------------- + +// InitGenesis initializes the genesis store using the provided data +func (k *Keeper) InitGenesis(ctx sdk.Context, data types.GenesisState) { + // Set the next pool id + k.SetNextPoolID(ctx, data.NextPoolID) + + // Store the pools + for _, pool := range data.Pools { + k.SavePool(ctx, pool) + } +} diff --git a/x/pools/module.go b/x/pools/module.go new file mode 100644 index 000000000..ff44fbc3e --- /dev/null +++ b/x/pools/module.go @@ -0,0 +1,143 @@ +package pools + +import ( + "context" + "encoding/json" + "fmt" + + "cosmossdk.io/core/appmodule" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/cometbft/cometbft/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/milkyway-labs/milkyway/x/pools/client/cli" + + "github.com/milkyway-labs/milkyway/x/pools/keeper" + "github.com/milkyway-labs/milkyway/x/pools/types" +) + +const ( + consensusVersion = 1 +) + +var ( + _ appmodule.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for the pools module. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the pools module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +func (AppModuleBasic) RegisterLegacyAminoCodec(_ *codec.LegacyAmino) {} + +// RegisterInterfaces registers the module's interface types +func (a AppModuleBasic) RegisterInterfaces(_ cdctypes.InterfaceRegistry) {} + +// DefaultGenesis returns the pools 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 pools 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() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err != nil { + panic(err) + } +} + +// GetTxCmd returns the pools module's root tx command. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return nil +} + +// GetQueryCmd returns the pools module's root query command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface for the pools module. +type AppModule struct { + AppModuleBasic + + // To ensure setting hooks properly, keeper must be a reference + keeper *keeper.Keeper +} + +func NewAppModule(cdc codec.Codec, keeper *keeper.Keeper) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// Name returns the pools module's name. +func (am AppModule) Name() string { + return am.AppModuleBasic.Name() +} + +// 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 pools module's invariants. +func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { + keeper.RegisterInvariants(ir, am.keeper) +} + +// InitGenesis performs the pools 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 + cdc.MustUnmarshalJSON(gs, &genState) + am.keeper.InitGenesis(ctx, genState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the pools module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := am.keeper.ExportGenesis(ctx) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion implements ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return consensusVersion } + +func (am AppModule) IsOnePerModuleType() {} + +func (am AppModule) IsAppModule() {} diff --git a/x/pools/types/genesis.go b/x/pools/types/genesis.go index 74dda93b3..e1f94a097 100644 --- a/x/pools/types/genesis.go +++ b/x/pools/types/genesis.go @@ -5,15 +5,15 @@ import ( ) // NewGenesis creates a new GenesisState instance -func NewGenesis(nextPoolID uint32, pools []Pool) GenesisState { - return GenesisState{ +func NewGenesis(nextPoolID uint32, pools []Pool) *GenesisState { + return &GenesisState{ NextPoolID: nextPoolID, Pools: pools, } } // DefaultGenesis returns the default GenesisState -func DefaultGenesis() GenesisState { +func DefaultGenesis() *GenesisState { return NewGenesis(1, nil) } diff --git a/x/pools/types/genesis_test.go b/x/pools/types/genesis_test.go index a0ef891e7..6ba029c19 100644 --- a/x/pools/types/genesis_test.go +++ b/x/pools/types/genesis_test.go @@ -11,7 +11,7 @@ import ( func TestGenesis_Validate(t *testing.T) { testCases := []struct { name string - genesis types.GenesisState + genesis *types.GenesisState shouldErr bool }{ { From 152975e8e12c5f14b0c917b194a52b34c962bdf9 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Sun, 9 Jun 2024 22:32:03 -0500 Subject: [PATCH 42/49] feat: add genesis keeper tests --- x/pools/keeper/genesis.go | 2 +- x/pools/keeper/genesis_test.go | 110 +++++++++++++++++++++++++++++++++ x/pools/module.go | 2 +- 3 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 x/pools/keeper/genesis_test.go diff --git a/x/pools/keeper/genesis.go b/x/pools/keeper/genesis.go index 41d94e5ff..0ef14ba8e 100644 --- a/x/pools/keeper/genesis.go +++ b/x/pools/keeper/genesis.go @@ -26,7 +26,7 @@ func (k *Keeper) exportNextPoolID(ctx sdk.Context) uint32 { // -------------------------------------------------------------------------------------------------------------------- // InitGenesis initializes the genesis store using the provided data -func (k *Keeper) InitGenesis(ctx sdk.Context, data types.GenesisState) { +func (k *Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { // Set the next pool id k.SetNextPoolID(ctx, data.NextPoolID) diff --git a/x/pools/keeper/genesis_test.go b/x/pools/keeper/genesis_test.go new file mode 100644 index 000000000..7d5bcfb62 --- /dev/null +++ b/x/pools/keeper/genesis_test.go @@ -0,0 +1,110 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/milkyway-labs/milkyway/x/pools/types" +) + +func (suite *KeeperTestSuite) TestKeeper_ExportGenesis() { + testCases := []struct { + name string + setup func() + store func(ctx sdk.Context) + expGenesis *types.GenesisState + }{ + { + name: "next pool id is exported properly", + store: func(ctx sdk.Context) { + suite.k.SetNextPoolID(ctx, 10) + }, + expGenesis: &types.GenesisState{ + NextPoolID: 10, + }, + }, + { + name: "pools are exported properly", + store: func(ctx sdk.Context) { + suite.k.SetNextPoolID(ctx, 1) + suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + suite.k.SavePool(ctx, types.NewPool(2, "uatom")) + }, + expGenesis: &types.GenesisState{ + NextPoolID: 1, + Pools: []types.Pool{ + types.NewPool(1, "umilk"), + types.NewPool(2, "uatom"), + }, + }, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.setup != nil { + tc.setup() + } + if tc.store != nil { + tc.store(ctx) + } + + genesis := suite.k.ExportGenesis(ctx) + suite.Require().Equal(tc.expGenesis, genesis) + }) + } +} + +func (suite *KeeperTestSuite) TestKeeper_InitGenesis() { + testCases := []struct { + name string + genesis *types.GenesisState + check func(ctx sdk.Context) + }{ + { + name: "default genesis is initialized properly", + genesis: types.DefaultGenesis(), + check: func(ctx sdk.Context) { + nextPoolID, err := suite.k.GetNextPoolID(ctx) + suite.Require().NoError(err) + suite.Require().Equal(uint32(1), nextPoolID) + }, + }, + { + name: "genesis with pools is initialized properly", + genesis: types.NewGenesis( + 10, + []types.Pool{ + types.NewPool(1, "umilk"), + types.NewPool(2, "uatom"), + }, + ), + check: func(ctx sdk.Context) { + nextPoolID, err := suite.k.GetNextPoolID(ctx) + suite.Require().NoError(err) + suite.Require().Equal(uint32(10), nextPoolID) + + pool, found := suite.k.GetPoolByDenom(ctx, "umilk") + suite.Require().True(found) + suite.Require().Equal(types.NewPool(1, "umilk"), pool) + + pool, found = suite.k.GetPoolByDenom(ctx, "uatom") + suite.Require().True(found) + suite.Require().Equal(types.NewPool(2, "uatom"), pool) + }, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + suite.k.InitGenesis(ctx, tc.genesis) + + if tc.check != nil { + tc.check(ctx) + } + }) + } +} diff --git a/x/pools/module.go b/x/pools/module.go index ff44fbc3e..3e1d94371 100644 --- a/x/pools/module.go +++ b/x/pools/module.go @@ -125,7 +125,7 @@ func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { var genState types.GenesisState cdc.MustUnmarshalJSON(gs, &genState) - am.keeper.InitGenesis(ctx, genState) + am.keeper.InitGenesis(ctx, &genState) return []abci.ValidatorUpdate{} } From f73f29596be6da9070ef46540ec482ff05fbcabd Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Sun, 9 Jun 2024 22:35:46 -0500 Subject: [PATCH 43/49] feat: add invariants --- x/pools/keeper/invariants.go | 63 ++++++++++++++++++++++++++ x/pools/keeper/invariants_test.go | 74 +++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 x/pools/keeper/invariants.go create mode 100644 x/pools/keeper/invariants_test.go diff --git a/x/pools/keeper/invariants.go b/x/pools/keeper/invariants.go new file mode 100644 index 000000000..8888346fd --- /dev/null +++ b/x/pools/keeper/invariants.go @@ -0,0 +1,63 @@ +package keeper + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/milkyway-labs/milkyway/x/pools/types" +) + +// RegisterInvariants registers all pools module invariants +func RegisterInvariants(ir sdk.InvariantRegistry, keeper *Keeper) { + ir.RegisterRoute(types.ModuleName, "valid-pools", + ValidPoolsInvariant(keeper)) +} + +// -------------------------------------------------------------------------------------------------------------------- + +// ValidPoolsInvariant checks that all the pools are valid +func ValidPoolsInvariant(k *Keeper) sdk.Invariant { + return func(ctx sdk.Context) (message string, broken bool) { + + // Get the next pool id. + nextPoolID, err := k.GetNextPoolID(ctx) + if err != nil { + return sdk.FormatInvariant(types.ModuleName, "invalid pools", "unable to get the next pool ID"), true + } + + var invalidPools []types.Pool + k.IteratePools(ctx, func(pool types.Pool) (stop bool) { + invalid := false + + // Make sure the pool ID is never greater or equal to the next pool ID + if pool.ID >= nextPoolID { + invalid = true + } + + // Make sure the pool is valid + err = pool.Validate() + if err != nil { + invalid = true + } + + if invalid { + invalidPools = append(invalidPools, pool) + } + + return false + }) + + return sdk.FormatInvariant(types.ModuleName, "invalid pools", + fmt.Sprintf("the following pools are invalid:\n %s", formatOutputPools(invalidPools)), + ), invalidPools != nil + } +} + +// formatOutputPools concatenates the given pools information into a string +func formatOutputPools(pools []types.Pool) (output string) { + for _, pool := range pools { + output += fmt.Sprintf("%d\n", pool.ID) + } + return output +} diff --git a/x/pools/keeper/invariants_test.go b/x/pools/keeper/invariants_test.go new file mode 100644 index 000000000..5f7c83fcf --- /dev/null +++ b/x/pools/keeper/invariants_test.go @@ -0,0 +1,74 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/milkyway-labs/milkyway/x/pools/keeper" + "github.com/milkyway-labs/milkyway/x/pools/types" +) + +func (suite *KeeperTestSuite) TestValidPoolsInvariant() { + testCases := []struct { + name string + setup func() + store func(ctx sdk.Context) + expBroken bool + }{ + { + name: "not found next service id breaks invariant", + store: func(ctx sdk.Context) { + suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + }, + expBroken: true, + }, + { + name: "service with id equals to next service id breaks invariant", + store: func(ctx sdk.Context) { + suite.k.SetNextPoolID(ctx, 1) + suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + }, + expBroken: true, + }, + { + name: "service with id higher than next service id breaks invariant", + store: func(ctx sdk.Context) { + suite.k.SetNextPoolID(ctx, 1) + suite.k.SavePool(ctx, types.NewPool(2, "umilk")) + }, + expBroken: true, + }, + { + name: "invalid service breaks invariant", + store: func(ctx sdk.Context) { + suite.k.SetNextPoolID(ctx, 2) + suite.k.SavePool(ctx, types.NewPool(1, "invalid!")) + }, + expBroken: true, + }, + { + name: "valid data does not break invariant", + store: func(ctx sdk.Context) { + suite.k.SetNextPoolID(ctx, 3) + suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + suite.k.SavePool(ctx, types.NewPool(2, "unit")) + }, + expBroken: false, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.setup != nil { + tc.setup() + } + if tc.store != nil { + tc.store(ctx) + } + + _, broken := keeper.ValidPoolsInvariant(suite.k)(ctx) + suite.Require().Equal(tc.expBroken, broken) + }) + } +} From c4b1198056d7eb6abb5c2545983ef866de891079 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Mon, 10 Jun 2024 07:20:34 -0500 Subject: [PATCH 44/49] chore: add pools module to app.go --- app/app.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/app.go b/app/app.go index f99bbf890..566c7b738 100644 --- a/app/app.go +++ b/app/app.go @@ -161,6 +161,9 @@ import ( "github.com/milkyway-labs/milkyway/x/operators" operatorskeeper "github.com/milkyway-labs/milkyway/x/operators/keeper" operatorstypes "github.com/milkyway-labs/milkyway/x/operators/types" + "github.com/milkyway-labs/milkyway/x/pools" + poolskeeper "github.com/milkyway-labs/milkyway/x/pools/keeper" + poolstypes "github.com/milkyway-labs/milkyway/x/pools/types" "github.com/milkyway-labs/milkyway/x/records" recordskeeper "github.com/milkyway-labs/milkyway/x/records/keeper" recordstypes "github.com/milkyway-labs/milkyway/x/records/types" @@ -284,6 +287,7 @@ type MilkyWayApp struct { ServicesKeeper *serviceskeeper.Keeper OperatorsKeeper *operatorskeeper.Keeper + PoolsKeeper *poolskeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper @@ -347,7 +351,7 @@ func NewMilkyWayApp( icacallbackstypes.StoreKey, recordstypes.StoreKey, stakeibctypes.StoreKey, // Custom modules - servicestypes.StoreKey, operatorstypes.StoreKey, + servicestypes.StoreKey, operatorstypes.StoreKey, poolstypes.StoreKey, ) tkeys := storetypes.NewTransientStoreKeys(forwardingtypes.TransientStoreKey) memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) @@ -874,6 +878,10 @@ func NewMilkyWayApp( communityPoolKeeper, authorityAddr, ) + app.PoolsKeeper = poolskeeper.NewKeeper( + app.appCodec, + keys[poolstypes.StoreKey], + ) /**** Module Options ****/ @@ -923,6 +931,7 @@ func NewMilkyWayApp( // custom modules services.NewAppModule(appCodec, app.ServicesKeeper), operators.NewAppModule(appCodec, app.OperatorsKeeper), + pools.NewAppModule(appCodec, app.PoolsKeeper), ) if err := app.setupIndexer(appOpts, homePath, ac, vc, appCodec); err != nil { @@ -963,6 +972,7 @@ func NewMilkyWayApp( servicestypes.ModuleName, operatorstypes.ModuleName, + poolstypes.ModuleName, ) app.ModuleManager.SetOrderEndBlockers( @@ -979,6 +989,7 @@ func NewMilkyWayApp( servicestypes.ModuleName, operatorstypes.ModuleName, + poolstypes.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -998,7 +1009,7 @@ func NewMilkyWayApp( stakeibctypes.ModuleName, epochstypes.ModuleName, icqtypes.ModuleName, recordstypes.ModuleName, ratelimittypes.ModuleName, icacallbackstypes.ModuleName, - servicestypes.ModuleName, operatorstypes.ModuleName, + servicestypes.ModuleName, operatorstypes.ModuleName, poolstypes.ModuleName, } app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...) From f95524aa3349d11c7f8ea27d01c1a19a2e144f25 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Mon, 10 Jun 2024 07:21:23 -0500 Subject: [PATCH 45/49] chore: fix test method name --- x/pools/keeper/alias_functions_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/pools/keeper/alias_functions_test.go b/x/pools/keeper/alias_functions_test.go index e6286057f..cb3736592 100644 --- a/x/pools/keeper/alias_functions_test.go +++ b/x/pools/keeper/alias_functions_test.go @@ -6,7 +6,7 @@ import ( "github.com/milkyway-labs/milkyway/x/pools/types" ) -func (suite *KeeperTestSuite) TestKepeer_GetPoolForDenom() { +func (suite *KeeperTestSuite) TestKeeper_GetPoolForDenom() { testCases := []struct { name string setup func() From eab4c339ecdc6c635efc3d541f1812999ab5ba5f Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Thu, 13 Jun 2024 13:30:41 -0500 Subject: [PATCH 46/49] feat: add pool address --- app/app.go | 1 + proto/milkyway/pools/v1/models.proto | 4 ++ proto/milkyway/pools/v1/query.proto | 3 +- x/pools/keeper/alias_functions.go | 14 +++++- x/pools/keeper/alias_functions_test.go | 6 ++- x/pools/keeper/common_test.go | 1 + x/pools/keeper/genesis.go | 5 +- x/pools/keeper/genesis_test.go | 7 ++- x/pools/keeper/grpc_query_test.go | 6 ++- x/pools/keeper/invariants_test.go | 19 ++++--- x/pools/keeper/keeper.go | 9 ++-- x/pools/keeper/pools.go | 12 ++++- x/pools/keeper/pools_test.go | 28 +++++++++-- x/pools/types/expected_keepers.go | 13 +++++ x/pools/types/models.go | 16 +++++- x/pools/types/models.pb.go | 70 +++++++++++++++++++++++--- x/pools/types/query.pb.go | 3 +- 17 files changed, 183 insertions(+), 34 deletions(-) create mode 100644 x/pools/types/expected_keepers.go diff --git a/app/app.go b/app/app.go index 566c7b738..68d2a28f7 100644 --- a/app/app.go +++ b/app/app.go @@ -881,6 +881,7 @@ func NewMilkyWayApp( app.PoolsKeeper = poolskeeper.NewKeeper( app.appCodec, keys[poolstypes.StoreKey], + app.AccountKeeper, ) /**** Module Options ****/ diff --git a/proto/milkyway/pools/v1/models.proto b/proto/milkyway/pools/v1/models.proto index 48d4b6074..cf20ec163 100644 --- a/proto/milkyway/pools/v1/models.proto +++ b/proto/milkyway/pools/v1/models.proto @@ -13,4 +13,8 @@ message Pool { // Denom represents the denomination of the tokens that are staked in the pool string denom = 2; + + // Address represents the address of the account that is associated with this + // pool. This will be used to store tokens that users delegate to this pool. + string address = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; } diff --git a/proto/milkyway/pools/v1/query.proto b/proto/milkyway/pools/v1/query.proto index d2c1b7f0e..db2d1bdca 100644 --- a/proto/milkyway/pools/v1/query.proto +++ b/proto/milkyway/pools/v1/query.proto @@ -33,7 +33,8 @@ message QueryPoolByIdRequest { uint32 pool_id = 1; } -// QueryPoolByDenomRequest is the request type for the Query/PollByDenom RPC method. +// QueryPoolByDenomRequest is the request type for the Query/PollByDenom RPC +// method. message QueryPoolByDenomRequest { // Denom is the denom for which the pool is to be queried string denom = 1; diff --git a/x/pools/keeper/alias_functions.go b/x/pools/keeper/alias_functions.go index e2131b48e..07d6cb609 100644 --- a/x/pools/keeper/alias_functions.go +++ b/x/pools/keeper/alias_functions.go @@ -2,11 +2,20 @@ package keeper import ( storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/milkyway-labs/milkyway/x/pools/types" ) +// createAccountIfNotExists creates an account if it does not exist +func (k *Keeper) createAccountIfNotExists(ctx sdk.Context, address sdk.AccAddress) { + if !k.accountKeeper.HasAccount(ctx, address) { + defer telemetry.IncrCounter(1, "new", "account") + k.accountKeeper.SetAccount(ctx, k.accountKeeper.NewAccountWithAddress(ctx, address)) + } +} + // IteratePools iterates over the pools in the store and performs a callback function func (k *Keeper) IteratePools(ctx sdk.Context, cb func(pool types.Pool) (stop bool)) { store := ctx.KVStore(k.storeKey) @@ -75,7 +84,10 @@ func (k *Keeper) CreateOrGetPoolByDenom(ctx sdk.Context, denom string) (types.Po } // Save the pool - k.SavePool(ctx, pool) + err = k.SavePool(ctx, pool) + if err != nil { + return types.Pool{}, err + } // Increment the pool id k.SetNextPoolID(ctx, poolID+1) diff --git a/x/pools/keeper/alias_functions_test.go b/x/pools/keeper/alias_functions_test.go index cb3736592..27d728e8f 100644 --- a/x/pools/keeper/alias_functions_test.go +++ b/x/pools/keeper/alias_functions_test.go @@ -24,7 +24,8 @@ func (suite *KeeperTestSuite) TestKeeper_GetPoolForDenom() { { name: "existing pool is returned properly", store: func(ctx sdk.Context) { - suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + err := suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + suite.Require().NoError(err) }, denom: "umilk", expFound: true, @@ -82,7 +83,8 @@ func (suite *KeeperTestSuite) TestKeeper_CreateOrGetPoolByDenom() { { name: "existing pool is returned properly", store: func(ctx sdk.Context) { - suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + err := suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + suite.Require().NoError(err) }, denom: "umilk", shouldErr: false, diff --git a/x/pools/keeper/common_test.go b/x/pools/keeper/common_test.go index 0a0b91c35..7ba83fab2 100644 --- a/x/pools/keeper/common_test.go +++ b/x/pools/keeper/common_test.go @@ -91,5 +91,6 @@ func (suite *KeeperTestSuite) SetupTest() { suite.k = keeper.NewKeeper( suite.cdc, suite.storeKey, + suite.ak, ) } diff --git a/x/pools/keeper/genesis.go b/x/pools/keeper/genesis.go index 0ef14ba8e..2906a52af 100644 --- a/x/pools/keeper/genesis.go +++ b/x/pools/keeper/genesis.go @@ -32,6 +32,9 @@ func (k *Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { // Store the pools for _, pool := range data.Pools { - k.SavePool(ctx, pool) + err := k.SavePool(ctx, pool) + if err != nil { + panic(err) + } } } diff --git a/x/pools/keeper/genesis_test.go b/x/pools/keeper/genesis_test.go index 7d5bcfb62..4f37d73cc 100644 --- a/x/pools/keeper/genesis_test.go +++ b/x/pools/keeper/genesis_test.go @@ -26,8 +26,11 @@ func (suite *KeeperTestSuite) TestKeeper_ExportGenesis() { name: "pools are exported properly", store: func(ctx sdk.Context) { suite.k.SetNextPoolID(ctx, 1) - suite.k.SavePool(ctx, types.NewPool(1, "umilk")) - suite.k.SavePool(ctx, types.NewPool(2, "uatom")) + + err := suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + suite.Require().NoError(err) + err = suite.k.SavePool(ctx, types.NewPool(2, "uatom")) + suite.Require().NoError(err) }, expGenesis: &types.GenesisState{ NextPoolID: 1, diff --git a/x/pools/keeper/grpc_query_test.go b/x/pools/keeper/grpc_query_test.go index 4b3f77dd9..d615325f8 100644 --- a/x/pools/keeper/grpc_query_test.go +++ b/x/pools/keeper/grpc_query_test.go @@ -25,7 +25,8 @@ func (suite *KeeperTestSuite) TestQueryServer_PoolById() { { name: "found pool is returned properly", store: func(ctx sdk.Context) { - suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + err := suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + suite.Require().NoError(err) }, request: &types.QueryPoolByIdRequest{ PoolId: 1, @@ -76,7 +77,8 @@ func (suite *KeeperTestSuite) TestQueryServer_PoolByDenom() { { name: "found pool is returned properly", store: func(ctx sdk.Context) { - suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + err := suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + suite.Require().NoError(err) }, request: &types.QueryPoolByDenomRequest{ Denom: "umilk", diff --git a/x/pools/keeper/invariants_test.go b/x/pools/keeper/invariants_test.go index 5f7c83fcf..33096dbdc 100644 --- a/x/pools/keeper/invariants_test.go +++ b/x/pools/keeper/invariants_test.go @@ -17,7 +17,8 @@ func (suite *KeeperTestSuite) TestValidPoolsInvariant() { { name: "not found next service id breaks invariant", store: func(ctx sdk.Context) { - suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + err := suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + suite.Require().NoError(err) }, expBroken: true, }, @@ -25,7 +26,8 @@ func (suite *KeeperTestSuite) TestValidPoolsInvariant() { name: "service with id equals to next service id breaks invariant", store: func(ctx sdk.Context) { suite.k.SetNextPoolID(ctx, 1) - suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + err := suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + suite.Require().NoError(err) }, expBroken: true, }, @@ -33,7 +35,8 @@ func (suite *KeeperTestSuite) TestValidPoolsInvariant() { name: "service with id higher than next service id breaks invariant", store: func(ctx sdk.Context) { suite.k.SetNextPoolID(ctx, 1) - suite.k.SavePool(ctx, types.NewPool(2, "umilk")) + err := suite.k.SavePool(ctx, types.NewPool(2, "umilk")) + suite.Require().NoError(err) }, expBroken: true, }, @@ -41,7 +44,8 @@ func (suite *KeeperTestSuite) TestValidPoolsInvariant() { name: "invalid service breaks invariant", store: func(ctx sdk.Context) { suite.k.SetNextPoolID(ctx, 2) - suite.k.SavePool(ctx, types.NewPool(1, "invalid!")) + err := suite.k.SavePool(ctx, types.NewPool(1, "invalid!")) + suite.Require().NoError(err) }, expBroken: true, }, @@ -49,8 +53,11 @@ func (suite *KeeperTestSuite) TestValidPoolsInvariant() { name: "valid data does not break invariant", store: func(ctx sdk.Context) { suite.k.SetNextPoolID(ctx, 3) - suite.k.SavePool(ctx, types.NewPool(1, "umilk")) - suite.k.SavePool(ctx, types.NewPool(2, "unit")) + + err := suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + suite.Require().NoError(err) + err = suite.k.SavePool(ctx, types.NewPool(2, "unit")) + suite.Require().NoError(err) }, expBroken: false, }, diff --git a/x/pools/keeper/keeper.go b/x/pools/keeper/keeper.go index 41f473818..72b188143 100644 --- a/x/pools/keeper/keeper.go +++ b/x/pools/keeper/keeper.go @@ -12,12 +12,15 @@ import ( type Keeper struct { storeKey storetypes.StoreKey cdc codec.Codec + + accountKeeper types.AccountKeeper } -func NewKeeper(cdc codec.Codec, storeKey storetypes.StoreKey) *Keeper { +func NewKeeper(cdc codec.Codec, storeKey storetypes.StoreKey, accountKeeper types.AccountKeeper) *Keeper { return &Keeper{ - storeKey: storeKey, - cdc: cdc, + storeKey: storeKey, + cdc: cdc, + accountKeeper: accountKeeper, } } diff --git a/x/pools/keeper/pools.go b/x/pools/keeper/pools.go index fa57b801c..197155a4a 100644 --- a/x/pools/keeper/pools.go +++ b/x/pools/keeper/pools.go @@ -3,6 +3,7 @@ package keeper import ( "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/milkyway-labs/milkyway/x/pools/types" ) @@ -28,9 +29,18 @@ func (k *Keeper) GetNextPoolID(ctx sdk.Context) (serviceID uint32, err error) { // -------------------------------------------------------------------------------------------------------------------- // SavePool stores the given pool inside the store -func (k *Keeper) SavePool(ctx sdk.Context, pool types.Pool) { +func (k *Keeper) SavePool(ctx sdk.Context, pool types.Pool) error { store := ctx.KVStore(k.storeKey) store.Set(types.GetPoolStoreKey(pool.ID), k.cdc.MustMarshal(&pool)) + + // Create the pool account if it does not exist + poolAddress, err := sdk.AccAddressFromBech32(pool.Address) + if err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid pool address: %s", pool.Address) + } + k.createAccountIfNotExists(ctx, poolAddress) + + return nil } // GetPool retrieves the pool with the given ID from the store. diff --git a/x/pools/keeper/pools_test.go b/x/pools/keeper/pools_test.go index 866e6eb1a..7c5a1577d 100644 --- a/x/pools/keeper/pools_test.go +++ b/x/pools/keeper/pools_test.go @@ -107,25 +107,37 @@ func (suite *KeeperTestSuite) TestKeeper_SavePool() { store: func(ctx sdk.Context) { suite.k.SetNextPoolID(ctx, 1) }, - shouldErr: true, + shouldErr: false, pool: types.NewPool(1, "uatom"), check: func(ctx sdk.Context) { + // Make sure the pool is saved properly pool, found := suite.k.GetPool(ctx, 1) suite.Require().True(found) suite.Require().Equal(types.NewPool(1, "uatom"), pool) + + // Make sure the pool account is created + hasAccount := suite.ak.HasAccount(ctx, types.GetPoolAddress(1)) + suite.Require().True(hasAccount) }, }, { name: "existing pool is overridden properly", setup: func() { suite.k.SetNextPoolID(suite.ctx, 1) - suite.k.SavePool(suite.ctx, types.NewPool(1, "uatom")) + err := suite.k.SavePool(suite.ctx, types.NewPool(1, "uatom")) + suite.Require().NoError(err) }, - pool: types.NewPool(1, "usdt"), + pool: types.NewPool(1, "usdt"), + shouldErr: false, check: func(ctx sdk.Context) { + // Make sure the pool is saved properly pool, found := suite.k.GetPool(ctx, 1) suite.Require().True(found) suite.Require().Equal(types.NewPool(1, "usdt"), pool) + + // Make sure the pool account is created + hasAccount := suite.ak.HasAccount(ctx, types.GetPoolAddress(1)) + suite.Require().True(hasAccount) }, }, } @@ -141,7 +153,12 @@ func (suite *KeeperTestSuite) TestKeeper_SavePool() { tc.store(ctx) } - suite.k.SavePool(ctx, tc.pool) + err := suite.k.SavePool(ctx, tc.pool) + if tc.shouldErr { + suite.Require().Error(err) + } else { + suite.Require().NoError(err) + } if tc.check != nil { tc.check(ctx) @@ -168,7 +185,8 @@ func (suite *KeeperTestSuite) TestKeeper_GetPool() { { name: "found pool is returned properly", store: func(ctx sdk.Context) { - suite.k.SavePool(ctx, types.NewPool(1, "uatom")) + err := suite.k.SavePool(ctx, types.NewPool(1, "uatom")) + suite.Require().NoError(err) }, poolID: 1, expFound: true, diff --git a/x/pools/types/expected_keepers.go b/x/pools/types/expected_keepers.go new file mode 100644 index 000000000..cd1e263ff --- /dev/null +++ b/x/pools/types/expected_keepers.go @@ -0,0 +1,13 @@ +package types + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type AccountKeeper interface { + NewAccountWithAddress(ctx context.Context, addr sdk.AccAddress) sdk.AccountI + HasAccount(ctx context.Context, addr sdk.AccAddress) bool + SetAccount(ctx context.Context, acc sdk.AccountI) +} diff --git a/x/pools/types/models.go b/x/pools/types/models.go index b48ea5a43..f2f98181a 100644 --- a/x/pools/types/models.go +++ b/x/pools/types/models.go @@ -5,8 +5,14 @@ import ( "strconv" sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) +// GetPoolAddress generates a pool address from its id +func GetPoolAddress(poolID uint32) sdk.AccAddress { + return authtypes.NewModuleAddress(fmt.Sprintf("pool-%d", poolID)) +} + // ParsePoolID parses a pool id from a string func ParsePoolID(value string) (uint32, error) { parsed, err := strconv.ParseUint(value, 10, 32) @@ -21,8 +27,9 @@ func ParsePoolID(value string) (uint32, error) { // NewPool creates a new Pool instance func NewPool(id uint32, denom string) Pool { return Pool{ - ID: id, - Denom: denom, + ID: id, + Denom: denom, + Address: GetPoolAddress(id).String(), } } @@ -36,5 +43,10 @@ func (p *Pool) Validate() error { return fmt.Errorf("invalid pool denom") } + _, err := sdk.AccAddressFromBech32(p.Address) + if err != nil { + return fmt.Errorf("invalid pool address") + } + return nil } diff --git a/x/pools/types/models.pb.go b/x/pools/types/models.pb.go index 1fa978842..cb329e852 100644 --- a/x/pools/types/models.pb.go +++ b/x/pools/types/models.pb.go @@ -30,6 +30,9 @@ type Pool struct { ID uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // Denom represents the denomination of the tokens that are staked in the pool Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` + // Address represents the address of the account that is associated with this + // pool. This will be used to store tokens that users delegate to this pool. + Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` } func (m *Pool) Reset() { *m = Pool{} } @@ -79,6 +82,13 @@ func (m *Pool) GetDenom() string { return "" } +func (m *Pool) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + func init() { proto.RegisterType((*Pool)(nil), "milkyway.pools.v1.Pool") } @@ -86,20 +96,23 @@ func init() { func init() { proto.RegisterFile("milkyway/pools/v1/models.proto", fileDescriptor_b29c6df2abe9a338) } var fileDescriptor_b29c6df2abe9a338 = []byte{ - // 207 bytes of a gzipped FileDescriptorProto + // 242 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcb, 0xcd, 0xcc, 0xc9, 0xae, 0x2c, 0x4f, 0xac, 0xd4, 0x2f, 0xc8, 0xcf, 0xcf, 0x29, 0xd6, 0x2f, 0x33, 0xd4, 0xcf, 0xcd, 0x4f, 0x49, 0xcd, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x84, 0xc9, 0xeb, 0x81, 0xe5, 0xf5, 0xca, 0x0c, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xb2, 0xfa, 0x20, 0x16, 0x44, 0xa1, 0x94, 0x64, 0x72, 0x7e, 0x71, 0x6e, 0x7e, 0x71, 0x3c, 0x44, 0x02, 0xc2, 0x81, 0x48, 0x29, - 0x99, 0x70, 0xb1, 0x04, 0xe4, 0xe7, 0xe7, 0x08, 0x89, 0x71, 0x31, 0x65, 0xa6, 0x48, 0x30, 0x2a, + 0x65, 0x70, 0xb1, 0x04, 0xe4, 0xe7, 0xe7, 0x08, 0x89, 0x71, 0x31, 0x65, 0xa6, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0xf0, 0x3a, 0xb1, 0x3d, 0xba, 0x27, 0xcf, 0xe4, 0xe9, 0x12, 0xc4, 0x94, 0x99, 0x22, 0x24, 0xc2, 0xc5, 0x9a, 0x92, 0x9a, 0x97, 0x9f, 0x2b, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0x19, 0x04, - 0xe1, 0x38, 0x79, 0x9e, 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, 0x7e, 0x7a, - 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xcc, 0x79, 0xba, 0x39, 0x89, 0x49, - 0xc5, 0x70, 0x9e, 0x7e, 0x05, 0xd4, 0x3b, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x77, - 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x84, 0x7a, 0x82, 0x76, 0xed, 0x00, 0x00, 0x00, + 0xe1, 0x08, 0x19, 0x71, 0xb1, 0x27, 0xa6, 0xa4, 0x14, 0xa5, 0x16, 0x17, 0x4b, 0x30, 0x83, 0xc4, + 0x9d, 0x24, 0x2e, 0x6d, 0xd1, 0x15, 0x81, 0x1a, 0xec, 0x08, 0x91, 0x09, 0x2e, 0x29, 0xca, 0xcc, + 0x4b, 0x0f, 0x82, 0x29, 0x74, 0xf2, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, + 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, + 0x28, 0xfd, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x98, 0x97, 0x74, + 0x73, 0x12, 0x93, 0x8a, 0xe1, 0x3c, 0xfd, 0x0a, 0x68, 0x10, 0x94, 0x54, 0x16, 0xa4, 0x16, 0x27, + 0xb1, 0x81, 0xdd, 0x6e, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xee, 0x3f, 0xe7, 0x79, 0x21, 0x01, + 0x00, 0x00, } func (m *Pool) Marshal() (dAtA []byte, err error) { @@ -122,6 +135,13 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintModels(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x1a + } if len(m.Denom) > 0 { i -= len(m.Denom) copy(dAtA[i:], m.Denom) @@ -161,6 +181,10 @@ func (m *Pool) Size() (n int) { if l > 0 { n += 1 + l + sovModels(uint64(l)) } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovModels(uint64(l)) + } return n } @@ -250,6 +274,38 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } m.Denom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + 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 ErrInvalidLengthModels + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModels + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipModels(dAtA[iNdEx:]) diff --git a/x/pools/types/query.pb.go b/x/pools/types/query.pb.go index 42854e9a7..a32595dc5 100644 --- a/x/pools/types/query.pb.go +++ b/x/pools/types/query.pb.go @@ -76,7 +76,8 @@ func (m *QueryPoolByIdRequest) GetPoolId() uint32 { return 0 } -// QueryPoolByDenomRequest is the request type for the Query/PollByDenom RPC method. +// QueryPoolByDenomRequest is the request type for the Query/PollByDenom RPC +// method. type QueryPoolByDenomRequest struct { // Denom is the denom for which the pool is to be queried Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` From 0bb28900d04e3793fe295fdba4b0d932ae30d5e2 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Fri, 14 Jun 2024 10:51:02 -0500 Subject: [PATCH 47/49] build: remove unwanted Makefile entry --- Makefile | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Makefile b/Makefile index ae2496f55..639475e9d 100644 --- a/Makefile +++ b/Makefile @@ -227,15 +227,6 @@ mockgen: .PHONY: mocks -############################################################################### -### Mocks ### -############################################################################### - -mockgen: - @go install go.uber.org/mock/mockgen@latest - @./scripts/mockgen.sh -.PHONY: mocks - ############################################################################### ### Tests & Simulation ### ############################################################################### From 284d4c6ef0a4025770f83051c3c7df471e30cb53 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Mon, 17 Jun 2024 10:47:27 -0500 Subject: [PATCH 48/49] feat: add invariant to check for duplicated pools by denom --- utils/slices.go | 22 +++++++++++++++ x/pools/keeper/invariants.go | 39 ++++++++++++++++++++++---- x/pools/keeper/invariants_test.go | 46 +++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 5 deletions(-) diff --git a/utils/slices.go b/utils/slices.go index 257f85695..795956232 100644 --- a/utils/slices.go +++ b/utils/slices.go @@ -12,3 +12,25 @@ func FindDuplicate[T any](slice []T, compare func(a T, b T) bool) *T { } return nil } + +// Map applies the given function to each element in the slice and returns a new slice with the results. +func Map[T, U any](slice []T, f func(T) U) []U { + result := make([]U, len(slice)) + for i, v := range slice { + result[i] = f(v) + } + return result +} + +// RemoveDuplicates removes all duplicate elements from the slice. +func RemoveDuplicates[T comparable](slice []T) []T { + seen := make(map[T]bool) + result := make([]T, 0, len(slice)) + for _, v := range slice { + if _, ok := seen[v]; !ok { + seen[v] = true + result = append(result, v) + } + } + return result +} diff --git a/x/pools/keeper/invariants.go b/x/pools/keeper/invariants.go index 8888346fd..b4b8e52a7 100644 --- a/x/pools/keeper/invariants.go +++ b/x/pools/keeper/invariants.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/milkyway-labs/milkyway/utils" "github.com/milkyway-labs/milkyway/x/pools/types" ) @@ -12,10 +13,27 @@ import ( func RegisterInvariants(ir sdk.InvariantRegistry, keeper *Keeper) { ir.RegisterRoute(types.ModuleName, "valid-pools", ValidPoolsInvariant(keeper)) + ir.RegisterRoute(types.ModuleName, "unique-pools", + UniquePoolsInvariant(keeper)) } // -------------------------------------------------------------------------------------------------------------------- +// formatOutputPools concatenates the given pools information into a string +func formatOutputPools(pools []types.Pool) (output string) { + // Get the unique IDs + uniquePoolIDs := utils.RemoveDuplicates(utils.Map(pools, func(pool types.Pool) uint32 { + return pool.ID + })) + + // Create the message string + for _, poolID := range uniquePoolIDs { + output += fmt.Sprintf("%d\n", poolID) + } + + return output +} + // ValidPoolsInvariant checks that all the pools are valid func ValidPoolsInvariant(k *Keeper) sdk.Invariant { return func(ctx sdk.Context) (message string, broken bool) { @@ -54,10 +72,21 @@ func ValidPoolsInvariant(k *Keeper) sdk.Invariant { } } -// formatOutputPools concatenates the given pools information into a string -func formatOutputPools(pools []types.Pool) (output string) { - for _, pool := range pools { - output += fmt.Sprintf("%d\n", pool.ID) +// UniquePoolsInvariant checks that there are no duplicated pools for the same denom +func UniquePoolsInvariant(k *Keeper) sdk.Invariant { + return func(ctx sdk.Context) (message string, broken bool) { + + var invalidPools []types.Pool + k.IteratePools(ctx, func(pool types.Pool) (stop bool) { + otherPool, found := k.GetPoolByDenom(ctx, pool.Denom) + if found && otherPool.ID != pool.ID { + invalidPools = append(invalidPools, pool) + } + return false + }) + + return sdk.FormatInvariant(types.ModuleName, "invalid pools", + fmt.Sprintf("the following pools have the same denoms:\n %s", formatOutputPools(invalidPools)), + ), invalidPools != nil } - return output } diff --git a/x/pools/keeper/invariants_test.go b/x/pools/keeper/invariants_test.go index 33096dbdc..7aa632b37 100644 --- a/x/pools/keeper/invariants_test.go +++ b/x/pools/keeper/invariants_test.go @@ -79,3 +79,49 @@ func (suite *KeeperTestSuite) TestValidPoolsInvariant() { }) } } + +func (suite *KeeperTestSuite) TestUniquePoolsInvariant() { + testCases := []struct { + name string + setup func() + store func(ctx sdk.Context) + expBroken bool + }{ + { + name: "duplicated pools break invariant", + store: func(ctx sdk.Context) { + err := suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + suite.Require().NoError(err) + err = suite.k.SavePool(ctx, types.NewPool(2, "umilk")) + suite.Require().NoError(err) + }, + expBroken: true, + }, + { + name: "valid data does not break invariant", + store: func(ctx sdk.Context) { + err := suite.k.SavePool(ctx, types.NewPool(1, "umilk")) + suite.Require().NoError(err) + err = suite.k.SavePool(ctx, types.NewPool(2, "unit")) + suite.Require().NoError(err) + }, + expBroken: false, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.setup != nil { + tc.setup() + } + if tc.store != nil { + tc.store(ctx) + } + + _, broken := keeper.UniquePoolsInvariant(suite.k)(ctx) + suite.Require().Equal(tc.expBroken, broken) + }) + } +} From c5ba1f0b9cd3693c07789cccf7cd4a99e29fd7b4 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Mon, 17 Jun 2024 10:47:45 -0500 Subject: [PATCH 49/49] feat(tests): improve CreateOrGetPoolByDenom tests --- x/pools/keeper/alias_functions_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/x/pools/keeper/alias_functions_test.go b/x/pools/keeper/alias_functions_test.go index 27d728e8f..bf0ba736a 100644 --- a/x/pools/keeper/alias_functions_test.go +++ b/x/pools/keeper/alias_functions_test.go @@ -93,21 +93,23 @@ func (suite *KeeperTestSuite) TestKeeper_CreateOrGetPoolByDenom() { { name: "non existing pool is created properly", store: func(ctx sdk.Context) { - suite.k.SetNextPoolID(ctx, 1) + suite.k.SetNextPoolID(ctx, 2) + err := suite.k.SavePool(ctx, types.NewPool(1, "unit")) + suite.Require().NoError(err) }, denom: "umilk", shouldErr: false, - expPool: types.NewPool(1, "umilk"), + expPool: types.NewPool(2, "umilk"), check: func(ctx sdk.Context) { // Make sure the pool is stored properly pool, found := suite.k.GetPoolByDenom(ctx, "umilk") suite.Require().True(found) - suite.Require().Equal(types.NewPool(1, "umilk"), pool) + suite.Require().Equal(types.NewPool(2, "umilk"), pool) // Make sure the next pool id has been incremented nextPoolID, err := suite.k.GetNextPoolID(ctx) suite.Require().NoError(err) - suite.Require().Equal(uint32(2), nextPoolID) + suite.Require().Equal(uint32(3), nextPoolID) }, }, }