From 21f52a1f2ca9e75a92f0b932d0339f796eb2b4fc Mon Sep 17 00:00:00 2001 From: JoowonYun Date: Thu, 5 Sep 2024 23:54:54 +0900 Subject: [PATCH 1/2] feat: x/volunteer use v1 proposal --- Dockerfile | 2 +- app/keepers/keepers.go | 6 +- app/modules.go | 10 +- docs/proto/proto-docs.md | 95 ++ proto/xpla/volunteer/v1beta1/proposal.proto | 4 + proto/xpla/volunteer/v1beta1/tx.proto | 63 + tests/e2e/integration_test.go | 218 ++- tests/e2e/util_test.go | 19 +- tests/integration/testutil/common.go | 2 +- x/volunteer/client/cli/flags.go | 19 - x/volunteer/client/cli/tx.go | 179 --- x/volunteer/client/cli/util.go | 38 - x/volunteer/client/proposal_handler.go | 13 - x/volunteer/keeper/keeper.go | 9 +- x/volunteer/keeper/migrations.go | 20 + x/volunteer/keeper/msg_server.go | 75 + x/volunteer/keeper/proposal_handler.go | 67 - x/volunteer/keeper/staking.go | 7 +- x/volunteer/module.go | 10 +- x/volunteer/types/codec.go | 13 +- .../types/{proposal.go => legacy_proposal.go} | 30 - x/volunteer/types/msg.go | 142 ++ x/volunteer/types/proposal.pb.go | 86 +- x/volunteer/types/tx.pb.go | 1214 +++++++++++++++++ 24 files changed, 1789 insertions(+), 552 deletions(-) create mode 100644 proto/xpla/volunteer/v1beta1/tx.proto delete mode 100644 x/volunteer/client/cli/flags.go delete mode 100644 x/volunteer/client/cli/tx.go delete mode 100644 x/volunteer/client/cli/util.go delete mode 100644 x/volunteer/client/proposal_handler.go create mode 100644 x/volunteer/keeper/migrations.go create mode 100644 x/volunteer/keeper/msg_server.go delete mode 100644 x/volunteer/keeper/proposal_handler.go rename x/volunteer/types/{proposal.go => legacy_proposal.go} (82%) create mode 100644 x/volunteer/types/msg.go create mode 100644 x/volunteer/types/tx.pb.go diff --git a/Dockerfile b/Dockerfile index 205289ae..7864d325 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ # docker run --rm -it --env-file=path/to/.env --name xpla-localnet xpladev/xpla ### BUILD -FROM golang:1.20-alpine3.17 AS build +FROM golang:1.21-alpine3.17 AS build # Create appuser. RUN adduser -D -g '' valiuser diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 6ef553be..27d18948 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -45,7 +45,6 @@ import ( slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/cosmos/cosmos-sdk/x/upgrade" upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" @@ -271,6 +270,7 @@ func NewAppKeeper( appCodec, appKeepers.StakingKeeper, appKeepers.DistrKeeper, + govModAddress, ) // register the staking hooks @@ -369,10 +369,8 @@ func NewAppKeeper( govRouter := govv1betatypes.NewRouter() govRouter. AddRoute(govtypes.RouterKey, govv1betatypes.ProposalHandler). - AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(appKeepers.UpgradeKeeper)). AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(appKeepers.IBCKeeper.ClientKeeper)). - AddRoute(erc20types.RouterKey, erc20.NewErc20ProposalHandler(&appKeepers.Erc20Keeper)). - AddRoute(volunteertypes.RouterKey, volunteerkeeper.NewVolunteerValidatorProposalHandler(appKeepers.VolunteerKeeper)) + AddRoute(erc20types.RouterKey, erc20.NewErc20ProposalHandler(&appKeepers.Erc20Keeper)) govConfig := govtypes.DefaultConfig() // set the MaxMetadataLen for proposals to the same value as it was pre-sdk v0.47.x diff --git a/app/modules.go b/app/modules.go index d53ceb51..6f026cef 100644 --- a/app/modules.go +++ b/app/modules.go @@ -38,7 +38,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/staking" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/cosmos-sdk/x/upgrade" - upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" router "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward" @@ -67,7 +66,6 @@ import ( rewardtypes "github.com/xpladev/xpla/x/reward/types" xplastaking "github.com/xpladev/xpla/x/staking" "github.com/xpladev/xpla/x/volunteer" - volunteerclient "github.com/xpladev/xpla/x/volunteer/client" volunteertypes "github.com/xpladev/xpla/x/volunteer/types" ) @@ -89,17 +87,13 @@ var maccPerms = map[string][]string{ } func getGovProposalHandlers() []govclient.ProposalHandler { - govProposalHandlers := volunteerclient.ProposalHandler - - return append(govProposalHandlers, []govclient.ProposalHandler{ - upgradeclient.LegacyProposalHandler, - upgradeclient.LegacyCancelProposalHandler, + return []govclient.ProposalHandler{ ibcclientclient.UpdateClientProposalHandler, ibcclientclient.UpgradeProposalHandler, erc20client.RegisterCoinProposalHandler, erc20client.RegisterERC20ProposalHandler, erc20client.ToggleTokenConversionProposalHandler, - }...) + } } // ModuleBasics defines the module BasicManager is in charge of setting up basic, diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index be27df23..327cd031 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -44,6 +44,14 @@ - [Query](#xpla.volunteer.v1beta1.Query) +- [xpla/volunteer/v1beta1/tx.proto](#xpla/volunteer/v1beta1/tx.proto) + - [MsgRegisterVolunteerValidator](#xpla.volunteer.v1beta1.MsgRegisterVolunteerValidator) + - [MsgRegisterVolunteerValidatorResponse](#xpla.volunteer.v1beta1.MsgRegisterVolunteerValidatorResponse) + - [MsgUnregisterVolunteerValidator](#xpla.volunteer.v1beta1.MsgUnregisterVolunteerValidator) + - [MsgUnregisterVolunteerValidatorResponse](#xpla.volunteer.v1beta1.MsgUnregisterVolunteerValidatorResponse) + + - [Msg](#xpla.volunteer.v1beta1.Msg) + - [Scalar Value Types](#scalar-value-types) @@ -484,6 +492,93 @@ Query defines the gRPC querier service for volunteer module. + +

Top

+ +## xpla/volunteer/v1beta1/tx.proto + + + + + +### MsgRegisterVolunteerValidator +MsgRegisterVolunteerValidator defines a message to register a new volunteer +validator. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `authority` | [string](#string) | | authority is the address of the governance account. | +| `validator_description` | [cosmos.staking.v1beta1.Description](#cosmos.staking.v1beta1.Description) | | | +| `delegator_address` | [string](#string) | | | +| `validator_address` | [string](#string) | | | +| `pubkey` | [google.protobuf.Any](#google.protobuf.Any) | | | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | + + + + + + + + +### MsgRegisterVolunteerValidatorResponse +MsgRegisterVolunteerValidatorResponse defines the RegisterVolunteerValidator +response. + + + + + + + + +### MsgUnregisterVolunteerValidator +MsgUnregisterVolunteerValidator defines a message to unregister a volunteer +validator. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `authority` | [string](#string) | | authority is the address of the governance account. | +| `validator_address` | [string](#string) | | | + + + + + + + + +### MsgUnregisterVolunteerValidatorResponse +MsgUnregisterVolunteerValidatorResponse defines the +UnregisterVolunteerValidator response. + + + + + + + + + + + + + + +### Msg +Msg defines the volunteer Msg service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `RegisterVolunteerValidator` | [MsgRegisterVolunteerValidator](#xpla.volunteer.v1beta1.MsgRegisterVolunteerValidator) | [MsgRegisterVolunteerValidatorResponse](#xpla.volunteer.v1beta1.MsgRegisterVolunteerValidatorResponse) | RegisterVolunteerValidator defines a method to register a new volunteer validator. | | +| `UnregisterVolunteerValidator` | [MsgUnregisterVolunteerValidator](#xpla.volunteer.v1beta1.MsgUnregisterVolunteerValidator) | [MsgUnregisterVolunteerValidatorResponse](#xpla.volunteer.v1beta1.MsgUnregisterVolunteerValidatorResponse) | UnregisterVolunteerValidator defines a method to unregister a volunteer | | + + + + + ## Scalar Value Types | .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby | diff --git a/proto/xpla/volunteer/v1beta1/proposal.proto b/proto/xpla/volunteer/v1beta1/proposal.proto index b4004d7c..bbb15c61 100644 --- a/proto/xpla/volunteer/v1beta1/proposal.proto +++ b/proto/xpla/volunteer/v1beta1/proposal.proto @@ -12,6 +12,7 @@ option go_package = "github.com/xpladev/xpla/x/volunteer/types"; // RegisterVolunteerValidatorProposal message RegisterVolunteerValidatorProposal { + option deprecated = true; option (amino.name) = "xpladev/RegisterVolunteerValidatorProposal"; option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; @@ -32,6 +33,7 @@ message RegisterVolunteerValidatorProposal { // RegisterVolunteerValidatorProposalWithDeposit message RegisterVolunteerValidatorProposalWithDeposit { + option deprecated = true; option (amino.name) = "xpladev/RegisterVolunteerValidatorProposalWithDeposit"; option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; @@ -53,6 +55,7 @@ message RegisterVolunteerValidatorProposalWithDeposit { // UnregisterVolunteerValidatorProposal message UnregisterVolunteerValidatorProposal { + option deprecated = true; option (amino.name) = "xpladev/UnregisterVolunteerValidatorProposal"; option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; @@ -65,6 +68,7 @@ message UnregisterVolunteerValidatorProposal { // UnregisterVolunteerValidatorProposalWithDeposit message UnregisterVolunteerValidatorProposalWithDeposit { + option deprecated = true; option (amino.name) = "xpladev/UnregisterVolunteerValidatorProposalWithDeposit"; option (gogoproto.equal) = false; diff --git a/proto/xpla/volunteer/v1beta1/tx.proto b/proto/xpla/volunteer/v1beta1/tx.proto new file mode 100644 index 00000000..3548915b --- /dev/null +++ b/proto/xpla/volunteer/v1beta1/tx.proto @@ -0,0 +1,63 @@ +syntax = "proto3"; +package xpla.volunteer.v1beta1; + +option go_package = "github.com/xpladev/xpla/x/volunteer/types"; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/staking/v1beta1/staking.proto"; +import "amino/amino.proto"; +import "cosmos/msg/v1/msg.proto"; + +// Msg defines the volunteer Msg service. +service Msg { + // RegisterVolunteerValidator defines a method to register a new volunteer + // validator. + rpc RegisterVolunteerValidator(MsgRegisterVolunteerValidator) + returns (MsgRegisterVolunteerValidatorResponse); + + // UnregisterVolunteerValidator defines a method to unregister a volunteer + rpc UnregisterVolunteerValidator(MsgUnregisterVolunteerValidator) + returns (MsgUnregisterVolunteerValidatorResponse); +} + +// MsgRegisterVolunteerValidator defines a message to register a new volunteer +// validator. +message MsgRegisterVolunteerValidator { + option (cosmos.msg.v1.signer) = "authority"; + option (amino.name) = "xpla/volunteer/MsgRegisterVolunteerValidator"; + + // authority is the address of the governance account. + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + cosmos.staking.v1beta1.Description validator_description = 2 + [ (gogoproto.nullable) = false ]; + string delegator_address = 3 + [ (gogoproto.moretags) = "yaml:\"delegator_address\"" ]; + string validator_address = 4 + [ (gogoproto.moretags) = "yaml:\"validator_address\"" ]; + google.protobuf.Any pubkey = 5 + [ (cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey" ]; + cosmos.base.v1beta1.Coin amount = 6 [ (gogoproto.nullable) = false ]; +} + +// MsgRegisterVolunteerValidatorResponse defines the RegisterVolunteerValidator +// response. +message MsgRegisterVolunteerValidatorResponse {} + +// MsgUnregisterVolunteerValidator defines a message to unregister a volunteer +// validator. +message MsgUnregisterVolunteerValidator { + option (cosmos.msg.v1.signer) = "authority"; + option (amino.name) = "xpla/volunteer/MsgUnregisterVolunteerValidator"; + + // authority is the address of the governance account. + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + string validator_address = 2 + [ (gogoproto.moretags) = "yaml:\"validator_address\"" ]; +} + +// MsgUnregisterVolunteerValidatorResponse defines the +// UnregisterVolunteerValidator response. +message MsgUnregisterVolunteerValidatorResponse {} \ No newline at end of file diff --git a/tests/e2e/integration_test.go b/tests/e2e/integration_test.go index 5e374bde..b3663ef4 100644 --- a/tests/e2e/integration_test.go +++ b/tests/e2e/integration_test.go @@ -15,11 +15,13 @@ import ( "golang.org/x/sync/errgroup" wasmtype "github.com/CosmWasm/wasmd/x/wasm/types" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" ed25519 "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdktypes "github.com/cosmos/cosmos-sdk/types" txtypes "github.com/cosmos/cosmos-sdk/types/tx" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govv1beta1types "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - paramtype "github.com/cosmos/cosmos-sdk/x/params/types/proposal" slashingtype "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtype "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -67,6 +69,8 @@ type WASMIntegrationTestSuite struct { VolunteerValidatorPVKey2 *PVKey VolunteerValidatorPVKey3 *PVKey Validator5PVKey *PVKey + + GovAddress string } func (i *WASMIntegrationTestSuite) SetupSuite() { @@ -130,6 +134,8 @@ func (i *WASMIntegrationTestSuite) SetupTest() { if err != nil { i.Fail("PVKey load fail") } + + i.GovAddress = authtypes.NewModuleAddress(govtypes.ModuleName).String() } func (i *WASMIntegrationTestSuite) TearDownTest() {} @@ -373,22 +379,20 @@ func (t *WASMIntegrationTestSuite) Test12_GeneralVolunteerValidatorRegistryUnreg { fmt.Println("Preparing proposal to add a volunteer validator") - proposalContent, err := volunteerValType.NewRegisterVolunteerValidatorProposal( - "register_volunteer_validator", - "Test volunteer validator registary", - sdktypes.AccAddress(t.VolunteerValidatorWallet1.ByteAddress.Bytes()), - sdktypes.ValAddress(t.VolunteerValidatorWallet1.ByteAddress.Bytes()), - &ed25519.PubKey{Key: t.VolunteerValidatorPVKey1.PubKey.Bytes()}, - sdktypes.NewCoin(xplatypes.DefaultDenom, amt), // smaller amount than other basic validators - stakingtype.NewDescription("volunteer_validator_1", "", "", "", ""), - ) - - assert.NoError(t.T(), err) + msgRegisterVolunteer := volunteerValType.MsgRegisterVolunteerValidator{ + DelegatorAddress: t.VolunteerValidatorWallet1.ByteAddress.String(), + ValidatorAddress: sdktypes.ValAddress(t.VolunteerValidatorWallet1.ByteAddress.Bytes()).String(), + Pubkey: codectypes.UnsafePackAny(&ed25519.PubKey{Key: t.VolunteerValidatorPVKey1.PubKey.Bytes()}), + Amount: sdktypes.NewCoin(xplatypes.DefaultDenom, amt), + Authority: t.GovAddress, + ValidatorDescription: stakingtype.NewDescription("volunteer_validator_1", "", "", "", ""), + } - err = applyVoteTallyingProposal( + err := applyVoteTallyingProposal( desc.GetConnectionWithContext(context.Background()), - []sdktypes.Msg{}, - proposalContent, + []sdktypes.Msg{&msgRegisterVolunteer}, + "register_volunteer_validator", + "Test volunteer validator registary", t.VolunteerValidatorWallet1, []*WalletInfo{t.ValidatorWallet1, t.ValidatorWallet2, t.ValidatorWallet3, t.ValidatorWallet4}, ) @@ -592,16 +596,16 @@ func (t *WASMIntegrationTestSuite) Test12_GeneralVolunteerValidatorRegistryUnreg { fmt.Println("Preparing proposal to remove a volunteer validator") - proposalContent := volunteerValType.NewUnregisterVolunteerValidatorProposal( - "unregister_volunteer_validator", - "Test volunteer validator unregistration", - sdktypes.ValAddress(t.VolunteerValidatorWallet1.ByteAddress.Bytes()), - ) + msgUnregisterVolunteerValidator := volunteerValType.MsgUnregisterVolunteerValidator{ + Authority: t.GovAddress, + ValidatorAddress: sdktypes.ValAddress(t.VolunteerValidatorWallet1.ByteAddress.Bytes()).String(), + } err := applyVoteTallyingProposal( desc.GetConnectionWithContext(context.Background()), - []sdktypes.Msg{}, - proposalContent, + []sdktypes.Msg{&msgUnregisterVolunteerValidator}, + "unregister_volunteer_validator", + "Test volunteer validator unregistration", t.VolunteerValidatorWallet1, []*WalletInfo{t.ValidatorWallet1, t.ValidatorWallet2, t.ValidatorWallet3, t.ValidatorWallet4}, ) @@ -696,25 +700,20 @@ func (t *WASMIntegrationTestSuite) Test13_MultipleProposals() { i := i eg.Go(func() error { - // apply proposal - proposalContent, err := volunteerValType.NewRegisterVolunteerValidatorProposal( - fmt.Sprintf("register_multiple_volunteer_validator_%d", i), - fmt.Sprintf("Test volunteer validator registary_%d", i), - sdktypes.AccAddress(t.VolunteerValidatorWallet2.ByteAddress.Bytes()), - sdktypes.ValAddress(t.VolunteerValidatorWallet2.ByteAddress.Bytes()), - &ed25519.PubKey{Key: t.VolunteerValidatorPVKey2.PubKey.Bytes()}, - sdktypes.NewCoin(xplatypes.DefaultDenom, amt), // smaller amount than other basic validators - stakingtype.NewDescription("volunteer_validator_2", "", "", "", ""), - ) - - if err != nil { - return err + msgRegisterVolunteer := volunteerValType.MsgRegisterVolunteerValidator{ + ValidatorDescription: stakingtype.NewDescription("volunteer_validator_2", "", "", "", ""), + DelegatorAddress: t.VolunteerValidatorWallet2.ByteAddress.String(), + ValidatorAddress: sdktypes.ValAddress(t.VolunteerValidatorWallet2.ByteAddress.Bytes()).String(), + Pubkey: codectypes.UnsafePackAny(&ed25519.PubKey{Key: t.VolunteerValidatorPVKey2.PubKey.Bytes()}), + Amount: sdktypes.NewCoin(xplatypes.DefaultDenom, amt), // smaller amount than other basic validators + Authority: t.GovAddress, } - err = applyVoteTallyingProposal( + err := applyVoteTallyingProposal( desc.GetConnectionWithContext(context.Background()), - []sdktypes.Msg{}, - proposalContent, + []sdktypes.Msg{&msgRegisterVolunteer}, + fmt.Sprintf("register_multiple_volunteer_validator_%d", i), + fmt.Sprintf("Test volunteer validator registary_%d", i), t.VolunteerValidatorWallet2, []*WalletInfo{t.ValidatorWallet1, t.ValidatorWallet2, t.ValidatorWallet3, t.ValidatorWallet4}, ) @@ -768,16 +767,16 @@ func (t *WASMIntegrationTestSuite) Test13_MultipleProposals() { eg.Go(func() error { // apply proposal - proposalContent := volunteerValType.NewUnregisterVolunteerValidatorProposal( - fmt.Sprintf("unregister_multiple_volunteer_validator_%d", i), - fmt.Sprintf("Test volunteer validator unregistary_%d", i), - sdktypes.ValAddress(t.VolunteerValidatorWallet2.ByteAddress.Bytes()), - ) + msgUnregisterVolunteerValidator := volunteerValType.MsgUnregisterVolunteerValidator{ + Authority: t.GovAddress, + ValidatorAddress: sdktypes.ValAddress(t.VolunteerValidatorWallet2.ByteAddress.Bytes()).String(), + } err := applyVoteTallyingProposal( desc.GetConnectionWithContext(context.Background()), - []sdktypes.Msg{}, - proposalContent, + []sdktypes.Msg{&msgUnregisterVolunteerValidator}, + fmt.Sprintf("unregister_multiple_volunteer_validator_%d", i), + fmt.Sprintf("Test volunteer validator unregistary_%d", i), t.VolunteerValidatorWallet2, []*WalletInfo{t.ValidatorWallet1, t.ValidatorWallet2, t.ValidatorWallet3, t.ValidatorWallet4}, ) @@ -830,31 +829,36 @@ func (t *WASMIntegrationTestSuite) Test14_TryChangingGeneralValidatorToVolunteer { fmt.Println("Try registering as a volunteer validator from the general validator...") - proposalContent, err := volunteerValType.NewRegisterVolunteerValidatorProposal( + msgRegisterVolunteer := volunteerValType.MsgRegisterVolunteerValidator{ + ValidatorDescription: stakingtype.NewDescription("volunteer_validator", "", "", "", ""), + DelegatorAddress: t.ValidatorWallet1.ByteAddress.String(), + ValidatorAddress: sdktypes.ValAddress(t.ValidatorWallet1.ByteAddress.Bytes()).String(), + Pubkey: codectypes.UnsafePackAny(&ed25519.PubKey{Key: t.Validator1PVKey.PubKey.Bytes()}), + Amount: sdktypes.NewCoin(xplatypes.DefaultDenom, amt), // smaller amount than other basic validators + Authority: t.GovAddress, + } + + err := applyVoteTallyingProposal( + desc.GetConnectionWithContext(context.Background()), + []sdktypes.Msg{&msgRegisterVolunteer}, "register_volunteer_validator_from_general_validator", "Test volunteer validator registary", - sdktypes.AccAddress(t.ValidatorWallet1.ByteAddress.Bytes()), - sdktypes.ValAddress(t.ValidatorWallet1.ByteAddress.Bytes()), - &ed25519.PubKey{Key: t.Validator1PVKey.PubKey.Bytes()}, - sdktypes.NewCoin(xplatypes.DefaultDenom, amt), // smaller amount than other basic validators - stakingtype.NewDescription("volunteer_validator", "", "", "", ""), + t.VolunteerValidatorWallet2, + []*WalletInfo{t.ValidatorWallet1, t.ValidatorWallet2, t.ValidatorWallet3, t.ValidatorWallet4}, ) assert.NoError(t.T(), err) - err = applyVoteTallyingProposal( - desc.GetConnectionWithContext(context.Background()), - []sdktypes.Msg{}, - proposalContent, - t.VolunteerValidatorWallet2, - []*WalletInfo{t.ValidatorWallet1, t.ValidatorWallet2, t.ValidatorWallet3, t.ValidatorWallet4}, - ) + client := volunteerValType.NewQueryClient(desc.GetConnectionWithContext(context.Background())) + validatorStatus, err := client.VolunteerValidators(context.Background(), &volunteerValType.QueryVolunteerValidatorsRequest{}) + assert.NoError(t.T(), err) + + thisVolunteerValAddress := sdktypes.ValAddress(t.ValidatorWallet1.ByteAddress).String() - if assert.Error(t.T(), err) { - fmt.Println(err) - fmt.Println("Expected failure! Test succeeded!") + if assert.NotContains(t.T(), validatorStatus.GetVolunteerValidators(), thisVolunteerValAddress) { + fmt.Println(thisVolunteerValAddress, "successfully dosen't exist from the validator set!") } else { - fmt.Println("Unexpected situation. Failure") + fmt.Println(thisVolunteerValAddress, "still exist!") t.T().Fail() } } @@ -883,23 +887,14 @@ func (t *WASMIntegrationTestSuite) Test15_ValidatorActiveSetChange() { fmt.Println("Decrease the number of active set") fmt.Println("Current # of validator:", maxValidators) - expectedChange := []paramtype.ParamChange{ - paramtype.NewParamChange(stakingtype.ModuleName, string(stakingtype.KeyMaxValidators), fmt.Sprintf("%d", maxValidators)), - } - msg, err := makeUpdateParamMaxValidators(desc.GetConnectionWithContext(context.Background()), maxValidators) assert.NoError(t.T(), err) - proposalContent := paramtype.NewParameterChangeProposal( - "decrease_validator_active_set", - "Decrease validator active set", - expectedChange, - ) - err = applyVoteTallyingProposal( desc.GetConnectionWithContext(context.Background()), []sdktypes.Msg{msg}, - proposalContent, + "decrease_validator_active_set", + "Decrease validator active set", t.ValidatorWallet2, []*WalletInfo{t.ValidatorWallet1, t.ValidatorWallet2, t.ValidatorWallet3, t.ValidatorWallet4}, ) @@ -948,22 +943,20 @@ func (t *WASMIntegrationTestSuite) Test15_ValidatorActiveSetChange() { { fmt.Println("Add one volunteer validator") - proposalContent, err := volunteerValType.NewRegisterVolunteerValidatorProposal( - "register_volunteer_validator_3", - "Test volunteer validator registry3 ", - sdktypes.AccAddress(t.VolunteerValidatorWallet3.ByteAddress.Bytes()), - sdktypes.ValAddress(t.VolunteerValidatorWallet3.ByteAddress.Bytes()), - &ed25519.PubKey{Key: t.VolunteerValidatorPVKey3.PubKey.Bytes()}, - sdktypes.NewCoin(xplatypes.DefaultDenom, volunteerValDelegationAmt), // smaller amount than other basic validators - stakingtype.NewDescription("volunteer_validator_3", "", "", "", ""), - ) - - assert.NoError(t.T(), err) + msgRegisterVolunteer := volunteerValType.MsgRegisterVolunteerValidator{ + ValidatorDescription: stakingtype.NewDescription("volunteer_validator_3", "", "", "", ""), + DelegatorAddress: t.VolunteerValidatorWallet3.ByteAddress.String(), + ValidatorAddress: sdktypes.ValAddress(t.VolunteerValidatorWallet3.ByteAddress.Bytes()).String(), + Pubkey: codectypes.UnsafePackAny(&ed25519.PubKey{Key: t.VolunteerValidatorPVKey3.PubKey.Bytes()}), + Amount: sdktypes.NewCoin(xplatypes.DefaultDenom, volunteerValDelegationAmt), // smaller amount than other basic validators + Authority: t.GovAddress, + } - err = applyVoteTallyingProposal( + err := applyVoteTallyingProposal( desc.GetConnectionWithContext(context.Background()), - []sdktypes.Msg{}, - proposalContent, + []sdktypes.Msg{&msgRegisterVolunteer}, + "register_volunteer_validator_3", + "Test volunteer validator registry3 ", t.VolunteerValidatorWallet3, []*WalletInfo{t.ValidatorWallet1, t.ValidatorWallet2, t.ValidatorWallet3, t.ValidatorWallet4}, ) @@ -1039,20 +1032,11 @@ func (t *WASMIntegrationTestSuite) Test15_ValidatorActiveSetChange() { msg, err := makeUpdateParamMaxValidators(desc.GetConnectionWithContext(context.Background()), maxValidators) - expectedChange := []paramtype.ParamChange{ - paramtype.NewParamChange(stakingtype.ModuleName, string(stakingtype.KeyMaxValidators), fmt.Sprintf("%d", maxValidators)), - } - - proposalContent := paramtype.NewParameterChangeProposal( - "increase_validator_active_set", - "Increase validator active set", - expectedChange, - ) - err = applyVoteTallyingProposal( desc.GetConnectionWithContext(context.Background()), []sdktypes.Msg{msg}, - proposalContent, + "increase_validator_active_set", + "Increase validator active set", t.ValidatorWallet1, []*WalletInfo{t.ValidatorWallet1, t.ValidatorWallet2, t.ValidatorWallet3, t.ValidatorWallet4}, ) @@ -1312,9 +1296,6 @@ func (t *WASMIntegrationTestSuite) Test15_ValidatorActiveSetChange() { // Setup { maxValidators = 4 - expectedChange := []paramtype.ParamChange{ - paramtype.NewParamChange(stakingtype.ModuleName, string(stakingtype.KeyMaxValidators), fmt.Sprintf("%d", maxValidators)), - } msg, err := makeUpdateParamMaxValidators(desc.GetConnectionWithContext(context.Background()), maxValidators) assert.NoError(t.T(), err) @@ -1322,16 +1303,11 @@ func (t *WASMIntegrationTestSuite) Test15_ValidatorActiveSetChange() { fmt.Println("Decrease the number of active set") fmt.Println("Current # of validator:", maxValidators) - proposalContent := paramtype.NewParameterChangeProposal( - "decrease_validator_active_set", - "Decrease validator active set", - expectedChange, - ) - err = applyVoteTallyingProposal( desc.GetConnectionWithContext(context.Background()), []sdktypes.Msg{msg}, - proposalContent, + "decrease_validator_active_set", + "Decrease validator active set", t.ValidatorWallet2, []*WalletInfo{t.ValidatorWallet1, t.ValidatorWallet2, t.ValidatorWallet3, t.ValidatorWallet4}, ) @@ -1530,9 +1506,6 @@ func (t *WASMIntegrationTestSuite) Test15_ValidatorActiveSetChange() { fmt.Println("Rolling back, MaxValidators to 6...") maxValidators = 6 - expectedChange := []paramtype.ParamChange{ - paramtype.NewParamChange(stakingtype.ModuleName, string(stakingtype.KeyMaxValidators), fmt.Sprintf("%d", maxValidators)), - } msg, err := makeUpdateParamMaxValidators(desc.GetConnectionWithContext(context.Background()), maxValidators) assert.NoError(t.T(), err) @@ -1540,16 +1513,11 @@ func (t *WASMIntegrationTestSuite) Test15_ValidatorActiveSetChange() { fmt.Println("Decrease the number of active set") fmt.Println("Current # of validator:", maxValidators) - paramChangeProposalContent := paramtype.NewParameterChangeProposal( - "decrease_validator_active_set", - "Decrease validator active set", - expectedChange, - ) - err = applyVoteTallyingProposal( desc.GetConnectionWithContext(context.Background()), []sdktypes.Msg{msg}, - paramChangeProposalContent, + "decrease_validator_active_set", + "Decrease validator active set", t.ValidatorWallet2, []*WalletInfo{t.ValidatorWallet1, t.ValidatorWallet2, t.ValidatorWallet3, t.ValidatorWallet4}, ) @@ -1559,16 +1527,16 @@ func (t *WASMIntegrationTestSuite) Test15_ValidatorActiveSetChange() { // Test { - unregisterProposalContent := volunteerValType.NewUnregisterVolunteerValidatorProposal( - "unregister_volunteer_validator", - "Test volunteer validator unregistration", - sdktypes.ValAddress(t.VolunteerValidatorWallet3.ByteAddress.Bytes()), - ) + msgUnregisterVolunteerValidator := volunteerValType.MsgUnregisterVolunteerValidator{ + Authority: t.GovAddress, + ValidatorAddress: sdktypes.ValAddress(t.VolunteerValidatorWallet3.ByteAddress.Bytes()).String(), + } err := applyVoteTallyingProposal( desc.GetConnectionWithContext(context.Background()), - []sdktypes.Msg{}, - unregisterProposalContent, + []sdktypes.Msg{&msgUnregisterVolunteerValidator}, + "unregister_volunteer_validator", + "Test volunteer validator unregistration", t.VolunteerValidatorWallet3, []*WalletInfo{t.ValidatorWallet1, t.ValidatorWallet2, t.ValidatorWallet3, t.ValidatorWallet4}, ) diff --git a/tests/e2e/util_test.go b/tests/e2e/util_test.go index 6467c019..576a32c9 100644 --- a/tests/e2e/util_test.go +++ b/tests/e2e/util_test.go @@ -198,7 +198,7 @@ func txCheck(txHash string) error { return err } -func applyVoteTallyingProposal(conn *grpc.ClientConn, proposalMsgs []sdktypes.Msg, proposalContent govv1beta1type.Content, proposerWallet *WalletInfo, voters []*WalletInfo) error { +func applyVoteTallyingProposal(conn *grpc.ClientConn, proposalMsgs []sdktypes.Msg, title, description string, proposerWallet *WalletInfo, voters []*WalletInfo) error { proposalId := uint64(0) { @@ -206,23 +206,8 @@ func applyVoteTallyingProposal(conn *grpc.ClientConn, proposalMsgs []sdktypes.Ms var msg sdktypes.Msg var err error - if len(proposalMsgs) > 0 { - msg, err = govv1type.NewMsgSubmitProposal(proposalMsgs, sdktypes.NewCoins(sdktypes.NewCoin(xplatypes.DefaultDenom, sdktypes.NewInt(10000000))), proposerWallet.ByteAddress.String(), "", proposalContent.GetTitle(), proposalContent.GetDescription()) - if err != nil { - return err - } - - } else { - msg, err = govv1beta1type.NewMsgSubmitProposal( - proposalContent, - sdktypes.NewCoins(sdktypes.NewCoin(xplatypes.DefaultDenom, sdktypes.NewInt(10000000))), - proposerWallet.ByteAddress, - ) - if err != nil { - return err - } - } + msg, err = govv1type.NewMsgSubmitProposal(proposalMsgs, sdktypes.NewCoins(sdktypes.NewCoin(xplatypes.DefaultDenom, sdktypes.NewInt(10000000))), proposerWallet.ByteAddress.String(), "", title, description) if err != nil { return err } diff --git a/tests/integration/testutil/common.go b/tests/integration/testutil/common.go index baae106a..26557547 100644 --- a/tests/integration/testutil/common.go +++ b/tests/integration/testutil/common.go @@ -193,7 +193,7 @@ func CreateTestInput(t *testing.T) TestInput { slashingKeeper := slashingkeeper.NewKeeper(appCodec, legacyAmino, keySlahsing, stakingKeeper, govModAddress) slashingKeeper.SetParams(ctx, slashingtypes.DefaultParams()) - volunteerKeeper = volunteerkeeper.NewKeeper(keyVolunteer, appCodec, stakingKeeper, distrKeeper) + volunteerKeeper = volunteerkeeper.NewKeeper(keyVolunteer, appCodec, stakingKeeper, distrKeeper, govModAddress) distrKeeper.SetFeePool(ctx, distrtypes.InitialFeePool()) distrParams := distrtypes.DefaultParams() diff --git a/x/volunteer/client/cli/flags.go b/x/volunteer/client/cli/flags.go deleted file mode 100644 index 7ea45067..00000000 --- a/x/volunteer/client/cli/flags.go +++ /dev/null @@ -1,19 +0,0 @@ -package cli - -import ( - flag "github.com/spf13/pflag" - - stakingcli "github.com/cosmos/cosmos-sdk/x/staking/client/cli" -) - -func flagSetDescriptionCreate() *flag.FlagSet { - fs := flag.NewFlagSet("", flag.ContinueOnError) - - fs.String(stakingcli.FlagMoniker, "", "The validator's name") - fs.String(stakingcli.FlagIdentity, "", "The optional identity signature (ex. UPort or Keybase)") - fs.String(stakingcli.FlagWebsite, "", "The validator's (optional) website") - fs.String(stakingcli.FlagSecurityContact, "", "The validator's (optional) security contact email") - fs.String(stakingcli.FlagDetails, "", "The validator's (optional) details") - - return fs -} diff --git a/x/volunteer/client/cli/tx.go b/x/volunteer/client/cli/tx.go deleted file mode 100644 index 564672a0..00000000 --- a/x/volunteer/client/cli/tx.go +++ /dev/null @@ -1,179 +0,0 @@ -package cli - -import ( - "fmt" - "strings" - - "github.com/spf13/cobra" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/version" - v1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - stakingcli "github.com/cosmos/cosmos-sdk/x/staking/client/cli" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - xplatypes "github.com/xpladev/xpla/types" - "github.com/xpladev/xpla/x/volunteer/types" -) - -func GetSubmitProposalRegisterVolunteerValidator() *cobra.Command { - cmd := &cobra.Command{ - Use: "register-volunteer-validator [proposal-file]", - Args: cobra.ExactArgs(1), - Short: "Submit a register volunteer validator proposal", - Long: strings.TrimSpace( - fmt.Sprintf(`Submit a register volunteer validator proposal along with an initial deposit. - The proposal details must be supplied via a JSON file. - - Example: -$ %s tx gov submit-proposal register-volunteer-validator - -Where proposal.json contains: - -{ - "title": "Register volunteer validator proposal", - "description": "Registration of validators independent of the active set", - "deposit": "10000000%s" -} -`, version.AppName, xplatypes.DefaultDenom)), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - proposal, err := ParseRegisterVolunteerValidatorProposalWithDeposit(clientCtx.Codec, args[0]) - if err != nil { - return err - } - - deposit, err := sdk.ParseCoinsNormalized(proposal.Deposit) - if err != nil { - return err - } - - fs := cmd.Flags() - - strAmount, _ := fs.GetString(stakingcli.FlagAmount) - amount, err := sdk.ParseCoinNormalized(strAmount) - if err != nil { - return err - } - - from := clientCtx.GetFromAddress() - - var pubKey cryptotypes.PubKey - pkStr, err := fs.GetString(stakingcli.FlagPubKey) - if err != nil { - return err - } - if err := clientCtx.Codec.UnmarshalInterfaceJSON([]byte(pkStr), &pubKey); err != nil { - return err - } - - moniker, _ := fs.GetString(stakingcli.FlagMoniker) - identity, _ := fs.GetString(stakingcli.FlagIdentity) - website, _ := fs.GetString(stakingcli.FlagWebsite) - security, _ := fs.GetString(stakingcli.FlagSecurityContact) - details, _ := fs.GetString(stakingcli.FlagDetails) - description := stakingtypes.NewDescription( - moniker, - identity, - website, - security, - details, - ) - - content, err := types.NewRegisterVolunteerValidatorProposal(proposal.Title, proposal.Description, from, sdk.ValAddress(from), pubKey, amount, description) - if err != nil { - return err - } - - msg, err := v1beta1.NewMsgSubmitProposal(content, deposit, from) - if err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - cmd.Flags().AddFlagSet(stakingcli.FlagSetPublicKey()) - cmd.Flags().AddFlagSet(stakingcli.FlagSetAmount()) - cmd.Flags().AddFlagSet(flagSetDescriptionCreate()) - - cmd.Flags().String(stakingcli.FlagIP, "", fmt.Sprintf("The node's public IP. It takes effect only when used in combination with --%s", flags.FlagGenerateOnly)) - cmd.Flags().String(stakingcli.FlagNodeID, "", "The node's ID") - - _ = cmd.MarkFlagRequired(flags.FlagFrom) - _ = cmd.MarkFlagRequired(stakingcli.FlagAmount) - _ = cmd.MarkFlagRequired(stakingcli.FlagPubKey) - _ = cmd.MarkFlagRequired(stakingcli.FlagMoniker) - - return cmd -} - -func GetSubmitProposalUnregisterVolunteerValidator() *cobra.Command { - bech32PrefixAccAddr := sdk.GetConfig().GetBech32AccountAddrPrefix() - - cmd := &cobra.Command{ - Use: "unregister-volunteer-validator [proposal-file]", - Args: cobra.ExactArgs(1), - Short: "Submit a unregister volunteer validator proposal", - Long: strings.TrimSpace( - fmt.Sprintf(`Submit a unregister volunteer validator proposal along with an initial deposit. - The proposal details must be supplied via a JSON file. - - Example: -$ %s tx gov submit-proposal unregister-volunteer-validator - -Where proposal.json contains: - -{ - "title": "Unregister volunteer validator proposal", - "description": "Unregistration of validators independent of the active set", - "validator_address": "%svaloper1luqjvjyns9e92h06tq6zqtw76k8xtegffyqca7", - "deposit": "10000000%s" -} -`, version.AppName, bech32PrefixAccAddr, xplatypes.DefaultDenom)), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - proposal, err := ParseUnregisterVolunteerValidatorProposalWithDeposit(clientCtx.Codec, args[0]) - if err != nil { - return err - } - - deposit, err := sdk.ParseCoinsNormalized(proposal.Deposit) - if err != nil { - return err - } - - valAddr, err := sdk.ValAddressFromBech32(proposal.ValidatorAddress) - if err != nil { - return err - } - - content := types.NewUnregisterVolunteerValidatorProposal(proposal.Title, proposal.Description, valAddr) - - from := clientCtx.GetFromAddress() - msg, err := v1beta1.NewMsgSubmitProposal(content, deposit, from) - if err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - _ = cmd.MarkFlagRequired(flags.FlagFrom) - - return cmd -} diff --git a/x/volunteer/client/cli/util.go b/x/volunteer/client/cli/util.go deleted file mode 100644 index 6178003f..00000000 --- a/x/volunteer/client/cli/util.go +++ /dev/null @@ -1,38 +0,0 @@ -package cli - -import ( - "os" - - "github.com/cosmos/cosmos-sdk/codec" - "github.com/xpladev/xpla/x/volunteer/types" -) - -func ParseRegisterVolunteerValidatorProposalWithDeposit(cdc codec.JSONCodec, proposalFile string) (types.RegisterVolunteerValidatorProposalWithDeposit, error) { - proposal := types.RegisterVolunteerValidatorProposalWithDeposit{} - - contents, err := os.ReadFile(proposalFile) - if err != nil { - return proposal, err - } - - if err = cdc.UnmarshalJSON(contents, &proposal); err != nil { - return proposal, err - } - - return proposal, nil -} - -func ParseUnregisterVolunteerValidatorProposalWithDeposit(cdc codec.JSONCodec, proposalFile string) (types.UnregisterVolunteerValidatorProposalWithDeposit, error) { - proposal := types.UnregisterVolunteerValidatorProposalWithDeposit{} - - contents, err := os.ReadFile(proposalFile) - if err != nil { - return proposal, err - } - - if err = cdc.UnmarshalJSON(contents, &proposal); err != nil { - return proposal, err - } - - return proposal, nil -} diff --git a/x/volunteer/client/proposal_handler.go b/x/volunteer/client/proposal_handler.go deleted file mode 100644 index e0f6a95e..00000000 --- a/x/volunteer/client/proposal_handler.go +++ /dev/null @@ -1,13 +0,0 @@ -package client - -import ( - govclient "github.com/cosmos/cosmos-sdk/x/gov/client" - "github.com/xpladev/xpla/x/volunteer/client/cli" -) - -var ( - ProposalHandler = []govclient.ProposalHandler{ - govclient.NewProposalHandler(cli.GetSubmitProposalRegisterVolunteerValidator), - govclient.NewProposalHandler(cli.GetSubmitProposalUnregisterVolunteerValidator), - } -) diff --git a/x/volunteer/keeper/keeper.go b/x/volunteer/keeper/keeper.go index 1bc2f904..592fb0f1 100644 --- a/x/volunteer/keeper/keeper.go +++ b/x/volunteer/keeper/keeper.go @@ -15,18 +15,25 @@ type Keeper struct { stakingKeeper types.StakingKeeper distKeeper types.DistributionKeeper + authority string } // NewKeeper constructs a message authorization Keeper -func NewKeeper(storeKey storetypes.StoreKey, cdc codec.BinaryCodec, sk types.StakingKeeper, dk types.DistributionKeeper) Keeper { +func NewKeeper(storeKey storetypes.StoreKey, cdc codec.BinaryCodec, sk types.StakingKeeper, dk types.DistributionKeeper, authority string) Keeper { return Keeper{ storeKey: storeKey, cdc: cdc, stakingKeeper: sk, distKeeper: dk, + authority: authority, } } +// GetAuthority returns the x/volunteer module's authority. +func (k Keeper) GetAuthority() string { + return k.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/volunteer/keeper/migrations.go b/x/volunteer/keeper/migrations.go new file mode 100644 index 00000000..c0558cb4 --- /dev/null +++ b/x/volunteer/keeper/migrations.go @@ -0,0 +1,20 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// Migrator is a struct for handling in-place store migrations. +type Migrator struct { + keeper Keeper +} + +// NewMigrator returns a new Migrator. +func NewMigrator(keeper Keeper) Migrator { + return Migrator{keeper: keeper} +} + +// Migrate1to2 migrates from version 1 to 2. +func (m Migrator) Migrate1to2(ctx sdk.Context) error { + return nil +} diff --git a/x/volunteer/keeper/msg_server.go b/x/volunteer/keeper/msg_server.go new file mode 100644 index 00000000..889a35e2 --- /dev/null +++ b/x/volunteer/keeper/msg_server.go @@ -0,0 +1,75 @@ +package keeper + +import ( + "context" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/xpladev/xpla/x/volunteer/types" +) + +type msgServer struct { + Keeper +} + +var _ types.MsgServer = msgServer{} + +func NewMsgServerImpl(k Keeper) types.MsgServer { + return &msgServer{Keeper: k} +} + +func (k msgServer) RegisterVolunteerValidator(goCtx context.Context, req *types.MsgRegisterVolunteerValidator) (*types.MsgRegisterVolunteerValidatorResponse, error) { + if k.authority != req.Authority { + return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, req.Authority) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + valAddress, err := sdk.ValAddressFromBech32(req.ValidatorAddress) + if err != nil { + return nil, err + } + + if _, found := k.stakingKeeper.GetValidator(ctx, valAddress); found { + return nil, stakingtypes.ErrValidatorOwnerExists + } + + k.SetVolunteerValidator(ctx, valAddress, types.NewVolunteerValidator(valAddress, 0)) + + createValidatorMsg := req.ToCreateValidator() + if err := k.CreateValidator(ctx, createValidatorMsg); err != nil { + return nil, err + } + + return &types.MsgRegisterVolunteerValidatorResponse{}, nil +} + +func (k msgServer) UnregisterVolunteerValidator(goCtx context.Context, req *types.MsgUnregisterVolunteerValidator) (*types.MsgUnregisterVolunteerValidatorResponse, error) { + if k.authority != req.Authority { + return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, req.Authority) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + valAddress, err := sdk.ValAddressFromBech32(req.ValidatorAddress) + if err != nil { + return nil, err + } + + _, found := k.GetVolunteerValidator(ctx, valAddress) + if !found { + return nil, errorsmod.Wrapf(errors.ErrNotFound, `volunteer validator (%s)`, valAddress.String()) + } + + if validator, found := k.stakingKeeper.GetValidator(ctx, valAddress); found { + _, err := k.stakingKeeper.Undelegate(ctx, sdk.AccAddress(valAddress), valAddress, validator.DelegatorShares) + if err != nil { + return nil, err + } + + k.DeleteVolunteerValidator(ctx, valAddress) + } + + return &types.MsgUnregisterVolunteerValidatorResponse{}, nil +} diff --git a/x/volunteer/keeper/proposal_handler.go b/x/volunteer/keeper/proposal_handler.go deleted file mode 100644 index b194be73..00000000 --- a/x/volunteer/keeper/proposal_handler.go +++ /dev/null @@ -1,67 +0,0 @@ -package keeper - -import ( - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - errortypes "github.com/cosmos/cosmos-sdk/types/errors" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/xpladev/xpla/x/volunteer/types" -) - -func NewVolunteerValidatorProposalHandler(k Keeper) govtypes.Handler { - return func(ctx sdk.Context, content govtypes.Content) error { - switch c := content.(type) { - case *types.RegisterVolunteerValidatorProposal: - return handlerRegisterVolunteerValidatorProposal(ctx, k, c) - case *types.UnregisterVolunteerValidatorProposal: - return handlerUnregisterVolunteerValidatorProposal(ctx, k, c) - default: - return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized volunteer validator proposal content type: %T", c) - } - } -} - -func handlerRegisterVolunteerValidatorProposal(ctx sdk.Context, k Keeper, p *types.RegisterVolunteerValidatorProposal) error { - valAddress, err := sdk.ValAddressFromBech32(p.ValidatorAddress) - if err != nil { - return err - } - - if _, found := k.stakingKeeper.GetValidator(ctx, valAddress); found { - return stakingtypes.ErrValidatorOwnerExists - } - - k.SetVolunteerValidator(ctx, valAddress, types.NewVolunteerValidator(valAddress, 0)) - - createValidatorMsg := p.ToCreateValidator() - if err := k.CreateValidator(ctx, createValidatorMsg); err != nil { - return err - } - - return nil -} - -func handlerUnregisterVolunteerValidatorProposal(ctx sdk.Context, k Keeper, p *types.UnregisterVolunteerValidatorProposal) error { - valAddress, err := sdk.ValAddressFromBech32(p.ValidatorAddress) - if err != nil { - return err - } - - _, found := k.GetVolunteerValidator(ctx, valAddress) - if !found { - return errorsmod.Wrapf(errortypes.ErrNotFound, `volunteer validator (%s)`, valAddress.String()) - } - - if validator, found := k.stakingKeeper.GetValidator(ctx, valAddress); found { - _, err := k.stakingKeeper.Undelegate(ctx, sdk.AccAddress(valAddress), valAddress, validator.DelegatorShares) - if err != nil { - return err - } - - k.DeleteVolunteerValidator(ctx, valAddress) - } - - return nil -} diff --git a/x/volunteer/keeper/staking.go b/x/volunteer/keeper/staking.go index 70a540bf..77a4bd94 100644 --- a/x/volunteer/keeper/staking.go +++ b/x/volunteer/keeper/staking.go @@ -1,6 +1,7 @@ package keeper import ( + errorsmod "cosmossdk.io/errors" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -20,7 +21,7 @@ func (k Keeper) CreateValidator(ctx sdk.Context, msg stakingtypes.MsgCreateValid pk, ok := msg.Pubkey.GetCachedValue().(cryptotypes.PubKey) if !ok { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "Expecting cryptostakingtypes.PubKey, got %T", pk) + return errorsmod.Wrapf(sdkerrors.ErrInvalidType, "Expecting cryptotypes.PubKey, got %T", pk) } if _, found := k.stakingKeeper.GetValidatorByConsAddr(ctx, sdk.GetConsAddress(pk)); found { @@ -29,7 +30,7 @@ func (k Keeper) CreateValidator(ctx sdk.Context, msg stakingtypes.MsgCreateValid bondDenom := k.stakingKeeper.BondDenom(ctx) if msg.Value.Denom != bondDenom { - return sdkerrors.Wrapf( + return errorsmod.Wrapf( sdkerrors.ErrInvalidRequest, "invalid coin denomination: got %s, expected %s", msg.Value.Denom, bondDenom, ) } @@ -49,7 +50,7 @@ func (k Keeper) CreateValidator(ctx sdk.Context, msg stakingtypes.MsgCreateValid } } if !hasKeyType { - return sdkerrors.Wrapf( + return errorsmod.Wrapf( stakingtypes.ErrValidatorPubKeyTypeNotSupported, "got: %s, expected: %s", pk.Type(), cp.Validator.PubKeyTypes, ) diff --git a/x/volunteer/module.go b/x/volunteer/module.go index f47fd404..d620199c 100644 --- a/x/volunteer/module.go +++ b/x/volunteer/module.go @@ -22,6 +22,8 @@ import ( "github.com/xpladev/xpla/x/volunteer/types" ) +const ConsensusVersion = 2 + var ( _ module.AppModule = AppModule{} _ module.AppModuleBasic = AppModuleBasic{} @@ -110,6 +112,12 @@ func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} func (am AppModule) RegisterServices(cfg module.Configurator) { querier := keeper.Querier{Keeper: am.keeper} types.RegisterQueryServer(cfg.QueryServer(), querier) + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + + m := keeper.NewMigrator(am.keeper) + if err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2); err != nil { + panic(fmt.Sprintf("failed to migrate x/%s from version 1 to 2: %v", types.ModuleName, err)) + } } // InitGenesis performs genesis initialization for the volunteer module. It returns @@ -129,7 +137,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements AppModule/ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 1 } +func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } // BeginBlock returns the begin blocker for the volunteer module. func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { diff --git a/x/volunteer/types/codec.go b/x/volunteer/types/codec.go index b6e35f1e..7642e63c 100644 --- a/x/volunteer/types/codec.go +++ b/x/volunteer/types/codec.go @@ -2,21 +2,22 @@ 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" - v1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + sdk "github.com/cosmos/cosmos-sdk/types" ) func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&RegisterVolunteerValidatorProposal{}, "xpladev/RegisterVolunteerValidatorProposal", nil) - cdc.RegisterConcrete(&UnregisterVolunteerValidatorProposal{}, "xpladev/UnregisterVolunteerValidatorProposal", nil) + legacy.RegisterAminoMsg(cdc, &MsgRegisterVolunteerValidator{}, "xpladev/MsgRegisterVolunteerValidator") + legacy.RegisterAminoMsg(cdc, &MsgUnregisterVolunteerValidator{}, "xpladev/MsgUnregisterVolunteerValidator") } func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterImplementations( - (*v1beta1.Content)(nil), - &RegisterVolunteerValidatorProposal{}, - &UnregisterVolunteerValidatorProposal{}, + (*sdk.Msg)(nil), + &MsgRegisterVolunteerValidator{}, + &MsgUnregisterVolunteerValidator{}, ) } diff --git a/x/volunteer/types/proposal.go b/x/volunteer/types/legacy_proposal.go similarity index 82% rename from x/volunteer/types/proposal.go rename to x/volunteer/types/legacy_proposal.go index c88ec150..128d4918 100644 --- a/x/volunteer/types/proposal.go +++ b/x/volunteer/types/legacy_proposal.go @@ -19,36 +19,6 @@ const ( ProposalTypeUnregisterVolunteerValidator ProposalType = "UnregisterVolunteerValidator" ) -var ( - _ govtypes.Content = &RegisterVolunteerValidatorProposal{} - _ govtypes.Content = &UnregisterVolunteerValidatorProposal{} -) - -func init() { - govtypes.RegisterProposalType(string(ProposalTypeRegisterVolunteerValidator)) - govtypes.RegisterProposalType(string(ProposalTypeUnregisterVolunteerValidator)) -} - -func NewRegisterVolunteerValidatorProposal(title, description string, delAddr sdk.AccAddress, valAddr sdk.ValAddress, pubKey cryptotypes.PubKey, - selfDelegation sdk.Coin, validatorDescription stakingtypes.Description) (*RegisterVolunteerValidatorProposal, error) { - var pkAny *codectypes.Any - if pubKey != nil { - var err error - if pkAny, err = codectypes.NewAnyWithValue(pubKey); err != nil { - return nil, err - } - } - return &RegisterVolunteerValidatorProposal{ - Title: title, - Description: description, - ValidatorDescription: validatorDescription, - Amount: selfDelegation, - DelegatorAddress: delAddr.String(), - ValidatorAddress: valAddr.String(), - Pubkey: pkAny, - }, nil -} - // GetTitle returns the title of a register volunteer validator proposal. func (p *RegisterVolunteerValidatorProposal) GetTitle() string { return p.Title } diff --git a/x/volunteer/types/msg.go b/x/volunteer/types/msg.go new file mode 100644 index 00000000..359d3d7f --- /dev/null +++ b/x/volunteer/types/msg.go @@ -0,0 +1,142 @@ +package types + +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +const ( + TypeMsgRegisterVolunteerValidator = "register_volunteer_validator" + TypeMsgUnregisterVolunteerValidator = "unregister_volunteer_validator" +) + +var ( + _ sdk.Msg = (*MsgRegisterVolunteerValidator)(nil) + _ codectypes.UnpackInterfacesMessage = (*MsgRegisterVolunteerValidator)(nil) + _ sdk.Msg = (*MsgUnregisterVolunteerValidator)(nil) +) + +func NewMsgRegisterVolunteerValidator(title, description string, delAddr sdk.AccAddress, valAddr sdk.ValAddress, pubKey cryptotypes.PubKey, + selfDelegation sdk.Coin, validatorDescription stakingtypes.Description) (*RegisterVolunteerValidatorProposal, error) { + var pkAny *codectypes.Any + if pubKey != nil { + var err error + if pkAny, err = codectypes.NewAnyWithValue(pubKey); err != nil { + return nil, err + } + } + return &RegisterVolunteerValidatorProposal{ + Title: title, + Description: description, + ValidatorDescription: validatorDescription, + Amount: selfDelegation, + DelegatorAddress: delAddr.String(), + ValidatorAddress: valAddr.String(), + Pubkey: pkAny, + }, nil +} + +func (msg MsgRegisterVolunteerValidator) Route() string { return RouterKey } + +func (msg MsgRegisterVolunteerValidator) Type() string { return TypeMsgRegisterVolunteerValidator } + +func (msg MsgRegisterVolunteerValidator) GetSigners() []sdk.AccAddress { + authority, _ := sdk.AccAddressFromBech32(msg.Authority) + return []sdk.AccAddress{authority} +} + +func (msg MsgRegisterVolunteerValidator) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +func (msg MsgRegisterVolunteerValidator) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return sdkerrors.ErrInvalidAddress.Wrapf("invalid authority address: %s", err) + } + + // note that unmarshaling from bech32 ensures either empty or valid + delAddr, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) + if err != nil { + return err + } + if delAddr.Empty() { + return stakingtypes.ErrEmptyDelegatorAddr + } + + if msg.ValidatorAddress == "" { + return stakingtypes.ErrEmptyValidatorAddr + } + + valAddr, err := sdk.ValAddressFromBech32(msg.ValidatorAddress) + if err != nil { + return err + } + if !sdk.AccAddress(valAddr).Equals(delAddr) { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "validator address is invalid") + } + + if msg.Pubkey == nil { + return stakingtypes.ErrEmptyValidatorPubKey + } + + if !msg.Amount.IsValid() || !msg.Amount.IsPositive() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid delegation amount") + } + + if msg.ValidatorDescription == (stakingtypes.Description{}) { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty description") + } + + return nil +} + +// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces +func (msg MsgRegisterVolunteerValidator) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { + var pubKey cryptotypes.PubKey + return unpacker.UnpackAny(msg.Pubkey, &pubKey) +} + +func (p MsgRegisterVolunteerValidator) ToCreateValidator() stakingtypes.MsgCreateValidator { + return stakingtypes.MsgCreateValidator{ + ValidatorAddress: p.ValidatorAddress, + DelegatorAddress: p.DelegatorAddress, + MinSelfDelegation: sdk.OneInt(), + Pubkey: p.Pubkey, + Value: p.Amount, + Description: p.ValidatorDescription, + Commission: stakingtypes.NewCommissionRates(sdk.OneDec(), sdk.OneDec(), sdk.ZeroDec()), + } +} + +func (msg MsgUnregisterVolunteerValidator) Route() string { return RouterKey } + +func (msg MsgUnregisterVolunteerValidator) Type() string { return TypeMsgUnregisterVolunteerValidator } + +func (msg MsgUnregisterVolunteerValidator) GetSigners() []sdk.AccAddress { + authority, _ := sdk.AccAddressFromBech32(msg.Authority) + return []sdk.AccAddress{authority} +} + +func (msg MsgUnregisterVolunteerValidator) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +func (msg MsgUnregisterVolunteerValidator) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return sdkerrors.ErrInvalidAddress.Wrapf("invalid authority address: %s", err) + } + + if msg.ValidatorAddress == "" { + return stakingtypes.ErrEmptyValidatorAddr + } + + _, err := sdk.ValAddressFromBech32(msg.ValidatorAddress) + if err != nil { + return err + } + + return nil +} diff --git a/x/volunteer/types/proposal.pb.go b/x/volunteer/types/proposal.pb.go index 1ec56af1..d6c41579 100644 --- a/x/volunteer/types/proposal.pb.go +++ b/x/volunteer/types/proposal.pb.go @@ -29,6 +29,8 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // RegisterVolunteerValidatorProposal +// +// Deprecated: Do not use. type RegisterVolunteerValidatorProposal struct { Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` @@ -72,6 +74,8 @@ func (m *RegisterVolunteerValidatorProposal) XXX_DiscardUnknown() { var xxx_messageInfo_RegisterVolunteerValidatorProposal proto.InternalMessageInfo // RegisterVolunteerValidatorProposalWithDeposit +// +// Deprecated: Do not use. type RegisterVolunteerValidatorProposalWithDeposit struct { Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` @@ -121,6 +125,8 @@ func (m *RegisterVolunteerValidatorProposalWithDeposit) XXX_DiscardUnknown() { var xxx_messageInfo_RegisterVolunteerValidatorProposalWithDeposit proto.InternalMessageInfo // UnregisterVolunteerValidatorProposal +// +// Deprecated: Do not use. type UnregisterVolunteerValidatorProposal struct { Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` @@ -160,6 +166,8 @@ func (m *UnregisterVolunteerValidatorProposal) XXX_DiscardUnknown() { var xxx_messageInfo_UnregisterVolunteerValidatorProposal proto.InternalMessageInfo // UnregisterVolunteerValidatorProposalWithDeposit +// +// Deprecated: Do not use. type UnregisterVolunteerValidatorProposalWithDeposit struct { Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` @@ -216,45 +224,45 @@ func init() { } var fileDescriptor_df7ee51656a08edb = []byte{ - // 596 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x55, 0x41, 0x6b, 0xd4, 0x40, - 0x18, 0x4d, 0xec, 0x76, 0xab, 0xd3, 0x4b, 0x1b, 0x56, 0x49, 0x8b, 0x64, 0x97, 0x58, 0xa1, 0x56, - 0x9b, 0x50, 0x45, 0x0a, 0x2b, 0x1e, 0xba, 0x2d, 0x45, 0xf1, 0x52, 0x02, 0x56, 0xf0, 0x60, 0x99, - 0x6c, 0xc6, 0x74, 0x68, 0x92, 0x09, 0x99, 0xc9, 0xd2, 0xfc, 0x03, 0xf1, 0xd4, 0xa3, 0xc7, 0xfd, - 0x09, 0x1e, 0xfc, 0x01, 0x1e, 0x4b, 0x4f, 0x3d, 0x7a, 0x2a, 0xb2, 0x7b, 0xd0, 0xb3, 0x47, 0x4f, - 0x92, 0xc9, 0x4c, 0x1a, 0x77, 0x85, 0x6e, 0x41, 0x0f, 0x42, 0x2f, 0xcb, 0x7e, 0xdf, 0xf7, 0xf2, - 0xf8, 0xde, 0xbc, 0x97, 0x0c, 0xb8, 0x7b, 0x18, 0x07, 0xd0, 0xee, 0x91, 0x20, 0x8d, 0x18, 0x42, - 0x89, 0xdd, 0x5b, 0x73, 0x11, 0x83, 0x6b, 0x76, 0x9c, 0x90, 0x98, 0x50, 0x18, 0x58, 0x71, 0x42, - 0x18, 0xd1, 0x6e, 0xe5, 0x30, 0xab, 0x84, 0x59, 0x02, 0xb6, 0xd8, 0xf0, 0x89, 0x4f, 0x38, 0xc4, - 0xce, 0xff, 0x15, 0xe8, 0xc5, 0x05, 0x9f, 0x10, 0x3f, 0x40, 0x36, 0xaf, 0xdc, 0xf4, 0xad, 0x0d, - 0xa3, 0x4c, 0x8e, 0xba, 0x84, 0x86, 0x84, 0xee, 0x15, 0xcf, 0x14, 0x85, 0x18, 0x19, 0x45, 0x65, - 0xbb, 0x90, 0xa2, 0x72, 0x8f, 0x2e, 0xc1, 0x91, 0x98, 0x2f, 0x89, 0x39, 0x65, 0xf0, 0x00, 0x47, - 0x7e, 0x09, 0x11, 0xb5, 0x40, 0xcd, 0xc3, 0x10, 0x47, 0xc4, 0xe6, 0xbf, 0x45, 0xcb, 0x3c, 0xaa, - 0x01, 0xd3, 0x41, 0x3e, 0xa6, 0x0c, 0x25, 0xbb, 0x52, 0xc2, 0x2e, 0x0c, 0xb0, 0x07, 0x19, 0x49, - 0x76, 0x84, 0x52, 0xad, 0x01, 0xa6, 0x19, 0x66, 0x01, 0xd2, 0xd5, 0x96, 0xba, 0x7c, 0xc3, 0x29, - 0x0a, 0xad, 0x05, 0x66, 0x3d, 0x44, 0xbb, 0x09, 0x8e, 0x19, 0x26, 0x91, 0x7e, 0x8d, 0xcf, 0xaa, - 0x2d, 0xed, 0x0d, 0xb8, 0xd9, 0x93, 0x64, 0x7b, 0x55, 0xec, 0x54, 0x4b, 0x5d, 0x9e, 0x7d, 0x78, - 0xc7, 0x12, 0x2a, 0xe5, 0x9e, 0x62, 0x6f, 0x6b, 0xeb, 0x1c, 0xda, 0xa9, 0x1d, 0x9f, 0x35, 0x15, - 0xa7, 0x51, 0xf2, 0x54, 0x66, 0xda, 0x73, 0x30, 0xef, 0xa1, 0x00, 0xf9, 0x9c, 0x1f, 0x7a, 0x5e, - 0x82, 0x28, 0xd5, 0x6b, 0xf9, 0x1e, 0x9d, 0xdb, 0x3f, 0xce, 0x9a, 0x7a, 0x06, 0xc3, 0xa0, 0x6d, - 0x8e, 0x41, 0x4c, 0x67, 0xae, 0xec, 0x6d, 0x14, 0xad, 0x9c, 0xea, 0x7c, 0x55, 0x49, 0x35, 0x3d, - 0x4a, 0x35, 0x06, 0x31, 0x9d, 0xb9, 0xb2, 0x27, 0xa9, 0xb6, 0x41, 0x3d, 0x4e, 0xdd, 0x03, 0x94, - 0xe9, 0x75, 0x2e, 0xb3, 0x61, 0x15, 0xa6, 0x5b, 0xd2, 0x74, 0x6b, 0x23, 0xca, 0x3a, 0xfa, 0xc9, - 0xa7, 0xd5, 0x86, 0xd0, 0xdf, 0x4d, 0xb2, 0x98, 0x11, 0x6b, 0x27, 0x75, 0x5f, 0xa0, 0xcc, 0x11, - 0x4f, 0x6b, 0xeb, 0xa0, 0x0e, 0x43, 0x92, 0x46, 0x4c, 0x9f, 0xe1, 0x3c, 0x0b, 0xf2, 0xb8, 0xf2, - 0x18, 0x94, 0x67, 0xb5, 0x49, 0xb0, 0x3c, 0x24, 0x01, 0x6f, 0x3f, 0x79, 0xd7, 0x6f, 0x2a, 0x1f, - 0xfa, 0x4d, 0xe5, 0x7b, 0xbf, 0xa9, 0xbc, 0xff, 0xf6, 0x71, 0x65, 0x25, 0xcf, 0xa8, 0x87, 0x7a, - 0xf6, 0xc5, 0x5e, 0x9b, 0x9f, 0x6b, 0x60, 0xf5, 0x62, 0xd8, 0x2b, 0xcc, 0xf6, 0xb7, 0x50, 0x4c, - 0x28, 0x66, 0x57, 0xe9, 0xf8, 0xaf, 0xd2, 0xa1, 0xe9, 0x60, 0xc6, 0x2b, 0x9c, 0xd3, 0xaf, 0x73, - 0x53, 0x64, 0xd9, 0xde, 0x16, 0xb9, 0x51, 0x65, 0x6e, 0x1e, 0x4f, 0x9e, 0x9b, 0x4a, 0x20, 0xcc, - 0x13, 0x15, 0x2c, 0xbd, 0x8c, 0x92, 0x7f, 0xf7, 0x5d, 0xb9, 0xff, 0x27, 0x3b, 0xa6, 0x38, 0x6e, - 0xec, 0xc0, 0xdb, 0x4f, 0x47, 0xdf, 0x86, 0x07, 0x52, 0xd5, 0x24, 0x3b, 0x9a, 0x3f, 0x55, 0x30, - 0x11, 0xf0, 0x6f, 0xbc, 0x11, 0x97, 0xd1, 0x55, 0xf5, 0xb1, 0xf6, 0xbb, 0x8f, 0xcf, 0x46, 0x7d, - 0x5c, 0xbf, 0x8c, 0xe2, 0x8a, 0x90, 0xce, 0xe6, 0xf1, 0xc0, 0x50, 0x4f, 0x07, 0x86, 0xfa, 0x75, - 0x60, 0xa8, 0x47, 0x43, 0x43, 0x39, 0x1d, 0x1a, 0xca, 0x97, 0xa1, 0xa1, 0xbc, 0xbe, 0xe7, 0x63, - 0xb6, 0x9f, 0xba, 0x56, 0x97, 0x84, 0xb6, 0x64, 0xe7, 0x17, 0xe6, 0x61, 0xe5, 0xca, 0x64, 0x59, - 0x8c, 0xa8, 0x5b, 0xe7, 0xc9, 0x7e, 0xf4, 0x2b, 0x00, 0x00, 0xff, 0xff, 0xf0, 0x06, 0x86, 0xe7, - 0x51, 0x07, 0x00, 0x00, + // 603 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x55, 0xcf, 0x6b, 0xd4, 0x40, + 0x18, 0xcd, 0xd8, 0xed, 0x56, 0xa7, 0x97, 0x36, 0xac, 0x32, 0x2d, 0x92, 0x2d, 0xb1, 0x42, 0xad, + 0x36, 0xa1, 0x8a, 0x14, 0x16, 0x44, 0xba, 0x2d, 0xe2, 0x8f, 0x4b, 0x09, 0x58, 0xc1, 0x83, 0x65, + 0xb2, 0x19, 0xd3, 0xa1, 0xd9, 0x4c, 0x48, 0x26, 0x4b, 0xf3, 0x1f, 0x88, 0x27, 0xf1, 0xe4, 0xb1, + 0x7f, 0x82, 0x07, 0xff, 0x02, 0x4f, 0x45, 0x3c, 0xf4, 0xe8, 0xa9, 0xc8, 0xee, 0x41, 0xcf, 0x9e, + 0x3d, 0x48, 0x26, 0x33, 0x69, 0xba, 0x2b, 0x74, 0x0b, 0x7a, 0x10, 0xbc, 0x2c, 0xfb, 0x7d, 0xdf, + 0xcb, 0xe3, 0x7b, 0xf3, 0x5e, 0x32, 0xf0, 0xfa, 0x7e, 0x14, 0x60, 0xbb, 0xc7, 0x82, 0x34, 0xe4, + 0x84, 0xc4, 0x76, 0x6f, 0xd5, 0x25, 0x1c, 0xaf, 0xda, 0x51, 0xcc, 0x22, 0x96, 0xe0, 0xc0, 0x8a, + 0x62, 0xc6, 0x99, 0x7e, 0x25, 0x87, 0x59, 0x25, 0xcc, 0x92, 0xb0, 0xf9, 0x86, 0xcf, 0x7c, 0x26, + 0x20, 0x76, 0xfe, 0xaf, 0x40, 0xcf, 0xcf, 0xf9, 0x8c, 0xf9, 0x01, 0xb1, 0x45, 0xe5, 0xa6, 0x2f, + 0x6d, 0x1c, 0x66, 0x6a, 0xd4, 0x61, 0x49, 0x97, 0x25, 0x3b, 0xc5, 0x33, 0x45, 0x21, 0x47, 0x46, + 0x51, 0xd9, 0x2e, 0x4e, 0x48, 0xb9, 0x47, 0x87, 0xd1, 0x50, 0xce, 0x17, 0xe5, 0x3c, 0xe1, 0x78, + 0x8f, 0x86, 0x7e, 0x09, 0x91, 0xb5, 0x44, 0xcd, 0xe2, 0x2e, 0x0d, 0x99, 0x2d, 0x7e, 0x8b, 0x96, + 0xf9, 0xb6, 0x06, 0x4d, 0x87, 0xf8, 0x34, 0xe1, 0x24, 0xde, 0x56, 0x12, 0xb6, 0x71, 0x40, 0x3d, + 0xcc, 0x59, 0xbc, 0x25, 0x95, 0xea, 0x0d, 0x38, 0xc9, 0x29, 0x0f, 0x08, 0x02, 0x0b, 0x60, 0xe9, + 0x92, 0x53, 0x14, 0xfa, 0x02, 0x9c, 0xf6, 0x48, 0xd2, 0x89, 0x69, 0xc4, 0x29, 0x0b, 0xd1, 0x05, + 0x31, 0xab, 0xb6, 0xf4, 0x17, 0xf0, 0x72, 0x4f, 0x91, 0xed, 0x54, 0xb1, 0x13, 0x0b, 0x60, 0x69, + 0xfa, 0xf6, 0x35, 0x4b, 0xaa, 0x54, 0x7b, 0xca, 0xbd, 0xad, 0xcd, 0x13, 0x68, 0xbb, 0x76, 0x78, + 0xdc, 0xd4, 0x9c, 0x46, 0xc9, 0x53, 0x99, 0xe9, 0x8f, 0xe0, 0xac, 0x47, 0x02, 0xe2, 0x0b, 0x7e, + 0xec, 0x79, 0x31, 0x49, 0x12, 0x54, 0xcb, 0xf7, 0x68, 0x5f, 0xfd, 0x71, 0xdc, 0x44, 0x19, 0xee, + 0x06, 0x2d, 0x73, 0x04, 0x62, 0x3a, 0x33, 0x65, 0x6f, 0xbd, 0x68, 0xe5, 0x54, 0x27, 0xab, 0x2a, + 0xaa, 0xc9, 0x61, 0xaa, 0x11, 0x88, 0xe9, 0xcc, 0x94, 0x3d, 0x45, 0xf5, 0x00, 0xd6, 0xa3, 0xd4, + 0xdd, 0x23, 0x19, 0xaa, 0x0b, 0x99, 0x0d, 0xab, 0x30, 0xdd, 0x52, 0xa6, 0x5b, 0xeb, 0x61, 0xd6, + 0x46, 0x9f, 0x3e, 0xac, 0x34, 0xa4, 0xfe, 0x4e, 0x9c, 0x45, 0x9c, 0x59, 0x5b, 0xa9, 0xfb, 0x84, + 0x64, 0x8e, 0x7c, 0x5a, 0x5f, 0x83, 0x75, 0xdc, 0x65, 0x69, 0xc8, 0xd1, 0x94, 0xe0, 0x99, 0x53, + 0xc7, 0x95, 0xc7, 0xa0, 0x3c, 0xab, 0x0d, 0x46, 0xd5, 0x21, 0x49, 0x78, 0xeb, 0xde, 0xab, 0x83, + 0xa6, 0xf6, 0xee, 0xa0, 0xa9, 0x7d, 0x3f, 0x68, 0x6a, 0xaf, 0xbf, 0xbd, 0x5f, 0x5e, 0xce, 0x33, + 0xea, 0x91, 0x9e, 0x7d, 0xb6, 0xd7, 0x08, 0x98, 0x1f, 0x6b, 0x70, 0xe5, 0x6c, 0xe0, 0x33, 0xca, + 0x77, 0x37, 0x49, 0xc4, 0x12, 0xca, 0xff, 0xe7, 0xe3, 0x9f, 0xca, 0x87, 0x8e, 0xe0, 0x94, 0x57, + 0x38, 0x87, 0x2e, 0x0a, 0x53, 0x54, 0xd9, 0x7a, 0x28, 0x93, 0x03, 0x54, 0x72, 0xee, 0x8e, 0x9f, + 0x9c, 0x4a, 0x20, 0x10, 0x30, 0x3f, 0x03, 0xb8, 0xf8, 0x34, 0x8c, 0xff, 0xde, 0xb7, 0xe5, 0xe6, + 0xef, 0x0c, 0x99, 0x10, 0xb8, 0x91, 0x23, 0x6f, 0xdd, 0x1f, 0x7e, 0x23, 0x6e, 0x29, 0x5d, 0xe3, + 0xec, 0x88, 0x80, 0xf9, 0x13, 0xc0, 0xb1, 0xa0, 0x7f, 0xe2, 0xad, 0x38, 0x8f, 0xb2, 0xaa, 0x97, + 0xb5, 0xd3, 0x5e, 0x3e, 0x1e, 0xf6, 0x72, 0xed, 0x3c, 0x9a, 0x4f, 0xb9, 0xd9, 0xde, 0x38, 0xec, + 0x1b, 0xe0, 0xa8, 0x6f, 0x80, 0xaf, 0x7d, 0x03, 0xbc, 0x19, 0x18, 0xda, 0xd1, 0xc0, 0xd0, 0xbe, + 0x0c, 0x0c, 0xed, 0xf9, 0x0d, 0x9f, 0xf2, 0xdd, 0xd4, 0xb5, 0x3a, 0xac, 0x6b, 0x2b, 0x7e, 0x71, + 0x71, 0xee, 0x57, 0xae, 0x4e, 0x9e, 0x45, 0x24, 0x71, 0xeb, 0x22, 0xdf, 0x77, 0x7e, 0x05, 0x00, + 0x00, 0xff, 0xff, 0x1a, 0x85, 0x36, 0x05, 0x59, 0x07, 0x00, 0x00, } func (m *RegisterVolunteerValidatorProposal) Marshal() (dAtA []byte, err error) { diff --git a/x/volunteer/types/tx.pb.go b/x/volunteer/types/tx.pb.go new file mode 100644 index 00000000..4dec2613 --- /dev/null +++ b/x/volunteer/types/tx.pb.go @@ -0,0 +1,1214 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: xpla/volunteer/v1beta1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + types1 "github.com/cosmos/cosmos-sdk/codec/types" + types2 "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + types "github.com/cosmos/cosmos-sdk/x/staking/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 + +// MsgRegisterVolunteerValidator defines a message to register a new volunteer +// validator. +type MsgRegisterVolunteerValidator struct { + // authority is the address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + ValidatorDescription types.Description `protobuf:"bytes,2,opt,name=validator_description,json=validatorDescription,proto3" json:"validator_description"` + DelegatorAddress string `protobuf:"bytes,3,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty" yaml:"delegator_address"` + ValidatorAddress string `protobuf:"bytes,4,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty" yaml:"validator_address"` + Pubkey *types1.Any `protobuf:"bytes,5,opt,name=pubkey,proto3" json:"pubkey,omitempty"` + Amount types2.Coin `protobuf:"bytes,6,opt,name=amount,proto3" json:"amount"` +} + +func (m *MsgRegisterVolunteerValidator) Reset() { *m = MsgRegisterVolunteerValidator{} } +func (m *MsgRegisterVolunteerValidator) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterVolunteerValidator) ProtoMessage() {} +func (*MsgRegisterVolunteerValidator) Descriptor() ([]byte, []int) { + return fileDescriptor_ae62d0c27add756a, []int{0} +} +func (m *MsgRegisterVolunteerValidator) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterVolunteerValidator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterVolunteerValidator.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 *MsgRegisterVolunteerValidator) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterVolunteerValidator.Merge(m, src) +} +func (m *MsgRegisterVolunteerValidator) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterVolunteerValidator) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterVolunteerValidator.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterVolunteerValidator proto.InternalMessageInfo + +func (m *MsgRegisterVolunteerValidator) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgRegisterVolunteerValidator) GetValidatorDescription() types.Description { + if m != nil { + return m.ValidatorDescription + } + return types.Description{} +} + +func (m *MsgRegisterVolunteerValidator) GetDelegatorAddress() string { + if m != nil { + return m.DelegatorAddress + } + return "" +} + +func (m *MsgRegisterVolunteerValidator) GetValidatorAddress() string { + if m != nil { + return m.ValidatorAddress + } + return "" +} + +func (m *MsgRegisterVolunteerValidator) GetPubkey() *types1.Any { + if m != nil { + return m.Pubkey + } + return nil +} + +func (m *MsgRegisterVolunteerValidator) GetAmount() types2.Coin { + if m != nil { + return m.Amount + } + return types2.Coin{} +} + +// MsgRegisterVolunteerValidatorResponse defines the RegisterVolunteerValidator +// response. +type MsgRegisterVolunteerValidatorResponse struct { +} + +func (m *MsgRegisterVolunteerValidatorResponse) Reset() { *m = MsgRegisterVolunteerValidatorResponse{} } +func (m *MsgRegisterVolunteerValidatorResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterVolunteerValidatorResponse) ProtoMessage() {} +func (*MsgRegisterVolunteerValidatorResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ae62d0c27add756a, []int{1} +} +func (m *MsgRegisterVolunteerValidatorResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterVolunteerValidatorResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterVolunteerValidatorResponse.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 *MsgRegisterVolunteerValidatorResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterVolunteerValidatorResponse.Merge(m, src) +} +func (m *MsgRegisterVolunteerValidatorResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterVolunteerValidatorResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterVolunteerValidatorResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterVolunteerValidatorResponse proto.InternalMessageInfo + +// MsgUnregisterVolunteerValidator defines a message to unregister a volunteer +// validator. +type MsgUnregisterVolunteerValidator struct { + // authority is the address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty" yaml:"validator_address"` +} + +func (m *MsgUnregisterVolunteerValidator) Reset() { *m = MsgUnregisterVolunteerValidator{} } +func (m *MsgUnregisterVolunteerValidator) String() string { return proto.CompactTextString(m) } +func (*MsgUnregisterVolunteerValidator) ProtoMessage() {} +func (*MsgUnregisterVolunteerValidator) Descriptor() ([]byte, []int) { + return fileDescriptor_ae62d0c27add756a, []int{2} +} +func (m *MsgUnregisterVolunteerValidator) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUnregisterVolunteerValidator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUnregisterVolunteerValidator.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 *MsgUnregisterVolunteerValidator) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUnregisterVolunteerValidator.Merge(m, src) +} +func (m *MsgUnregisterVolunteerValidator) XXX_Size() int { + return m.Size() +} +func (m *MsgUnregisterVolunteerValidator) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUnregisterVolunteerValidator.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUnregisterVolunteerValidator proto.InternalMessageInfo + +func (m *MsgUnregisterVolunteerValidator) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUnregisterVolunteerValidator) GetValidatorAddress() string { + if m != nil { + return m.ValidatorAddress + } + return "" +} + +// MsgUnregisterVolunteerValidatorResponse defines the +// UnregisterVolunteerValidator response. +type MsgUnregisterVolunteerValidatorResponse struct { +} + +func (m *MsgUnregisterVolunteerValidatorResponse) Reset() { + *m = MsgUnregisterVolunteerValidatorResponse{} +} +func (m *MsgUnregisterVolunteerValidatorResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUnregisterVolunteerValidatorResponse) ProtoMessage() {} +func (*MsgUnregisterVolunteerValidatorResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ae62d0c27add756a, []int{3} +} +func (m *MsgUnregisterVolunteerValidatorResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUnregisterVolunteerValidatorResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUnregisterVolunteerValidatorResponse.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 *MsgUnregisterVolunteerValidatorResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUnregisterVolunteerValidatorResponse.Merge(m, src) +} +func (m *MsgUnregisterVolunteerValidatorResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUnregisterVolunteerValidatorResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUnregisterVolunteerValidatorResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUnregisterVolunteerValidatorResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgRegisterVolunteerValidator)(nil), "xpla.volunteer.v1beta1.MsgRegisterVolunteerValidator") + proto.RegisterType((*MsgRegisterVolunteerValidatorResponse)(nil), "xpla.volunteer.v1beta1.MsgRegisterVolunteerValidatorResponse") + proto.RegisterType((*MsgUnregisterVolunteerValidator)(nil), "xpla.volunteer.v1beta1.MsgUnregisterVolunteerValidator") + proto.RegisterType((*MsgUnregisterVolunteerValidatorResponse)(nil), "xpla.volunteer.v1beta1.MsgUnregisterVolunteerValidatorResponse") +} + +func init() { proto.RegisterFile("xpla/volunteer/v1beta1/tx.proto", fileDescriptor_ae62d0c27add756a) } + +var fileDescriptor_ae62d0c27add756a = []byte{ + // 590 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcf, 0x6b, 0x13, 0x41, + 0x14, 0xce, 0xa6, 0x31, 0xd0, 0xf1, 0xd2, 0x2e, 0x51, 0xb7, 0xa1, 0x6e, 0xca, 0xaa, 0xf4, 0x07, + 0x3a, 0x4b, 0x2b, 0x5a, 0x08, 0x48, 0x49, 0x2a, 0x82, 0x48, 0x40, 0x56, 0xec, 0xc1, 0x83, 0x65, + 0x36, 0x3b, 0x4e, 0x97, 0xee, 0xee, 0x2c, 0x3b, 0xb3, 0x21, 0x7b, 0xf5, 0xe8, 0x45, 0xf1, 0xe4, + 0x9f, 0xd1, 0x83, 0xfe, 0x0f, 0xc5, 0x53, 0xf1, 0xe4, 0xa9, 0x48, 0x72, 0xc8, 0xdd, 0xbf, 0x40, + 0x76, 0x77, 0x66, 0x53, 0x9a, 0xb2, 0x42, 0xe8, 0x25, 0x93, 0x37, 0xef, 0x7b, 0x5f, 0xbe, 0xf7, + 0xbd, 0x37, 0x01, 0xad, 0x61, 0xe8, 0x21, 0x73, 0x40, 0xbd, 0x38, 0xe0, 0x18, 0x47, 0xe6, 0x60, + 0xdb, 0xc6, 0x1c, 0x6d, 0x9b, 0x7c, 0x08, 0xc3, 0x88, 0x72, 0xaa, 0xde, 0x4e, 0x01, 0xb0, 0x00, + 0x40, 0x01, 0x68, 0x36, 0x08, 0x25, 0x34, 0x83, 0x98, 0xe9, 0xb7, 0x1c, 0xdd, 0x5c, 0x21, 0x94, + 0x12, 0x0f, 0x9b, 0x59, 0x64, 0xc7, 0x1f, 0x4c, 0x14, 0x24, 0x32, 0xd5, 0xa7, 0xcc, 0xa7, 0xec, + 0x30, 0xaf, 0xc9, 0x03, 0x91, 0xd2, 0xf3, 0xc8, 0xb4, 0x11, 0xc3, 0x85, 0x82, 0x3e, 0x75, 0x03, + 0x91, 0xbf, 0x2f, 0xf2, 0x8c, 0xa3, 0x63, 0x37, 0x20, 0x05, 0x44, 0xc4, 0x02, 0xb5, 0x8c, 0x7c, + 0x37, 0xa0, 0x66, 0xf6, 0x29, 0xae, 0xee, 0x88, 0x42, 0x9f, 0xa5, 0x45, 0xe9, 0x91, 0x27, 0x8c, + 0xcf, 0x35, 0x70, 0xb7, 0xc7, 0x88, 0x85, 0x89, 0xcb, 0x38, 0x8e, 0x0e, 0x64, 0x7b, 0x07, 0xc8, + 0x73, 0x1d, 0xc4, 0x69, 0xa4, 0x3e, 0x05, 0x8b, 0x28, 0xe6, 0x47, 0x34, 0x72, 0x79, 0xa2, 0x29, + 0x6b, 0xca, 0xc6, 0x62, 0x57, 0xfb, 0xf5, 0xfd, 0x51, 0x43, 0x08, 0xef, 0x38, 0x4e, 0x84, 0x19, + 0x7b, 0xc3, 0x23, 0x37, 0x20, 0xd6, 0x14, 0xaa, 0xbe, 0x07, 0xb7, 0x06, 0x92, 0xe4, 0xd0, 0xc1, + 0xac, 0x1f, 0xb9, 0x21, 0x77, 0x69, 0xa0, 0x55, 0xd7, 0x94, 0x8d, 0x9b, 0x3b, 0xf7, 0xa0, 0x20, + 0x90, 0xda, 0x45, 0x2f, 0xf0, 0xf9, 0x14, 0xda, 0xad, 0x9d, 0x9e, 0xb7, 0x2a, 0x56, 0xa3, 0xe0, + 0xb9, 0x90, 0x53, 0x5f, 0x82, 0x65, 0x07, 0x7b, 0x98, 0x64, 0xfc, 0x28, 0x57, 0xa1, 0x2d, 0x64, + 0xfa, 0x56, 0xff, 0x9e, 0xb7, 0xb4, 0x04, 0xf9, 0x5e, 0xdb, 0x98, 0x81, 0x18, 0xd6, 0x52, 0x71, + 0x27, 0xb4, 0xa7, 0x54, 0x53, 0xa9, 0x92, 0xaa, 0x76, 0x99, 0x6a, 0x06, 0x62, 0x58, 0x4b, 0xc5, + 0x9d, 0xa4, 0x7a, 0x01, 0xea, 0x61, 0x6c, 0x1f, 0xe3, 0x44, 0xbb, 0x91, 0xb5, 0xd9, 0x80, 0xf9, + 0x22, 0x40, 0xb9, 0x08, 0xb0, 0x13, 0x24, 0x5d, 0xed, 0xe7, 0xd4, 0xc0, 0x7e, 0x94, 0x84, 0x9c, + 0xc2, 0xd7, 0xb1, 0xfd, 0x0a, 0x27, 0x96, 0xa8, 0x56, 0x77, 0x41, 0x1d, 0xf9, 0x34, 0x0e, 0xb8, + 0x56, 0xcf, 0x78, 0x56, 0xa4, 0x5d, 0xe9, 0x6a, 0x14, 0x5e, 0xed, 0x53, 0x57, 0x9a, 0x24, 0xe0, + 0xed, 0xbd, 0x8f, 0x93, 0x93, 0xad, 0xe9, 0x18, 0x3e, 0x4d, 0x4e, 0xb6, 0x1e, 0x5e, 0x5a, 0xed, + 0xd2, 0x79, 0x1b, 0xeb, 0xe0, 0x41, 0x29, 0xc0, 0xc2, 0x2c, 0xa4, 0x01, 0xc3, 0xc6, 0x44, 0x01, + 0xad, 0x1e, 0x23, 0x6f, 0x83, 0xe8, 0xfa, 0x97, 0xe7, 0xca, 0x89, 0x54, 0xe7, 0x99, 0x48, 0xbb, + 0x33, 0x6b, 0x08, 0x9c, 0x35, 0xa4, 0xac, 0x0b, 0x63, 0x13, 0xac, 0xff, 0x07, 0x22, 0x4d, 0xd9, + 0xf9, 0x51, 0x05, 0x0b, 0x3d, 0x46, 0xd4, 0xaf, 0x0a, 0x68, 0x96, 0x3c, 0xaa, 0x27, 0xf0, 0xea, + 0x7f, 0x13, 0x58, 0x6a, 0x7d, 0xf3, 0xd9, 0x5c, 0x65, 0x52, 0x9c, 0xfa, 0x4d, 0x01, 0xab, 0xa5, + 0xe3, 0xda, 0x2d, 0xe1, 0x2f, 0x2b, 0x6c, 0xee, 0xcd, 0x59, 0x28, 0xa5, 0x75, 0xf7, 0x4f, 0x47, + 0xba, 0x72, 0x36, 0xd2, 0x95, 0x3f, 0x23, 0x5d, 0xf9, 0x32, 0xd6, 0x2b, 0x67, 0x63, 0xbd, 0xf2, + 0x7b, 0xac, 0x57, 0xde, 0x6d, 0x12, 0x97, 0x1f, 0xc5, 0x36, 0xec, 0x53, 0xdf, 0x4c, 0x7f, 0xc4, + 0xc1, 0x83, 0xec, 0x34, 0x87, 0x17, 0x26, 0xc8, 0x93, 0x10, 0x33, 0xbb, 0x9e, 0x3d, 0xb2, 0xc7, + 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x72, 0x29, 0x99, 0x77, 0xcc, 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 { + // RegisterVolunteerValidator defines a method to register a new volunteer + // validator. + RegisterVolunteerValidator(ctx context.Context, in *MsgRegisterVolunteerValidator, opts ...grpc.CallOption) (*MsgRegisterVolunteerValidatorResponse, error) + // UnregisterVolunteerValidator defines a method to unregister a volunteer + UnregisterVolunteerValidator(ctx context.Context, in *MsgUnregisterVolunteerValidator, opts ...grpc.CallOption) (*MsgUnregisterVolunteerValidatorResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) RegisterVolunteerValidator(ctx context.Context, in *MsgRegisterVolunteerValidator, opts ...grpc.CallOption) (*MsgRegisterVolunteerValidatorResponse, error) { + out := new(MsgRegisterVolunteerValidatorResponse) + err := c.cc.Invoke(ctx, "/xpla.volunteer.v1beta1.Msg/RegisterVolunteerValidator", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UnregisterVolunteerValidator(ctx context.Context, in *MsgUnregisterVolunteerValidator, opts ...grpc.CallOption) (*MsgUnregisterVolunteerValidatorResponse, error) { + out := new(MsgUnregisterVolunteerValidatorResponse) + err := c.cc.Invoke(ctx, "/xpla.volunteer.v1beta1.Msg/UnregisterVolunteerValidator", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // RegisterVolunteerValidator defines a method to register a new volunteer + // validator. + RegisterVolunteerValidator(context.Context, *MsgRegisterVolunteerValidator) (*MsgRegisterVolunteerValidatorResponse, error) + // UnregisterVolunteerValidator defines a method to unregister a volunteer + UnregisterVolunteerValidator(context.Context, *MsgUnregisterVolunteerValidator) (*MsgUnregisterVolunteerValidatorResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) RegisterVolunteerValidator(ctx context.Context, req *MsgRegisterVolunteerValidator) (*MsgRegisterVolunteerValidatorResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterVolunteerValidator not implemented") +} +func (*UnimplementedMsgServer) UnregisterVolunteerValidator(ctx context.Context, req *MsgUnregisterVolunteerValidator) (*MsgUnregisterVolunteerValidatorResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UnregisterVolunteerValidator not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_RegisterVolunteerValidator_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRegisterVolunteerValidator) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RegisterVolunteerValidator(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/xpla.volunteer.v1beta1.Msg/RegisterVolunteerValidator", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RegisterVolunteerValidator(ctx, req.(*MsgRegisterVolunteerValidator)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UnregisterVolunteerValidator_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUnregisterVolunteerValidator) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UnregisterVolunteerValidator(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/xpla.volunteer.v1beta1.Msg/UnregisterVolunteerValidator", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UnregisterVolunteerValidator(ctx, req.(*MsgUnregisterVolunteerValidator)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "xpla.volunteer.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RegisterVolunteerValidator", + Handler: _Msg_RegisterVolunteerValidator_Handler, + }, + { + MethodName: "UnregisterVolunteerValidator", + Handler: _Msg_UnregisterVolunteerValidator_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "xpla/volunteer/v1beta1/tx.proto", +} + +func (m *MsgRegisterVolunteerValidator) 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 *MsgRegisterVolunteerValidator) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterVolunteerValidator) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + if m.Pubkey != nil { + { + size, err := m.Pubkey.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x22 + } + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.ValidatorDescription.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRegisterVolunteerValidatorResponse) 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 *MsgRegisterVolunteerValidatorResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterVolunteerValidatorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUnregisterVolunteerValidator) 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 *MsgUnregisterVolunteerValidator) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUnregisterVolunteerValidator) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUnregisterVolunteerValidatorResponse) 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 *MsgUnregisterVolunteerValidatorResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUnregisterVolunteerValidatorResponse) 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 *MsgRegisterVolunteerValidator) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.ValidatorDescription.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Pubkey != nil { + l = m.Pubkey.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgRegisterVolunteerValidatorResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUnregisterVolunteerValidator) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUnregisterVolunteerValidatorResponse) 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 *MsgRegisterVolunteerValidator) 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: MsgRegisterVolunteerValidator: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterVolunteerValidator: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorDescription", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ValidatorDescription.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", 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.DelegatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", 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.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pubkey", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pubkey == nil { + m.Pubkey = &types1.Any{} + } + if err := m.Pubkey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 *MsgRegisterVolunteerValidatorResponse) 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: MsgRegisterVolunteerValidatorResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterVolunteerValidatorResponse: 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 (m *MsgUnregisterVolunteerValidator) 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: MsgUnregisterVolunteerValidator: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUnregisterVolunteerValidator: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", 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.ValidatorAddress = 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 *MsgUnregisterVolunteerValidatorResponse) 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: MsgUnregisterVolunteerValidatorResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUnregisterVolunteerValidatorResponse: 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 38c1c65e1cee96363825d3bbb3710f397c55512b Mon Sep 17 00:00:00 2001 From: JoowonYun Date: Fri, 6 Sep 2024 19:04:19 +0900 Subject: [PATCH 2/2] fix: support to legacy proposal unmarsahl --- x/volunteer/types/codec.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/x/volunteer/types/codec.go b/x/volunteer/types/codec.go index 7642e63c..8e083158 100644 --- a/x/volunteer/types/codec.go +++ b/x/volunteer/types/codec.go @@ -6,14 +6,23 @@ import ( "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" + v1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&RegisterVolunteerValidatorProposal{}, "xpladev/RegisterVolunteerValidatorProposal", nil) + cdc.RegisterConcrete(&UnregisterVolunteerValidatorProposal{}, "xpladev/UnregisterVolunteerValidatorProposal", nil) legacy.RegisterAminoMsg(cdc, &MsgRegisterVolunteerValidator{}, "xpladev/MsgRegisterVolunteerValidator") legacy.RegisterAminoMsg(cdc, &MsgUnregisterVolunteerValidator{}, "xpladev/MsgUnregisterVolunteerValidator") } func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations( + (*v1beta1.Content)(nil), + &RegisterVolunteerValidatorProposal{}, + &UnregisterVolunteerValidatorProposal{}, + ) + registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgRegisterVolunteerValidator{},