diff --git a/CHANGELOG.md b/CHANGELOG.md index cf97f71f1fe2..260f2bb1b21f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -95,9 +95,11 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#9854](https://github.com/cosmos/cosmos-sdk/pull/9854) Fixed the `make proto-gen` to get dynamic container name based on project name for the cosmos based sdks. * [\#9829](https://github.com/cosmos/cosmos-sdk/pull/9829) Fixed Coin denom sorting not being checked during `Balance.Validate` check. Refactored the Validation logic to use `Coins.Validate` for `Balance.Coins`. + [\#9965](https://github.com/cosmos/cosmos-sdk/pull/9965) Fixed `simd version` command output to report the right release tag. ++ [\#9980](https://github.com/cosmos/cosmos-sdk/pull/9980) Returning the error when the invalid argument is passed to bank query total supply cli. ### State Machine Breaking +* (x/auth)[\#9596](https://github.com/cosmos/cosmos-sdk/pull/9596) Enable creating periodic vesting accounts with a transactions instead of requiring them to be created in genesis. * (x/bank) [\#9611](https://github.com/cosmos/cosmos-sdk/pull/9611) Introduce a new index to act as a reverse index between a denomination and address allowing to query for token holders of a specific denomination. `DenomOwners` is updated to use the new reverse index. * (x/bank) [\#9832] (https://github.com/cosmos/cosmos-sdk/pull/9832) Account balance is stored as `sdk.Int` rather than `sdk.Coin`. diff --git a/cosmovisor/README.md b/cosmovisor/README.md index 4e9b7a4b2716..37fb361c2126 100644 --- a/cosmovisor/README.md +++ b/cosmovisor/README.md @@ -1,21 +1,25 @@ # Cosmosvisor Quick Start -`cosmovisor` is a small process manager for Cosmos SDK application binaries that monitors the governance module via stdout for incoming chain upgrade proposals. If it sees a proposal that gets approved, `cosmovisor` can automatically download the new binary, stop the current binary, switch from the old binary to the new one, and finally restart the node with the new binary. +`cosmovisor` is a small process manager for Cosmos SDK application binaries that monitors the governance module for incoming chain upgrade proposals. If it sees a proposal that gets approved, `cosmovisor` can automatically download the new binary, stop the current binary, switch from the old binary to the new one, and finally restart the node with the new binary. *Note: If new versions of the application are not set up to run in-place store migrations, migrations will need to be run manually before restarting `cosmovisor` with the new binary. For this reason, we recommend applications adopt in-place store migrations.* +*Note: If validators would like to enable the auto-download option, and they are currently running an application using Cosmos SDK `v0.42`, they will need to use Cosmovisor [`v0.1`](https://github.com/cosmos/cosmos-sdk/releases/tag/cosmovisor%2Fv0.1.0). Later versions of Cosmovisor do not support Cosmos SDK `v0.42` or earlier if the auto-download option is enabled.* + ## Contributing -Release branches has the following format `release/cosmovisor/vA.B.x`, where A and B are a number (eg: `release/cosmovisor/v0.1.x`). Releases are tagged using the following format: `cosmovisor/vA.B.C`. +Release branches have the following format `release/cosmovisor/vA.B.x`, where A and B are a number (e.g. `release/cosmovisor/v0.1.x`). Releases are tagged using the following format: `cosmovisor/vA.B.C`. ## Installation -To install `cosmovisor`, run the following command: +To install the latest version of `cosmovisor`, run the following command: ``` -go get github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor +go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@latest ``` +*Note: If you are using go `v1.15` or earlier, you will need to use `go get`, and you may want to run the command outside a project directory.* + ## Command Line Arguments And Environment Variables All arguments passed to `cosmovisor` will be passed to the application binary (as a subprocess). `cosmovisor` will return `/dev/stdout` and `/dev/stderr` of the subprocess as its own. For this reason, `cosmovisor` cannot accept any command-line arguments other than those available to the application binary, nor will it print anything to output other than what is printed by the application binary. diff --git a/docs/building-modules/errors.md b/docs/building-modules/errors.md index d1bc36824562..0eb3728a5e72 100644 --- a/docs/building-modules/errors.md +++ b/docs/building-modules/errors.md @@ -18,7 +18,7 @@ of errors is handled via the `types/errors` package. Example: -+++ https://github.com/cosmos/cosmos-sdk/blob/v0.38.1/x/distribution/types/errors.go#L1-L21 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.43.0/x/distribution/types/errors.go#L1-L21 Each custom module error must provide the codespace, which is typically the module name (e.g. "distribution") and is unique per module, and a uint32 code. Together, the codespace and code diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 72c8471bc0a6..29a74149cff7 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -658,12 +658,6 @@ - [Query](#cosmos.upgrade.v1beta1.Query) -- [cosmos/vesting/v1beta1/tx.proto](#cosmos/vesting/v1beta1/tx.proto) - - [MsgCreateVestingAccount](#cosmos.vesting.v1beta1.MsgCreateVestingAccount) - - [MsgCreateVestingAccountResponse](#cosmos.vesting.v1beta1.MsgCreateVestingAccountResponse) - - - [Msg](#cosmos.vesting.v1beta1.Msg) - - [cosmos/vesting/v1beta1/vesting.proto](#cosmos/vesting/v1beta1/vesting.proto) - [BaseVestingAccount](#cosmos.vesting.v1beta1.BaseVestingAccount) - [ContinuousVestingAccount](#cosmos.vesting.v1beta1.ContinuousVestingAccount) @@ -672,6 +666,14 @@ - [PeriodicVestingAccount](#cosmos.vesting.v1beta1.PeriodicVestingAccount) - [PermanentLockedAccount](#cosmos.vesting.v1beta1.PermanentLockedAccount) +- [cosmos/vesting/v1beta1/tx.proto](#cosmos/vesting/v1beta1/tx.proto) + - [MsgCreatePeriodicVestingAccount](#cosmos.vesting.v1beta1.MsgCreatePeriodicVestingAccount) + - [MsgCreatePeriodicVestingAccountResponse](#cosmos.vesting.v1beta1.MsgCreatePeriodicVestingAccountResponse) + - [MsgCreateVestingAccount](#cosmos.vesting.v1beta1.MsgCreateVestingAccount) + - [MsgCreateVestingAccountResponse](#cosmos.vesting.v1beta1.MsgCreateVestingAccountResponse) + + - [Msg](#cosmos.vesting.v1beta1.Msg) + - [Scalar Value Types](#scalar-value-types) @@ -9416,62 +9418,6 @@ Query defines the gRPC upgrade querier service. - -
- -## cosmos/vesting/v1beta1/tx.proto - - - - - -### MsgCreateVestingAccount -MsgCreateVestingAccount defines a message that enables creating a vesting -account. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `from_address` | [string](#string) | | | -| `to_address` | [string](#string) | | | -| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | -| `end_time` | [int64](#int64) | | | -| `delayed` | [bool](#bool) | | | - - - - - - - - -### MsgCreateVestingAccountResponse -MsgCreateVestingAccountResponse defines the Msg/CreateVestingAccount response type. - - - - - - - - - - - - - - -### Msg -Msg defines the bank Msg service. - -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `CreateVestingAccount` | [MsgCreateVestingAccount](#cosmos.vesting.v1beta1.MsgCreateVestingAccount) | [MsgCreateVestingAccountResponse](#cosmos.vesting.v1beta1.MsgCreateVestingAccountResponse) | CreateVestingAccount defines a method that enables creating a vesting account. | | - - - - - @@ -9593,6 +9539,92 @@ still be used for delegating and for governance votes even while locked. + + + +## cosmos/vesting/v1beta1/tx.proto + + + + + +### MsgCreatePeriodicVestingAccount +MsgCreateVestingAccount defines a message that enables creating a vesting +account. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `from_address` | [string](#string) | | | +| `to_address` | [string](#string) | | | +| `start_time` | [int64](#int64) | | | +| `vesting_periods` | [Period](#cosmos.vesting.v1beta1.Period) | repeated | | + + + + + + + + +### MsgCreatePeriodicVestingAccountResponse + + + + + + + + + +### MsgCreateVestingAccount +MsgCreateVestingAccount defines a message that enables creating a vesting +account. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `from_address` | [string](#string) | | | +| `to_address` | [string](#string) | | | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `end_time` | [int64](#int64) | | | +| `delayed` | [bool](#bool) | | | + + + + + + + + +### MsgCreateVestingAccountResponse +MsgCreateVestingAccountResponse defines the Msg/CreateVestingAccount response type. + + + + + + + + + + + + + + +### Msg +Msg defines the bank Msg service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `CreateVestingAccount` | [MsgCreateVestingAccount](#cosmos.vesting.v1beta1.MsgCreateVestingAccount) | [MsgCreateVestingAccountResponse](#cosmos.vesting.v1beta1.MsgCreateVestingAccountResponse) | CreateVestingAccount defines a method that enables creating a vesting account. | | +| `CreatePeriodicVestingAccount` | [MsgCreatePeriodicVestingAccount](#cosmos.vesting.v1beta1.MsgCreatePeriodicVestingAccount) | [MsgCreatePeriodicVestingAccountResponse](#cosmos.vesting.v1beta1.MsgCreatePeriodicVestingAccountResponse) | CreatePeriodicVestingAccount defines a method that enables creating a periodic vesting account. | | + + + + + ## Scalar Value Types | .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby | diff --git a/docs/migrations/chain-upgrade-guide-043.md b/docs/migrations/chain-upgrade-guide-043.md index 129d22314c59..b927116d20b3 100644 --- a/docs/migrations/chain-upgrade-guide-043.md +++ b/docs/migrations/chain-upgrade-guide-043.md @@ -24,7 +24,7 @@ Instead of starting a new chain, the upgrade binary will read the existing datab We recommend using [In-Place Store Migrations](../core/upgrade.html) to upgrade your chain from v0.42 to v0.43. The first step is to make sure all your modules follow the [Module Upgrade Guide](../building-modules/upgrade.html). The second step is to add an [upgrade handler](../core/upgrade.html#running-migrations) to `app.go`. -In this document, we'll provide an example of what the upgrade handler looks like for a chain upgrading module versions for the first time. It's critical to note that the initial version of each module must be set to `1` rather than `0` or else the upgrade handler will re-initialize each module. +In this document, we'll provide an example of what the upgrade handler looks like for a chain upgrading module versions for the first time. It's critical to note that the initial consensus version of each module must be set to `1` rather than `0` or else the upgrade handler will re-initialize each module. In addition to migrating existing modules, the upgrade handler also performs store upgrades for new modules. In the example below, we'll be adding store migrations for two new modules made available in v0.43: `x/authz` and `x/feegrant`. @@ -32,7 +32,11 @@ In addition to migrating existing modules, the upgrade handler also performs sto We recommend validators use [Cosmovisor](../run-node/cosmovisor.html), which is a process manager for running application binaries. For security reasons, we recommend validators build their own upgrade binaries rather than enabling the auto-download option. Validators may still choose to use the auto-download option if the necessary security guarantees are in place (i.e. the URL provided in the upgrade proposal for the downloadable upgrade binary includes a proper checksum). -Validators can use the auto-restart option to prevent unecessary downtime during the upgrade process. The auto-restart option will automatically restart the chain with the upgrade binary once the chain has halted at the proposed upgrade height. With the auto-restart option, validators can prepare the upgrade binary in advance and then relax at the time of the upgrade. +::: tip +If validators would like to enable the auto-download option, and they are currently running an application using Cosmos SDK `v0.42`, they will need to use Cosmovisor [`v0.1`](https://github.com/cosmos/cosmos-sdk/releases/tag/cosmovisor%2Fv0.1.0). Later versions of Cosmovisor do not support Cosmos SDK `v0.42` or earlier if the auto-download option is enabled. +::: + +Validators can use the auto-restart option to prevent unnecessary downtime during the upgrade process. The auto-restart option will automatically restart the chain with the upgrade binary once the chain has halted at the proposed upgrade height. With the auto-restart option, validators can prepare the upgrade binary in advance and then relax at the time of the upgrade. ## Migrating app.toml @@ -42,7 +46,9 @@ With the update to `v0.43`, new server configuration options have been added to The following example will walk through the upgrade process using `simapp` as our blockchain application. We will be upgrading `simapp` from v0.42 to v0.43. We will be building the upgrade binary ourselves and enabling the auto-restart option. -*Note: In this example, we will be starting a new chain from `v0.42`. The binary for this version will be the genesis binary. For validators using Cosmovisor for the first time, the binary for the current version of the chain should be used as the genesis binary (i.e. the starting binary). For more information, see [Cosmovisor](../run-node/cosmovisor.html).* +::: tip +In the following example, we start a new chain from `v0.42`. The binary for this version will be the genesis binary. For validators using Cosmovisor for the first time on an existing chain, either the binary for the current version of the chain should be used as the genesis binary (i.e. the starting binary) or validators should update the `current` symbolic link to point to the upgrade directory. For more information, see [Cosmovisor](../run-node/cosmovisor.html). +::: ### Initial Setup @@ -108,12 +114,16 @@ Now that our node is initialized and we are ready to start a new `simapp` chain, ### Cosmovisor Setup -First, install or update `cosmovisor`: +Install the `cosmovisor` binary: ``` -go get github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor +go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@v0.1.0 ``` +::: tip +If you are using go `v1.15` or earlier, you will need to change out of the `cosmos-sdk` directory, run `go get` instead of `go install`, and then change back into the `cosmos-sdk` repository. +::: + Set the required environment variables: ``` diff --git a/proto/cosmos/vesting/v1beta1/tx.proto b/proto/cosmos/vesting/v1beta1/tx.proto index c49be802a76e..8cd4eb7a48d1 100644 --- a/proto/cosmos/vesting/v1beta1/tx.proto +++ b/proto/cosmos/vesting/v1beta1/tx.proto @@ -3,6 +3,7 @@ package cosmos.vesting.v1beta1; import "gogoproto/gogo.proto"; import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/vesting/v1beta1/vesting.proto"; option go_package = "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"; @@ -11,6 +12,9 @@ service Msg { // CreateVestingAccount defines a method that enables creating a vesting // account. rpc CreateVestingAccount(MsgCreateVestingAccount) returns (MsgCreateVestingAccountResponse); + // CreatePeriodicVestingAccount defines a method that enables creating a + // periodic vesting account. + rpc CreatePeriodicVestingAccount(MsgCreatePeriodicVestingAccount) returns (MsgCreatePeriodicVestingAccountResponse); } // MsgCreateVestingAccount defines a message that enables creating a vesting @@ -28,4 +32,18 @@ message MsgCreateVestingAccount { } // MsgCreateVestingAccountResponse defines the Msg/CreateVestingAccount response type. -message MsgCreateVestingAccountResponse {} \ No newline at end of file +message MsgCreateVestingAccountResponse {} + + +// MsgCreateVestingAccount defines a message that enables creating a vesting +// account. +message MsgCreatePeriodicVestingAccount { + option (gogoproto.equal) = false; + + string from_address = 1 [(gogoproto.moretags) = "yaml:\"from_address\""]; + string to_address = 2 [(gogoproto.moretags) = "yaml:\"to_address\""]; + int64 start_time = 3 [(gogoproto.moretags) = "yaml:\"start_time\""]; + repeated Period vesting_periods = 4 [(gogoproto.nullable) = false]; +} + +message MsgCreatePeriodicVestingAccountResponse {} diff --git a/store/cachekv/store.go b/store/cachekv/store.go index 48c59d8da8d3..f302d1873081 100644 --- a/store/cachekv/store.go +++ b/store/cachekv/store.go @@ -238,12 +238,13 @@ func (store *Store) dirtyItems(start, end []byte) { // Only entrypoint to mutate store.cache. func (store *Store) setCacheValue(key, value []byte, deleted bool, dirty bool) { - store.cache[conv.UnsafeBytesToStr(key)] = &cValue{ + keyStr := conv.UnsafeBytesToStr(key) + store.cache[keyStr] = &cValue{ value: value, deleted: deleted, dirty: dirty, } if dirty { - store.unsortedCache[conv.UnsafeBytesToStr(key)] = struct{}{} + store.unsortedCache[keyStr] = struct{}{} } } diff --git a/x/auth/vesting/client/cli/tx.go b/x/auth/vesting/client/cli/tx.go index 686a941e5de2..28c7e67dec9d 100644 --- a/x/auth/vesting/client/cli/tx.go +++ b/x/auth/vesting/client/cli/tx.go @@ -1,6 +1,9 @@ package cli import ( + "encoding/json" + "fmt" + "io/ioutil" "strconv" "github.com/spf13/cobra" @@ -29,6 +32,7 @@ func GetTxCmd() *cobra.Command { txCmd.AddCommand( NewMsgCreateVestingAccountCmd(), + NewMsgCreatePeriodicVestingAccountCmd(), ) return txCmd @@ -79,3 +83,90 @@ timestamp.`, return cmd } + +type VestingData struct { + StartTime int64 `json:"start_time"` + Periods []InputPeriod `json:"periods"` +} + +type InputPeriod struct { + Coins string `json:"coins"` + Length int64 `json:"length_seconds"` +} + +// NewMsgCreatePeriodicVestingAccountCmd returns a CLI command handler for creating a +// MsgCreatePeriodicVestingAccountCmd transaction. +func NewMsgCreatePeriodicVestingAccountCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-periodic-vesting-account [to_address] [periods_json_file]", + Short: "Create a new vesting account funded with an allocation of tokens.", + Long: `A sequence of coins and period length in seconds. Periods are sequential, in that the duration of of a period only starts at the end of the previous period. The duration of the first period starts upon account creation. For instance, the following periods.json file shows 20 "test" coins vesting 30 days apart from each other. + Where periods.json contains: + + An array of coin strings and unix epoch times for coins to vest +{ "start_time": 1625204910, +"period":[ + { + "coins": "10test", + "length_seconds":2592000 //30 days + }, + { + "coins": "10test", + "length_seconds":2592000 //30 days + }, +] + } + `, + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + toAddr, err := sdk.AccAddressFromBech32(args[0]) + if err != nil { + return err + } + + contents, err := ioutil.ReadFile(args[1]) + if err != nil { + return err + } + + var vestingData VestingData + + err = json.Unmarshal(contents, &vestingData) + if err != nil { + return err + } + + var periods []types.Period + + for i, p := range vestingData.Periods { + + amount, err := sdk.ParseCoinsNormalized(p.Coins) + if err != nil { + return err + } + + if p.Length < 0 { + return fmt.Errorf("invalid period length of %d in period %d, length must be greater than 0", p.Length, i) + } + period := types.Period{Length: p.Length, Amount: amount} + periods = append(periods, period) + } + + msg := types.NewMsgCreatePeriodicVestingAccount(clientCtx.GetFromAddress(), toAddr, vestingData.StartTime, periods) + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/auth/vesting/msg_server.go b/x/auth/vesting/msg_server.go index 795fc2c60581..5557b96ba4a3 100644 --- a/x/auth/vesting/msg_server.go +++ b/x/auth/vesting/msg_server.go @@ -98,3 +98,63 @@ func (s msgServer) CreateVestingAccount(goCtx context.Context, msg *types.MsgCre return &types.MsgCreateVestingAccountResponse{}, nil } + +func (s msgServer) CreatePeriodicVestingAccount(goCtx context.Context, msg *types.MsgCreatePeriodicVestingAccount) (*types.MsgCreatePeriodicVestingAccountResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + ak := s.AccountKeeper + bk := s.BankKeeper + + from, err := sdk.AccAddressFromBech32(msg.FromAddress) + if err != nil { + return nil, err + } + to, err := sdk.AccAddressFromBech32(msg.ToAddress) + if err != nil { + return nil, err + } + + if acc := ak.GetAccount(ctx, to); acc != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "account %s already exists", msg.ToAddress) + } + + var totalCoins sdk.Coins + + for _, period := range msg.VestingPeriods { + totalCoins = totalCoins.Add(period.Amount...) + } + + baseAccount := ak.NewAccountWithAddress(ctx, to) + + acc := types.NewPeriodicVestingAccount(baseAccount.(*authtypes.BaseAccount), totalCoins.Sort(), msg.StartTime, msg.VestingPeriods) + + ak.SetAccount(ctx, acc) + + defer func() { + telemetry.IncrCounter(1, "new", "account") + + for _, a := range totalCoins { + if a.Amount.IsInt64() { + telemetry.SetGaugeWithLabels( + []string{"tx", "msg", "create_periodic_vesting_account"}, + float32(a.Amount.Int64()), + []metrics.Label{telemetry.NewLabel("denom", a.Denom)}, + ) + } + } + }() + + err = bk.SendCoins(ctx, from, to, totalCoins) + if err != nil { + return nil, err + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + ) + return &types.MsgCreatePeriodicVestingAccountResponse{}, nil + +} diff --git a/x/auth/vesting/types/msgs.go b/x/auth/vesting/types/msgs.go index 4a0034901e0d..4b63ffba655a 100644 --- a/x/auth/vesting/types/msgs.go +++ b/x/auth/vesting/types/msgs.go @@ -1,6 +1,8 @@ package types import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -8,8 +10,13 @@ import ( // TypeMsgCreateVestingAccount defines the type value for a MsgCreateVestingAccount. const TypeMsgCreateVestingAccount = "msg_create_vesting_account" +// TypeMsgCreatePeriodicVestingAccount defines the type value for a MsgCreateVestingAccount. +const TypeMsgCreatePeriodicVestingAccount = "msg_create_periodic_vesting_account" + var _ sdk.Msg = &MsgCreateVestingAccount{} +var _ sdk.Msg = &MsgCreatePeriodicVestingAccount{} + // NewMsgCreateVestingAccount returns a reference to a new MsgCreateVestingAccount. //nolint:interfacer func NewMsgCreateVestingAccount(fromAddr, toAddr sdk.AccAddress, amount sdk.Coins, endTime int64, delayed bool) *MsgCreateVestingAccount { @@ -63,3 +70,66 @@ func (msg MsgCreateVestingAccount) GetSigners() []sdk.AccAddress { addr, _ := sdk.AccAddressFromBech32(msg.FromAddress) return []sdk.AccAddress{addr} } + +// NewMsgCreatePeriodicVestingAccount returns a reference to a new MsgCreatePeriodicVestingAccount. +//nolint:interfacer +func NewMsgCreatePeriodicVestingAccount(fromAddr, toAddr sdk.AccAddress, startTime int64, periods []Period) *MsgCreatePeriodicVestingAccount { + return &MsgCreatePeriodicVestingAccount{ + FromAddress: fromAddr.String(), + ToAddress: toAddr.String(), + StartTime: startTime, + VestingPeriods: periods, + } +} + +// Route returns the message route for a MsgCreatePeriodicVestingAccount. +func (msg MsgCreatePeriodicVestingAccount) Route() string { return RouterKey } + +// Type returns the message type for a MsgCreatePeriodicVestingAccount. +func (msg MsgCreatePeriodicVestingAccount) Type() string { return TypeMsgCreatePeriodicVestingAccount } + +// GetSigners returns the expected signers for a MsgCreatePeriodicVestingAccount. +func (msg MsgCreatePeriodicVestingAccount) GetSigners() []sdk.AccAddress { + from, err := sdk.AccAddressFromBech32(msg.FromAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{from} +} + +// GetSignBytes returns the bytes all expected signers must sign over for a +// MsgCreatePeriodicVestingAccount. +func (msg MsgCreatePeriodicVestingAccount) GetSignBytes() []byte { + return sdk.MustSortJSON(amino.MustMarshalJSON(&msg)) +} + +// ValidateBasic Implements Msg. +func (msg MsgCreatePeriodicVestingAccount) ValidateBasic() error { + from, err := sdk.AccAddressFromBech32(msg.FromAddress) + if err != nil { + return err + } + to, err := sdk.AccAddressFromBech32(msg.ToAddress) + if err != nil { + return err + } + if err := sdk.VerifyAddressFormat(from); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address: %s", err) + } + + if err := sdk.VerifyAddressFormat(to); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid recipient address: %s", err) + } + + if msg.StartTime < 1 { + return fmt.Errorf("invalid start time of %d, length must be greater than 0", msg.StartTime) + } + + for i, period := range msg.VestingPeriods { + if period.Length < 1 { + return fmt.Errorf("invalid period length of %d in period %d, length must be greater than 0", period.Length, i) + } + } + + return nil +} diff --git a/x/auth/vesting/types/tx.pb.go b/x/auth/vesting/types/tx.pb.go index d07a154dd326..1124087de5d7 100644 --- a/x/auth/vesting/types/tx.pb.go +++ b/x/auth/vesting/types/tx.pb.go @@ -145,41 +145,158 @@ func (m *MsgCreateVestingAccountResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCreateVestingAccountResponse proto.InternalMessageInfo +// MsgCreateVestingAccount defines a message that enables creating a vesting +// account. +type MsgCreatePeriodicVestingAccount struct { + FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty" yaml:"from_address"` + ToAddress string `protobuf:"bytes,2,opt,name=to_address,json=toAddress,proto3" json:"to_address,omitempty" yaml:"to_address"` + StartTime int64 `protobuf:"varint,3,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty" yaml:"start_time"` + VestingPeriods []Period `protobuf:"bytes,4,rep,name=vesting_periods,json=vestingPeriods,proto3" json:"vesting_periods"` +} + +func (m *MsgCreatePeriodicVestingAccount) Reset() { *m = MsgCreatePeriodicVestingAccount{} } +func (m *MsgCreatePeriodicVestingAccount) String() string { return proto.CompactTextString(m) } +func (*MsgCreatePeriodicVestingAccount) ProtoMessage() {} +func (*MsgCreatePeriodicVestingAccount) Descriptor() ([]byte, []int) { + return fileDescriptor_5338ca97811f9792, []int{2} +} +func (m *MsgCreatePeriodicVestingAccount) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreatePeriodicVestingAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreatePeriodicVestingAccount.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 *MsgCreatePeriodicVestingAccount) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreatePeriodicVestingAccount.Merge(m, src) +} +func (m *MsgCreatePeriodicVestingAccount) XXX_Size() int { + return m.Size() +} +func (m *MsgCreatePeriodicVestingAccount) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreatePeriodicVestingAccount.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreatePeriodicVestingAccount proto.InternalMessageInfo + +func (m *MsgCreatePeriodicVestingAccount) GetFromAddress() string { + if m != nil { + return m.FromAddress + } + return "" +} + +func (m *MsgCreatePeriodicVestingAccount) GetToAddress() string { + if m != nil { + return m.ToAddress + } + return "" +} + +func (m *MsgCreatePeriodicVestingAccount) GetStartTime() int64 { + if m != nil { + return m.StartTime + } + return 0 +} + +func (m *MsgCreatePeriodicVestingAccount) GetVestingPeriods() []Period { + if m != nil { + return m.VestingPeriods + } + return nil +} + +type MsgCreatePeriodicVestingAccountResponse struct { +} + +func (m *MsgCreatePeriodicVestingAccountResponse) Reset() { + *m = MsgCreatePeriodicVestingAccountResponse{} +} +func (m *MsgCreatePeriodicVestingAccountResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreatePeriodicVestingAccountResponse) ProtoMessage() {} +func (*MsgCreatePeriodicVestingAccountResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5338ca97811f9792, []int{3} +} +func (m *MsgCreatePeriodicVestingAccountResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreatePeriodicVestingAccountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreatePeriodicVestingAccountResponse.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 *MsgCreatePeriodicVestingAccountResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreatePeriodicVestingAccountResponse.Merge(m, src) +} +func (m *MsgCreatePeriodicVestingAccountResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreatePeriodicVestingAccountResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreatePeriodicVestingAccountResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreatePeriodicVestingAccountResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgCreateVestingAccount)(nil), "cosmos.vesting.v1beta1.MsgCreateVestingAccount") proto.RegisterType((*MsgCreateVestingAccountResponse)(nil), "cosmos.vesting.v1beta1.MsgCreateVestingAccountResponse") + proto.RegisterType((*MsgCreatePeriodicVestingAccount)(nil), "cosmos.vesting.v1beta1.MsgCreatePeriodicVestingAccount") + proto.RegisterType((*MsgCreatePeriodicVestingAccountResponse)(nil), "cosmos.vesting.v1beta1.MsgCreatePeriodicVestingAccountResponse") } func init() { proto.RegisterFile("cosmos/vesting/v1beta1/tx.proto", fileDescriptor_5338ca97811f9792) } var fileDescriptor_5338ca97811f9792 = []byte{ - // 410 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x52, 0xbd, 0xae, 0xd3, 0x30, - 0x14, 0x8e, 0x6f, 0x2e, 0xf7, 0xc7, 0x17, 0x09, 0x91, 0x16, 0x1a, 0x3a, 0xc4, 0x21, 0x53, 0x16, - 0x6c, 0x5a, 0x90, 0x90, 0xba, 0x35, 0x1d, 0x51, 0x97, 0x08, 0x31, 0xb0, 0x54, 0x4e, 0x62, 0xd2, - 0x88, 0x26, 0xae, 0x62, 0xb7, 0x6a, 0x37, 0x46, 0x46, 0x1e, 0x81, 0x99, 0xa7, 0x60, 0xec, 0xd8, - 0x91, 0x29, 0xa0, 0x76, 0x61, 0xee, 0x13, 0xa0, 0xc4, 0x49, 0x61, 0x68, 0x91, 0x98, 0xec, 0xa3, - 0xef, 0xc7, 0xe7, 0x7c, 0x3e, 0x10, 0x85, 0x5c, 0xa4, 0x5c, 0x90, 0x25, 0x13, 0x32, 0xc9, 0x62, - 0xb2, 0xec, 0x05, 0x4c, 0xd2, 0x1e, 0x91, 0x2b, 0x3c, 0xcf, 0xb9, 0xe4, 0xc6, 0x63, 0x45, 0xc0, - 0x35, 0x01, 0xd7, 0x84, 0x6e, 0x3b, 0xe6, 0x31, 0xaf, 0x28, 0xa4, 0xbc, 0x29, 0x76, 0xd7, 0xaa, - 0xed, 0x02, 0x2a, 0xd8, 0xd1, 0x2b, 0xe4, 0x49, 0xa6, 0x70, 0xe7, 0xdb, 0x05, 0xec, 0x8c, 0x45, - 0x3c, 0xca, 0x19, 0x95, 0xec, 0xad, 0xb2, 0x1c, 0x86, 0x21, 0x5f, 0x64, 0xd2, 0x18, 0xc0, 0xfb, - 0xef, 0x73, 0x9e, 0x4e, 0x68, 0x14, 0xe5, 0x4c, 0x08, 0x13, 0xd8, 0xc0, 0xbd, 0xf5, 0x3a, 0x87, - 0x02, 0xb5, 0xd6, 0x34, 0x9d, 0x0d, 0x9c, 0xbf, 0x51, 0xc7, 0xbf, 0x2b, 0xcb, 0xa1, 0xaa, 0x8c, - 0x97, 0x10, 0x4a, 0x7e, 0x54, 0x5e, 0x54, 0xca, 0x47, 0x87, 0x02, 0x3d, 0x54, 0xca, 0x3f, 0x98, - 0xe3, 0xdf, 0x4a, 0xde, 0xa8, 0x42, 0x78, 0x45, 0xd3, 0xf2, 0x6d, 0x53, 0xb7, 0x75, 0xf7, 0xae, - 0xff, 0x04, 0xd7, 0xc3, 0x96, 0xed, 0x37, 0x93, 0xe2, 0x11, 0x4f, 0x32, 0xef, 0xf9, 0xa6, 0x40, - 0xda, 0xd7, 0x1f, 0xc8, 0x8d, 0x13, 0x39, 0x5d, 0x04, 0x38, 0xe4, 0x29, 0xa9, 0x67, 0x55, 0xc7, - 0x33, 0x11, 0x7d, 0x20, 0x72, 0x3d, 0x67, 0xa2, 0x12, 0x08, 0xbf, 0xb6, 0x36, 0x30, 0xbc, 0x61, - 0x59, 0x34, 0x91, 0x49, 0xca, 0xcc, 0x4b, 0x1b, 0xb8, 0xba, 0xd7, 0x3a, 0x14, 0xe8, 0x81, 0x6a, - 0xac, 0x41, 0x1c, 0xff, 0x9a, 0x65, 0xd1, 0x9b, 0x24, 0x65, 0x86, 0x09, 0xaf, 0x23, 0x36, 0xa3, - 0x6b, 0x16, 0x99, 0xf7, 0x6c, 0xe0, 0xde, 0xf8, 0x4d, 0x39, 0xb8, 0xfc, 0xf5, 0x05, 0x01, 0xe7, - 0x29, 0x44, 0x67, 0x12, 0xf4, 0x99, 0x98, 0xf3, 0x4c, 0xb0, 0xfe, 0x27, 0x00, 0xf5, 0xb1, 0x88, - 0x8d, 0x8f, 0x00, 0xb6, 0x4f, 0x46, 0x4d, 0xf0, 0xe9, 0x5f, 0xc5, 0x67, 0x9c, 0xbb, 0xaf, 0xfe, - 0x53, 0xd0, 0xb4, 0xe2, 0xbd, 0xde, 0xec, 0x2c, 0xb0, 0xdd, 0x59, 0xe0, 0xe7, 0xce, 0x02, 0x9f, - 0xf7, 0x96, 0xb6, 0xdd, 0x5b, 0xda, 0xf7, 0xbd, 0xa5, 0xbd, 0xeb, 0xfd, 0x33, 0xc9, 0x15, 0xa1, - 0x0b, 0x39, 0x3d, 0xae, 0x65, 0x15, 0x6c, 0x70, 0x55, 0x2d, 0xd1, 0x8b, 0xdf, 0x01, 0x00, 0x00, - 0xff, 0xff, 0xe7, 0x28, 0xaf, 0xe5, 0xb5, 0x02, 0x00, 0x00, + // 519 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x54, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0xf6, 0xc5, 0xa1, 0x6d, 0xae, 0x88, 0x0a, 0xb7, 0x50, 0x13, 0x21, 0x3b, 0x9c, 0x90, 0x30, + 0x03, 0x67, 0x52, 0x2a, 0x21, 0x65, 0x41, 0x75, 0x47, 0x14, 0x09, 0x59, 0x88, 0x81, 0x25, 0xba, + 0xd8, 0x87, 0x6b, 0x51, 0xfb, 0x22, 0xdf, 0xa5, 0x6a, 0x36, 0x7e, 0x02, 0x23, 0x13, 0x42, 0x62, + 0xe3, 0x57, 0x30, 0x76, 0xec, 0xc8, 0x14, 0x50, 0xb2, 0x30, 0xe7, 0x17, 0x20, 0xdf, 0x9d, 0xd3, + 0x0c, 0x49, 0x23, 0x58, 0x98, 0x92, 0xe7, 0xef, 0xfb, 0xde, 0xbd, 0xf7, 0xbd, 0x77, 0x07, 0xdd, + 0x88, 0xf1, 0x8c, 0x71, 0xff, 0x8c, 0x72, 0x91, 0xe6, 0x89, 0x7f, 0xd6, 0xee, 0x53, 0x41, 0xda, + 0xbe, 0x38, 0xc7, 0x83, 0x82, 0x09, 0x66, 0xdd, 0x55, 0x04, 0xac, 0x09, 0x58, 0x13, 0x9a, 0x7b, + 0x09, 0x4b, 0x98, 0xa4, 0xf8, 0xe5, 0x3f, 0xc5, 0x6e, 0x3a, 0x3a, 0x5d, 0x9f, 0x70, 0x3a, 0xcf, + 0x15, 0xb1, 0x34, 0xd7, 0xf8, 0xc3, 0x15, 0xc7, 0x55, 0xd9, 0x25, 0x0b, 0x7d, 0xaf, 0xc1, 0xfd, + 0x2e, 0x4f, 0x8e, 0x0b, 0x4a, 0x04, 0x7d, 0xa3, 0xa0, 0xa3, 0x28, 0x62, 0xc3, 0x5c, 0x58, 0x1d, + 0x78, 0xf3, 0x5d, 0xc1, 0xb2, 0x1e, 0x89, 0xe3, 0x82, 0x72, 0x6e, 0x83, 0x16, 0xf0, 0x1a, 0xc1, + 0xfe, 0x6c, 0xec, 0xee, 0x8e, 0x48, 0x76, 0xda, 0x41, 0x8b, 0x28, 0x0a, 0xb7, 0xcb, 0xf0, 0x48, + 0x45, 0xd6, 0x21, 0x84, 0x82, 0xcd, 0x95, 0x35, 0xa9, 0xbc, 0x33, 0x1b, 0xbb, 0xb7, 0x95, 0xf2, + 0x0a, 0x43, 0x61, 0x43, 0xb0, 0x4a, 0x15, 0xc1, 0x0d, 0x92, 0x95, 0x67, 0xdb, 0x66, 0xcb, 0xf4, + 0xb6, 0x0f, 0xee, 0x61, 0x6d, 0x49, 0xd9, 0x64, 0xe5, 0x07, 0x3e, 0x66, 0x69, 0x1e, 0x3c, 0xbd, + 0x18, 0xbb, 0xc6, 0xb7, 0x9f, 0xae, 0x97, 0xa4, 0xe2, 0x64, 0xd8, 0xc7, 0x11, 0xcb, 0x7c, 0xdd, + 0xb1, 0xfa, 0x79, 0xc2, 0xe3, 0xf7, 0xbe, 0x18, 0x0d, 0x28, 0x97, 0x02, 0x1e, 0xea, 0xd4, 0x16, + 0x86, 0x5b, 0x34, 0x8f, 0x7b, 0x22, 0xcd, 0xa8, 0x5d, 0x6f, 0x01, 0xcf, 0x0c, 0x76, 0x67, 0x63, + 0x77, 0x47, 0x15, 0x56, 0x21, 0x28, 0xdc, 0xa4, 0x79, 0xfc, 0x3a, 0xcd, 0xa8, 0x65, 0xc3, 0xcd, + 0x98, 0x9e, 0x92, 0x11, 0x8d, 0xed, 0x1b, 0x2d, 0xe0, 0x6d, 0x85, 0x55, 0xd8, 0xa9, 0xff, 0xfe, + 0xe2, 0x02, 0xf4, 0x00, 0xba, 0x2b, 0x1c, 0x0c, 0x29, 0x1f, 0xb0, 0x9c, 0x53, 0xf4, 0xb9, 0xb6, + 0xc0, 0x79, 0x45, 0x8b, 0x94, 0xc5, 0x69, 0xf4, 0xdf, 0xdd, 0x3e, 0x84, 0x90, 0x0b, 0x52, 0x08, + 0x65, 0x85, 0x29, 0xad, 0x58, 0x50, 0x5d, 0x61, 0x28, 0x6c, 0xc8, 0x40, 0xda, 0xd1, 0x85, 0x3b, + 0x7a, 0x85, 0x7a, 0x03, 0xd9, 0x09, 0xb7, 0xeb, 0x72, 0x58, 0x0e, 0x5e, 0xbe, 0xbf, 0x58, 0x35, + 0x1c, 0xd4, 0xcb, 0x89, 0x85, 0xb7, 0x34, 0xaa, 0x3e, 0x72, 0xe9, 0xa1, 0x81, 0x1e, 0xc3, 0x47, + 0x6b, 0xfc, 0xa9, 0xbc, 0x3c, 0xf8, 0x5a, 0x83, 0x66, 0x97, 0x27, 0xd6, 0x07, 0x00, 0xf7, 0x96, + 0xae, 0xad, 0xbf, 0xaa, 0x8e, 0x15, 0x53, 0x6a, 0x3e, 0xff, 0x4b, 0x41, 0x55, 0x8a, 0xf5, 0x09, + 0xc0, 0xfb, 0xd7, 0xce, 0x74, 0x7d, 0xe6, 0xe5, 0xc2, 0xe6, 0x8b, 0x7f, 0x14, 0x56, 0xa5, 0x05, + 0x2f, 0x2f, 0x26, 0x0e, 0xb8, 0x9c, 0x38, 0xe0, 0xd7, 0xc4, 0x01, 0x1f, 0xa7, 0x8e, 0x71, 0x39, + 0x75, 0x8c, 0x1f, 0x53, 0xc7, 0x78, 0xdb, 0xbe, 0xf6, 0xc2, 0x9c, 0xfb, 0x64, 0x28, 0x4e, 0xe6, + 0x8f, 0x86, 0xbc, 0x3f, 0xfd, 0x0d, 0xf9, 0x56, 0x3c, 0xfb, 0x13, 0x00, 0x00, 0xff, 0xff, 0x28, + 0x5a, 0x9c, 0x7b, 0xc2, 0x04, 0x00, 0x00, } func (this *MsgCreateVestingAccount) Equal(that interface{}) bool { @@ -239,6 +356,9 @@ type MsgClient interface { // CreateVestingAccount defines a method that enables creating a vesting // account. CreateVestingAccount(ctx context.Context, in *MsgCreateVestingAccount, opts ...grpc.CallOption) (*MsgCreateVestingAccountResponse, error) + // CreatePeriodicVestingAccount defines a method that enables creating a + // periodic vesting account. + CreatePeriodicVestingAccount(ctx context.Context, in *MsgCreatePeriodicVestingAccount, opts ...grpc.CallOption) (*MsgCreatePeriodicVestingAccountResponse, error) } type msgClient struct { @@ -258,11 +378,23 @@ func (c *msgClient) CreateVestingAccount(ctx context.Context, in *MsgCreateVesti return out, nil } +func (c *msgClient) CreatePeriodicVestingAccount(ctx context.Context, in *MsgCreatePeriodicVestingAccount, opts ...grpc.CallOption) (*MsgCreatePeriodicVestingAccountResponse, error) { + out := new(MsgCreatePeriodicVestingAccountResponse) + err := c.cc.Invoke(ctx, "/cosmos.vesting.v1beta1.Msg/CreatePeriodicVestingAccount", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // CreateVestingAccount defines a method that enables creating a vesting // account. CreateVestingAccount(context.Context, *MsgCreateVestingAccount) (*MsgCreateVestingAccountResponse, error) + // CreatePeriodicVestingAccount defines a method that enables creating a + // periodic vesting account. + CreatePeriodicVestingAccount(context.Context, *MsgCreatePeriodicVestingAccount) (*MsgCreatePeriodicVestingAccountResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -272,6 +404,9 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) CreateVestingAccount(ctx context.Context, req *MsgCreateVestingAccount) (*MsgCreateVestingAccountResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateVestingAccount not implemented") } +func (*UnimplementedMsgServer) CreatePeriodicVestingAccount(ctx context.Context, req *MsgCreatePeriodicVestingAccount) (*MsgCreatePeriodicVestingAccountResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreatePeriodicVestingAccount not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -295,6 +430,24 @@ func _Msg_CreateVestingAccount_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Msg_CreatePeriodicVestingAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreatePeriodicVestingAccount) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreatePeriodicVestingAccount(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.vesting.v1beta1.Msg/CreatePeriodicVestingAccount", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreatePeriodicVestingAccount(ctx, req.(*MsgCreatePeriodicVestingAccount)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "cosmos.vesting.v1beta1.Msg", HandlerType: (*MsgServer)(nil), @@ -303,6 +456,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "CreateVestingAccount", Handler: _Msg_CreateVestingAccount_Handler, }, + { + MethodName: "CreatePeriodicVestingAccount", + Handler: _Msg_CreatePeriodicVestingAccount_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmos/vesting/v1beta1/tx.proto", @@ -397,6 +554,85 @@ func (m *MsgCreateVestingAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int return len(dAtA) - i, nil } +func (m *MsgCreatePeriodicVestingAccount) 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 *MsgCreatePeriodicVestingAccount) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreatePeriodicVestingAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.VestingPeriods) > 0 { + for iNdEx := len(m.VestingPeriods) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.VestingPeriods[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if m.StartTime != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.StartTime)) + i-- + dAtA[i] = 0x18 + } + if len(m.ToAddress) > 0 { + i -= len(m.ToAddress) + copy(dAtA[i:], m.ToAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.ToAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.FromAddress) > 0 { + i -= len(m.FromAddress) + copy(dAtA[i:], m.FromAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.FromAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreatePeriodicVestingAccountResponse) 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 *MsgCreatePeriodicVestingAccountResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreatePeriodicVestingAccountResponse) 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 @@ -446,6 +682,41 @@ func (m *MsgCreateVestingAccountResponse) Size() (n int) { return n } +func (m *MsgCreatePeriodicVestingAccount) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FromAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ToAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.StartTime != 0 { + n += 1 + sovTx(uint64(m.StartTime)) + } + if len(m.VestingPeriods) > 0 { + for _, e := range m.VestingPeriods { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgCreatePeriodicVestingAccountResponse) 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 } @@ -689,6 +960,223 @@ func (m *MsgCreateVestingAccountResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgCreatePeriodicVestingAccount) 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: MsgCreatePeriodicVestingAccount: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreatePeriodicVestingAccount: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FromAddress", 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.FromAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ToAddress", 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.ToAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) + } + m.StartTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.StartTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VestingPeriods", 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 + } + m.VestingPeriods = append(m.VestingPeriods, Period{}) + if err := m.VestingPeriods[len(m.VestingPeriods)-1].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 *MsgCreatePeriodicVestingAccountResponse) 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: MsgCreatePeriodicVestingAccountResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreatePeriodicVestingAccountResponse: 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 diff --git a/x/bank/client/cli/query.go b/x/bank/client/cli/query.go index 4019bb738d9a..f5ddcd0c4db9 100644 --- a/x/bank/client/cli/query.go +++ b/x/bank/client/cli/query.go @@ -159,6 +159,7 @@ func GetCmdQueryTotalSupply() *cobra.Command { cmd := &cobra.Command{ Use: "total", Short: "Query the total supply of coins of the chain", + Args: cobra.NoArgs, Long: strings.TrimSpace( fmt.Sprintf(`Query total supply of coins that are held by accounts in the chain.