From abce938f217bc06aed7155741acab0c69ef0a3a3 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 16 Oct 2019 10:20:24 +0200 Subject: [PATCH 001/184] Add docs --- x/delegation/README.md | 121 +++++++++++++++++++++++++++++++++++++++++ x/delegation/doc.go | 32 +++++++++++ 2 files changed, 153 insertions(+) create mode 100644 x/delegation/README.md create mode 100644 x/delegation/doc.go diff --git a/x/delegation/README.md b/x/delegation/README.md new file mode 100644 index 000000000000..6a1cb65ca3e3 --- /dev/null +++ b/x/delegation/README.md @@ -0,0 +1,121 @@ +## Fee Delegation Work + +Much of this is ported from an older implementation of fee delegation from aaronc. + +To take a look at this (which had many changes to auth as well, which has been heavily refactored upstream): + +``` +git remote add keys https://github.com/cosmos-cg-key-management/cosmos-sdk.git +git fetch keys +git diff --compact-summary f1b08b85f 980d713f +``` + +This is based on https://gist.github.com/aaronc/b60628017352df5983791cad30babe56#fee-delegation + +In particular the following parts: + +-------------------- + +The `delegation` module also allows for fee delegation via some +changes to the `AnteHandler` and `StdTx`. The behavior is similar +to that described above for `Msg` delegations except using +the interface `FeeAllowance` instead of `Capability`: + +```go +// FeeAllowance defines a permission for one account to use another account's balance +// to pay fees +type FeeAllowance interface { + // Accept checks whether this allowance allows the provided fees to be spent, + // and optionally updates the allowance or deletes it entirely + Accept(fee sdk.Coins, block abci.Header) (allow bool, updated FeeAllowance, delete bool) +} +``` + +An example `FeeAllowance` could be created that simply sets a `SpendLimit`: + +```go +type BasicFeeAllowance struct { + // SpendLimit specifies the maximum amount of tokens that can be spent + // by this capability and will be updated as tokens are spent. If it is + // empty, there is no spend limit and any amount of coins can be spent. + SpendLimit sdk.Coins +} + +func (cap BasicFeeAllowance) Accept(fee sdk.Coins, block abci.Header) (allow bool, updated FeeAllowance, delete bool) { + left, invalid := cap.SpendLimit.SafeSub(fee) + if invalid { + return false, nil, false + } + if left.IsZero() { + return true, nil, true + } + return true, BasicFeeAllowance{SpendLimit: left}, false +} + +``` + +Other `FeeAllowance` types could be created such as a daily spend limit. + +## `StdTx` and `AnteHandler` changes + +In order to support delegated fees `StdTx` and the `AnteHandler` needed to be changed. + +The field `FeeAccount` was added to `StdTx`. + +```go +type StdTx struct { + Msgs []sdk.Msg `json:"msg"` + Fee StdFee `json:"fee"` + Signatures []StdSignature `json:"signatures"` + Memo string `json:"memo"` + // FeeAccount is an optional account that fees can be spent from if such + // delegation is enabled + FeeAccount sdk.AccAddress `json:"fee_account"` +} +``` + +An interface `FeeDelegationHandler` (which is implemented by the `delegation` module) was created and a parameter for it was added to the default `AnteHandler`: + +```go +type FeeDelegationHandler interface { + // AllowDelegatedFees checks if the grantee can use the granter's account to spend the specified fees, updating + // any fee allowance in accordance with the provided fees + AllowDelegatedFees(ctx sdk.Context, grantee sdk.AccAddress, granter sdk.AccAddress, fee sdk.Coins) bool +} + +// NewAnteHandler returns an AnteHandler that checks and increments sequence +// numbers, checks signatures & account numbers, and deducts fees from the first +// signer. +func NewAnteHandler(ak AccountKeeper, fck FeeCollectionKeeper, feeDelegationHandler FeeDelegationHandler, sigGasConsumer SignatureVerificationGasConsumer) sdk.AnteHandler { +``` + +Basically if someone sets `FeeAccount` on `StdTx`, the `AnteHandler` will call into the `delegation` module via its `FeeDelegationHandler` and check if the tx's fees have been delegated by that `FeeAccount` to the key actually signing the transaction. + +## Core `FeeAllowance` types + +```go +type BasicFeeAllowance struct { + // SpendLimit specifies the maximum amount of tokens that can be spent + // by this capability and will be updated as tokens are spent. If it is + // empty, there is no spend limit and any amount of coins can be spent. + SpendLimit sdk.Coins + // Expiration specifies an optional time when this allowance expires + Expiration time.Time +} + +type PeriodicFeeAllowance struct { + BasicFeeAllowance + // Period specifies the time duration in which PeriodSpendLimit coins can + // be spent before that allowance is reset + Period time.Duration + // PeriodSpendLimit specifies the maximum number of coins that can be spent + // in the Period + PeriodSpendLimit sdk.Coins + // PeriodCanSpend is the number of coins left to be spend before the PeriodReset time + PeriodCanSpend sdk.Coins + // PeriodReset is the time at which this period resets and a new one begins, + // it is calculated from the start time of the first transaction after the + // last period ended + PeriodReset time.Time +} +``` \ No newline at end of file diff --git a/x/delegation/doc.go b/x/delegation/doc.go new file mode 100644 index 000000000000..8d9a71fa04b7 --- /dev/null +++ b/x/delegation/doc.go @@ -0,0 +1,32 @@ +/* +Package delegation provides functionality for delegating sub-permissions +from one account to another account. + +The first implementation allows the delegation for the payment of transaction fees. +Effectively, this allows for a user to pay fees using the balance of an account +different from their own. Example use cases would be allowing a key on a device to +pay for fees using a master wallet, or a third party service allowing users to +pay for transactions without ever really holding their own tokens. This package +provides ways for specifying fee allowances such that delegating fees +to another account can be done with clear and safe restrictions. + +A user would delegate fees to a user using MsgDelegateFeeAllowance and revoke +that delegation using MsgRevokeFeeAllowance. In both cases Granter is the one +who is delegating fees and Grantee is the one who is receiving the delegation. +So grantee would correspond to the one who is signing a transaction and the +granter would be the address they place in StdTx.FeeAccount. + +The fee allowance that a grantee receives is specified by an implementation of +the FeeAllowance interface. Two FeeAllowance implementations are provided in +this package: BasicFeeAllowance and PeriodicFeeAllowance. + +TODO: update if needed with new modular ante handler + +In order to integrate this into an application, the "ante handler" which deducts +fees must call Keeper.AllowDelegatedFees to check if +the provided StdTx.Fee can be delegated from the Std.TxFeeAccount address +to the first signer of the transaction. An example usage would be: + +allow := feeDelegationKeeper.AllowDelegatedFees(ctx, signers[0], stdTx.FeeAccount, stdTx.Fee.Amount) +*/ +package delegation From ea6fe7d851123fac3667a3332b1e28ef76aed672 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 16 Oct 2019 10:45:17 +0200 Subject: [PATCH 002/184] Add BasicFeeAllowance implementation --- x/delegation/exported/fees.go | 19 ++++++++++++ x/delegation/internal/types/basic_fee.go | 38 ++++++++++++++++++++++++ x/delegation/internal/types/codec.go | 22 ++++++++++++++ x/delegation/internal/types/errors.go | 23 ++++++++++++++ x/delegation/internal/types/key.go | 15 ++++++++++ 5 files changed, 117 insertions(+) create mode 100644 x/delegation/exported/fees.go create mode 100644 x/delegation/internal/types/basic_fee.go create mode 100644 x/delegation/internal/types/codec.go create mode 100644 x/delegation/internal/types/errors.go create mode 100644 x/delegation/internal/types/key.go diff --git a/x/delegation/exported/fees.go b/x/delegation/exported/fees.go new file mode 100644 index 000000000000..b18c1d51354e --- /dev/null +++ b/x/delegation/exported/fees.go @@ -0,0 +1,19 @@ +package exported + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + abci "github.com/tendermint/tendermint/abci/types" +) + +// FeeAllowance implementations are tied to a given delegator and delegatee, +// and are used to enforce limits on this payment. +type FeeAllowance interface { + // Accept can use fee payment requested as well as timestamp/height of the current block + // to determine whether or not to process this. + // If it returns an error, the fee payment is rejected, otherwise it is accepted. + // The FeeAllowance implementation is expected to update it's internal state + // and will be saved again after an acceptance. + // If remove is true (regardless of the error), the FeeAllowance will be deleted from storage + // (eg. when it expires) + Accept(fee sdk.Coins, block abci.Header) (remove bool, err error) +} diff --git a/x/delegation/internal/types/basic_fee.go b/x/delegation/internal/types/basic_fee.go new file mode 100644 index 000000000000..195df50869ea --- /dev/null +++ b/x/delegation/internal/types/basic_fee.go @@ -0,0 +1,38 @@ +package types + +import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/delegation/exported" + abci "github.com/tendermint/tendermint/abci/types" +) + +// BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens +// that optionally expires. The delegatee can use up to SpendLimit to cover fees. +type BasicFeeAllowance struct { + // SpendLimit is the maximum amount of tokens to be spent + SpendLimit sdk.Coins + + // TODO: make this time or height + // Expiration specifies an optional time when this allowance expires + // is Expiration.IsZero() then it never expires + Expiration time.Time +} + +var _ exported.FeeAllowance = (*BasicFeeAllowance)(nil) + +// Accept implements FeeAllowance and deducts the fees from the SpendLimit if possible +func (a *BasicFeeAllowance) Accept(fee sdk.Coins, block abci.Header) (remove bool, err error) { + // TODO: handle expiry + + left, invalid := a.SpendLimit.SafeSub(fee) + if invalid { + return false, ErrFeeLimitExceeded() + } + if left.IsZero() { + return true, nil + } + a.SpendLimit = left + return false, nil +} diff --git a/x/delegation/internal/types/codec.go b/x/delegation/internal/types/codec.go new file mode 100644 index 000000000000..e0836dacbb4d --- /dev/null +++ b/x/delegation/internal/types/codec.go @@ -0,0 +1,22 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/x/delegation/exported" +) + +// RegisterCodec registers the account types and interface +func RegisterCodec(cdc *codec.Codec) { + cdc.RegisterInterface((*exported.FeeAllowance)(nil), nil) + cdc.RegisterConcrete(&BasicFeeAllowance{}, "cosmos-sdk/BasicFeeAllowance", nil) +} + +// ModuleCdc generic sealed codec to be used throughout module +var ModuleCdc *codec.Codec + +func init() { + cdc := codec.New() + RegisterCodec(cdc) + codec.RegisterCrypto(cdc) + ModuleCdc = cdc.Seal() +} diff --git a/x/delegation/internal/types/errors.go b/x/delegation/internal/types/errors.go new file mode 100644 index 000000000000..778c7d131d54 --- /dev/null +++ b/x/delegation/internal/types/errors.go @@ -0,0 +1,23 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// Codes for governance errors +const ( + DefaultCodespace sdk.CodespaceType = ModuleName + + CodeFeeLimitExceeded sdk.CodeType = 1 + CodeFeeLimitExpired sdk.CodeType = 2 +) + +// ErrFeeLimitExceeded error if there are not enough allowance to cover the fees +func ErrFeeLimitExceeded() sdk.Error { + return sdk.NewError(DefaultCodespace, CodeFeeLimitExceeded, "fee limit exceeded") +} + +// ErrFeeLimitExpired error if the allowance has expired +func ErrFeeLimitExpired() sdk.Error { + return sdk.NewError(DefaultCodespace, CodeFeeLimitExpired, "fee limit expired") +} diff --git a/x/delegation/internal/types/key.go b/x/delegation/internal/types/key.go new file mode 100644 index 000000000000..1e4528e100c4 --- /dev/null +++ b/x/delegation/internal/types/key.go @@ -0,0 +1,15 @@ +package types + +const ( + // ModuleName is the module name constant used in many places + ModuleName = "delegation" + + // StoreKey is the store key string for supply + StoreKey = ModuleName + + // RouterKey is the message route for supply + RouterKey = ModuleName + + // QuerierRoute is the querier route for supply + QuerierRoute = ModuleName +) From c46153cf0bea71f0b32c3d66fafd7a8a47bfb0bf Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 16 Oct 2019 11:26:37 +0200 Subject: [PATCH 003/184] Add expiration structs and complete basic fee --- x/delegation/exported/fees.go | 5 +- x/delegation/internal/types/basic_fee.go | 27 ++--- x/delegation/internal/types/errors.go | 12 +++ x/delegation/internal/types/expiration.go | 115 ++++++++++++++++++++++ 4 files changed, 146 insertions(+), 13 deletions(-) create mode 100644 x/delegation/internal/types/expiration.go diff --git a/x/delegation/exported/fees.go b/x/delegation/exported/fees.go index b18c1d51354e..a757073c05ac 100644 --- a/x/delegation/exported/fees.go +++ b/x/delegation/exported/fees.go @@ -1,8 +1,9 @@ package exported import ( + "time" + sdk "github.com/cosmos/cosmos-sdk/types" - abci "github.com/tendermint/tendermint/abci/types" ) // FeeAllowance implementations are tied to a given delegator and delegatee, @@ -15,5 +16,5 @@ type FeeAllowance interface { // and will be saved again after an acceptance. // If remove is true (regardless of the error), the FeeAllowance will be deleted from storage // (eg. when it expires) - Accept(fee sdk.Coins, block abci.Header) (remove bool, err error) + Accept(fee sdk.Coins, blockTime time.Time, blockHeight int64) (remove bool, err error) } diff --git a/x/delegation/internal/types/basic_fee.go b/x/delegation/internal/types/basic_fee.go index 195df50869ea..322ce457d602 100644 --- a/x/delegation/internal/types/basic_fee.go +++ b/x/delegation/internal/types/basic_fee.go @@ -5,7 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/delegation/exported" - abci "github.com/tendermint/tendermint/abci/types" ) // BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens @@ -14,25 +13,31 @@ type BasicFeeAllowance struct { // SpendLimit is the maximum amount of tokens to be spent SpendLimit sdk.Coins - // TODO: make this time or height - // Expiration specifies an optional time when this allowance expires - // is Expiration.IsZero() then it never expires - Expiration time.Time + // Expiration specifies an optional time or height when this allowance expires. + // If Expiration.IsZero() then it never expires + Expiration ExpiresAt } var _ exported.FeeAllowance = (*BasicFeeAllowance)(nil) // Accept implements FeeAllowance and deducts the fees from the SpendLimit if possible -func (a *BasicFeeAllowance) Accept(fee sdk.Coins, block abci.Header) (remove bool, err error) { - // TODO: handle expiry +func (a *BasicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockHeight int64) (remove bool, err error) { + if a.Expiration.IsExpired(blockTime, blockHeight) { + return true, ErrFeeLimitExpired() + } left, invalid := a.SpendLimit.SafeSub(fee) if invalid { return false, ErrFeeLimitExceeded() } - if left.IsZero() { - return true, nil - } + a.SpendLimit = left - return false, nil + return left.IsZero(), nil +} + +func (a BasicFeeAllowance) ValidateBasic() error { + if a.SpendLimit.Empty() || !a.SpendLimit.IsAllPositive() { + return ErrNonPositiveCoins() + } + return a.Expiration.ValidateBasic() } diff --git a/x/delegation/internal/types/errors.go b/x/delegation/internal/types/errors.go index 778c7d131d54..320f13e50402 100644 --- a/x/delegation/internal/types/errors.go +++ b/x/delegation/internal/types/errors.go @@ -10,6 +10,8 @@ const ( CodeFeeLimitExceeded sdk.CodeType = 1 CodeFeeLimitExpired sdk.CodeType = 2 + CodeInvalidPeriod sdk.CodeType = 3 + CodeNonPositiveCoins sdk.CodeType = 4 ) // ErrFeeLimitExceeded error if there are not enough allowance to cover the fees @@ -21,3 +23,13 @@ func ErrFeeLimitExceeded() sdk.Error { func ErrFeeLimitExpired() sdk.Error { return sdk.NewError(DefaultCodespace, CodeFeeLimitExpired, "fee limit expired") } + +// ErrInvalidPeriod error if the period is invalid or doesn't match the expiration +func ErrInvalidPeriod(reason string) sdk.Error { + return sdk.NewError(DefaultCodespace, CodeInvalidPeriod, reason) +} + +// ErrNonPositiveCoins error if some fees or allowance are non positive +func ErrNonPositiveCoins() sdk.Error { + return sdk.NewError(DefaultCodespace, CodeNonPositiveCoins, "non positive coin amount") +} diff --git a/x/delegation/internal/types/expiration.go b/x/delegation/internal/types/expiration.go new file mode 100644 index 000000000000..7eb75654d652 --- /dev/null +++ b/x/delegation/internal/types/expiration.go @@ -0,0 +1,115 @@ +package types + +import "time" + +// ExpiresAt is a point in time where something expires. +// It may be *either* block time or block height +type ExpiresAt struct { + Time time.Time `json:"time" yaml:"time"` + Height int64 `json:"height" yaml:"height"` +} + +// ExpiresAtTime creates an expiration at the given time +func ExpiresAtTime(t time.Time) ExpiresAt { + return ExpiresAt{Time: t} +} + +// ExpiresAtHeight creates an expiration at the given height +func ExpiresAtHeight(h int64) ExpiresAt { + return ExpiresAt{Height: h} +} + +// ValidateBasic performs basic sanity checks. +// Note that empty expiration is allowed +func (e ExpiresAt) ValidateBasic() error { + if !e.Time.IsZero() && e.Height != 0 { + return ErrInvalidPeriod("both time and height are set") + } + if e.Height < 0 { + return ErrInvalidPeriod("negative height") + } + return nil +} + +// IsZero returns true for an uninitialized struct +func (e ExpiresAt) IsZero() bool { + return e.Time.IsZero() && e.Height == 0 +} + +// IsExpired returns if the time or height is *equal to* or greater +// than the defined expiration point. Note that it is expired upon +// an exact match. +// +// Note a "zero" ExpiresAt is never expired +func (e ExpiresAt) IsExpired(t time.Time, h int64) bool { + if !e.Time.IsZero() && !t.Before(e.Time) { + return true + } + return e.Height != 0 && h >= e.Height +} + +// IsCompatible returns true iff the two use the same units. +// If false, they cannot be added. +func (e ExpiresAt) IsCompatible(p Period) bool { + if !e.Time.IsZero() { + return p.Clock > 0 + } + return p.Block > 0 +} + +// Step will increase the expiration point by one period +// It returns an error if the period is incompatible +func (e *ExpiresAt) Step(p Period) error { + if !e.IsCompatible(p) { + return ErrInvalidPeriod("expires_at and period have different units") + } + if !e.Time.IsZero() { + e.Time = e.Time.Add(p.Clock) + } else { + e.Height = e.Height + p.Block + } + return nil +} + +// Period is a repeating unit of either clock time or number of blocks. +// This is designed to be added to an ExpiresAt struct. +type Period struct { + Clock time.Duration `json:"clock" yaml:"clock"` + Block int64 `json:"block" yaml:"block"` +} + +// ClockPeriod creates an period by clock time +func ClockPeriod(d time.Duration) Period { + // assert nothing negative + if d < 0 { + panic("Cannot use a negative duration") + } + return Period{Clock: d} +} + +// BlockPeriod creates an period by block height +func BlockPeriod(h int64) Period { + // assert nothing negative + if h < 0 { + panic("Cannot use a negative block step") + } + return Period{Block: h} +} + +// ValidateBasic performs basic sanity checks +// Note that exactly one must be set and it must be positive +func (p Period) ValidateBasic() error { + if p.Block == 0 && p.Clock == 0 { + return ErrInvalidPeriod("neither time and height are set") + } + if p.Block != 0 && p.Clock != 0 { + return ErrInvalidPeriod("both time and height are set") + } + if p.Block < 0 { + return ErrInvalidPeriod("negative block step") + } + if p.Clock < 0 { + return ErrInvalidPeriod("negative clock step") + } + return nil +} From 42c17f5815c27625375bc7667f6ec1dc66b61a4f Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 16 Oct 2019 11:46:11 +0200 Subject: [PATCH 004/184] Add delegation messages, add validation logic --- types/errors.go | 13 ++++ x/delegation/exported/fees.go | 4 ++ x/delegation/internal/types/basic_fee.go | 8 ++- x/delegation/internal/types/codec.go | 2 +- x/delegation/internal/types/msgs.go | 91 ++++++++++++++++++++++++ 5 files changed, 115 insertions(+), 3 deletions(-) create mode 100644 x/delegation/internal/types/msgs.go diff --git a/types/errors.go b/types/errors.go index 1447a21b4cd3..d23d2e9bb322 100644 --- a/types/errors.go +++ b/types/errors.go @@ -309,6 +309,19 @@ func ResultFromError(err error) Result { } } +// ConvertError will take a standard error (from types/error) and +// convert it to an sdk.Error +func ConvertError(err error) Error { + if err == nil { + return nil + } + if sdk, ok := err.(Error); ok { + return sdk + } + space, code, log := sdkerrors.ABCIInfo(err, false) + return NewError(CodespaceType(space), CodeType(code), log) +} + //---------------------------------------- // REST error utilities diff --git a/x/delegation/exported/fees.go b/x/delegation/exported/fees.go index a757073c05ac..a9c57de6c823 100644 --- a/x/delegation/exported/fees.go +++ b/x/delegation/exported/fees.go @@ -17,4 +17,8 @@ type FeeAllowance interface { // If remove is true (regardless of the error), the FeeAllowance will be deleted from storage // (eg. when it expires) Accept(fee sdk.Coins, blockTime time.Time, blockHeight int64) (remove bool, err error) + + // ValidateBasic should evaluate this FeeAllowance for internal consistency. + // Don't allow negative amounts, or negative periods for example. + ValidateBasic() error } diff --git a/x/delegation/internal/types/basic_fee.go b/x/delegation/internal/types/basic_fee.go index 322ce457d602..01b23be9d286 100644 --- a/x/delegation/internal/types/basic_fee.go +++ b/x/delegation/internal/types/basic_fee.go @@ -35,9 +35,13 @@ func (a *BasicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockHeig return left.IsZero(), nil } +// ValidateBasic implements FeeAllowance and enforces basic sanity checks func (a BasicFeeAllowance) ValidateBasic() error { - if a.SpendLimit.Empty() || !a.SpendLimit.IsAllPositive() { - return ErrNonPositiveCoins() + if !a.SpendLimit.IsValid() { + return sdk.ErrInvalidCoins("send amount is invalid: " + a.SpendLimit.String()) + } + if !a.SpendLimit.IsAllPositive() { + return sdk.ErrInvalidCoins("spend limit must be positive") } return a.Expiration.ValidateBasic() } diff --git a/x/delegation/internal/types/codec.go b/x/delegation/internal/types/codec.go index e0836dacbb4d..b7fc25bb04d7 100644 --- a/x/delegation/internal/types/codec.go +++ b/x/delegation/internal/types/codec.go @@ -8,7 +8,7 @@ import ( // RegisterCodec registers the account types and interface func RegisterCodec(cdc *codec.Codec) { cdc.RegisterInterface((*exported.FeeAllowance)(nil), nil) - cdc.RegisterConcrete(&BasicFeeAllowance{}, "cosmos-sdk/BasicFeeAllowance", nil) + cdc.RegisterConcrete(&BasicFeeAllowance{}, "delegation/BasicFeeAllowance", nil) } // ModuleCdc generic sealed codec to be used throughout module diff --git a/x/delegation/internal/types/msgs.go b/x/delegation/internal/types/msgs.go new file mode 100644 index 000000000000..b89817166a65 --- /dev/null +++ b/x/delegation/internal/types/msgs.go @@ -0,0 +1,91 @@ +package types + +import ( + "encoding/json" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/delegation/exported" +) + +// MsgDelegateFeeAllowance adds permission for Grantee to spend up to Allowance +// of fees from the account of Granter. +// If there was already an existing delegation, this overwrites it. +type MsgDelegateFeeAllowance struct { + Granter sdk.AccAddress `json:"granter" yaml:"granter"` + Grantee sdk.AccAddress `json:"grantee" yaml:"grantee"` + Allowance exported.FeeAllowance `json:"allowance" yaml:"allowance"` +} + +func NewMsgDelegateFeeAllowance(granter sdk.AccAddress, grantee sdk.AccAddress, allowance exported.FeeAllowance) MsgDelegateFeeAllowance { + return MsgDelegateFeeAllowance{Granter: granter, Grantee: grantee, Allowance: allowance} +} + +func (msg MsgDelegateFeeAllowance) Route() string { + return "delegation" +} + +func (msg MsgDelegateFeeAllowance) Type() string { + return "delegate-fee-allowance" +} + +func (msg MsgDelegateFeeAllowance) ValidateBasic() sdk.Error { + if msg.Granter.Empty() { + return sdk.ErrInvalidAddress("missing granter address") + } + if msg.Grantee.Empty() { + return sdk.ErrInvalidAddress("missing grantee address") + } + return sdk.ConvertError(msg.Allowance.ValidateBasic()) +} + +func (msg MsgDelegateFeeAllowance) GetSignBytes() []byte { + b, err := json.Marshal(msg) + if err != nil { + panic(err) + } + return sdk.MustSortJSON(b) +} + +func (msg MsgDelegateFeeAllowance) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{msg.Granter} +} + +// MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee. +type MsgRevokeFeeAllowance struct { + Granter sdk.AccAddress `json:"granter" yaml:"granter"` + Grantee sdk.AccAddress `json:"grantee" yaml:"granter"` +} + +func NewMsgRevokeFeeAllowance(granter sdk.AccAddress, grantee sdk.AccAddress) MsgRevokeFeeAllowance { + return MsgRevokeFeeAllowance{Granter: granter, Grantee: grantee} +} + +func (msg MsgRevokeFeeAllowance) Route() string { + return "delegation" +} + +func (msg MsgRevokeFeeAllowance) Type() string { + return "revoke-fee-allowance" +} + +func (msg MsgRevokeFeeAllowance) ValidateBasic() sdk.Error { + if msg.Granter.Empty() { + return sdk.ErrInvalidAddress("missing granter address") + } + if msg.Grantee.Empty() { + return sdk.ErrInvalidAddress("missing grantee address") + } + return nil +} + +func (msg MsgRevokeFeeAllowance) GetSignBytes() []byte { + b, err := json.Marshal(msg) + if err != nil { + panic(err) + } + return sdk.MustSortJSON(b) +} + +func (msg MsgRevokeFeeAllowance) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{msg.Granter} +} From 0c137cb1d0f4072db0d64e162b00c0a00c3041a6 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 16 Oct 2019 12:49:32 +0200 Subject: [PATCH 005/184] Add keeper and helper structs --- x/delegation/internal/keeper/keeper.go | 116 +++++++++++++++++++++++++ x/delegation/internal/types/errors.go | 6 -- x/delegation/internal/types/grant.go | 24 +++++ x/delegation/internal/types/key.go | 22 +++++ 4 files changed, 162 insertions(+), 6 deletions(-) create mode 100644 x/delegation/internal/keeper/keeper.go create mode 100644 x/delegation/internal/types/grant.go diff --git a/x/delegation/internal/keeper/keeper.go b/x/delegation/internal/keeper/keeper.go new file mode 100644 index 000000000000..e7baa5ee44b7 --- /dev/null +++ b/x/delegation/internal/keeper/keeper.go @@ -0,0 +1,116 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/delegation/exported" + "github.com/cosmos/cosmos-sdk/x/delegation/internal/types" +) + +type Keeper struct { + storeKey sdk.StoreKey + cdc *codec.Codec +} + +// NewKeeper creates a DelegationKeeper +func NewKeeper(storeKey sdk.StoreKey, cdc *codec.Codec) Keeper { + return Keeper{storeKey, cdc} +} + +// DelegateFeeAllowance creates a new grant +func (k Keeper) DelegateFeeAllowance(ctx sdk.Context, grant types.FeeAllowanceGrant) error { + store := ctx.KVStore(k.storeKey) + key := types.FeeAllowanceKey(grant.Granter, grant.Grantee) + + bz, err := k.cdc.MarshalBinaryBare(grant) + if err != nil { + return err + } + store.Set(key, bz) + return nil +} + +// RevokeFeeAllowance removes an existing grant +func (k Keeper) RevokeFeeAllowance(ctx sdk.Context, granter sdk.AccAddress, grantee sdk.AccAddress) { + store := ctx.KVStore(k.storeKey) + key := types.FeeAllowanceKey(granter, grantee) + store.Delete(key) +} + +// GetFeeAllowance returns the allowance between the granter and grantee. +// If there is none, it returns nil, nil. +// Returns an error on parsing issues +func (k Keeper) GetFeeAllowance(ctx sdk.Context, granter sdk.AccAddress, grantee sdk.AccAddress) (exported.FeeAllowance, error) { + grant, err := k.GetFeeGrant(ctx, granter, grantee) + if err != nil { + return nil, err + } + return grant.Allowance, nil +} + +// GetFeeGrant returns entire grant between both accounts +func (k Keeper) GetFeeGrant(ctx sdk.Context, granter sdk.AccAddress, grantee sdk.AccAddress) (*types.FeeAllowanceGrant, error) { + store := ctx.KVStore(k.storeKey) + key := types.FeeAllowanceKey(granter, grantee) + bz := store.Get(key) + if len(bz) == 0 { + return nil, nil + } + + var grant types.FeeAllowanceGrant + err := k.cdc.UnmarshalBinaryBare(bz, &grant) + if err != nil { + return nil, err + } + return &grant, nil +} + +// GetAllFeeAllowances returns a list of all the grants from anyone to the given grantee. +func (k Keeper) GetAllFeeAllowances(ctx sdk.Context, grantee sdk.AccAddress) ([]types.FeeAllowanceGrant, error) { + store := ctx.KVStore(k.storeKey) + var grants []types.FeeAllowanceGrant + + prefix := types.FeeAllowancePrefixByGrantee(grantee) + iter := sdk.KVStorePrefixIterator(store, prefix) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + bz := iter.Value() + var grant types.FeeAllowanceGrant + err := k.cdc.UnmarshalBinaryBare(bz, &grant) + if err != nil { + return nil, err + } + grants = append(grants, grant) + } + return grants, nil +} + +// UseDelegatedFees will try to pay the given fee from the granter's account as requested by the grantee +// (true, nil) will update the allowance, and assumes the AnteHandler deducts the given fees +// (false, nil) rejects payment on behalf of grantee +// (?, err) means there was a data parsing error (abort tx and log this info) +func (k Keeper) UseDelegatedFees(ctx sdk.Context, granter sdk.AccAddress, grantee sdk.AccAddress, fee sdk.Coins) bool { + grant, err := k.GetFeeGrant(ctx, granter, grantee) + if err != nil { + // we should acknowlegde a db issue somehow (better?) + ctx.Logger().Error(err.Error()) + return false + } + + remove, err := grant.Allowance.Accept(fee, ctx.BlockTime(), ctx.BlockHeight()) + if remove { + k.RevokeFeeAllowance(ctx, granter, grantee) + return err == nil + } + if err != nil { + return false + } + + // if we accepted, store the updated state of the allowance + if err := k.DelegateFeeAllowance(ctx, *grant); err != nil { + // we should acknowlegde a db issue somehow (better?) + ctx.Logger().Error(err.Error()) + return false + } + return true +} diff --git a/x/delegation/internal/types/errors.go b/x/delegation/internal/types/errors.go index 320f13e50402..1d5c57115030 100644 --- a/x/delegation/internal/types/errors.go +++ b/x/delegation/internal/types/errors.go @@ -11,7 +11,6 @@ const ( CodeFeeLimitExceeded sdk.CodeType = 1 CodeFeeLimitExpired sdk.CodeType = 2 CodeInvalidPeriod sdk.CodeType = 3 - CodeNonPositiveCoins sdk.CodeType = 4 ) // ErrFeeLimitExceeded error if there are not enough allowance to cover the fees @@ -28,8 +27,3 @@ func ErrFeeLimitExpired() sdk.Error { func ErrInvalidPeriod(reason string) sdk.Error { return sdk.NewError(DefaultCodespace, CodeInvalidPeriod, reason) } - -// ErrNonPositiveCoins error if some fees or allowance are non positive -func ErrNonPositiveCoins() sdk.Error { - return sdk.NewError(DefaultCodespace, CodeNonPositiveCoins, "non positive coin amount") -} diff --git a/x/delegation/internal/types/grant.go b/x/delegation/internal/types/grant.go new file mode 100644 index 000000000000..33aa7e29f7df --- /dev/null +++ b/x/delegation/internal/types/grant.go @@ -0,0 +1,24 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/delegation/exported" +) + +// FeeAllowanceGrant is stored in the KVStore to record a grant with full context +type FeeAllowanceGrant struct { + Granter sdk.AccAddress `json:"granter" yaml:"granter"` + Grantee sdk.AccAddress `json:"grantee" yaml:"grantee"` + Allowance exported.FeeAllowance `json:"allowance" yaml:"allowance"` +} + +// ValidateBasic ensures that +func (a FeeAllowanceGrant) ValidateBasic() error { + if a.Granter.Empty() { + return sdk.ErrInvalidAddress("missing granter address") + } + if a.Grantee.Empty() { + return sdk.ErrInvalidAddress("missing grantee address") + } + return a.Allowance.ValidateBasic() +} diff --git a/x/delegation/internal/types/key.go b/x/delegation/internal/types/key.go index 1e4528e100c4..6e5987fa08b7 100644 --- a/x/delegation/internal/types/key.go +++ b/x/delegation/internal/types/key.go @@ -1,5 +1,11 @@ package types +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + const ( // ModuleName is the module name constant used in many places ModuleName = "delegation" @@ -13,3 +19,19 @@ const ( // QuerierRoute is the querier route for supply QuerierRoute = ModuleName ) + +var ( + // FeeAllowanceKeyPrefix is the set of the kvstore for fee allowance data + FeeAllowanceKeyPrefix = []byte{0x00} +) + +// FeeAllowanceKey is the cannonical key to store a grant from granter to grantee +// We store by grantee first to allow searching by everyone who granted to you +func FeeAllowanceKey(granter sdk.AccAddress, grantee sdk.AccAddress) []byte { + return append(FeeAllowanceKeyPrefix, []byte(fmt.Sprintf("%s/%s", grantee, granter))...) +} + +// FeeAllowancePrefixByGrantee returns a prefix to scan for all grants to this given address. +func FeeAllowancePrefixByGrantee(grantee sdk.AccAddress) []byte { + return append(FeeAllowanceKeyPrefix, []byte(fmt.Sprintf("%s/", grantee))...) +} From 67cb830c81aa6e51d9ff75a80889482e3a52e78b Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 16 Oct 2019 12:54:00 +0200 Subject: [PATCH 006/184] Add alias and handler to top level --- x/delegation/alias.go | 53 +++++++++++++++++++++++++++++++++++++++++ x/delegation/handler.go | 24 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 x/delegation/alias.go create mode 100644 x/delegation/handler.go diff --git a/x/delegation/alias.go b/x/delegation/alias.go new file mode 100644 index 000000000000..8a2eda474911 --- /dev/null +++ b/x/delegation/alias.go @@ -0,0 +1,53 @@ +// nolint +// autogenerated code using github.com/rigelrozanski/multitool +// aliases generated for the following subdirectories: +// ALIASGEN: github.com/cosmos/cosmos-sdk/x/delegation/internal/types +// ALIASGEN: github.com/cosmos/cosmos-sdk/x/delegation/internal/keeper +package delegation + +import ( + "github.com/cosmos/cosmos-sdk/x/delegation/internal/keeper" + "github.com/cosmos/cosmos-sdk/x/delegation/internal/types" +) + +const ( + DefaultCodespace = types.DefaultCodespace + CodeFeeLimitExceeded = types.CodeFeeLimitExceeded + CodeFeeLimitExpired = types.CodeFeeLimitExpired + CodeInvalidPeriod = types.CodeInvalidPeriod + ModuleName = types.ModuleName + StoreKey = types.StoreKey + RouterKey = types.RouterKey + QuerierRoute = types.QuerierRoute +) + +var ( + // functions aliases + RegisterCodec = types.RegisterCodec + ErrFeeLimitExceeded = types.ErrFeeLimitExceeded + ErrFeeLimitExpired = types.ErrFeeLimitExpired + ErrInvalidPeriod = types.ErrInvalidPeriod + ExpiresAtTime = types.ExpiresAtTime + ExpiresAtHeight = types.ExpiresAtHeight + ClockPeriod = types.ClockPeriod + BlockPeriod = types.BlockPeriod + FeeAllowanceKey = types.FeeAllowanceKey + FeeAllowancePrefixByGrantee = types.FeeAllowancePrefixByGrantee + NewMsgDelegateFeeAllowance = types.NewMsgDelegateFeeAllowance + NewMsgRevokeFeeAllowance = types.NewMsgRevokeFeeAllowance + NewKeeper = keeper.NewKeeper + + // variable aliases + ModuleCdc = types.ModuleCdc + FeeAllowanceKeyPrefix = types.FeeAllowanceKeyPrefix +) + +type ( + BasicFeeAllowance = types.BasicFeeAllowance + ExpiresAt = types.ExpiresAt + Period = types.Period + FeeAllowanceGrant = types.FeeAllowanceGrant + MsgDelegateFeeAllowance = types.MsgDelegateFeeAllowance + MsgRevokeFeeAllowance = types.MsgRevokeFeeAllowance + Keeper = keeper.Keeper +) diff --git a/x/delegation/handler.go b/x/delegation/handler.go new file mode 100644 index 000000000000..070673fceb3a --- /dev/null +++ b/x/delegation/handler.go @@ -0,0 +1,24 @@ +package delegation + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func NewHandler(k Keeper) sdk.Handler { + return func(ctx sdk.Context, msg sdk.Msg) sdk.Result { + switch msg := msg.(type) { + case MsgDelegateFeeAllowance: + grant := FeeAllowanceGrant{Granter: msg.Granter, Grantee: msg.Grantee, Allowance: msg.Allowance} + k.DelegateFeeAllowance(ctx, grant) + return sdk.Result{} + case MsgRevokeFeeAllowance: + k.RevokeFeeAllowance(ctx, msg.Granter, msg.Grantee) + return sdk.Result{} + default: + errMsg := fmt.Sprintf("Unrecognized data Msg type: %v", msg.Type()) + return sdk.ErrUnknownRequest(errMsg).Result() + } + } +} From f6ba9bcdfe756bda1c340167faab86b3f3313d9a Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 16 Oct 2019 14:07:09 +0200 Subject: [PATCH 007/184] Add delegation module --- x/delegation/module.go | 154 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 x/delegation/module.go diff --git a/x/delegation/module.go b/x/delegation/module.go new file mode 100644 index 000000000000..a491b39b3ea9 --- /dev/null +++ b/x/delegation/module.go @@ -0,0 +1,154 @@ +package delegation + +import ( + "encoding/json" + + "github.com/gorilla/mux" + "github.com/spf13/cobra" + + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/cosmos/cosmos-sdk/client/context" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" +) + +// TODO: +// * genesis +// * querier +// * cli +// * rest +// * ante handler +// -> changes to auth, etc + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// AppModuleBasic defines the basic application module used by the delegation module. +type AppModuleBasic struct{} + +// Name returns the delegation module's name. +func (AppModuleBasic) Name() string { + return ModuleName +} + +// RegisterCodec registers the delegation module's types for the given codec. +func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { + RegisterCodec(cdc) +} + +// DefaultGenesis returns default genesis state as raw bytes for the delegation +// module. +func (AppModuleBasic) DefaultGenesis() json.RawMessage { + panic("not implemented!") + // return ModuleCdc.MustMarshalJSON(DefaultGenesisState()) +} + +// ValidateGenesis performs genesis state validation for the delegation module. +func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { + // TODO + return nil + // var data GenesisState + // err := ModuleCdc.UnmarshalJSON(bz, &data) + // if err != nil { + // return err + // } + // return ValidateGenesis(data) +} + +// RegisterRESTRoutes registers the REST routes for the delegation module. +func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router) { + // TODO + // rest.RegisterRoutes(ctx, rtr) +} + +// GetTxCmd returns the root tx command for the delegation module. +func (AppModuleBasic) GetTxCmd(_ *codec.Codec) *cobra.Command { + // TODO + return nil +} + +// GetQueryCmd returns no root query command for the delegation module. +func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { + // TODO + return nil + // return cli.GetQueryCmd(cdc) +} + +//____________________________________________________________________________ + +// AppModule implements an application module for the delegation module. +type AppModule struct { + AppModuleBasic + keeper Keeper +} + +// NewAppModule creates a new AppModule object +func NewAppModule(keeper Keeper) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{}, + keeper: keeper, + } +} + +// Name returns the delegation module's name. +func (AppModule) Name() string { + return ModuleName +} + +// RegisterInvariants registers the delegation module invariants. +func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { + // TODO? + // RegisterInvariants(ir, am.keeper) +} + +// Route returns the message routing key for the delegation module. +func (AppModule) Route() string { + return RouterKey +} + +// NewHandler returns an sdk.Handler for the delegation module. +func (am AppModule) NewHandler() sdk.Handler { + return NewHandler(am.keeper) +} + +// QuerierRoute returns the delegation module's querier route name. +func (AppModule) QuerierRoute() string { + return QuerierRoute +} + +// NewQuerierHandler returns the delegation module sdk.Querier. +func (am AppModule) NewQuerierHandler() sdk.Querier { + panic("not implemented!") + // return NewQuerier(am.keeper) +} + +// InitGenesis performs genesis initialization for the delegation module. It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate { + // TODO + // var genesisState GenesisState + // ModuleCdc.MustUnmarshalJSON(data, &genesisState) + // InitGenesis(ctx, am.keeper, am.ak, genesisState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the exported genesis state as raw bytes for the delegation +// module. +func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { + panic("not implemented!") + // gs := ExportGenesis(ctx, am.keeper) + // return ModuleCdc.MustMarshalJSON(gs) +} + +// BeginBlock returns the begin blocker for the delegation module. +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock returns the end blocker for the delegation module. It returns no validator +// updates. +func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} From a00236646cdd19d9faad32f8898eac85e07e370e Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 16 Oct 2019 14:13:20 +0200 Subject: [PATCH 008/184] Add basic querier --- x/delegation/internal/keeper/querier.go | 44 +++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 x/delegation/internal/keeper/querier.go diff --git a/x/delegation/internal/keeper/querier.go b/x/delegation/internal/keeper/querier.go new file mode 100644 index 000000000000..ab12c5ecb804 --- /dev/null +++ b/x/delegation/internal/keeper/querier.go @@ -0,0 +1,44 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + abci "github.com/tendermint/tendermint/abci/types" +) + +const ( + QueryGetFeeAllowances = "fees" +) + +// NewQuerier creates a new querier +func NewQuerier(keeper Keeper) sdk.Querier { + return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, sdk.Error) { + switch path[0] { + case QueryGetFeeAllowances: + return queryGetFeeAllowances(ctx, path[1:], keeper) + default: + return nil, sdk.ErrUnknownRequest("Unknown package delegation query endpoint") + } + } +} + +func queryGetFeeAllowances(ctx sdk.Context, args []string, keeper Keeper) ([]byte, sdk.Error) { + grantee := args[0] + granteeAddr, err := sdk.AccAddressFromBech32(grantee) + if err != nil { + return nil, sdk.ErrInternal(sdk.AppendMsgToErr("invalid address", err.Error())) + } + + fees, err := keeper.GetAllFeeAllowances(ctx, granteeAddr) + if err != nil { + return nil, sdk.ConvertError(err) + } + if fees == nil { + return []byte("[]"), nil + } + + bz, err := keeper.cdc.MarshalJSON(fees) + if err != nil { + return nil, sdk.ErrInternal(sdk.AppendMsgToErr("could not marshal result to JSON", err.Error())) + } + return bz, nil +} From 15c63619efc08270ac1adc1dd0180983d3751ec1 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 16 Oct 2019 14:43:08 +0200 Subject: [PATCH 009/184] Add types tests --- x/delegation/internal/types/expiration.go | 8 - .../internal/types/expiration_test.go | 169 ++++++++++++++++++ 2 files changed, 169 insertions(+), 8 deletions(-) create mode 100644 x/delegation/internal/types/expiration_test.go diff --git a/x/delegation/internal/types/expiration.go b/x/delegation/internal/types/expiration.go index 7eb75654d652..f82af4d84721 100644 --- a/x/delegation/internal/types/expiration.go +++ b/x/delegation/internal/types/expiration.go @@ -80,19 +80,11 @@ type Period struct { // ClockPeriod creates an period by clock time func ClockPeriod(d time.Duration) Period { - // assert nothing negative - if d < 0 { - panic("Cannot use a negative duration") - } return Period{Clock: d} } // BlockPeriod creates an period by block height func BlockPeriod(h int64) Period { - // assert nothing negative - if h < 0 { - panic("Cannot use a negative block step") - } return Period{Block: h} } diff --git a/x/delegation/internal/types/expiration_test.go b/x/delegation/internal/types/expiration_test.go new file mode 100644 index 000000000000..5b032d204a08 --- /dev/null +++ b/x/delegation/internal/types/expiration_test.go @@ -0,0 +1,169 @@ +package types + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestExpiresAt(t *testing.T) { + now := time.Now() + + cases := map[string]struct { + example ExpiresAt + valid bool + zero bool + before *ExpiresAt + after *ExpiresAt + }{ + "basic": { + example: ExpiresAtHeight(100), + valid: true, + before: &ExpiresAt{Height: 50, Time: now}, + after: &ExpiresAt{Height: 122, Time: now}, + }, + "zero": { + example: ExpiresAt{}, + zero: true, + valid: true, + before: &ExpiresAt{Height: 1}, + }, + "double": { + example: ExpiresAt{Height: 100, Time: now}, + valid: false, + }, + "match height": { + example: ExpiresAtHeight(1000), + valid: true, + before: &ExpiresAt{Height: 999, Time: now}, + after: &ExpiresAt{Height: 1000, Time: now}, + }, + "match time": { + example: ExpiresAtTime(now), + valid: true, + before: &ExpiresAt{Height: 43, Time: now.Add(-1 * time.Second)}, + after: &ExpiresAt{Height: 76, Time: now}, + }, + } + + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + err := tc.example.ValidateBasic() + assert.Equal(t, tc.zero, tc.example.IsZero()) + if !tc.valid { + require.Error(t, err) + return + } + require.NoError(t, err) + + if tc.before != nil { + assert.Equal(t, false, tc.example.IsExpired(tc.before.Time, tc.before.Height)) + } + if tc.after != nil { + assert.Equal(t, true, tc.example.IsExpired(tc.after.Time, tc.after.Height)) + } + }) + } +} + +func TestPeriodValid(t *testing.T) { + now := time.Now() + + cases := map[string]struct { + period Period + valid bool + compatible ExpiresAt + incompatible ExpiresAt + }{ + "basic height": { + period: BlockPeriod(100), + valid: true, + compatible: ExpiresAtHeight(50), + incompatible: ExpiresAtTime(now), + }, + "basic time": { + period: ClockPeriod(time.Hour), + valid: true, + compatible: ExpiresAtTime(now), + incompatible: ExpiresAtHeight(50), + }, + "zero": { + period: Period{}, + valid: false, + }, + "double": { + period: Period{Block: 100, Clock: time.Hour}, + valid: false, + }, + "negative clock": { + period: ClockPeriod(-1 * time.Hour), + valid: false, + }, + "negative block": { + period: BlockPeriod(-5), + valid: false, + }, + } + + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + err := tc.period.ValidateBasic() + if !tc.valid { + require.Error(t, err) + return + } + require.NoError(t, err) + + assert.Equal(t, true, tc.compatible.IsCompatible(tc.period)) + assert.Equal(t, false, tc.incompatible.IsCompatible(tc.period)) + }) + } +} + +func TestPeriodStep(t *testing.T) { + now := time.Now() + + cases := map[string]struct { + expires ExpiresAt + period Period + valid bool + result ExpiresAt + }{ + "add height": { + expires: ExpiresAtHeight(789), + period: BlockPeriod(100), + valid: true, + result: ExpiresAtHeight(889), + }, + "add time": { + expires: ExpiresAtTime(now), + period: ClockPeriod(time.Hour), + valid: true, + result: ExpiresAtTime(now.Add(time.Hour)), + }, + "mismatch": { + expires: ExpiresAtHeight(789), + period: ClockPeriod(time.Hour), + valid: false, + }, + } + + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + err := tc.period.ValidateBasic() + require.NoError(t, err) + err = tc.expires.ValidateBasic() + require.NoError(t, err) + + err = tc.expires.Step(tc.period) + if !tc.valid { + require.Error(t, err) + return + } + require.NoError(t, err) + require.Equal(t, tc.result, tc.expires) + }) + } +} From 410d1f19ca56f07ae7e01563c2fae9186f99b017 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 16 Oct 2019 14:55:36 +0200 Subject: [PATCH 010/184] Add types tests --- x/delegation/internal/types/basic_fee_test.go | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 x/delegation/internal/types/basic_fee_test.go diff --git a/x/delegation/internal/types/basic_fee_test.go b/x/delegation/internal/types/basic_fee_test.go new file mode 100644 index 000000000000..4e7c0e726dc3 --- /dev/null +++ b/x/delegation/internal/types/basic_fee_test.go @@ -0,0 +1,108 @@ +package types + +import ( + "testing" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestBasicFeeValidAllow(t *testing.T) { + eth := sdk.NewCoins(sdk.NewInt64Coin("eth", 10)) + atom := sdk.NewCoins(sdk.NewInt64Coin("atom", 555)) + smallAtom := sdk.NewCoins(sdk.NewInt64Coin("atom", 43)) + leftAtom := sdk.NewCoins(sdk.NewInt64Coin("atom", 512)) + + cases := map[string]struct { + allow BasicFeeAllowance + valid bool + // all below checks are ignored if invalid + fee sdk.Coins + blockTime time.Time + blockHeight int64 + accept bool + remove bool + remains sdk.Coins + }{ + "empty": { + allow: BasicFeeAllowance{}, + valid: false, + }, + "small fee": { + allow: BasicFeeAllowance{ + SpendLimit: atom, + }, + valid: true, + fee: smallAtom, + accept: true, + remove: false, + remains: leftAtom, + }, + "all fee": { + allow: BasicFeeAllowance{ + SpendLimit: smallAtom, + }, + valid: true, + fee: smallAtom, + accept: true, + remove: true, + }, + "wrong fee": { + allow: BasicFeeAllowance{ + SpendLimit: smallAtom, + }, + valid: true, + fee: eth, + accept: false, + }, + "non-expired": { + allow: BasicFeeAllowance{ + SpendLimit: atom, + Expiration: ExpiresAtHeight(100), + }, + valid: true, + fee: smallAtom, + blockHeight: 85, + accept: true, + remove: false, + remains: leftAtom, + }, + "expired": { + allow: BasicFeeAllowance{ + SpendLimit: atom, + Expiration: ExpiresAtHeight(100), + }, + valid: true, + fee: smallAtom, + blockHeight: 121, + accept: false, + remove: true, + }, + } + + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + err := tc.allow.ValidateBasic() + if !tc.valid { + require.Error(t, err) + return + } + require.NoError(t, err) + + // now try to deduct + remove, err := tc.allow.Accept(tc.fee, tc.blockTime, tc.blockHeight) + if !tc.accept { + require.Error(t, err) + return + } + require.NoError(t, err) + + require.Equal(t, tc.remove, remove) + if !remove { + assert.Equal(t, tc.allow.SpendLimit, tc.remains) + } + }) + } +} From f65db09669fb73cc8716d55dbfae37476558b78d Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 16 Oct 2019 15:36:37 +0200 Subject: [PATCH 011/184] More internal test coverage --- x/delegation/internal/keeper/keeper.go | 4 +- x/delegation/internal/keeper/keeper_test.go | 186 ++++++++++++++++++++ x/delegation/internal/types/grant.go | 3 + x/delegation/internal/types/grant_test.go | 98 +++++++++++ 4 files changed, 289 insertions(+), 2 deletions(-) create mode 100644 x/delegation/internal/keeper/keeper_test.go create mode 100644 x/delegation/internal/types/grant_test.go diff --git a/x/delegation/internal/keeper/keeper.go b/x/delegation/internal/keeper/keeper.go index e7baa5ee44b7..9654c28c24e0 100644 --- a/x/delegation/internal/keeper/keeper.go +++ b/x/delegation/internal/keeper/keeper.go @@ -42,10 +42,10 @@ func (k Keeper) RevokeFeeAllowance(ctx sdk.Context, granter sdk.AccAddress, gran // Returns an error on parsing issues func (k Keeper) GetFeeAllowance(ctx sdk.Context, granter sdk.AccAddress, grantee sdk.AccAddress) (exported.FeeAllowance, error) { grant, err := k.GetFeeGrant(ctx, granter, grantee) - if err != nil { + if grant == nil { return nil, err } - return grant.Allowance, nil + return grant.Allowance, err } // GetFeeGrant returns entire grant between both accounts diff --git a/x/delegation/internal/keeper/keeper_test.go b/x/delegation/internal/keeper/keeper_test.go new file mode 100644 index 000000000000..c85eb1012d13 --- /dev/null +++ b/x/delegation/internal/keeper/keeper_test.go @@ -0,0 +1,186 @@ +package keeper_test + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + abci "github.com/tendermint/tendermint/abci/types" + "github.com/tendermint/tendermint/libs/log" + dbm "github.com/tendermint/tm-db" + + codec "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/delegation/exported" + "github.com/cosmos/cosmos-sdk/x/delegation/internal/keeper" + "github.com/cosmos/cosmos-sdk/x/delegation/internal/types" +) + +type testInput struct { + cdc *codec.Codec + ctx sdk.Context + dk keeper.Keeper +} + +func setupTestInput() testInput { + db := dbm.NewMemDB() + + cdc := codec.New() + types.RegisterCodec(cdc) + sdk.RegisterCodec(cdc) + + delCapKey := sdk.NewKVStoreKey("delKey") + + ms := store.NewCommitMultiStore(db) + ms.MountStoreWithDB(delCapKey, sdk.StoreTypeIAVL, db) + ms.LoadLatestVersion() + + dk := keeper.NewKeeper(delCapKey, cdc) + + ctx := sdk.NewContext(ms, abci.Header{ChainID: "test-chain-id", Time: time.Now().UTC(), Height: 1234}, false, log.NewNopLogger()) + return testInput{cdc: cdc, ctx: ctx, dk: dk} +} + +var ( + // some valid cosmos keys.... + addr = mustAddr("cosmos157ez5zlaq0scm9aycwphhqhmg3kws4qusmekll") + addr2 = mustAddr("cosmos1rjxwm0rwyuldsg00qf5lt26wxzzppjzxs2efdw") + addr3 = mustAddr("cosmos1qk93t4j0yyzgqgt6k5qf8deh8fq6smpn3ntu3x") + addr4 = mustAddr("cosmos1p9qh4ldfd6n0qehujsal4k7g0e37kel90rc4ts") +) + +func mustAddr(acc string) sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(acc) + if err != nil { + panic(err) + } + return addr +} + +func TestKeeperCrud(t *testing.T) { + input := setupTestInput() + ctx := input.ctx + k := input.dk + + // some helpers + atom := sdk.NewCoins(sdk.NewInt64Coin("atom", 555)) + eth := sdk.NewCoins(sdk.NewInt64Coin("eth", 123)) + basic := types.BasicFeeAllowance{ + SpendLimit: atom, + Expiration: types.ExpiresAtHeight(334455), + } + basic2 := types.BasicFeeAllowance{ + SpendLimit: eth, + Expiration: types.ExpiresAtHeight(172436), + } + + // let's set up some initial state here + err := k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + Granter: addr, Grantee: addr2, Allowance: &basic, + }) + require.NoError(t, err) + err = k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + Granter: addr, Grantee: addr3, Allowance: &basic2, + }) + require.NoError(t, err) + err = k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + Granter: addr2, Grantee: addr3, Allowance: &basic, + }) + require.NoError(t, err) + err = k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + Granter: addr2, Grantee: addr4, Allowance: &basic, + }) + require.NoError(t, err) + err = k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + Granter: addr4, Grantee: addr, Allowance: &basic2, + }) + require.NoError(t, err) + + // remove some, overwrite other + k.RevokeFeeAllowance(ctx, addr, addr2) + k.RevokeFeeAllowance(ctx, addr, addr3) + err = k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + Granter: addr, Grantee: addr3, Allowance: &basic, + }) + require.NoError(t, err) + err = k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + Granter: addr2, Grantee: addr3, Allowance: &basic2, + }) + require.NoError(t, err) + + // end state: + // addr -> addr3 (basic) + // addr2 -> addr3 (basic2), addr4(basic) + // addr4 -> addr (basic2) + + // then lots of queries + cases := map[string]struct { + grantee sdk.AccAddress + granter sdk.AccAddress + allowance exported.FeeAllowance + }{ + "addr revoked": { + granter: addr, + grantee: addr2, + }, + "addr revoked and added": { + granter: addr, + grantee: addr3, + allowance: &basic, + }, + "addr never there": { + granter: addr, + grantee: addr4, + }, + "addr modified": { + granter: addr2, + grantee: addr3, + allowance: &basic2, + }, + } + + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + allow, err := k.GetFeeAllowance(ctx, tc.granter, tc.grantee) + require.NoError(t, err) + if tc.allowance == nil { + require.Nil(t, allow) + return + } + require.NotNil(t, allow) + b, ok := allow.(*types.BasicFeeAllowance) + require.True(t, ok) + require.Equal(t, tc.allowance, b) + }) + } + + allCases := map[string]struct { + grantee sdk.AccAddress + grants []types.FeeAllowanceGrant + }{ + "addr2 has none": { + grantee: addr2, + }, + "addr has one": { + grantee: addr, + grants: []types.FeeAllowanceGrant{{Granter: addr4, Grantee: addr, Allowance: &basic2}}, + }, + "addr3 has two": { + grantee: addr3, + grants: []types.FeeAllowanceGrant{ + {Granter: addr, Grantee: addr3, Allowance: &basic}, + {Granter: addr2, Grantee: addr3, Allowance: &basic2}, + }, + }, + } + + for name, tc := range allCases { + t.Run(name, func(t *testing.T) { + grants, err := k.GetAllFeeAllowances(ctx, tc.grantee) + require.NoError(t, err) + assert.Equal(t, tc.grants, grants) + }) + } +} diff --git a/x/delegation/internal/types/grant.go b/x/delegation/internal/types/grant.go index 33aa7e29f7df..c7bed78b6e30 100644 --- a/x/delegation/internal/types/grant.go +++ b/x/delegation/internal/types/grant.go @@ -20,5 +20,8 @@ func (a FeeAllowanceGrant) ValidateBasic() error { if a.Grantee.Empty() { return sdk.ErrInvalidAddress("missing grantee address") } + if a.Grantee.Equals(a.Granter) { + return sdk.ErrInvalidAddress("cannot self-grant fees") + } return a.Allowance.ValidateBasic() } diff --git a/x/delegation/internal/types/grant_test.go b/x/delegation/internal/types/grant_test.go new file mode 100644 index 000000000000..527806f1bccd --- /dev/null +++ b/x/delegation/internal/types/grant_test.go @@ -0,0 +1,98 @@ +package types + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestGrant(t *testing.T) { + addr, err := sdk.AccAddressFromBech32("cosmos1qk93t4j0yyzgqgt6k5qf8deh8fq6smpn3ntu3x") + require.NoError(t, err) + addr2, err := sdk.AccAddressFromBech32("cosmos1p9qh4ldfd6n0qehujsal4k7g0e37kel90rc4ts") + require.NoError(t, err) + atom := sdk.NewCoins(sdk.NewInt64Coin("atom", 555)) + + cdc := codec.New() + RegisterCodec(cdc) + + cases := map[string]struct { + grant FeeAllowanceGrant + valid bool + }{ + "good": { + grant: FeeAllowanceGrant{ + Grantee: addr, + Granter: addr2, + Allowance: &BasicFeeAllowance{ + SpendLimit: atom, + Expiration: ExpiresAtHeight(100), + }, + }, + valid: true, + }, + "no grantee": { + grant: FeeAllowanceGrant{ + Granter: addr2, + Allowance: &BasicFeeAllowance{ + SpendLimit: atom, + Expiration: ExpiresAtHeight(100), + }, + }, + }, + "no granter": { + grant: FeeAllowanceGrant{ + Grantee: addr2, + Allowance: &BasicFeeAllowance{ + SpendLimit: atom, + Expiration: ExpiresAtHeight(100), + }, + }, + }, + "self-grant": { + grant: FeeAllowanceGrant{ + Grantee: addr2, + Granter: addr2, + Allowance: &BasicFeeAllowance{ + SpendLimit: atom, + Expiration: ExpiresAtHeight(100), + }, + }, + }, + "bad allowance": { + grant: FeeAllowanceGrant{ + Grantee: addr, + Granter: addr2, + Allowance: &BasicFeeAllowance{ + Expiration: ExpiresAtHeight(100), + }, + }, + }, + } + + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + err := tc.grant.ValidateBasic() + if !tc.valid { + require.Error(t, err) + return + } + require.NoError(t, err) + + // if it is valid, let's try to serialize, deserialize, and make sure it matches + bz, err := cdc.MarshalBinaryBare(tc.grant) + require.NoError(t, err) + var loaded FeeAllowanceGrant + err = cdc.UnmarshalBinaryBare(bz, &loaded) + require.NoError(t, err) + + err = tc.grant.ValidateBasic() + require.NoError(t, err) + assert.Equal(t, tc.grant, loaded) + }) + } + +} From e0f632780a4a91253ebf5823d9c4e70f87fa2eac Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 16 Oct 2019 16:05:28 +0200 Subject: [PATCH 012/184] Solid internal test coverage --- x/delegation/internal/keeper/keeper_test.go | 91 +++++++++++++++++++- x/delegation/internal/keeper/querier_test.go | 88 +++++++++++++++++++ x/delegation/module.go | 3 +- 3 files changed, 177 insertions(+), 5 deletions(-) create mode 100644 x/delegation/internal/keeper/querier_test.go diff --git a/x/delegation/internal/keeper/keeper_test.go b/x/delegation/internal/keeper/keeper_test.go index c85eb1012d13..649e0c639b28 100644 --- a/x/delegation/internal/keeper/keeper_test.go +++ b/x/delegation/internal/keeper/keeper_test.go @@ -150,9 +150,7 @@ func TestKeeperCrud(t *testing.T) { return } require.NotNil(t, allow) - b, ok := allow.(*types.BasicFeeAllowance) - require.True(t, ok) - require.Equal(t, tc.allowance, b) + require.Equal(t, tc.allowance, allow) }) } @@ -184,3 +182,90 @@ func TestKeeperCrud(t *testing.T) { }) } } + +func TestUseDelegatedFee(t *testing.T) { + input := setupTestInput() + ctx := input.ctx + k := input.dk + + // some helpers + atom := sdk.NewCoins(sdk.NewInt64Coin("atom", 555)) + eth := sdk.NewCoins(sdk.NewInt64Coin("eth", 123)) + future := types.BasicFeeAllowance{ + SpendLimit: atom, + Expiration: types.ExpiresAtHeight(5678), + } + expired := types.BasicFeeAllowance{ + SpendLimit: eth, + Expiration: types.ExpiresAtHeight(55), + } + + // for testing limits of the contract + hugeAtom := sdk.NewCoins(sdk.NewInt64Coin("atom", 9999)) + smallAtom := sdk.NewCoins(sdk.NewInt64Coin("atom", 1)) + futureAfterSmall := types.BasicFeeAllowance{ + SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 554)), + Expiration: types.ExpiresAtHeight(5678), + } + + // then lots of queries + cases := map[string]struct { + grantee sdk.AccAddress + granter sdk.AccAddress + fee sdk.Coins + allowed bool + final exported.FeeAllowance + }{ + "use entire pot": { + granter: addr, + grantee: addr2, + fee: atom, + allowed: true, + final: nil, + }, + "expired and removed": { + granter: addr, + grantee: addr3, + fee: eth, + allowed: false, + final: nil, + }, + "too high": { + granter: addr, + grantee: addr2, + fee: hugeAtom, + allowed: false, + final: &future, + }, + "use a little": { + granter: addr, + grantee: addr2, + fee: smallAtom, + allowed: true, + final: &futureAfterSmall, + }, + } + + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + // let's set up some initial state here + // addr -> addr2 (future) + // addr -> addr3 (expired) + err := k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + Granter: addr, Grantee: addr2, Allowance: &future, + }) + require.NoError(t, err) + err = k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + Granter: addr, Grantee: addr3, Allowance: &expired, + }) + require.NoError(t, err) + + allowed := k.UseDelegatedFees(ctx, tc.granter, tc.grantee, tc.fee) + require.Equal(t, tc.allowed, allowed) + + loaded, err := k.GetFeeAllowance(ctx, tc.granter, tc.grantee) + require.NoError(t, err) + require.Equal(t, tc.final, loaded) + }) + } +} diff --git a/x/delegation/internal/keeper/querier_test.go b/x/delegation/internal/keeper/querier_test.go new file mode 100644 index 000000000000..7cec96217859 --- /dev/null +++ b/x/delegation/internal/keeper/querier_test.go @@ -0,0 +1,88 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + abci "github.com/tendermint/tendermint/abci/types" + + codec "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/delegation/internal/keeper" + "github.com/cosmos/cosmos-sdk/x/delegation/internal/types" +) + +func TestQuery(t *testing.T) { + input := setupTestInput() + ctx := input.ctx + k := input.dk + + cdc := codec.New() + types.RegisterCodec(cdc) + + // some helpers + grant1 := types.FeeAllowanceGrant{ + Granter: addr, + Grantee: addr3, + Allowance: &types.BasicFeeAllowance{ + SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 555)), + Expiration: types.ExpiresAtHeight(334455), + }, + } + grant2 := types.FeeAllowanceGrant{ + Granter: addr2, + Grantee: addr3, + Allowance: &types.BasicFeeAllowance{ + SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("eth", 123)), + Expiration: types.ExpiresAtHeight(334455), + }, + } + + // let's set up some initial state here + err := k.DelegateFeeAllowance(ctx, grant1) + require.NoError(t, err) + err = k.DelegateFeeAllowance(ctx, grant2) + require.NoError(t, err) + + // now try some queries + cases := map[string]struct { + path []string + valid bool + res []types.FeeAllowanceGrant + }{ + "bad path": { + path: []string{"foo", "bar"}, + }, + "no data": { + // addr in bech32 + path: []string{"fees", "cosmos157ez5zlaq0scm9aycwphhqhmg3kws4qusmekll"}, + valid: true, + }, + "two grants": { + // addr3 in bech32 + path: []string{"fees", "cosmos1qk93t4j0yyzgqgt6k5qf8deh8fq6smpn3ntu3x"}, + valid: true, + res: []types.FeeAllowanceGrant{grant1, grant2}, + }, + } + + querier := keeper.NewQuerier(k) + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + bz, err := querier(ctx, tc.path, abci.RequestQuery{}) + if !tc.valid { + require.Error(t, err) + return + } + require.NoError(t, err) + + var grants []types.FeeAllowanceGrant + serr := cdc.UnmarshalJSON(bz, &grants) + require.NoError(t, serr) + + assert.Equal(t, tc.res, grants) + }) + } + +} diff --git a/x/delegation/module.go b/x/delegation/module.go index a491b39b3ea9..8736a1ae9976 100644 --- a/x/delegation/module.go +++ b/x/delegation/module.go @@ -15,11 +15,10 @@ import ( ) // TODO: +// * ante handler // * genesis -// * querier // * cli // * rest -// * ante handler // -> changes to auth, etc var ( From 93c9b7e99d229ca0d57a656561fbe5417dc3988a Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 16 Oct 2019 18:39:22 +0200 Subject: [PATCH 013/184] Expose Querier to top level module --- x/delegation/alias.go | 18 ++++++++++-------- x/delegation/module.go | 3 +-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/x/delegation/alias.go b/x/delegation/alias.go index 8a2eda474911..7bfc3f7d5fbf 100644 --- a/x/delegation/alias.go +++ b/x/delegation/alias.go @@ -11,14 +11,15 @@ import ( ) const ( - DefaultCodespace = types.DefaultCodespace - CodeFeeLimitExceeded = types.CodeFeeLimitExceeded - CodeFeeLimitExpired = types.CodeFeeLimitExpired - CodeInvalidPeriod = types.CodeInvalidPeriod - ModuleName = types.ModuleName - StoreKey = types.StoreKey - RouterKey = types.RouterKey - QuerierRoute = types.QuerierRoute + DefaultCodespace = types.DefaultCodespace + CodeFeeLimitExceeded = types.CodeFeeLimitExceeded + CodeFeeLimitExpired = types.CodeFeeLimitExpired + CodeInvalidPeriod = types.CodeInvalidPeriod + ModuleName = types.ModuleName + StoreKey = types.StoreKey + RouterKey = types.RouterKey + QuerierRoute = types.QuerierRoute + QueryGetFeeAllowances = keeper.QueryGetFeeAllowances ) var ( @@ -36,6 +37,7 @@ var ( NewMsgDelegateFeeAllowance = types.NewMsgDelegateFeeAllowance NewMsgRevokeFeeAllowance = types.NewMsgRevokeFeeAllowance NewKeeper = keeper.NewKeeper + NewQuerier = keeper.NewQuerier // variable aliases ModuleCdc = types.ModuleCdc diff --git a/x/delegation/module.go b/x/delegation/module.go index 8736a1ae9976..04adfb0f7e9b 100644 --- a/x/delegation/module.go +++ b/x/delegation/module.go @@ -121,8 +121,7 @@ func (AppModule) QuerierRoute() string { // NewQuerierHandler returns the delegation module sdk.Querier. func (am AppModule) NewQuerierHandler() sdk.Querier { - panic("not implemented!") - // return NewQuerier(am.keeper) + return NewQuerier(am.keeper) } // InitGenesis performs genesis initialization for the delegation module. It returns From 7968441a4d1add9b7844320ad9c45892a09a9467 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 16 Oct 2019 18:59:53 +0200 Subject: [PATCH 014/184] Add FeeAccount to auth/types, like StdTx, SignDoc --- x/auth/types/stdsignmsg.go | 15 ++++++++------- x/auth/types/stdtx.go | 18 +++++++++++++----- x/auth/types/stdtx_test.go | 23 ++++++++++++----------- x/auth/types/test_common.go | 27 ++++++++++++++++++++++----- x/auth/types/txbuilder.go | 21 +++++++++++++++++---- x/auth/types/txbuilder_test.go | 4 +++- 6 files changed, 75 insertions(+), 33 deletions(-) diff --git a/x/auth/types/stdsignmsg.go b/x/auth/types/stdsignmsg.go index e018dac40048..f27b00291fb8 100644 --- a/x/auth/types/stdsignmsg.go +++ b/x/auth/types/stdsignmsg.go @@ -8,15 +8,16 @@ import ( // a Msg with the other requirements for a StdSignDoc before // it is signed. For use in the CLI. type StdSignMsg struct { - ChainID string `json:"chain_id" yaml:"chain_id"` - AccountNumber uint64 `json:"account_number" yaml:"account_number"` - Sequence uint64 `json:"sequence" yaml:"sequence"` - Fee StdFee `json:"fee" yaml:"fee"` - Msgs []sdk.Msg `json:"msgs" yaml:"msgs"` - Memo string `json:"memo" yaml:"memo"` + ChainID string `json:"chain_id" yaml:"chain_id"` + AccountNumber uint64 `json:"account_number" yaml:"account_number"` + Sequence uint64 `json:"sequence" yaml:"sequence"` + Fee StdFee `json:"fee" yaml:"fee"` + Msgs []sdk.Msg `json:"msgs" yaml:"msgs"` + Memo string `json:"memo" yaml:"memo"` + FeeAccount sdk.AccAddress `json:"fee_account" yaml:"fee_account"` } // get message bytes func (msg StdSignMsg) Bytes() []byte { - return StdSignBytes(msg.ChainID, msg.AccountNumber, msg.Sequence, msg.Fee, msg.Msgs, msg.Memo) + return StdSignBytes(msg.ChainID, msg.AccountNumber, msg.Sequence, msg.Fee, msg.Msgs, msg.Memo, msg.FeeAccount) } diff --git a/x/auth/types/stdtx.go b/x/auth/types/stdtx.go index fa8b5d100d5f..713539d2ca2b 100644 --- a/x/auth/types/stdtx.go +++ b/x/auth/types/stdtx.go @@ -26,14 +26,16 @@ type StdTx struct { Fee StdFee `json:"fee" yaml:"fee"` Signatures []StdSignature `json:"signatures" yaml:"signatures"` Memo string `json:"memo" yaml:"memo"` + FeeAccount sdk.AccAddress `json:"fee_account" yaml:"fee_account"` } -func NewStdTx(msgs []sdk.Msg, fee StdFee, sigs []StdSignature, memo string) StdTx { +func NewStdTx(msgs []sdk.Msg, fee StdFee, sigs []StdSignature, memo string, feeAccount sdk.AccAddress) StdTx { return StdTx{ Msgs: msgs, Fee: fee, Signatures: sigs, Memo: memo, + FeeAccount: feeAccount, } } @@ -98,6 +100,9 @@ func (tx StdTx) GetSigners() []sdk.AccAddress { // GetMemo returns the memo func (tx StdTx) GetMemo() string { return tx.Memo } +// GetFeeAccount returns the account paying the fees (often nil, default ot first signer) +func (tx StdTx) GetFeeAccount() sdk.AccAddress { return tx.FeeAccount } + // GetSignatures returns the signature of signers who signed the Msg. // CONTRACT: Length returned is same as length of // pubkeys returned from MsgKeySigners, and the order @@ -133,7 +138,7 @@ func (tx StdTx) GetSignBytes(ctx sdk.Context, acc exported.Account) []byte { } return StdSignBytes( - chainID, accNum, acc.GetSequence(), tx.Fee, tx.Msgs, tx.Memo, + chainID, accNum, acc.GetSequence(), tx.Fee, tx.Msgs, tx.Memo, tx.FeeAccount, ) } @@ -210,10 +215,11 @@ type StdSignDoc struct { Memo string `json:"memo" yaml:"memo"` Msgs []json.RawMessage `json:"msgs" yaml:"msgs"` Sequence uint64 `json:"sequence" yaml:"sequence"` + FeeAccount sdk.AccAddress `json:"fee_account" yaml:"fee_account"` } // StdSignBytes returns the bytes to sign for a transaction. -func StdSignBytes(chainID string, accnum uint64, sequence uint64, fee StdFee, msgs []sdk.Msg, memo string) []byte { +func StdSignBytes(chainID string, accnum uint64, sequence uint64, fee StdFee, msgs []sdk.Msg, memo string, feeAccount sdk.AccAddress) []byte { msgsBytes := make([]json.RawMessage, 0, len(msgs)) for _, msg := range msgs { msgsBytes = append(msgsBytes, json.RawMessage(msg.GetSignBytes())) @@ -225,6 +231,7 @@ func StdSignBytes(chainID string, accnum uint64, sequence uint64, fee StdFee, ms Memo: memo, Msgs: msgsBytes, Sequence: sequence, + FeeAccount: feeAccount, }) if err != nil { panic(err) @@ -234,8 +241,9 @@ func StdSignBytes(chainID string, accnum uint64, sequence uint64, fee StdFee, ms // StdSignature represents a sig type StdSignature struct { - crypto.PubKey `json:"pub_key" yaml:"pub_key"` // optional - Signature []byte `json:"signature" yaml:"signature"` + // Pubkey is optional + crypto.PubKey `json:"pub_key" yaml:"pub_key"` + Signature []byte `json:"signature" yaml:"signature"` } // DefaultTxDecoder logic for standard transaction decoding diff --git a/x/auth/types/stdtx_test.go b/x/auth/types/stdtx_test.go index 375a15c49cc4..c731b595cff2 100644 --- a/x/auth/types/stdtx_test.go +++ b/x/auth/types/stdtx_test.go @@ -25,7 +25,7 @@ func TestStdTx(t *testing.T) { fee := NewTestStdFee() sigs := []StdSignature{} - tx := NewStdTx(msgs, fee, sigs, "") + tx := NewStdTx(msgs, fee, sigs, "", nil) require.Equal(t, msgs, tx.GetMsgs()) require.Equal(t, sigs, tx.Signatures) @@ -35,12 +35,13 @@ func TestStdTx(t *testing.T) { func TestStdSignBytes(t *testing.T) { type args struct { - chainID string - accnum uint64 - sequence uint64 - fee StdFee - msgs []sdk.Msg - memo string + chainID string + accnum uint64 + sequence uint64 + fee StdFee + msgs []sdk.Msg + memo string + feeAccount sdk.AccAddress } defaultFee := NewTestStdFee() tests := []struct { @@ -48,12 +49,12 @@ func TestStdSignBytes(t *testing.T) { want string }{ { - args{"1234", 3, 6, defaultFee, []sdk.Msg{sdk.NewTestMsg(addr)}, "memo"}, - fmt.Sprintf("{\"account_number\":\"3\",\"chain_id\":\"1234\",\"fee\":{\"amount\":[{\"amount\":\"150\",\"denom\":\"atom\"}],\"gas\":\"100000\"},\"memo\":\"memo\",\"msgs\":[[\"%s\"]],\"sequence\":\"6\"}", addr), + args{"1234", 3, 6, defaultFee, []sdk.Msg{sdk.NewTestMsg(addr)}, "memo", nil}, + fmt.Sprintf(`{"account_number":"3","chain_id":"1234","fee":{"amount":[{"amount":"150","denom":"atom"}],"gas":"100000"},"fee_account":"","memo":"memo","msgs":[["%s"]],"sequence":"6"}`, addr), }, } for i, tc := range tests { - got := string(StdSignBytes(tc.args.chainID, tc.args.accnum, tc.args.sequence, tc.args.fee, tc.args.msgs, tc.args.memo)) + got := string(StdSignBytes(tc.args.chainID, tc.args.accnum, tc.args.sequence, tc.args.fee, tc.args.msgs, tc.args.memo, tc.args.feeAccount)) require.Equal(t, tc.want, got, "Got unexpected result on test case i: %d", i) } } @@ -124,7 +125,7 @@ func TestDefaultTxEncoder(t *testing.T) { fee := NewTestStdFee() sigs := []StdSignature{} - tx := NewStdTx(msgs, fee, sigs, "") + tx := NewStdTx(msgs, fee, sigs, "", nil) cdcBytes, err := cdc.MarshalBinaryLengthPrefixed(tx) diff --git a/x/auth/types/test_common.go b/x/auth/types/test_common.go index 9e2ba20e98d2..447ae77d1be3 100644 --- a/x/auth/types/test_common.go +++ b/x/auth/types/test_common.go @@ -35,7 +35,7 @@ func KeyTestPubAddr() (crypto.PrivKey, crypto.PubKey, sdk.AccAddress) { func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums []uint64, seqs []uint64, fee StdFee) sdk.Tx { sigs := make([]StdSignature, len(privs)) for i, priv := range privs { - signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], fee, msgs, "") + signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], fee, msgs, "", nil) sig, err := priv.Sign(signBytes) if err != nil { @@ -45,14 +45,14 @@ func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums sigs[i] = StdSignature{PubKey: priv.PubKey(), Signature: sig} } - tx := NewStdTx(msgs, fee, sigs, "") + tx := NewStdTx(msgs, fee, sigs, "", nil) return tx } func NewTestTxWithMemo(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums []uint64, seqs []uint64, fee StdFee, memo string) sdk.Tx { sigs := make([]StdSignature, len(privs)) for i, priv := range privs { - signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], fee, msgs, memo) + signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], fee, msgs, memo, nil) sig, err := priv.Sign(signBytes) if err != nil { @@ -62,7 +62,24 @@ func NewTestTxWithMemo(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, sigs[i] = StdSignature{PubKey: priv.PubKey(), Signature: sig} } - tx := NewStdTx(msgs, fee, sigs, memo) + tx := NewStdTx(msgs, fee, sigs, memo, nil) + return tx +} + +func NewTestTxWithFeeAccount(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums []uint64, seqs []uint64, fee StdFee, feeAccount sdk.AccAddress) sdk.Tx { + sigs := make([]StdSignature, len(privs)) + for i, priv := range privs { + signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], fee, msgs, "", feeAccount) + + sig, err := priv.Sign(signBytes) + if err != nil { + panic(err) + } + + sigs[i] = StdSignature{PubKey: priv.PubKey(), Signature: sig} + } + + tx := NewStdTx(msgs, fee, sigs, "", feeAccount) return tx } @@ -77,6 +94,6 @@ func NewTestTxWithSignBytes(msgs []sdk.Msg, privs []crypto.PrivKey, accNums []ui sigs[i] = StdSignature{PubKey: priv.PubKey(), Signature: sig} } - tx := NewStdTx(msgs, fee, sigs, memo) + tx := NewStdTx(msgs, fee, sigs, memo, nil) return tx } diff --git a/x/auth/types/txbuilder.go b/x/auth/types/txbuilder.go index 7d60086a137d..d2852a98e564 100644 --- a/x/auth/types/txbuilder.go +++ b/x/auth/types/txbuilder.go @@ -24,6 +24,7 @@ type TxBuilder struct { simulateAndExecute bool chainID string memo string + feeAccount sdk.AccAddress fees sdk.Coins gasPrices sdk.DecCoins } @@ -31,7 +32,7 @@ type TxBuilder struct { // NewTxBuilder returns a new initialized TxBuilder. func NewTxBuilder( txEncoder sdk.TxEncoder, accNumber, seq, gas uint64, gasAdj float64, - simulateAndExecute bool, chainID, memo string, fees sdk.Coins, gasPrices sdk.DecCoins, + simulateAndExecute bool, chainID, memo string, feeAccount sdk.AccAddress, fees sdk.Coins, gasPrices sdk.DecCoins, ) TxBuilder { return TxBuilder{ @@ -44,6 +45,7 @@ func NewTxBuilder( simulateAndExecute: simulateAndExecute, chainID: chainID, memo: memo, + feeAccount: feeAccount, fees: fees, gasPrices: gasPrices, } @@ -101,6 +103,9 @@ func (bldr TxBuilder) ChainID() string { return bldr.chainID } // Memo returns the memo message func (bldr TxBuilder) Memo() string { return bldr.memo } +// FeeAccount returns an alternate account to pay fees +func (bldr *TxBuilder) FeeAccount() sdk.AccAddress { return bldr.feeAccount } + // Fees returns the fees for the transaction func (bldr TxBuilder) Fees() sdk.Coins { return bldr.fees } @@ -125,6 +130,12 @@ func (bldr TxBuilder) WithGas(gas uint64) TxBuilder { return bldr } +// WithFeeAccount returns a copy of the context with an updated FeeAccount. +func (bldr TxBuilder) WithFeeAccount(feeAccount sdk.AccAddress) TxBuilder { + bldr.feeAccount = feeAccount + return bldr +} + // WithFees returns a copy of the context with an updated fee. func (bldr TxBuilder) WithFees(fees string) TxBuilder { parsedFees, err := sdk.ParseCoins(fees) @@ -201,6 +212,7 @@ func (bldr TxBuilder) BuildSignMsg(msgs []sdk.Msg) (StdSignMsg, error) { AccountNumber: bldr.accountNumber, Sequence: bldr.sequence, Memo: bldr.memo, + FeeAccount: bldr.feeAccount, Msgs: msgs, Fee: NewStdFee(bldr.gas, fees), }, nil @@ -214,7 +226,7 @@ func (bldr TxBuilder) Sign(name, passphrase string, msg StdSignMsg) ([]byte, err return nil, err } - return bldr.txEncoder(NewStdTx(msg.Msgs, msg.Fee, []StdSignature{sig}, msg.Memo)) + return bldr.txEncoder(NewStdTx(msg.Msgs, msg.Fee, []StdSignature{sig}, msg.Memo, msg.FeeAccount)) } // BuildAndSign builds a single message to be signed, and signs a transaction @@ -238,7 +250,7 @@ func (bldr TxBuilder) BuildTxForSim(msgs []sdk.Msg) ([]byte, error) { // the ante handler will populate with a sentinel pubkey sigs := []StdSignature{{}} - return bldr.txEncoder(NewStdTx(signMsg.Msgs, signMsg.Fee, sigs, signMsg.Memo)) + return bldr.txEncoder(NewStdTx(signMsg.Msgs, signMsg.Fee, sigs, signMsg.Memo, signMsg.FeeAccount)) } // SignStdTx appends a signature to a StdTx and returns a copy of it. If append @@ -255,6 +267,7 @@ func (bldr TxBuilder) SignStdTx(name, passphrase string, stdTx StdTx, appendSig Fee: stdTx.Fee, Msgs: stdTx.GetMsgs(), Memo: stdTx.GetMemo(), + FeeAccount: stdTx.FeeAccount, }) if err != nil { return @@ -266,7 +279,7 @@ func (bldr TxBuilder) SignStdTx(name, passphrase string, stdTx StdTx, appendSig } else { sigs = append(sigs, stdSignature) } - signedStdTx = NewStdTx(stdTx.GetMsgs(), stdTx.Fee, sigs, stdTx.GetMemo()) + signedStdTx = NewStdTx(stdTx.GetMsgs(), stdTx.Fee, sigs, stdTx.GetMemo(), bldr.feeAccount) return } diff --git a/x/auth/types/txbuilder_test.go b/x/auth/types/txbuilder_test.go index 063401c8a4ba..8d87c502ba0c 100644 --- a/x/auth/types/txbuilder_test.go +++ b/x/auth/types/txbuilder_test.go @@ -20,6 +20,7 @@ func TestTxBuilderBuild(t *testing.T) { SimulateGas bool ChainID string Memo string + FeeAccount sdk.AccAddress Fees sdk.Coins GasPrices sdk.DecCoins } @@ -135,7 +136,8 @@ func TestTxBuilderBuild(t *testing.T) { bldr := NewTxBuilder( tt.fields.TxEncoder, tt.fields.AccountNumber, tt.fields.Sequence, tt.fields.Gas, tt.fields.GasAdjustment, tt.fields.SimulateGas, - tt.fields.ChainID, tt.fields.Memo, tt.fields.Fees, tt.fields.GasPrices, + tt.fields.ChainID, tt.fields.Memo, tt.fields.FeeAccount, + tt.fields.Fees, tt.fields.GasPrices, ) got, err := bldr.BuildSignMsg(tt.msgs) require.Equal(t, tt.wantErr, (err != nil)) From 7e82fb88f1ac76165583f87f8dd2325d9fbb9f49 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 16 Oct 2019 19:12:20 +0200 Subject: [PATCH 015/184] Fix all tests in x/auth --- simapp/test_helpers.go | 4 ++-- types/rest/rest.go | 21 +++++++++++---------- x/auth/ante/ante_test.go | 2 +- x/auth/client/cli/tx_multisign.go | 4 ++-- x/auth/client/cli/tx_sign.go | 2 +- x/auth/client/utils/rest.go | 4 ++-- x/auth/client/utils/tx.go | 2 +- x/auth/client/utils/tx_test.go | 8 ++++++-- x/mock/app.go | 4 ++-- 9 files changed, 28 insertions(+), 23 deletions(-) diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index c108d9f9f5e1..9166d55e1b98 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -120,7 +120,7 @@ func GenTx(msgs []sdk.Msg, accnums []uint64, seq []uint64, priv ...crypto.PrivKe for i, p := range priv { // use a empty chainID for ease of testing - sig, err := p.Sign(auth.StdSignBytes("", accnums[i], seq[i], fee, msgs, memo)) + sig, err := p.Sign(auth.StdSignBytes("", accnums[i], seq[i], fee, msgs, memo, nil)) if err != nil { panic(err) } @@ -131,7 +131,7 @@ func GenTx(msgs []sdk.Msg, accnums []uint64, seq []uint64, priv ...crypto.PrivKe } } - return auth.NewStdTx(msgs, fee, sigs, memo) + return auth.NewStdTx(msgs, fee, sigs, memo, nil) } // SignCheckDeliver checks a generated signed transaction and simulates a diff --git a/types/rest/rest.go b/types/rest/rest.go index 89770c944650..7a9048522177 100644 --- a/types/rest/rest.go +++ b/types/rest/rest.go @@ -47,16 +47,17 @@ type GasEstimateResponse struct { // BaseReq defines a structure that can be embedded in other request structures // that all share common "base" fields. type BaseReq struct { - From string `json:"from"` - Memo string `json:"memo"` - ChainID string `json:"chain_id"` - AccountNumber uint64 `json:"account_number"` - Sequence uint64 `json:"sequence"` - Fees sdk.Coins `json:"fees"` - GasPrices sdk.DecCoins `json:"gas_prices"` - Gas string `json:"gas"` - GasAdjustment string `json:"gas_adjustment"` - Simulate bool `json:"simulate"` + From string `json:"from"` + Memo string `json:"memo"` + ChainID string `json:"chain_id"` + AccountNumber uint64 `json:"account_number"` + Sequence uint64 `json:"sequence"` + Fees sdk.Coins `json:"fees"` + FeeAccount sdk.AccAddress `json:"fee_account"` + GasPrices sdk.DecCoins `json:"gas_prices"` + Gas string `json:"gas"` + GasAdjustment string `json:"gas_adjustment"` + Simulate bool `json:"simulate"` } // NewBaseReq creates a new basic request instance and sanitizes its values diff --git a/x/auth/ante/ante_test.go b/x/auth/ante/ante_test.go index 60fe2149cd62..c74b2c223d5c 100644 --- a/x/auth/ante/ante_test.go +++ b/x/auth/ante/ante_test.go @@ -513,7 +513,7 @@ func TestAnteHandlerBadSignBytes(t *testing.T) { for _, cs := range cases { tx := types.NewTestTxWithSignBytes( msgs, privs, accnums, seqs, fee, - types.StdSignBytes(cs.chainID, cs.accnum, cs.seq, cs.fee, cs.msgs, ""), + types.StdSignBytes(cs.chainID, cs.accnum, cs.seq, cs.fee, cs.msgs, "", nil), "", ) checkInvalidTx(t, anteHandler, ctx, tx, false, cs.code) diff --git a/x/auth/client/cli/tx_multisign.go b/x/auth/client/cli/tx_multisign.go index e6d958a5d9cd..ae020f7fcb54 100644 --- a/x/auth/client/cli/tx_multisign.go +++ b/x/auth/client/cli/tx_multisign.go @@ -102,7 +102,7 @@ func makeMultiSignCmd(cdc *codec.Codec) func(cmd *cobra.Command, args []string) // Validate each signature sigBytes := types.StdSignBytes( txBldr.ChainID(), txBldr.AccountNumber(), txBldr.Sequence(), - stdTx.Fee, stdTx.GetMsgs(), stdTx.GetMemo(), + stdTx.Fee, stdTx.GetMsgs(), stdTx.GetMemo(), stdTx.FeeAccount, ) if ok := stdSig.PubKey.VerifyBytes(sigBytes, stdSig.Signature); !ok { return fmt.Errorf("couldn't verify signature") @@ -113,7 +113,7 @@ func makeMultiSignCmd(cdc *codec.Codec) func(cmd *cobra.Command, args []string) } newStdSig := types.StdSignature{Signature: cdc.MustMarshalBinaryBare(multisigSig), PubKey: multisigPub} - newTx := types.NewStdTx(stdTx.GetMsgs(), stdTx.Fee, []types.StdSignature{newStdSig}, stdTx.GetMemo()) + newTx := types.NewStdTx(stdTx.GetMsgs(), stdTx.Fee, []types.StdSignature{newStdSig}, stdTx.GetMemo(), stdTx.GetFeeAccount()) sigOnly := viper.GetBool(flagSigOnly) var json []byte diff --git a/x/auth/client/cli/tx_sign.go b/x/auth/client/cli/tx_sign.go index d4af880d3e91..b5fb15031038 100644 --- a/x/auth/client/cli/tx_sign.go +++ b/x/auth/client/cli/tx_sign.go @@ -230,7 +230,7 @@ func printAndValidateSigs( sigBytes := types.StdSignBytes( chainID, acc.GetAccountNumber(), acc.GetSequence(), - stdTx.Fee, stdTx.GetMsgs(), stdTx.GetMemo(), + stdTx.Fee, stdTx.GetMsgs(), stdTx.GetMemo(), stdTx.GetFeeAccount(), ) if ok := sig.VerifyBytes(sigBytes, sig.Signature); !ok { diff --git a/x/auth/client/utils/rest.go b/x/auth/client/utils/rest.go index 9423fe629ee4..dce53f67d8c3 100644 --- a/x/auth/client/utils/rest.go +++ b/x/auth/client/utils/rest.go @@ -26,7 +26,7 @@ func WriteGenerateStdTxResponse(w http.ResponseWriter, cliCtx context.CLIContext txBldr := types.NewTxBuilder( GetTxEncoder(cliCtx.Codec), br.AccountNumber, br.Sequence, gas, gasAdj, - br.Simulate, br.ChainID, br.Memo, br.Fees, br.GasPrices, + br.Simulate, br.ChainID, br.Memo, br.FeeAccount, br.Fees, br.GasPrices, ) if br.Simulate || simAndExec { @@ -53,7 +53,7 @@ func WriteGenerateStdTxResponse(w http.ResponseWriter, cliCtx context.CLIContext return } - output, err := cliCtx.Codec.MarshalJSON(types.NewStdTx(stdMsg.Msgs, stdMsg.Fee, nil, stdMsg.Memo)) + output, err := cliCtx.Codec.MarshalJSON(types.NewStdTx(stdMsg.Msgs, stdMsg.Fee, nil, stdMsg.Memo, stdMsg.FeeAccount)) if err != nil { rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) return diff --git a/x/auth/client/utils/tx.go b/x/auth/client/utils/tx.go index d2212a039ad4..a94b96717162 100644 --- a/x/auth/client/utils/tx.go +++ b/x/auth/client/utils/tx.go @@ -349,7 +349,7 @@ func buildUnsignedStdTxOffline(txBldr authtypes.TxBuilder, cliCtx context.CLICon return stdTx, nil } - return authtypes.NewStdTx(stdSignMsg.Msgs, stdSignMsg.Fee, nil, stdSignMsg.Memo), nil + return authtypes.NewStdTx(stdSignMsg.Msgs, stdSignMsg.Fee, nil, stdSignMsg.Memo, stdSignMsg.FeeAccount), nil } func isTxSigner(user sdk.AccAddress, signers []sdk.AccAddress) bool { diff --git a/x/auth/client/utils/tx_test.go b/x/auth/client/utils/tx_test.go index 3ae79f7bdc6f..4274abf78df0 100644 --- a/x/auth/client/utils/tx_test.go +++ b/x/auth/client/utils/tx_test.go @@ -98,7 +98,9 @@ func TestReadStdTxFromFile(t *testing.T) { // Build a test transaction fee := authtypes.NewStdFee(50000, sdk.Coins{sdk.NewInt64Coin("atom", 150)}) - stdTx := authtypes.NewStdTx([]sdk.Msg{}, fee, []authtypes.StdSignature{}, "foomemo") + feeAccount, err := sdk.AccAddressFromBech32("cosmos1zxcxurm8gwp43n4efqms6484gkdnnq763w03t6") + require.NoError(t, err) + stdTx := authtypes.NewStdTx([]sdk.Msg{}, fee, []authtypes.StdSignature{}, "foomemo", feeAccount) // Write it to the file encodedTx, _ := cdc.MarshalJSON(stdTx) @@ -109,11 +111,13 @@ func TestReadStdTxFromFile(t *testing.T) { decodedTx, err := ReadStdTxFromFile(cdc, jsonTxFile.Name()) require.NoError(t, err) require.Equal(t, decodedTx.Memo, "foomemo") + require.Equal(t, decodedTx.FeeAccount, feeAccount) + require.Equal(t, decodedTx.Fee, fee) } func compareEncoders(t *testing.T, expected sdk.TxEncoder, actual sdk.TxEncoder) { msgs := []sdk.Msg{sdk.NewTestMsg(addr)} - tx := authtypes.NewStdTx(msgs, authtypes.StdFee{}, []authtypes.StdSignature{}, "") + tx := authtypes.NewStdTx(msgs, authtypes.StdFee{}, []authtypes.StdSignature{}, "", nil) defaultEncoderBytes, err := expected(tx) require.NoError(t, err) diff --git a/x/mock/app.go b/x/mock/app.go index 1e59e050507b..04e4230ee411 100644 --- a/x/mock/app.go +++ b/x/mock/app.go @@ -217,7 +217,7 @@ func GenTx(msgs []sdk.Msg, accnums []uint64, seq []uint64, priv ...crypto.PrivKe memo := "testmemotestmemo" for i, p := range priv { - sig, err := p.Sign(auth.StdSignBytes(chainID, accnums[i], seq[i], fee, msgs, memo)) + sig, err := p.Sign(auth.StdSignBytes(chainID, accnums[i], seq[i], fee, msgs, memo, nil)) if err != nil { panic(err) } @@ -228,7 +228,7 @@ func GenTx(msgs []sdk.Msg, accnums []uint64, seq []uint64, priv ...crypto.PrivKe } } - return auth.NewStdTx(msgs, fee, sigs, memo) + return auth.NewStdTx(msgs, fee, sigs, memo, nil) } // GeneratePrivKeys generates a total n secp256k1 private keys. From 64d5159089b2a1c4192eeb1d8f99f5d3ee9afbf1 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 16 Oct 2019 19:15:01 +0200 Subject: [PATCH 016/184] All tests pass --- x/distribution/client/cli/tx_test.go | 1 + x/genutil/types/genesis_state_test.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/x/distribution/client/cli/tx_test.go b/x/distribution/client/cli/tx_test.go index af09d5445a89..51ae03488d8b 100644 --- a/x/distribution/client/cli/tx_test.go +++ b/x/distribution/client/cli/tx_test.go @@ -24,6 +24,7 @@ func createFakeTxBuilder() auth.TxBuilder { false, "test_chain", "hello", + nil, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1))), sdk.DecCoins{sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, sdk.NewDecWithPrec(10000, sdk.Precision))}, ) diff --git a/x/genutil/types/genesis_state_test.go b/x/genutil/types/genesis_state_test.go index aed7cd7f311e..1f9ebf67a1e5 100644 --- a/x/genutil/types/genesis_state_test.go +++ b/x/genutil/types/genesis_state_test.go @@ -27,7 +27,7 @@ func TestValidateGenesisMultipleMessages(t *testing.T) { msg2 := stakingtypes.NewMsgCreateValidator(sdk.ValAddress(pk2.Address()), pk2, sdk.NewInt64Coin(sdk.DefaultBondDenom, 50), desc, comm, sdk.OneInt()) - genTxs := authtypes.NewStdTx([]sdk.Msg{msg1, msg2}, authtypes.StdFee{}, nil, "") + genTxs := authtypes.NewStdTx([]sdk.Msg{msg1, msg2}, authtypes.StdFee{}, nil, "", nil) genesisState := NewGenesisStateFromStdTx([]authtypes.StdTx{genTxs}) err := ValidateGenesis(genesisState) @@ -39,7 +39,7 @@ func TestValidateGenesisBadMessage(t *testing.T) { msg1 := stakingtypes.NewMsgEditValidator(sdk.ValAddress(pk1.Address()), desc, nil, nil) - genTxs := authtypes.NewStdTx([]sdk.Msg{msg1}, authtypes.StdFee{}, nil, "") + genTxs := authtypes.NewStdTx([]sdk.Msg{msg1}, authtypes.StdFee{}, nil, "", nil) genesisState := NewGenesisStateFromStdTx([]authtypes.StdTx{genTxs}) err := ValidateGenesis(genesisState) From 8b2b64b51156c010bd2bb8c888d777af7b39532b Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 16 Oct 2019 19:20:45 +0200 Subject: [PATCH 017/184] Appease the Golang Linter --- x/delegation/handler.go | 2 +- x/delegation/internal/keeper/keeper.go | 4 ++-- x/delegation/internal/types/basic_fee_test.go | 4 ++-- x/delegation/internal/types/expiration.go | 2 +- x/delegation/internal/types/key.go | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/x/delegation/handler.go b/x/delegation/handler.go index 070673fceb3a..367eb7b21523 100644 --- a/x/delegation/handler.go +++ b/x/delegation/handler.go @@ -10,7 +10,7 @@ func NewHandler(k Keeper) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) sdk.Result { switch msg := msg.(type) { case MsgDelegateFeeAllowance: - grant := FeeAllowanceGrant{Granter: msg.Granter, Grantee: msg.Grantee, Allowance: msg.Allowance} + grant := FeeAllowanceGrant(msg) k.DelegateFeeAllowance(ctx, grant) return sdk.Result{} case MsgRevokeFeeAllowance: diff --git a/x/delegation/internal/keeper/keeper.go b/x/delegation/internal/keeper/keeper.go index 9654c28c24e0..2546b6af7b68 100644 --- a/x/delegation/internal/keeper/keeper.go +++ b/x/delegation/internal/keeper/keeper.go @@ -92,7 +92,7 @@ func (k Keeper) GetAllFeeAllowances(ctx sdk.Context, grantee sdk.AccAddress) ([] func (k Keeper) UseDelegatedFees(ctx sdk.Context, granter sdk.AccAddress, grantee sdk.AccAddress, fee sdk.Coins) bool { grant, err := k.GetFeeGrant(ctx, granter, grantee) if err != nil { - // we should acknowlegde a db issue somehow (better?) + // we should acknowledge a db issue somehow (better?) ctx.Logger().Error(err.Error()) return false } @@ -108,7 +108,7 @@ func (k Keeper) UseDelegatedFees(ctx sdk.Context, granter sdk.AccAddress, grante // if we accepted, store the updated state of the allowance if err := k.DelegateFeeAllowance(ctx, *grant); err != nil { - // we should acknowlegde a db issue somehow (better?) + // we should acknowledge a db issue somehow (better?) ctx.Logger().Error(err.Error()) return false } diff --git a/x/delegation/internal/types/basic_fee_test.go b/x/delegation/internal/types/basic_fee_test.go index 4e7c0e726dc3..857153d05cc7 100644 --- a/x/delegation/internal/types/basic_fee_test.go +++ b/x/delegation/internal/types/basic_fee_test.go @@ -17,11 +17,11 @@ func TestBasicFeeValidAllow(t *testing.T) { cases := map[string]struct { allow BasicFeeAllowance - valid bool - // all below checks are ignored if invalid + // all other checks are ignored if valid=false fee sdk.Coins blockTime time.Time blockHeight int64 + valid bool accept bool remove bool remains sdk.Coins diff --git a/x/delegation/internal/types/expiration.go b/x/delegation/internal/types/expiration.go index f82af4d84721..09ae0ec449ad 100644 --- a/x/delegation/internal/types/expiration.go +++ b/x/delegation/internal/types/expiration.go @@ -66,7 +66,7 @@ func (e *ExpiresAt) Step(p Period) error { if !e.Time.IsZero() { e.Time = e.Time.Add(p.Clock) } else { - e.Height = e.Height + p.Block + e.Height += p.Block } return nil } diff --git a/x/delegation/internal/types/key.go b/x/delegation/internal/types/key.go index 6e5987fa08b7..88b2901326c0 100644 --- a/x/delegation/internal/types/key.go +++ b/x/delegation/internal/types/key.go @@ -25,7 +25,7 @@ var ( FeeAllowanceKeyPrefix = []byte{0x00} ) -// FeeAllowanceKey is the cannonical key to store a grant from granter to grantee +// FeeAllowanceKey is the canonical key to store a grant from granter to grantee // We store by grantee first to allow searching by everyone who granted to you func FeeAllowanceKey(granter sdk.AccAddress, grantee sdk.AccAddress) []byte { return append(FeeAllowanceKeyPrefix, []byte(fmt.Sprintf("%s/%s", grantee, granter))...) From be12b4464dc9bc40bfdb33681b2a5a19ffce41d2 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 16 Oct 2019 19:25:57 +0200 Subject: [PATCH 018/184] Add fee-account command line flag --- client/flags/flags.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/flags/flags.go b/client/flags/flags.go index 62f2a8d012f9..774b3ccd8c95 100644 --- a/client/flags/flags.go +++ b/client/flags/flags.go @@ -54,6 +54,7 @@ const ( FlagRPCWriteTimeout = "write-timeout" FlagOutputDocument = "output-document" // inspired by wget -O FlagSkipConfirmation = "yes" + FlagFeeAccount = "fee-account" ) // LineBreak can be included in a command list to provide a blank line @@ -99,6 +100,7 @@ func PostCommands(cmds ...*cobra.Command) []*cobra.Command { c.Flags().Bool(FlagDryRun, false, "ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it") c.Flags().Bool(FlagGenerateOnly, false, "Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase is not accessible and the node operates offline)") c.Flags().BoolP(FlagSkipConfirmation, "y", false, "Skip tx broadcasting prompt confirmation") + c.Flags().String(FlagFeeAccount, "", "Set a fee account to pay fess with if they have been delegated by this account") // --gas can accept integers and "simulate" c.Flags().Var(&GasFlagVar, "gas", fmt.Sprintf( From c703e599fb5ded3f0650e57761744a17029699df Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 17 Oct 2019 11:46:00 +0200 Subject: [PATCH 019/184] Start on DelegatedDeductFeeDecorator --- x/delegation/internal/ante/fee.go | 81 ++++++++++++++++++++++++++ x/delegation/internal/ante/fee_test.go | 1 + 2 files changed, 82 insertions(+) create mode 100644 x/delegation/internal/ante/fee.go create mode 100644 x/delegation/internal/ante/fee_test.go diff --git a/x/delegation/internal/ante/fee.go b/x/delegation/internal/ante/fee.go new file mode 100644 index 000000000000..6f323de698a0 --- /dev/null +++ b/x/delegation/internal/ante/fee.go @@ -0,0 +1,81 @@ +package ante + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + // we depend on the auth module internals... maybe some more of this can be exported? + // but things like `x/auth/types/FeeCollectorName` are quite clearly tied to it + authAnte "github.com/cosmos/cosmos-sdk/x/auth/ante" + authKeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/delegation/internal/keeper" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +var ( + _ DelegatedFeeTx = (*authTypes.StdTx)(nil) // assert StdTx implements DelegatedFeeTx +) + +// DelegatedFeeTx defines the interface to be implemented by Tx to use the DelegatedFeeDecorator +type DelegatedFeeTx interface { + authAnte.FeeTx + GetFeeAccount() sdk.AccAddress +} + +// DeductDelegatedFeeDecorator deducts fees from the first signer of the tx +// If the first signer does not have the funds to pay for the fees, return with InsufficientFunds error +// Call next AnteHandler if fees successfully deducted +// CONTRACT: Tx must implement DelegatedFeeTx interface to use DeductDelegatedFeeDecorator +type DeductDelegatedFeeDecorator struct { + base authAnte.DeductFeeDecorator + ak authKeeper.AccountKeeper + dk keeper.Keeper + sk authTypes.SupplyKeeper +} + +func NewDeductDelegatedFeeDecorator(ak authKeeper.AccountKeeper, sk authTypes.SupplyKeeper, dk keeper.Keeper) DeductDelegatedFeeDecorator { + return DeductDelegatedFeeDecorator{ + base: authAnte.NewDeductFeeDecorator(ak, sk), + ak: ak, + dk: dk, + sk: sk, + } +} + +func (d DeductDelegatedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { + // make sure there is a delegation, if not, default to the standard DeductFeeDecorator behavior + var granter sdk.AccAddress + delTx, ok := tx.(DelegatedFeeTx) + if ok { + granter = delTx.GetFeeAccount() + } + if granter == nil { + // just defer to the basic DeductFeeHandler + return d.base.AnteHandle(ctx, tx, simulate, next) + } + + // short-circuit on zero fee + fee := delTx.GetFee() + if fee.IsZero() { + return next(ctx, tx, simulate) + } + + // ensure the delegation is allowed + grantee := delTx.FeePayer() + allowed := d.dk.UseDelegatedFees(ctx, granter, grantee, fee) + if !allowed { + return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s not allowed to pay fees from %s", grantee, granter) + } + + // now deduct fees from the granter + feePayerAcc := d.ak.GetAccount(ctx, granter) + if feePayerAcc == nil { + return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "granter address: %s does not exist", granter) + } + err = authAnte.DeductFees(d.sk, ctx, feePayerAcc, fee) + if err != nil { + return ctx, err + } + return next(ctx, tx, simulate) +} diff --git a/x/delegation/internal/ante/fee_test.go b/x/delegation/internal/ante/fee_test.go new file mode 100644 index 000000000000..dfb29020286b --- /dev/null +++ b/x/delegation/internal/ante/fee_test.go @@ -0,0 +1 @@ +package ante \ No newline at end of file From 907776f3353565b761fa80895a693aff9b380baf Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 17 Oct 2019 11:53:52 +0200 Subject: [PATCH 020/184] Cleanup the Decorator --- x/delegation/internal/ante/fee.go | 61 ++++++++++++++++++------------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/x/delegation/internal/ante/fee.go b/x/delegation/internal/ante/fee.go index 6f323de698a0..c1f988e4094c 100644 --- a/x/delegation/internal/ante/fee.go +++ b/x/delegation/internal/ante/fee.go @@ -1,6 +1,8 @@ package ante import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" // we depend on the auth module internals... maybe some more of this can be exported? @@ -28,50 +30,57 @@ type DelegatedFeeTx interface { // Call next AnteHandler if fees successfully deducted // CONTRACT: Tx must implement DelegatedFeeTx interface to use DeductDelegatedFeeDecorator type DeductDelegatedFeeDecorator struct { - base authAnte.DeductFeeDecorator - ak authKeeper.AccountKeeper - dk keeper.Keeper - sk authTypes.SupplyKeeper + ak authKeeper.AccountKeeper + dk keeper.Keeper + sk authTypes.SupplyKeeper } func NewDeductDelegatedFeeDecorator(ak authKeeper.AccountKeeper, sk authTypes.SupplyKeeper, dk keeper.Keeper) DeductDelegatedFeeDecorator { return DeductDelegatedFeeDecorator{ - base: authAnte.NewDeductFeeDecorator(ak, sk), - ak: ak, - dk: dk, - sk: sk, + ak: ak, + dk: dk, + sk: sk, } } func (d DeductDelegatedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { - // make sure there is a delegation, if not, default to the standard DeductFeeDecorator behavior - var granter sdk.AccAddress - delTx, ok := tx.(DelegatedFeeTx) - if ok { - granter = delTx.GetFeeAccount() - } - if granter == nil { - // just defer to the basic DeductFeeHandler - return d.base.AnteHandle(ctx, tx, simulate, next) + feeTx, ok := tx.(authAnte.FeeTx) + if !ok { + return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") } // short-circuit on zero fee - fee := delTx.GetFee() + fee := feeTx.GetFee() if fee.IsZero() { return next(ctx, tx, simulate) } + // sanity check from DeductFeeDecorator + if addr := d.sk.GetModuleAddress(authTypes.FeeCollectorName); addr == nil { + panic(fmt.Sprintf("%s module account has not been set", authTypes.FeeCollectorName)) + } + + // see if there is a delegation + var feePayer sdk.AccAddress + if delTx, ok := tx.(DelegatedFeeTx); ok { + feePayer = delTx.GetFeeAccount() + } - // ensure the delegation is allowed - grantee := delTx.FeePayer() - allowed := d.dk.UseDelegatedFees(ctx, granter, grantee, fee) - if !allowed { - return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s not allowed to pay fees from %s", grantee, granter) + txSigner := feeTx.FeePayer() + if feePayer == nil { + // if this is not explicitly set, use the first signer as always + feePayer = txSigner + } else { + // ensure the delegation is allowed + allowed := d.dk.UseDelegatedFees(ctx, feePayer, txSigner, fee) + if !allowed { + return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s not allowed to pay fees from %s", txSigner, feePayer) + } } - // now deduct fees from the granter - feePayerAcc := d.ak.GetAccount(ctx, granter) + // now, either way, we know that we are authorized to deduct the fees from the feePayer account + feePayerAcc := d.ak.GetAccount(ctx, feePayer) if feePayerAcc == nil { - return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "granter address: %s does not exist", granter) + return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "fee payer address: %s does not exist", feePayer) } err = authAnte.DeductFees(d.sk, ctx, feePayerAcc, fee) if err != nil { From 005afd96e8e1858c5506be2d0cfe0a904124641b Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 17 Oct 2019 12:09:48 +0200 Subject: [PATCH 021/184] Wire up delegation module in simapp --- simapp/app.go | 27 ++++++++++++++++----------- x/delegation/module.go | 5 +++-- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index 32501acebad8..ac0ac5c07331 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -18,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/vesting" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/crisis" + "github.com/cosmos/cosmos-sdk/x/delegation" distr "github.com/cosmos/cosmos-sdk/x/distribution" "github.com/cosmos/cosmos-sdk/x/genutil" "github.com/cosmos/cosmos-sdk/x/gov" @@ -90,16 +91,17 @@ type SimApp struct { tkeys map[string]*sdk.TransientStoreKey // keepers - AccountKeeper auth.AccountKeeper - BankKeeper bank.Keeper - SupplyKeeper supply.Keeper - StakingKeeper staking.Keeper - SlashingKeeper slashing.Keeper - MintKeeper mint.Keeper - DistrKeeper distr.Keeper - GovKeeper gov.Keeper - CrisisKeeper crisis.Keeper - ParamsKeeper params.Keeper + AccountKeeper auth.AccountKeeper + BankKeeper bank.Keeper + SupplyKeeper supply.Keeper + StakingKeeper staking.Keeper + SlashingKeeper slashing.Keeper + MintKeeper mint.Keeper + DistrKeeper distr.Keeper + GovKeeper gov.Keeper + CrisisKeeper crisis.Keeper + DelegationKeeper delegation.Keeper + ParamsKeeper params.Keeper // the module manager mm *module.Manager @@ -156,6 +158,7 @@ func NewSimApp( app.SlashingKeeper = slashing.NewKeeper(app.cdc, keys[slashing.StoreKey], &stakingKeeper, slashingSubspace, slashing.DefaultCodespace) app.CrisisKeeper = crisis.NewKeeper(crisisSubspace, invCheckPeriod, app.SupplyKeeper, auth.FeeCollectorName) + app.DelegationKeeper = delegation.NewKeeper(app.cdc, keys[delegation.StoreKey]) // register the proposal types govRouter := gov.NewRouter() @@ -184,6 +187,7 @@ func NewSimApp( distr.NewAppModule(app.DistrKeeper, app.SupplyKeeper), slashing.NewAppModule(app.SlashingKeeper, app.StakingKeeper), staking.NewAppModule(app.StakingKeeper, app.AccountKeeper, app.SupplyKeeper), + delegation.NewAppModule(app.DelegationKeeper), ) // During begin block slashing happens after distr.BeginBlocker so that @@ -199,7 +203,7 @@ func NewSimApp( auth.ModuleName, distr.ModuleName, staking.ModuleName, bank.ModuleName, slashing.ModuleName, gov.ModuleName, mint.ModuleName, supply.ModuleName, crisis.ModuleName, - genutil.ModuleName, + genutil.ModuleName, delegation.ModuleName, ) app.mm.RegisterInvariants(&app.CrisisKeeper) @@ -218,6 +222,7 @@ func NewSimApp( distr.NewAppModule(app.DistrKeeper, app.SupplyKeeper), staking.NewAppModule(app.StakingKeeper, app.AccountKeeper, app.SupplyKeeper), slashing.NewAppModule(app.SlashingKeeper, app.StakingKeeper), + // delegation.NewAppModule(app.DelegationKeeper), ) app.sm.RegisterStoreDecoders() diff --git a/x/delegation/module.go b/x/delegation/module.go index 04adfb0f7e9b..a3c09da29f8e 100644 --- a/x/delegation/module.go +++ b/x/delegation/module.go @@ -42,7 +42,7 @@ func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { // DefaultGenesis returns default genesis state as raw bytes for the delegation // module. func (AppModuleBasic) DefaultGenesis() json.RawMessage { - panic("not implemented!") + return []byte("{}") // return ModuleCdc.MustMarshalJSON(DefaultGenesisState()) } @@ -137,7 +137,8 @@ func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.Va // ExportGenesis returns the exported genesis state as raw bytes for the delegation // module. func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { - panic("not implemented!") + // TODO + return []byte("{}") // gs := ExportGenesis(ctx, am.keeper) // return ModuleCdc.MustMarshalJSON(gs) } From 45c64d251d5e1bfece98d3df3952cab30e65c083 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 17 Oct 2019 12:10:24 +0200 Subject: [PATCH 022/184] add basic test for decorator (no delegation) --- x/delegation/internal/ante/fee_test.go | 63 ++++++++++++++++++++- x/delegation/internal/keeper/keeper.go | 6 +- x/delegation/internal/keeper/keeper_test.go | 2 +- 3 files changed, 66 insertions(+), 5 deletions(-) diff --git a/x/delegation/internal/ante/fee_test.go b/x/delegation/internal/ante/fee_test.go index dfb29020286b..e61941ff339c 100644 --- a/x/delegation/internal/ante/fee_test.go +++ b/x/delegation/internal/ante/fee_test.go @@ -1 +1,62 @@ -package ante \ No newline at end of file +package ante_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + abci "github.com/tendermint/tendermint/abci/types" + "github.com/tendermint/tendermint/crypto" + + "github.com/cosmos/cosmos-sdk/simapp" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/delegation/internal/ante" + // delTypes "github.com/cosmos/cosmos-sdk/x/delegation/internal/types" +) + +func TestDeductFeesNoDelegation(t *testing.T) { + // setup + app, ctx := createTestApp(true) + + // keys and addresses + priv1, _, addr1 := authtypes.KeyTestPubAddr() + + // msg and signatures + msg1 := authtypes.NewTestMsg(addr1) + fee := authtypes.NewTestStdFee() + + msgs := []sdk.Msg{msg1} + + privs, accNums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} + tx := authtypes.NewTestTx(ctx, msgs, privs, accNums, seqs, fee) + + // Set account with insufficient funds + acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr1) + acc.SetCoins([]sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(10))}) + app.AccountKeeper.SetAccount(ctx, acc) + + dfd := ante.NewDeductDelegatedFeeDecorator(app.AccountKeeper, app.SupplyKeeper, app.DelegationKeeper) + antehandler := sdk.ChainAnteDecorators(dfd) + + _, err := antehandler(ctx, tx, false) + + require.NotNil(t, err, "Tx did not error when fee payer had insufficient funds") + + // Set account with sufficient funds + acc.SetCoins([]sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(200))}) + app.AccountKeeper.SetAccount(ctx, acc) + + _, err = antehandler(ctx, tx, false) + + require.Nil(t, err, "Tx errored after account has been set with sufficient funds") +} + +// returns context and app with params set on account keeper +func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { + app := simapp.Setup(isCheckTx) + ctx := app.BaseApp.NewContext(isCheckTx, abci.Header{}) + app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) + + return app, ctx +} diff --git a/x/delegation/internal/keeper/keeper.go b/x/delegation/internal/keeper/keeper.go index 2546b6af7b68..d0aac56c0726 100644 --- a/x/delegation/internal/keeper/keeper.go +++ b/x/delegation/internal/keeper/keeper.go @@ -8,13 +8,13 @@ import ( ) type Keeper struct { - storeKey sdk.StoreKey cdc *codec.Codec + storeKey sdk.StoreKey } // NewKeeper creates a DelegationKeeper -func NewKeeper(storeKey sdk.StoreKey, cdc *codec.Codec) Keeper { - return Keeper{storeKey, cdc} +func NewKeeper(cdc *codec.Codec, storeKey sdk.StoreKey) Keeper { + return Keeper{cdc: cdc, storeKey: storeKey} } // DelegateFeeAllowance creates a new grant diff --git a/x/delegation/internal/keeper/keeper_test.go b/x/delegation/internal/keeper/keeper_test.go index 649e0c639b28..617623ed3dd9 100644 --- a/x/delegation/internal/keeper/keeper_test.go +++ b/x/delegation/internal/keeper/keeper_test.go @@ -37,7 +37,7 @@ func setupTestInput() testInput { ms.MountStoreWithDB(delCapKey, sdk.StoreTypeIAVL, db) ms.LoadLatestVersion() - dk := keeper.NewKeeper(delCapKey, cdc) + dk := keeper.NewKeeper(cdc, delCapKey) ctx := sdk.NewContext(ms, abci.Header{ChainID: "test-chain-id", Time: time.Now().UTC(), Height: 1234}, false, log.NewNopLogger()) return testInput{cdc: cdc, ctx: ctx, dk: dk} From 87fd0ce345ddf38e0080ff86dcc99345d5a3a526 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 17 Oct 2019 12:53:31 +0200 Subject: [PATCH 023/184] Table tests for deduct fees --- x/delegation/internal/ante/fee_test.go | 104 ++++++++++++++++++------- 1 file changed, 75 insertions(+), 29 deletions(-) diff --git a/x/delegation/internal/ante/fee_test.go b/x/delegation/internal/ante/fee_test.go index e61941ff339c..000fac453f5a 100644 --- a/x/delegation/internal/ante/fee_test.go +++ b/x/delegation/internal/ante/fee_test.go @@ -18,38 +18,84 @@ import ( func TestDeductFeesNoDelegation(t *testing.T) { // setup app, ctx := createTestApp(true) - - // keys and addresses - priv1, _, addr1 := authtypes.KeyTestPubAddr() - - // msg and signatures - msg1 := authtypes.NewTestMsg(addr1) - fee := authtypes.NewTestStdFee() - - msgs := []sdk.Msg{msg1} - - privs, accNums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} - tx := authtypes.NewTestTx(ctx, msgs, privs, accNums, seqs, fee) - - // Set account with insufficient funds - acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr1) - acc.SetCoins([]sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(10))}) - app.AccountKeeper.SetAccount(ctx, acc) - dfd := ante.NewDeductDelegatedFeeDecorator(app.AccountKeeper, app.SupplyKeeper, app.DelegationKeeper) antehandler := sdk.ChainAnteDecorators(dfd) - _, err := antehandler(ctx, tx, false) - - require.NotNil(t, err, "Tx did not error when fee payer had insufficient funds") - - // Set account with sufficient funds - acc.SetCoins([]sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(200))}) - app.AccountKeeper.SetAccount(ctx, acc) - - _, err = antehandler(ctx, tx, false) - - require.Nil(t, err, "Tx errored after account has been set with sufficient funds") + // keys and addresses + priv1, _, addr1 := authtypes.KeyTestPubAddr() + priv2, _, addr2 := authtypes.KeyTestPubAddr() + priv3, _, addr3 := authtypes.KeyTestPubAddr() + priv4, _, addr4 := authtypes.KeyTestPubAddr() + + // Set addr1 with insufficient funds + acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1) + acc1.SetCoins([]sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(10))}) + app.AccountKeeper.SetAccount(ctx, acc1) + + // Set addr2 with more funds + acc2 := app.AccountKeeper.NewAccountWithAddress(ctx, addr2) + acc2.SetCoins([]sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(99999))}) + app.AccountKeeper.SetAccount(ctx, acc2) + + // Set delegation from addr2 to addr3 (plenty to pay) + + // Set delegation from addr1 to addr4 (insufficient funds) + + cases := map[string]struct { + signerKey crypto.PrivKey + signer sdk.AccAddress + feeAccount sdk.AccAddress + fee int64 + valid bool + }{ + "paying with low funds": { + signerKey: priv1, + signer: addr1, + fee: 50, + valid: false, + }, + "paying with good funds": { + signerKey: priv2, + signer: addr2, + fee: 50, + valid: true, + }, + "paying with no account": { + signerKey: priv3, + signer: addr3, + fee: 1, + valid: false, + }, + "no fee with real account": { + signerKey: priv1, + signer: addr1, + fee: 0, + valid: true, + }, + "no fee with no account": { + signerKey: priv4, + signer: addr4, + fee: 0, + valid: true, + }, + } + + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + // msg and signatures + fee := authtypes.NewStdFee(100000, sdk.NewCoins(sdk.NewInt64Coin("atom", tc.fee))) + msgs := []sdk.Msg{sdk.NewTestMsg(tc.signer)} + privs, accNums, seqs := []crypto.PrivKey{tc.signerKey}, []uint64{0}, []uint64{0} + tx := authtypes.NewTestTxWithFeeAccount(ctx, msgs, privs, accNums, seqs, fee, tc.feeAccount) + + _, err := antehandler(ctx, tx, false) + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } } // returns context and app with params set on account keeper From d03c65009f8d858b834ba164f0ab4159cc0c8cde Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 17 Oct 2019 13:04:36 +0200 Subject: [PATCH 024/184] Table tests over all conditions of delegated fee decorator --- simapp/app.go | 3 +- x/delegation/internal/ante/fee_test.go | 57 +++++++++++++++++++++++++- x/delegation/internal/keeper/keeper.go | 3 ++ 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index ac0ac5c07331..fc7895c3eec0 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -54,6 +54,7 @@ var ( params.AppModuleBasic{}, crisis.AppModuleBasic{}, slashing.AppModuleBasic{}, + delegation.AppModuleBasic{}, ) // module account permissions @@ -124,7 +125,7 @@ func NewSimApp( keys := sdk.NewKVStoreKeys(bam.MainStoreKey, auth.StoreKey, staking.StoreKey, supply.StoreKey, mint.StoreKey, distr.StoreKey, slashing.StoreKey, - gov.StoreKey, params.StoreKey) + gov.StoreKey, params.StoreKey, delegation.StoreKey) tkeys := sdk.NewTransientStoreKeys(params.TStoreKey) app := &SimApp{ diff --git a/x/delegation/internal/ante/fee_test.go b/x/delegation/internal/ante/fee_test.go index 000fac453f5a..7f89fc84b254 100644 --- a/x/delegation/internal/ante/fee_test.go +++ b/x/delegation/internal/ante/fee_test.go @@ -12,6 +12,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/delegation/internal/ante" + "github.com/cosmos/cosmos-sdk/x/delegation/internal/types" // delTypes "github.com/cosmos/cosmos-sdk/x/delegation/internal/types" ) @@ -38,8 +39,34 @@ func TestDeductFeesNoDelegation(t *testing.T) { app.AccountKeeper.SetAccount(ctx, acc2) // Set delegation from addr2 to addr3 (plenty to pay) + err := app.DelegationKeeper.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + Granter: addr2, + Grantee: addr3, + Allowance: &types.BasicFeeAllowance{ + SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 500)), + }, + }) + require.NoError(t, err) + + // Set low delegation from addr2 to addr4 (delegation will reject) + err = app.DelegationKeeper.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + Granter: addr2, + Grantee: addr4, + Allowance: &types.BasicFeeAllowance{ + SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 20)), + }, + }) + require.NoError(t, err) - // Set delegation from addr1 to addr4 (insufficient funds) + // Set delegation from addr1 to addr4 (cannot cover this ) + err = app.DelegationKeeper.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + Granter: addr2, + Grantee: addr3, + Allowance: &types.BasicFeeAllowance{ + SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 500)), + }, + }) + require.NoError(t, err) cases := map[string]struct { signerKey crypto.PrivKey @@ -78,6 +105,34 @@ func TestDeductFeesNoDelegation(t *testing.T) { fee: 0, valid: true, }, + "valid delegation": { + signerKey: priv3, + signer: addr3, + feeAccount: addr2, + fee: 50, + valid: true, + }, + "no delegation": { + signerKey: priv3, + signer: addr3, + feeAccount: addr1, + fee: 2, + valid: false, + }, + "allowance smaller than requested fee": { + signerKey: priv4, + signer: addr4, + feeAccount: addr2, + fee: 50, + valid: false, + }, + "granter cannot cover allowed delegation": { + signerKey: priv4, + signer: addr4, + feeAccount: addr1, + fee: 50, + valid: false, + }, } for name, tc := range cases { diff --git a/x/delegation/internal/keeper/keeper.go b/x/delegation/internal/keeper/keeper.go index d0aac56c0726..e0ba70f7524d 100644 --- a/x/delegation/internal/keeper/keeper.go +++ b/x/delegation/internal/keeper/keeper.go @@ -96,6 +96,9 @@ func (k Keeper) UseDelegatedFees(ctx sdk.Context, granter sdk.AccAddress, grante ctx.Logger().Error(err.Error()) return false } + if grant == nil || grant.Allowance == nil { + return false + } remove, err := grant.Allowance.Accept(fee, ctx.BlockTime(), ctx.BlockHeight()) if remove { From e476c030dc1c5b0a180a69abe124124a76e3c976 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 17 Oct 2019 13:19:57 +0200 Subject: [PATCH 025/184] Build full ante handler stack and test it --- x/delegation/internal/ante/ante.go | 27 ++++++ x/delegation/internal/ante/fee_test.go | 112 ++++++++++++++++++++++--- 2 files changed, 128 insertions(+), 11 deletions(-) create mode 100644 x/delegation/internal/ante/ante.go diff --git a/x/delegation/internal/ante/ante.go b/x/delegation/internal/ante/ante.go new file mode 100644 index 000000000000..e4d343a5f86d --- /dev/null +++ b/x/delegation/internal/ante/ante.go @@ -0,0 +1,27 @@ +package ante + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + authAnte "github.com/cosmos/cosmos-sdk/x/auth/ante" + authKeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/delegation/internal/keeper" +) + +// NewAnteHandler is just like auth.NewAnteHandler, except we use the DeductDelegatedFeeDecorator +// in order to allow payment of fees via a delegation. +func NewAnteHandler(ak authKeeper.AccountKeeper, supplyKeeper authTypes.SupplyKeeper, dk keeper.Keeper, sigGasConsumer authAnte.SignatureVerificationGasConsumer) sdk.AnteHandler { + return sdk.ChainAnteDecorators( + authAnte.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first + authAnte.NewMempoolFeeDecorator(), + authAnte.NewValidateBasicDecorator(), + authAnte.NewValidateMemoDecorator(ak), + authAnte.NewConsumeGasForTxSizeDecorator(ak), + authAnte.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators + authAnte.NewValidateSigCountDecorator(ak), + NewDeductDelegatedFeeDecorator(ak, supplyKeeper, dk), + authAnte.NewSigGasConsumeDecorator(ak, sigGasConsumer), + authAnte.NewSigVerificationDecorator(ak), + authAnte.NewIncrementSequenceDecorator(ak), // innermost AnteDecorator + ) +} diff --git a/x/delegation/internal/ante/fee_test.go b/x/delegation/internal/ante/fee_test.go index 7f89fc84b254..1abc98f0617f 100644 --- a/x/delegation/internal/ante/fee_test.go +++ b/x/delegation/internal/ante/fee_test.go @@ -19,8 +19,13 @@ import ( func TestDeductFeesNoDelegation(t *testing.T) { // setup app, ctx := createTestApp(true) + + // this just tests our handler dfd := ante.NewDeductDelegatedFeeDecorator(app.AccountKeeper, app.SupplyKeeper, app.DelegationKeeper) - antehandler := sdk.ChainAnteDecorators(dfd) + ourAnteHandler := sdk.ChainAnteDecorators(dfd) + + // this tests the whole stack + anteHandlerStack := ante.NewAnteHandler(app.AccountKeeper, app.SupplyKeeper, app.DelegationKeeper, SigGasNoConsumer) // keys and addresses priv1, _, addr1 := authtypes.KeyTestPubAddr() @@ -72,65 +77,145 @@ func TestDeductFeesNoDelegation(t *testing.T) { signerKey crypto.PrivKey signer sdk.AccAddress feeAccount sdk.AccAddress + handler sdk.AnteHandler fee int64 valid bool }{ - "paying with low funds": { + "paying with low funds (only ours)": { signerKey: priv1, signer: addr1, fee: 50, + handler: ourAnteHandler, valid: false, }, - "paying with good funds": { + "paying with good funds (only ours)": { signerKey: priv2, signer: addr2, fee: 50, + handler: ourAnteHandler, valid: true, }, - "paying with no account": { + "paying with no account (only ours)": { signerKey: priv3, signer: addr3, fee: 1, + handler: ourAnteHandler, valid: false, }, - "no fee with real account": { + "no fee with real account (only ours)": { signerKey: priv1, signer: addr1, fee: 0, + handler: ourAnteHandler, valid: true, }, - "no fee with no account": { + "no fee with no account (only ours)": { signerKey: priv4, signer: addr4, fee: 0, + handler: ourAnteHandler, valid: true, }, - "valid delegation": { + "valid delegation (only ours)": { signerKey: priv3, signer: addr3, feeAccount: addr2, fee: 50, + handler: ourAnteHandler, valid: true, }, - "no delegation": { + "no delegation (only ours)": { signerKey: priv3, signer: addr3, feeAccount: addr1, fee: 2, + handler: ourAnteHandler, valid: false, }, - "allowance smaller than requested fee": { + "allowance smaller than requested fee (only ours)": { signerKey: priv4, signer: addr4, feeAccount: addr2, fee: 50, + handler: ourAnteHandler, valid: false, }, - "granter cannot cover allowed delegation": { + "granter cannot cover allowed delegation (only ours)": { signerKey: priv4, signer: addr4, feeAccount: addr1, fee: 50, + handler: ourAnteHandler, + valid: false, + }, + + "paying with low funds (whole stack)": { + signerKey: priv1, + signer: addr1, + fee: 50, + handler: anteHandlerStack, + valid: false, + }, + "paying with good funds (whole stack)": { + signerKey: priv2, + signer: addr2, + fee: 50, + handler: anteHandlerStack, + valid: true, + }, + "paying with no account (whole stack)": { + signerKey: priv3, + signer: addr3, + fee: 1, + handler: anteHandlerStack, + valid: false, + }, + "no fee with real account (whole stack)": { + signerKey: priv1, + signer: addr1, + fee: 0, + handler: anteHandlerStack, + valid: true, + }, + // TODO: cannot pay zero fees if account doesn't exist (is this good?) + // "no fee with no account (whole stack)": { + // signerKey: priv4, + // signer: addr4, + // fee: 0, + // handler: anteHandlerStack, + // valid: true, + // }, + // TODO: cannot delegate fees if account doesn't exist (this must change for delegation) + // "valid delegation (whole stack)": { + // signerKey: priv3, + // signer: addr3, + // feeAccount: addr2, + // fee: 50, + // handler: anteHandlerStack, + // valid: true, + // }, + "no delegation (whole stack)": { + signerKey: priv3, + signer: addr3, + feeAccount: addr1, + fee: 2, + handler: anteHandlerStack, + valid: false, + }, + "allowance smaller than requested fee (whole stack)": { + signerKey: priv4, + signer: addr4, + feeAccount: addr2, + fee: 50, + handler: anteHandlerStack, + valid: false, + }, + "granter cannot cover allowed delegation (whole stack)": { + signerKey: priv4, + signer: addr4, + feeAccount: addr1, + fee: 50, + handler: anteHandlerStack, valid: false, }, } @@ -143,7 +228,7 @@ func TestDeductFeesNoDelegation(t *testing.T) { privs, accNums, seqs := []crypto.PrivKey{tc.signerKey}, []uint64{0}, []uint64{0} tx := authtypes.NewTestTxWithFeeAccount(ctx, msgs, privs, accNums, seqs, fee, tc.feeAccount) - _, err := antehandler(ctx, tx, false) + _, err := tc.handler(ctx, tx, false) if tc.valid { require.NoError(t, err) } else { @@ -161,3 +246,8 @@ func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { return app, ctx } + +// don't cosume any gas +func SigGasNoConsumer(meter sdk.GasMeter, sig []byte, pubkey crypto.PubKey, params authtypes.Params) error { + return nil +} From 182eb3435a2e3fee7518ab22ef078b9ba6b8acb0 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 17 Oct 2019 15:01:23 +0200 Subject: [PATCH 026/184] Start genesis --- x/delegation/genesis.go | 24 +++++++++++++++++++ x/delegation/module.go | 51 +++++++++++++++++++++-------------------- 2 files changed, 50 insertions(+), 25 deletions(-) create mode 100644 x/delegation/genesis.go diff --git a/x/delegation/genesis.go b/x/delegation/genesis.go new file mode 100644 index 000000000000..e5a5117dd215 --- /dev/null +++ b/x/delegation/genesis.go @@ -0,0 +1,24 @@ +package delegation + +import sdk "github.com/cosmos/cosmos-sdk/types" + +type GenesisState []FeeAllowanceGrant + +func (g GenesisState) ValidateBasic() error { + for _, f := range g { + err := f.ValidateBasic() + if err != nil { + return err + } + } + return nil +} + +func InitGenesis(ctx sdk.Context, k Keeper, data GenesisState) { + // TODO +} + +func ExportGenesis(ctx sdk.Context, k Keeper) GenesisState { + // TODO + return {} +} diff --git a/x/delegation/module.go b/x/delegation/module.go index a3c09da29f8e..6b91b3bda239 100644 --- a/x/delegation/module.go +++ b/x/delegation/module.go @@ -15,11 +15,11 @@ import ( ) // TODO: -// * ante handler // * genesis // * cli // * rest -// -> changes to auth, etc +// * periodic fee +// -> change StdFee instead of StdTx, etc? var ( _ module.AppModule = AppModule{} @@ -42,20 +42,25 @@ func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { // DefaultGenesis returns default genesis state as raw bytes for the delegation // module. func (AppModuleBasic) DefaultGenesis() json.RawMessage { - return []byte("{}") - // return ModuleCdc.MustMarshalJSON(DefaultGenesisState()) + return []byte("[]") } // ValidateGenesis performs genesis state validation for the delegation module. -func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { - // TODO - return nil - // var data GenesisState - // err := ModuleCdc.UnmarshalJSON(bz, &data) - // if err != nil { - // return err - // } - // return ValidateGenesis(data) +func (a AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { + _, err := a.getValidatedGenesis(bz) + return err +} + +func (a AppModuleBasic) getValidatedGenesis(bz json.RawMessage) (GenesisState, error) { + cdc := codec.New() + a.RegisterCodec(cdc) + + var data GenesisState + err := cdc.UnmarshalJSON(bz, &data) + if err != nil { + return nil, err + } + return data, data.ValidateBasic() } // RegisterRESTRoutes registers the REST routes for the delegation module. @@ -99,10 +104,7 @@ func (AppModule) Name() string { } // RegisterInvariants registers the delegation module invariants. -func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { - // TODO? - // RegisterInvariants(ir, am.keeper) -} +func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {} // Route returns the message routing key for the delegation module. func (AppModule) Route() string { @@ -127,20 +129,19 @@ func (am AppModule) NewQuerierHandler() sdk.Querier { // InitGenesis performs genesis initialization for the delegation module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate { - // TODO - // var genesisState GenesisState - // ModuleCdc.MustUnmarshalJSON(data, &genesisState) - // InitGenesis(ctx, am.keeper, am.ak, genesisState) + genesisState, err := am.getValidatedGenesis(data) + if err != nil { + panic(err) + } + InitGenesis(ctx, am.keeper, genesisState) return []abci.ValidatorUpdate{} } // ExportGenesis returns the exported genesis state as raw bytes for the delegation // module. func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { - // TODO - return []byte("{}") - // gs := ExportGenesis(ctx, am.keeper) - // return ModuleCdc.MustMarshalJSON(gs) + gs := ExportGenesis(ctx, am.keeper) + return ModuleCdc.MustMarshalJSON(gs) } // BeginBlock returns the begin blocker for the delegation module. From 071e111705c70f8b5e41db305891cec0d79be8a1 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 17 Oct 2019 16:54:17 +0200 Subject: [PATCH 027/184] Implement Genesis --- x/delegation/genesis.go | 19 +++++++++++----- x/delegation/internal/keeper/keeper.go | 24 +++++++++++++++++++-- x/delegation/internal/keeper/keeper_test.go | 2 +- x/delegation/internal/keeper/querier.go | 2 +- x/delegation/module.go | 10 +++++++-- 5 files changed, 46 insertions(+), 11 deletions(-) diff --git a/x/delegation/genesis.go b/x/delegation/genesis.go index e5a5117dd215..4aae4e68433a 100644 --- a/x/delegation/genesis.go +++ b/x/delegation/genesis.go @@ -2,8 +2,10 @@ package delegation import sdk "github.com/cosmos/cosmos-sdk/types" +// GenesisState contains a set of fee allowances, persisted from the store type GenesisState []FeeAllowanceGrant +// ValidateBasic ensures all grants in the genesis state are valid func (g GenesisState) ValidateBasic() error { for _, f := range g { err := f.ValidateBasic() @@ -14,11 +16,18 @@ func (g GenesisState) ValidateBasic() error { return nil } -func InitGenesis(ctx sdk.Context, k Keeper, data GenesisState) { - // TODO +// InitGenesis will initialize the keeper from a *previously validated* GenesisState +func InitGenesis(ctx sdk.Context, k Keeper, gen GenesisState) error { + for _, f := range gen { + err := k.DelegateFeeAllowance(ctx, f) + if err != nil { + return err + } + } + return nil } -func ExportGenesis(ctx sdk.Context, k Keeper) GenesisState { - // TODO - return {} +// ExportGenesis will dump the contents of the keeper into a serializable GenesisState +func ExportGenesis(ctx sdk.Context, k Keeper) (GenesisState, error) { + return k.GetAllFeeAllowances(ctx) } diff --git a/x/delegation/internal/keeper/keeper.go b/x/delegation/internal/keeper/keeper.go index e0ba70f7524d..670051191967 100644 --- a/x/delegation/internal/keeper/keeper.go +++ b/x/delegation/internal/keeper/keeper.go @@ -65,8 +65,8 @@ func (k Keeper) GetFeeGrant(ctx sdk.Context, granter sdk.AccAddress, grantee sdk return &grant, nil } -// GetAllFeeAllowances returns a list of all the grants from anyone to the given grantee. -func (k Keeper) GetAllFeeAllowances(ctx sdk.Context, grantee sdk.AccAddress) ([]types.FeeAllowanceGrant, error) { +// GetAllMyFeeAllowances returns a list of all the grants from anyone to the given grantee. +func (k Keeper) GetAllMyFeeAllowances(ctx sdk.Context, grantee sdk.AccAddress) ([]types.FeeAllowanceGrant, error) { store := ctx.KVStore(k.storeKey) var grants []types.FeeAllowanceGrant @@ -85,6 +85,26 @@ func (k Keeper) GetAllFeeAllowances(ctx sdk.Context, grantee sdk.AccAddress) ([] return grants, nil } +// GetAllFeeAllowances returns a list of all the grants in the store. +// This is very expensive and only designed for export genesis +func (k Keeper) GetAllFeeAllowances(ctx sdk.Context) ([]types.FeeAllowanceGrant, error) { + store := ctx.KVStore(k.storeKey) + var grants []types.FeeAllowanceGrant + + iter := sdk.KVStorePrefixIterator(store, types.FeeAllowanceKeyPrefix) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + bz := iter.Value() + var grant types.FeeAllowanceGrant + err := k.cdc.UnmarshalBinaryBare(bz, &grant) + if err != nil { + return nil, err + } + grants = append(grants, grant) + } + return grants, nil +} + // UseDelegatedFees will try to pay the given fee from the granter's account as requested by the grantee // (true, nil) will update the allowance, and assumes the AnteHandler deducts the given fees // (false, nil) rejects payment on behalf of grantee diff --git a/x/delegation/internal/keeper/keeper_test.go b/x/delegation/internal/keeper/keeper_test.go index 617623ed3dd9..5c5bd671b641 100644 --- a/x/delegation/internal/keeper/keeper_test.go +++ b/x/delegation/internal/keeper/keeper_test.go @@ -176,7 +176,7 @@ func TestKeeperCrud(t *testing.T) { for name, tc := range allCases { t.Run(name, func(t *testing.T) { - grants, err := k.GetAllFeeAllowances(ctx, tc.grantee) + grants, err := k.GetAllMyFeeAllowances(ctx, tc.grantee) require.NoError(t, err) assert.Equal(t, tc.grants, grants) }) diff --git a/x/delegation/internal/keeper/querier.go b/x/delegation/internal/keeper/querier.go index ab12c5ecb804..238d5cba428b 100644 --- a/x/delegation/internal/keeper/querier.go +++ b/x/delegation/internal/keeper/querier.go @@ -28,7 +28,7 @@ func queryGetFeeAllowances(ctx sdk.Context, args []string, keeper Keeper) ([]byt return nil, sdk.ErrInternal(sdk.AppendMsgToErr("invalid address", err.Error())) } - fees, err := keeper.GetAllFeeAllowances(ctx, granteeAddr) + fees, err := keeper.GetAllMyFeeAllowances(ctx, granteeAddr) if err != nil { return nil, sdk.ConvertError(err) } diff --git a/x/delegation/module.go b/x/delegation/module.go index 6b91b3bda239..4ba94502d1b0 100644 --- a/x/delegation/module.go +++ b/x/delegation/module.go @@ -133,14 +133,20 @@ func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.Va if err != nil { panic(err) } - InitGenesis(ctx, am.keeper, genesisState) + err = InitGenesis(ctx, am.keeper, genesisState) + if err != nil { + panic(err) + } return []abci.ValidatorUpdate{} } // ExportGenesis returns the exported genesis state as raw bytes for the delegation // module. func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { - gs := ExportGenesis(ctx, am.keeper) + gs, err := ExportGenesis(ctx, am.keeper) + if err != nil { + panic(err) + } return ModuleCdc.MustMarshalJSON(gs) } From 98b88a32a9a8acbc3a847deeec4f04208471b392 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Fri, 18 Oct 2019 10:45:28 +0200 Subject: [PATCH 028/184] Rename package delegation to subkeys --- simapp/app.go | 16 ++++++++-------- x/{delegation => subkeys}/README.md | 0 x/{delegation => subkeys}/alias.go | 10 +++++----- x/{delegation => subkeys}/doc.go | 6 +++--- x/{delegation => subkeys}/exported/fees.go | 0 x/{delegation => subkeys}/genesis.go | 8 +++++++- x/{delegation => subkeys}/handler.go | 2 +- x/{delegation => subkeys}/internal/ante/ante.go | 2 +- x/{delegation => subkeys}/internal/ante/fee.go | 2 +- .../internal/ante/fee_test.go | 6 +++--- .../internal/keeper/keeper.go | 4 ++-- .../internal/keeper/keeper_test.go | 6 +++--- .../internal/keeper/querier.go | 2 +- .../internal/keeper/querier_test.go | 4 ++-- .../internal/types/basic_fee.go | 2 +- .../internal/types/basic_fee_test.go | 0 .../internal/types/codec.go | 2 +- .../internal/types/errors.go | 0 .../internal/types/expiration.go | 0 .../internal/types/expiration_test.go | 0 .../internal/types/grant.go | 2 +- .../internal/types/grant_test.go | 0 x/{delegation => subkeys}/internal/types/key.go | 0 x/{delegation => subkeys}/internal/types/msgs.go | 2 +- x/{delegation => subkeys}/module.go | 3 +-- 25 files changed, 42 insertions(+), 37 deletions(-) rename x/{delegation => subkeys}/README.md (100%) rename x/{delegation => subkeys}/alias.go (86%) rename x/{delegation => subkeys}/doc.go (92%) rename x/{delegation => subkeys}/exported/fees.go (100%) rename x/{delegation => subkeys}/genesis.go (67%) rename x/{delegation => subkeys}/handler.go (96%) rename x/{delegation => subkeys}/internal/ante/ante.go (95%) rename x/{delegation => subkeys}/internal/ante/fee.go (97%) rename x/{delegation => subkeys}/internal/ante/fee_test.go (97%) rename x/{delegation => subkeys}/internal/keeper/keeper.go (97%) rename x/{delegation => subkeys}/internal/keeper/keeper_test.go (97%) rename x/{delegation => subkeys}/internal/keeper/querier.go (92%) rename x/{delegation => subkeys}/internal/keeper/querier_test.go (94%) rename x/{delegation => subkeys}/internal/types/basic_fee.go (96%) rename x/{delegation => subkeys}/internal/types/basic_fee_test.go (100%) rename x/{delegation => subkeys}/internal/types/codec.go (90%) rename x/{delegation => subkeys}/internal/types/errors.go (100%) rename x/{delegation => subkeys}/internal/types/expiration.go (100%) rename x/{delegation => subkeys}/internal/types/expiration_test.go (100%) rename x/{delegation => subkeys}/internal/types/grant.go (93%) rename x/{delegation => subkeys}/internal/types/grant_test.go (100%) rename x/{delegation => subkeys}/internal/types/key.go (100%) rename x/{delegation => subkeys}/internal/types/msgs.go (97%) rename x/{delegation => subkeys}/module.go (99%) diff --git a/simapp/app.go b/simapp/app.go index fc7895c3eec0..118cda2d0195 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -18,7 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/vesting" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/crisis" - "github.com/cosmos/cosmos-sdk/x/delegation" + "github.com/cosmos/cosmos-sdk/x/subkeys" distr "github.com/cosmos/cosmos-sdk/x/distribution" "github.com/cosmos/cosmos-sdk/x/genutil" "github.com/cosmos/cosmos-sdk/x/gov" @@ -54,7 +54,7 @@ var ( params.AppModuleBasic{}, crisis.AppModuleBasic{}, slashing.AppModuleBasic{}, - delegation.AppModuleBasic{}, + subkeys.AppModuleBasic{}, ) // module account permissions @@ -101,7 +101,7 @@ type SimApp struct { DistrKeeper distr.Keeper GovKeeper gov.Keeper CrisisKeeper crisis.Keeper - DelegationKeeper delegation.Keeper + DelegationKeeper subkeys.Keeper ParamsKeeper params.Keeper // the module manager @@ -125,7 +125,7 @@ func NewSimApp( keys := sdk.NewKVStoreKeys(bam.MainStoreKey, auth.StoreKey, staking.StoreKey, supply.StoreKey, mint.StoreKey, distr.StoreKey, slashing.StoreKey, - gov.StoreKey, params.StoreKey, delegation.StoreKey) + gov.StoreKey, params.StoreKey, subkeys.StoreKey) tkeys := sdk.NewTransientStoreKeys(params.TStoreKey) app := &SimApp{ @@ -159,7 +159,7 @@ func NewSimApp( app.SlashingKeeper = slashing.NewKeeper(app.cdc, keys[slashing.StoreKey], &stakingKeeper, slashingSubspace, slashing.DefaultCodespace) app.CrisisKeeper = crisis.NewKeeper(crisisSubspace, invCheckPeriod, app.SupplyKeeper, auth.FeeCollectorName) - app.DelegationKeeper = delegation.NewKeeper(app.cdc, keys[delegation.StoreKey]) + app.DelegationKeeper = subkeys.NewKeeper(app.cdc, keys[subkeys.StoreKey]) // register the proposal types govRouter := gov.NewRouter() @@ -188,7 +188,7 @@ func NewSimApp( distr.NewAppModule(app.DistrKeeper, app.SupplyKeeper), slashing.NewAppModule(app.SlashingKeeper, app.StakingKeeper), staking.NewAppModule(app.StakingKeeper, app.AccountKeeper, app.SupplyKeeper), - delegation.NewAppModule(app.DelegationKeeper), + subkeys.NewAppModule(app.DelegationKeeper), ) // During begin block slashing happens after distr.BeginBlocker so that @@ -204,7 +204,7 @@ func NewSimApp( auth.ModuleName, distr.ModuleName, staking.ModuleName, bank.ModuleName, slashing.ModuleName, gov.ModuleName, mint.ModuleName, supply.ModuleName, crisis.ModuleName, - genutil.ModuleName, delegation.ModuleName, + genutil.ModuleName, subkeys.ModuleName, ) app.mm.RegisterInvariants(&app.CrisisKeeper) @@ -223,7 +223,7 @@ func NewSimApp( distr.NewAppModule(app.DistrKeeper, app.SupplyKeeper), staking.NewAppModule(app.StakingKeeper, app.AccountKeeper, app.SupplyKeeper), slashing.NewAppModule(app.SlashingKeeper, app.StakingKeeper), - // delegation.NewAppModule(app.DelegationKeeper), + // subkeys.NewAppModule(app.DelegationKeeper), ) app.sm.RegisterStoreDecoders() diff --git a/x/delegation/README.md b/x/subkeys/README.md similarity index 100% rename from x/delegation/README.md rename to x/subkeys/README.md diff --git a/x/delegation/alias.go b/x/subkeys/alias.go similarity index 86% rename from x/delegation/alias.go rename to x/subkeys/alias.go index 7bfc3f7d5fbf..9bdce90331f7 100644 --- a/x/delegation/alias.go +++ b/x/subkeys/alias.go @@ -1,13 +1,13 @@ // nolint // autogenerated code using github.com/rigelrozanski/multitool // aliases generated for the following subdirectories: -// ALIASGEN: github.com/cosmos/cosmos-sdk/x/delegation/internal/types -// ALIASGEN: github.com/cosmos/cosmos-sdk/x/delegation/internal/keeper -package delegation +// ALIASGEN: github.com/cosmos/cosmos-sdk/x/subkeys/internal/types +// ALIASGEN: github.com/cosmos/cosmos-sdk/x/subkeys/internal/keeper +package subkeys import ( - "github.com/cosmos/cosmos-sdk/x/delegation/internal/keeper" - "github.com/cosmos/cosmos-sdk/x/delegation/internal/types" + "github.com/cosmos/cosmos-sdk/x/subkeys/internal/keeper" + "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types" ) const ( diff --git a/x/delegation/doc.go b/x/subkeys/doc.go similarity index 92% rename from x/delegation/doc.go rename to x/subkeys/doc.go index 8d9a71fa04b7..d21ec229452e 100644 --- a/x/delegation/doc.go +++ b/x/subkeys/doc.go @@ -1,6 +1,6 @@ /* -Package delegation provides functionality for delegating sub-permissions -from one account to another account. +Package subkeys provides functionality for delegating sub-permissions +from one account (key) to another account (key). The first implementation allows the delegation for the payment of transaction fees. Effectively, this allows for a user to pay fees using the balance of an account @@ -29,4 +29,4 @@ to the first signer of the transaction. An example usage would be: allow := feeDelegationKeeper.AllowDelegatedFees(ctx, signers[0], stdTx.FeeAccount, stdTx.Fee.Amount) */ -package delegation +package subkeys diff --git a/x/delegation/exported/fees.go b/x/subkeys/exported/fees.go similarity index 100% rename from x/delegation/exported/fees.go rename to x/subkeys/exported/fees.go diff --git a/x/delegation/genesis.go b/x/subkeys/genesis.go similarity index 67% rename from x/delegation/genesis.go rename to x/subkeys/genesis.go index 4aae4e68433a..28b403921fbf 100644 --- a/x/delegation/genesis.go +++ b/x/subkeys/genesis.go @@ -1,4 +1,4 @@ -package delegation +package subkeys import sdk "github.com/cosmos/cosmos-sdk/types" @@ -29,5 +29,11 @@ func InitGenesis(ctx sdk.Context, k Keeper, gen GenesisState) error { // ExportGenesis will dump the contents of the keeper into a serializable GenesisState func ExportGenesis(ctx sdk.Context, k Keeper) (GenesisState, error) { + // TODO: all expiration heights will be thrown off if we dump state and start at a new + // chain at height 0. Maybe we need to allow the Allowances to "prepare themselves" + // for export, like if they have exiry at 5000 and current is 4000, they export with + // expiry of 1000. It would need a new method on the FeeAllowance interface. + // + // Currently, we handle expirations naively return k.GetAllFeeAllowances(ctx) } diff --git a/x/delegation/handler.go b/x/subkeys/handler.go similarity index 96% rename from x/delegation/handler.go rename to x/subkeys/handler.go index 367eb7b21523..a2438a542cf7 100644 --- a/x/delegation/handler.go +++ b/x/subkeys/handler.go @@ -1,4 +1,4 @@ -package delegation +package subkeys import ( "fmt" diff --git a/x/delegation/internal/ante/ante.go b/x/subkeys/internal/ante/ante.go similarity index 95% rename from x/delegation/internal/ante/ante.go rename to x/subkeys/internal/ante/ante.go index e4d343a5f86d..dcac1b0295f1 100644 --- a/x/delegation/internal/ante/ante.go +++ b/x/subkeys/internal/ante/ante.go @@ -5,7 +5,7 @@ import ( authAnte "github.com/cosmos/cosmos-sdk/x/auth/ante" authKeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/delegation/internal/keeper" + "github.com/cosmos/cosmos-sdk/x/subkeys/internal/keeper" ) // NewAnteHandler is just like auth.NewAnteHandler, except we use the DeductDelegatedFeeDecorator diff --git a/x/delegation/internal/ante/fee.go b/x/subkeys/internal/ante/fee.go similarity index 97% rename from x/delegation/internal/ante/fee.go rename to x/subkeys/internal/ante/fee.go index c1f988e4094c..23f6645e86dc 100644 --- a/x/delegation/internal/ante/fee.go +++ b/x/subkeys/internal/ante/fee.go @@ -10,7 +10,7 @@ import ( authAnte "github.com/cosmos/cosmos-sdk/x/auth/ante" authKeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/delegation/internal/keeper" + "github.com/cosmos/cosmos-sdk/x/subkeys/internal/keeper" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) diff --git a/x/delegation/internal/ante/fee_test.go b/x/subkeys/internal/ante/fee_test.go similarity index 97% rename from x/delegation/internal/ante/fee_test.go rename to x/subkeys/internal/ante/fee_test.go index 1abc98f0617f..d96a418b6fa6 100644 --- a/x/delegation/internal/ante/fee_test.go +++ b/x/subkeys/internal/ante/fee_test.go @@ -11,9 +11,9 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/delegation/internal/ante" - "github.com/cosmos/cosmos-sdk/x/delegation/internal/types" - // delTypes "github.com/cosmos/cosmos-sdk/x/delegation/internal/types" + "github.com/cosmos/cosmos-sdk/x/subkeys/internal/ante" + "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types" + // delTypes "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types" ) func TestDeductFeesNoDelegation(t *testing.T) { diff --git a/x/delegation/internal/keeper/keeper.go b/x/subkeys/internal/keeper/keeper.go similarity index 97% rename from x/delegation/internal/keeper/keeper.go rename to x/subkeys/internal/keeper/keeper.go index 670051191967..272d88296fe4 100644 --- a/x/delegation/internal/keeper/keeper.go +++ b/x/subkeys/internal/keeper/keeper.go @@ -3,8 +3,8 @@ package keeper import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/delegation/exported" - "github.com/cosmos/cosmos-sdk/x/delegation/internal/types" + "github.com/cosmos/cosmos-sdk/x/subkeys/exported" + "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types" ) type Keeper struct { diff --git a/x/delegation/internal/keeper/keeper_test.go b/x/subkeys/internal/keeper/keeper_test.go similarity index 97% rename from x/delegation/internal/keeper/keeper_test.go rename to x/subkeys/internal/keeper/keeper_test.go index 5c5bd671b641..1f923c866a2c 100644 --- a/x/delegation/internal/keeper/keeper_test.go +++ b/x/subkeys/internal/keeper/keeper_test.go @@ -13,9 +13,9 @@ import ( codec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/delegation/exported" - "github.com/cosmos/cosmos-sdk/x/delegation/internal/keeper" - "github.com/cosmos/cosmos-sdk/x/delegation/internal/types" + "github.com/cosmos/cosmos-sdk/x/subkeys/exported" + "github.com/cosmos/cosmos-sdk/x/subkeys/internal/keeper" + "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types" ) type testInput struct { diff --git a/x/delegation/internal/keeper/querier.go b/x/subkeys/internal/keeper/querier.go similarity index 92% rename from x/delegation/internal/keeper/querier.go rename to x/subkeys/internal/keeper/querier.go index 238d5cba428b..4728c3e2bf2c 100644 --- a/x/delegation/internal/keeper/querier.go +++ b/x/subkeys/internal/keeper/querier.go @@ -16,7 +16,7 @@ func NewQuerier(keeper Keeper) sdk.Querier { case QueryGetFeeAllowances: return queryGetFeeAllowances(ctx, path[1:], keeper) default: - return nil, sdk.ErrUnknownRequest("Unknown package delegation query endpoint") + return nil, sdk.ErrUnknownRequest("Unknown package subkeys query endpoint") } } } diff --git a/x/delegation/internal/keeper/querier_test.go b/x/subkeys/internal/keeper/querier_test.go similarity index 94% rename from x/delegation/internal/keeper/querier_test.go rename to x/subkeys/internal/keeper/querier_test.go index 7cec96217859..e9bc45f68b26 100644 --- a/x/delegation/internal/keeper/querier_test.go +++ b/x/subkeys/internal/keeper/querier_test.go @@ -9,8 +9,8 @@ import ( codec "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/delegation/internal/keeper" - "github.com/cosmos/cosmos-sdk/x/delegation/internal/types" + "github.com/cosmos/cosmos-sdk/x/subkeys/internal/keeper" + "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types" ) func TestQuery(t *testing.T) { diff --git a/x/delegation/internal/types/basic_fee.go b/x/subkeys/internal/types/basic_fee.go similarity index 96% rename from x/delegation/internal/types/basic_fee.go rename to x/subkeys/internal/types/basic_fee.go index 01b23be9d286..9a110ff54f16 100644 --- a/x/delegation/internal/types/basic_fee.go +++ b/x/subkeys/internal/types/basic_fee.go @@ -4,7 +4,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/delegation/exported" + "github.com/cosmos/cosmos-sdk/x/subkeys/exported" ) // BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens diff --git a/x/delegation/internal/types/basic_fee_test.go b/x/subkeys/internal/types/basic_fee_test.go similarity index 100% rename from x/delegation/internal/types/basic_fee_test.go rename to x/subkeys/internal/types/basic_fee_test.go diff --git a/x/delegation/internal/types/codec.go b/x/subkeys/internal/types/codec.go similarity index 90% rename from x/delegation/internal/types/codec.go rename to x/subkeys/internal/types/codec.go index b7fc25bb04d7..cbc66ed8612f 100644 --- a/x/delegation/internal/types/codec.go +++ b/x/subkeys/internal/types/codec.go @@ -2,7 +2,7 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/x/delegation/exported" + "github.com/cosmos/cosmos-sdk/x/subkeys/exported" ) // RegisterCodec registers the account types and interface diff --git a/x/delegation/internal/types/errors.go b/x/subkeys/internal/types/errors.go similarity index 100% rename from x/delegation/internal/types/errors.go rename to x/subkeys/internal/types/errors.go diff --git a/x/delegation/internal/types/expiration.go b/x/subkeys/internal/types/expiration.go similarity index 100% rename from x/delegation/internal/types/expiration.go rename to x/subkeys/internal/types/expiration.go diff --git a/x/delegation/internal/types/expiration_test.go b/x/subkeys/internal/types/expiration_test.go similarity index 100% rename from x/delegation/internal/types/expiration_test.go rename to x/subkeys/internal/types/expiration_test.go diff --git a/x/delegation/internal/types/grant.go b/x/subkeys/internal/types/grant.go similarity index 93% rename from x/delegation/internal/types/grant.go rename to x/subkeys/internal/types/grant.go index c7bed78b6e30..bb7006ac837f 100644 --- a/x/delegation/internal/types/grant.go +++ b/x/subkeys/internal/types/grant.go @@ -2,7 +2,7 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/delegation/exported" + "github.com/cosmos/cosmos-sdk/x/subkeys/exported" ) // FeeAllowanceGrant is stored in the KVStore to record a grant with full context diff --git a/x/delegation/internal/types/grant_test.go b/x/subkeys/internal/types/grant_test.go similarity index 100% rename from x/delegation/internal/types/grant_test.go rename to x/subkeys/internal/types/grant_test.go diff --git a/x/delegation/internal/types/key.go b/x/subkeys/internal/types/key.go similarity index 100% rename from x/delegation/internal/types/key.go rename to x/subkeys/internal/types/key.go diff --git a/x/delegation/internal/types/msgs.go b/x/subkeys/internal/types/msgs.go similarity index 97% rename from x/delegation/internal/types/msgs.go rename to x/subkeys/internal/types/msgs.go index b89817166a65..7686f95a3a5a 100644 --- a/x/delegation/internal/types/msgs.go +++ b/x/subkeys/internal/types/msgs.go @@ -4,7 +4,7 @@ import ( "encoding/json" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/delegation/exported" + "github.com/cosmos/cosmos-sdk/x/subkeys/exported" ) // MsgDelegateFeeAllowance adds permission for Grantee to spend up to Allowance diff --git a/x/delegation/module.go b/x/subkeys/module.go similarity index 99% rename from x/delegation/module.go rename to x/subkeys/module.go index 4ba94502d1b0..b0b32332ea77 100644 --- a/x/delegation/module.go +++ b/x/subkeys/module.go @@ -1,4 +1,4 @@ -package delegation +package subkeys import ( "encoding/json" @@ -15,7 +15,6 @@ import ( ) // TODO: -// * genesis // * cli // * rest // * periodic fee From 376e9cd8ee77fdb1db50642b991921796d55a902 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Fri, 18 Oct 2019 10:50:11 +0200 Subject: [PATCH 029/184] Clarify antes test cases, handle empty account w/o fees --- x/subkeys/internal/ante/fee.go | 11 +++++---- x/subkeys/internal/ante/fee_test.go | 36 ++++++++++++++--------------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/x/subkeys/internal/ante/fee.go b/x/subkeys/internal/ante/fee.go index 23f6645e86dc..be95b3c4fcc8 100644 --- a/x/subkeys/internal/ante/fee.go +++ b/x/subkeys/internal/ante/fee.go @@ -49,17 +49,13 @@ func (d DeductDelegatedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") } - // short-circuit on zero fee - fee := feeTx.GetFee() - if fee.IsZero() { - return next(ctx, tx, simulate) - } // sanity check from DeductFeeDecorator if addr := d.sk.GetModuleAddress(authTypes.FeeCollectorName); addr == nil { panic(fmt.Sprintf("%s module account has not been set", authTypes.FeeCollectorName)) } // see if there is a delegation + fee := feeTx.GetFee() var feePayer sdk.AccAddress if delTx, ok := tx.(DelegatedFeeTx); ok { feePayer = delTx.GetFeeAccount() @@ -82,6 +78,11 @@ func (d DeductDelegatedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu if feePayerAcc == nil { return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "fee payer address: %s does not exist", feePayer) } + + // deduct fee if non-zero + if fee.IsZero() { + return next(ctx, tx, simulate) + } err = authAnte.DeductFees(d.sk, ctx, feePayerAcc, fee) if err != nil { return ctx, err diff --git a/x/subkeys/internal/ante/fee_test.go b/x/subkeys/internal/ante/fee_test.go index d96a418b6fa6..82c57cfffa39 100644 --- a/x/subkeys/internal/ante/fee_test.go +++ b/x/subkeys/internal/ante/fee_test.go @@ -114,9 +114,9 @@ func TestDeductFeesNoDelegation(t *testing.T) { signer: addr4, fee: 0, handler: ourAnteHandler, - valid: true, + valid: false, }, - "valid delegation (only ours)": { + "valid delegation without account (only ours)": { signerKey: priv3, signer: addr3, feeAccount: addr2, @@ -177,23 +177,21 @@ func TestDeductFeesNoDelegation(t *testing.T) { handler: anteHandlerStack, valid: true, }, - // TODO: cannot pay zero fees if account doesn't exist (is this good?) - // "no fee with no account (whole stack)": { - // signerKey: priv4, - // signer: addr4, - // fee: 0, - // handler: anteHandlerStack, - // valid: true, - // }, - // TODO: cannot delegate fees if account doesn't exist (this must change for delegation) - // "valid delegation (whole stack)": { - // signerKey: priv3, - // signer: addr3, - // feeAccount: addr2, - // fee: 50, - // handler: anteHandlerStack, - // valid: true, - // }, + "no fee with no account (whole stack)": { + signerKey: priv4, + signer: addr4, + fee: 0, + handler: anteHandlerStack, + valid: false, + }, + "valid delegation without account (whole stack)": { + signerKey: priv3, + signer: addr3, + feeAccount: addr2, + fee: 50, + handler: anteHandlerStack, + valid: true, + }, "no delegation (whole stack)": { signerKey: priv3, signer: addr3, From 529764f437e8725fc4e716b4429d0ed905d17211 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Fri, 18 Oct 2019 11:04:43 +0200 Subject: [PATCH 030/184] Allow paying delegated fees with no account --- x/subkeys/internal/ante/ante.go | 4 +++- x/subkeys/internal/ante/fee.go | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/x/subkeys/internal/ante/ante.go b/x/subkeys/internal/ante/ante.go index dcac1b0295f1..35560c713aee 100644 --- a/x/subkeys/internal/ante/ante.go +++ b/x/subkeys/internal/ante/ante.go @@ -17,9 +17,11 @@ func NewAnteHandler(ak authKeeper.AccountKeeper, supplyKeeper authTypes.SupplyKe authAnte.NewValidateBasicDecorator(), authAnte.NewValidateMemoDecorator(ak), authAnte.NewConsumeGasForTxSizeDecorator(ak), + // DeductDelegatedFeeDecorator will create an empty account if we sign with no tokens but valid validation + // This must be before SetPubKey, ValidateSigCount, SigVerification, which error if account doesn't exist yet + NewDeductDelegatedFeeDecorator(ak, supplyKeeper, dk), authAnte.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators authAnte.NewValidateSigCountDecorator(ak), - NewDeductDelegatedFeeDecorator(ak, supplyKeeper, dk), authAnte.NewSigGasConsumeDecorator(ak, sigGasConsumer), authAnte.NewSigVerificationDecorator(ak), authAnte.NewIncrementSequenceDecorator(ak), // innermost AnteDecorator diff --git a/x/subkeys/internal/ante/fee.go b/x/subkeys/internal/ante/fee.go index be95b3c4fcc8..16f665eca0e3 100644 --- a/x/subkeys/internal/ante/fee.go +++ b/x/subkeys/internal/ante/fee.go @@ -79,6 +79,15 @@ func (d DeductDelegatedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "fee payer address: %s does not exist", feePayer) } + // if there was a valid delegation, ensure that the txSigner account exists (we create it if needed) + if !txSigner.Equals(feePayer) { + signerAcc := d.ak.GetAccount(ctx, txSigner) + if signerAcc == nil { + signerAcc = d.ak.NewAccountWithAddress(ctx, txSigner) + d.ak.SetAccount(ctx, signerAcc) + } + } + // deduct fee if non-zero if fee.IsZero() { return next(ctx, tx, simulate) From d293aae9161ca787a8fdb9079de4a1ee7bb664d4 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Fri, 18 Oct 2019 11:15:18 +0200 Subject: [PATCH 031/184] Pull mempool into delegated ante, for control on StdFee --- x/subkeys/internal/ante/ante.go | 2 +- x/subkeys/internal/ante/mempool.go | 55 +++++++++++++++++++++ x/subkeys/internal/ante/mempool_test.go | 64 +++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 x/subkeys/internal/ante/mempool.go create mode 100644 x/subkeys/internal/ante/mempool_test.go diff --git a/x/subkeys/internal/ante/ante.go b/x/subkeys/internal/ante/ante.go index 35560c713aee..2efe2365192e 100644 --- a/x/subkeys/internal/ante/ante.go +++ b/x/subkeys/internal/ante/ante.go @@ -13,7 +13,7 @@ import ( func NewAnteHandler(ak authKeeper.AccountKeeper, supplyKeeper authTypes.SupplyKeeper, dk keeper.Keeper, sigGasConsumer authAnte.SignatureVerificationGasConsumer) sdk.AnteHandler { return sdk.ChainAnteDecorators( authAnte.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first - authAnte.NewMempoolFeeDecorator(), + NewDelegatedMempoolFeeDecorator(), authAnte.NewValidateBasicDecorator(), authAnte.NewValidateMemoDecorator(ak), authAnte.NewConsumeGasForTxSizeDecorator(ak), diff --git a/x/subkeys/internal/ante/mempool.go b/x/subkeys/internal/ante/mempool.go new file mode 100644 index 000000000000..ccea3c47122f --- /dev/null +++ b/x/subkeys/internal/ante/mempool.go @@ -0,0 +1,55 @@ +package ante + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + // we depend on the auth module internals... maybe some more of this can be exported? + // but things like `x/auth/types/FeeCollectorName` are quite clearly tied to it + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// DelegatedMempoolFeeDecorator will check if the transaction's fee is at least as large +// as the local validator's minimum gasFee (defined in validator config). +// If fee is too low, decorator returns error and tx is rejected from mempool. +// Note this only applies when ctx.CheckTx = true +// If fee is high enough or not CheckTx, then call next AnteHandler +// CONTRACT: Tx must implement FeeTx to use DelegatedMempoolFeeDecorator +type DelegatedMempoolFeeDecorator struct{} + +func NewDelegatedMempoolFeeDecorator() DelegatedMempoolFeeDecorator { + return DelegatedMempoolFeeDecorator{} +} + +func (mfd DelegatedMempoolFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { + feeTx, ok := tx.(DelegatedFeeTx) + if !ok { + return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") + } + feeCoins := feeTx.GetFee() + gas := feeTx.GetGas() + + // Ensure that the provided fees meet a minimum threshold for the validator, + // if this is a CheckTx. This is only for local mempool purposes, and thus + // is only ran on check tx. + if ctx.IsCheckTx() && !simulate { + minGasPrices := ctx.MinGasPrices() + if !minGasPrices.IsZero() { + requiredFees := make(sdk.Coins, len(minGasPrices)) + + // Determine the required fees by multiplying each required minimum gas + // price by the gas limit, where fee = ceil(minGasPrice * gasLimit). + glDec := sdk.NewDec(int64(gas)) + for i, gp := range minGasPrices { + fee := gp.Amount.Mul(glDec) + requiredFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt()) + } + + if !feeCoins.IsAnyGTE(requiredFees) { + return ctx, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees) + } + } + } + + return next(ctx, tx, simulate) +} diff --git a/x/subkeys/internal/ante/mempool_test.go b/x/subkeys/internal/ante/mempool_test.go new file mode 100644 index 000000000000..4b9c8b9608ec --- /dev/null +++ b/x/subkeys/internal/ante/mempool_test.go @@ -0,0 +1,64 @@ +package ante_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto" + + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + + // "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types" + "github.com/cosmos/cosmos-sdk/x/subkeys/internal/ante" +) + +func TestEnsureMempoolFees(t *testing.T) { + // setup + _, ctx := createTestApp(true) + + mfd := ante.NewDelegatedMempoolFeeDecorator() + antehandler := sdk.ChainAnteDecorators(mfd) + + // keys and addresses + priv1, _, addr1 := authtypes.KeyTestPubAddr() + + // msg and signatures + msg1 := authtypes.NewTestMsg(addr1) + fee := authtypes.NewStdFee(100000, sdk.NewCoins(sdk.NewInt64Coin("atom", 100))) + + msgs := []sdk.Msg{msg1} + + privs, accNums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} + // TODO + tx := authtypes.NewTestTx(ctx, msgs, privs, accNums, seqs, fee) + + // Set high gas price so standard test fee fails + atomPrice := sdk.NewDecCoinFromDec("atom", sdk.NewDec(200).Quo(sdk.NewDec(100000))) + highGasPrice := []sdk.DecCoin{atomPrice} + ctx = ctx.WithMinGasPrices(highGasPrice) + + // Set IsCheckTx to true + ctx = ctx.WithIsCheckTx(true) + + // antehandler errors with insufficient fees + _, err := antehandler(ctx, tx, false) + require.NotNil(t, err, "Decorator should have errored on too low fee for local gasPrice") + + // Set IsCheckTx to false + ctx = ctx.WithIsCheckTx(false) + + // antehandler should not error since we do not check minGasPrice in DeliverTx + _, err = antehandler(ctx, tx, false) + require.Nil(t, err, "DelegatedMempoolFeeDecorator returned error in DeliverTx") + + // Set IsCheckTx back to true for testing sufficient mempool fee + ctx = ctx.WithIsCheckTx(true) + + atomPrice = sdk.NewDecCoinFromDec("atom", sdk.NewDec(0).Quo(sdk.NewDec(100000))) + lowGasPrice := []sdk.DecCoin{atomPrice} + ctx = ctx.WithMinGasPrices(lowGasPrice) + + _, err = antehandler(ctx, tx, false) + require.Nil(t, err, "Decorator should not have errored on fee higher than local gasPrice") +} From a8b3e3101d71845f7132afebd6d555020980b6aa Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Fri, 18 Oct 2019 11:39:17 +0200 Subject: [PATCH 032/184] Use custom DelegatedTx, DelegatedFee for subkeys --- x/subkeys/internal/ante/fee.go | 44 ++-- x/subkeys/internal/ante/fee_test.go | 7 +- x/subkeys/internal/ante/mempool.go | 2 +- x/subkeys/internal/ante/mempool_test.go | 7 +- x/subkeys/internal/types/tx/test_common.go | 26 +++ x/subkeys/internal/types/tx/tx.go | 241 +++++++++++++++++++++ 6 files changed, 295 insertions(+), 32 deletions(-) create mode 100644 x/subkeys/internal/types/tx/test_common.go create mode 100644 x/subkeys/internal/types/tx/tx.go diff --git a/x/subkeys/internal/ante/fee.go b/x/subkeys/internal/ante/fee.go index 16f665eca0e3..af502c7f24df 100644 --- a/x/subkeys/internal/ante/fee.go +++ b/x/subkeys/internal/ante/fee.go @@ -11,18 +11,22 @@ import ( authKeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/subkeys/internal/keeper" + "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types/tx" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) var ( - _ DelegatedFeeTx = (*authTypes.StdTx)(nil) // assert StdTx implements DelegatedFeeTx + _ DelegatedFeeTx = (*tx.DelegatedTx)(nil) // assert StdTx implements DelegatedFeeTx ) // DelegatedFeeTx defines the interface to be implemented by Tx to use the DelegatedFeeDecorator type DelegatedFeeTx interface { - authAnte.FeeTx - GetFeeAccount() sdk.AccAddress + sdk.Tx + GetGas() uint64 + GetFee() sdk.Coins + FeePayer() sdk.AccAddress + MainSigner() sdk.AccAddress } // DeductDelegatedFeeDecorator deducts fees from the first signer of the tx @@ -44,9 +48,9 @@ func NewDeductDelegatedFeeDecorator(ak authKeeper.AccountKeeper, sk authTypes.Su } func (d DeductDelegatedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { - feeTx, ok := tx.(authAnte.FeeTx) + feeTx, ok := tx.(DelegatedFeeTx) if !ok { - return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") + return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a DelegatedFeeTx") } // sanity check from DeductFeeDecorator @@ -54,23 +58,22 @@ func (d DeductDelegatedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu panic(fmt.Sprintf("%s module account has not been set", authTypes.FeeCollectorName)) } - // see if there is a delegation fee := feeTx.GetFee() - var feePayer sdk.AccAddress - if delTx, ok := tx.(DelegatedFeeTx); ok { - feePayer = delTx.GetFeeAccount() - } + feePayer := feeTx.FeePayer() + txSigner := feeTx.MainSigner() - txSigner := feeTx.FeePayer() - if feePayer == nil { - // if this is not explicitly set, use the first signer as always - feePayer = txSigner - } else { - // ensure the delegation is allowed + // ensure the delegation is allowed, if we request a different fee payer + if !txSigner.Equals(feePayer) { allowed := d.dk.UseDelegatedFees(ctx, feePayer, txSigner, fee) if !allowed { return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s not allowed to pay fees from %s", txSigner, feePayer) } + // if there was a valid delegation, ensure that the txSigner account exists (we create it if needed) + signerAcc := d.ak.GetAccount(ctx, txSigner) + if signerAcc == nil { + signerAcc = d.ak.NewAccountWithAddress(ctx, txSigner) + d.ak.SetAccount(ctx, signerAcc) + } } // now, either way, we know that we are authorized to deduct the fees from the feePayer account @@ -79,15 +82,6 @@ func (d DeductDelegatedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "fee payer address: %s does not exist", feePayer) } - // if there was a valid delegation, ensure that the txSigner account exists (we create it if needed) - if !txSigner.Equals(feePayer) { - signerAcc := d.ak.GetAccount(ctx, txSigner) - if signerAcc == nil { - signerAcc = d.ak.NewAccountWithAddress(ctx, txSigner) - d.ak.SetAccount(ctx, signerAcc) - } - } - // deduct fee if non-zero if fee.IsZero() { return next(ctx, tx, simulate) diff --git a/x/subkeys/internal/ante/fee_test.go b/x/subkeys/internal/ante/fee_test.go index 82c57cfffa39..aa091760ad1b 100644 --- a/x/subkeys/internal/ante/fee_test.go +++ b/x/subkeys/internal/ante/fee_test.go @@ -13,7 +13,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/subkeys/internal/ante" "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types" - // delTypes "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types" + "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types/tx" ) func TestDeductFeesNoDelegation(t *testing.T) { @@ -221,10 +221,11 @@ func TestDeductFeesNoDelegation(t *testing.T) { for name, tc := range cases { t.Run(name, func(t *testing.T) { // msg and signatures - fee := authtypes.NewStdFee(100000, sdk.NewCoins(sdk.NewInt64Coin("atom", tc.fee))) + fee := tx.NewDelegatedFee(100000, sdk.NewCoins(sdk.NewInt64Coin("atom", tc.fee)), tc.feeAccount) msgs := []sdk.Msg{sdk.NewTestMsg(tc.signer)} privs, accNums, seqs := []crypto.PrivKey{tc.signerKey}, []uint64{0}, []uint64{0} - tx := authtypes.NewTestTxWithFeeAccount(ctx, msgs, privs, accNums, seqs, fee, tc.feeAccount) + + tx := tx.NewTestTx(ctx, msgs, privs, accNums, seqs, fee) _, err := tc.handler(ctx, tx, false) if tc.valid { diff --git a/x/subkeys/internal/ante/mempool.go b/x/subkeys/internal/ante/mempool.go index ccea3c47122f..7beaa57542be 100644 --- a/x/subkeys/internal/ante/mempool.go +++ b/x/subkeys/internal/ante/mempool.go @@ -24,7 +24,7 @@ func NewDelegatedMempoolFeeDecorator() DelegatedMempoolFeeDecorator { func (mfd DelegatedMempoolFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { feeTx, ok := tx.(DelegatedFeeTx) if !ok { - return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") + return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a DelegatedFeeTx") } feeCoins := feeTx.GetFee() gas := feeTx.GetGas() diff --git a/x/subkeys/internal/ante/mempool_test.go b/x/subkeys/internal/ante/mempool_test.go index 4b9c8b9608ec..347c00dd9215 100644 --- a/x/subkeys/internal/ante/mempool_test.go +++ b/x/subkeys/internal/ante/mempool_test.go @@ -9,8 +9,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - // "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types" "github.com/cosmos/cosmos-sdk/x/subkeys/internal/ante" + "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types/tx" ) func TestEnsureMempoolFees(t *testing.T) { @@ -25,13 +25,14 @@ func TestEnsureMempoolFees(t *testing.T) { // msg and signatures msg1 := authtypes.NewTestMsg(addr1) - fee := authtypes.NewStdFee(100000, sdk.NewCoins(sdk.NewInt64Coin("atom", 100))) + // TODO: try this with real delegation + fee := tx.NewDelegatedFee(100000, sdk.NewCoins(sdk.NewInt64Coin("atom", 100)), nil) msgs := []sdk.Msg{msg1} privs, accNums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} // TODO - tx := authtypes.NewTestTx(ctx, msgs, privs, accNums, seqs, fee) + tx := tx.NewTestTx(ctx, msgs, privs, accNums, seqs, fee) // Set high gas price so standard test fee fails atomPrice := sdk.NewDecCoinFromDec("atom", sdk.NewDec(200).Quo(sdk.NewDec(100000))) diff --git a/x/subkeys/internal/types/tx/test_common.go b/x/subkeys/internal/types/tx/test_common.go new file mode 100644 index 000000000000..cda6ae55e8ea --- /dev/null +++ b/x/subkeys/internal/types/tx/test_common.go @@ -0,0 +1,26 @@ +// noalias +package tx + +import ( + "github.com/tendermint/tendermint/crypto" + + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums []uint64, seqs []uint64, fee DelegatedFee) sdk.Tx { + sigs := make([]authtypes.StdSignature, len(privs)) + for i, priv := range privs { + signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], fee, msgs, "") + + sig, err := priv.Sign(signBytes) + if err != nil { + panic(err) + } + + sigs[i] = authtypes.StdSignature{PubKey: priv.PubKey(), Signature: sig} + } + + tx := NewDelegatedTx(msgs, fee, sigs, "") + return tx +} diff --git a/x/subkeys/internal/types/tx/tx.go b/x/subkeys/internal/types/tx/tx.go new file mode 100644 index 000000000000..339983b7e08e --- /dev/null +++ b/x/subkeys/internal/types/tx/tx.go @@ -0,0 +1,241 @@ +package tx + +import ( + "encoding/json" + "fmt" + + "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/multisig" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/exported" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +var ( + // _ sdk.Tx = (*DelegatedTx)(nil) + + maxGasWanted = uint64((1 << 63) - 1) +) + +// DelegatedTx is wraps a Msg with Fee and Signatures, +// adding the ability to delegate the fee payment +// NOTE: the first signature responsible for paying fees, either directly, +// or must be authorized to spend from the provided Fee.FeeAccount +type DelegatedTx struct { + Msgs []sdk.Msg `json:"msg" yaml:"msg"` + Fee DelegatedFee `json:"fee" yaml:"fee"` + Signatures []authtypes.StdSignature `json:"signatures" yaml:"signatures"` + Memo string `json:"memo" yaml:"memo"` + FeeAccount sdk.AccAddress `json:"fee_account" yaml:"fee_account"` +} + +func NewDelegatedTx(msgs []sdk.Msg, fee DelegatedFee, sigs []authtypes.StdSignature, memo string) DelegatedTx { + return DelegatedTx{ + Msgs: msgs, + Fee: fee, + Signatures: sigs, + Memo: memo, + } +} + +// GetMsgs returns the all the transaction's messages. +func (tx DelegatedTx) GetMsgs() []sdk.Msg { return tx.Msgs } + +// ValidateBasic does a simple and lightweight validation check that doesn't +// require access to any other information. +func (tx DelegatedTx) ValidateBasic() sdk.Error { + stdSigs := tx.GetSignatures() + + if tx.Fee.Gas > maxGasWanted { + return sdk.ErrGasOverflow(fmt.Sprintf("invalid gas supplied; %d > %d", tx.Fee.Gas, maxGasWanted)) + } + if tx.Fee.Amount.IsAnyNegative() { + return sdk.ErrInsufficientFee(fmt.Sprintf("invalid fee %s amount provided", tx.Fee.Amount)) + } + if len(stdSigs) == 0 { + return sdk.ErrNoSignatures("no signers") + } + if len(stdSigs) != len(tx.GetSigners()) { + return sdk.ErrUnauthorized("wrong number of signers") + } + + return nil +} + +// CountSubKeys counts the total number of keys for a multi-sig public key. +func CountSubKeys(pub crypto.PubKey) int { + v, ok := pub.(multisig.PubKeyMultisigThreshold) + if !ok { + return 1 + } + + numKeys := 0 + for _, subkey := range v.PubKeys { + numKeys += CountSubKeys(subkey) + } + + return numKeys +} + +// GetSigners returns the addresses that must sign the transaction. +// Addresses are returned in a deterministic order. +// They are accumulated from the GetSigners method for each Msg +// in the order they appear in tx.GetMsgs(). +// Duplicate addresses will be omitted. +func (tx DelegatedTx) GetSigners() []sdk.AccAddress { + seen := map[string]bool{} + var signers []sdk.AccAddress + for _, msg := range tx.GetMsgs() { + for _, addr := range msg.GetSigners() { + if !seen[addr.String()] { + signers = append(signers, addr) + seen[addr.String()] = true + } + } + } + return signers +} + +// GetMemo returns the memo +func (tx DelegatedTx) GetMemo() string { return tx.Memo } + +// GetSignatures returns the signature of signers who signed the Msg. +// CONTRACT: Length returned is same as length of +// pubkeys returned from MsgKeySigners, and the order +// matches. +// CONTRACT: If the signature is missing (ie the Msg is +// invalid), then the corresponding signature is +// .Empty(). +func (tx DelegatedTx) GetSignatures() [][]byte { + sigs := make([][]byte, len(tx.Signatures)) + for i, stdSig := range tx.Signatures { + sigs[i] = stdSig.Signature + } + return sigs +} + +// GetPubkeys returns the pubkeys of signers if the pubkey is included in the signature +// If pubkey is not included in the signature, then nil is in the slice instead +func (tx DelegatedTx) GetPubKeys() []crypto.PubKey { + pks := make([]crypto.PubKey, len(tx.Signatures)) + for i, stdSig := range tx.Signatures { + pks[i] = stdSig.PubKey + } + return pks +} + +// GetSignBytes returns the signBytes of the tx for a given signer +func (tx DelegatedTx) GetSignBytes(ctx sdk.Context, acc exported.Account) []byte { + genesis := ctx.BlockHeight() == 0 + chainID := ctx.ChainID() + var accNum uint64 + if !genesis { + accNum = acc.GetAccountNumber() + } + return StdSignBytes(chainID, accNum, acc.GetSequence(), tx.Fee, tx.Msgs, tx.Memo) +} + +// GetGas returns the Gas in DelegatedFee +func (tx DelegatedTx) GetGas() uint64 { return tx.Fee.Gas } + +// GetFee returns the FeeAmount in DelegatedFee +func (tx DelegatedTx) GetFee() sdk.Coins { return tx.Fee.Amount } + +// FeePayer returns the address that is responsible for paying fee +// This can be explicily set in DelegatedFee, or defaults to MainSigner +func (tx DelegatedTx) FeePayer() sdk.AccAddress { + if len(tx.Fee.FeeAccount) != 0 { + return tx.Fee.FeeAccount + } + return tx.MainSigner() +} + +// MainSigner returns the first signer of the tx, by default this +// account is responsible for fees, if not explicitly set. +func (tx DelegatedTx) MainSigner() sdk.AccAddress { + if len(tx.GetSigners()) != 0 { + return tx.GetSigners()[0] + } + return sdk.AccAddress{} +} + +// DelegatedFee includes the amount of coins paid in fees and the maximum +// gas to be used by the transaction. The ratio yields an effective "gasprice", +// which must be above some miminum to be accepted into the mempool. +type DelegatedFee struct { + Amount sdk.Coins `json:"amount" yaml:"amount"` + Gas uint64 `json:"gas" yaml:"gas"` + FeeAccount sdk.AccAddress `json:"fee_account,omitempty" yaml:"fee_account"` +} + +// NewDelegatedFee returns a new instance of DelegatedFee +func NewDelegatedFee(gas uint64, amount sdk.Coins, feeAccount sdk.AccAddress) DelegatedFee { + return DelegatedFee{ + Amount: amount, + Gas: gas, + FeeAccount: feeAccount, + } +} + +// Bytes for signing later +func (fee DelegatedFee) Bytes() []byte { + // normalize. XXX + // this is a sign of something ugly + // (in the lcd_test, client side its null, + // server side its []) + if len(fee.Amount) == 0 { + fee.Amount = sdk.NewCoins() + } + cdc := codec.New() + bz, err := cdc.MarshalJSON(fee) + if err != nil { + panic(err) + } + return bz +} + +// GasPrices returns the gas prices for a DelegatedFee. +// +// NOTE: The gas prices returned are not the true gas prices that were +// originally part of the submitted transaction because the fee is computed +// as fee = ceil(gasWanted * gasPrices). +func (fee DelegatedFee) GasPrices() sdk.DecCoins { + return sdk.NewDecCoins(fee.Amount).QuoDec(sdk.NewDec(int64(fee.Gas))) +} + +// DelegatedSignDoc is replay-prevention structure. +// It includes the result of msg.GetSignBytes(), +// as well as the ChainID (prevent cross chain replay) +// and the Sequence numbers for each signature (prevent +// inchain replay and enforce tx ordering per account). +type DelegatedSignDoc struct { + AccountNumber uint64 `json:"account_number" yaml:"account_number"` + ChainID string `json:"chain_id" yaml:"chain_id"` + Fee json.RawMessage `json:"fee" yaml:"fee"` + Memo string `json:"memo" yaml:"memo"` + Msgs []json.RawMessage `json:"msgs" yaml:"msgs"` + Sequence uint64 `json:"sequence" yaml:"sequence"` +} + +// StdSignBytes returns the bytes to sign for a transaction. +func StdSignBytes(chainID string, accnum uint64, sequence uint64, fee DelegatedFee, msgs []sdk.Msg, memo string) []byte { + cdc := codec.New() + msgsBytes := make([]json.RawMessage, 0, len(msgs)) + for _, msg := range msgs { + msgsBytes = append(msgsBytes, json.RawMessage(msg.GetSignBytes())) + } + bz, err := cdc.MarshalJSON(DelegatedSignDoc{ + AccountNumber: accnum, + ChainID: chainID, + Fee: json.RawMessage(fee.Bytes()), + Memo: memo, + Msgs: msgsBytes, + Sequence: sequence, + }) + if err != nil { + panic(err) + } + return sdk.MustSortJSON(bz) +} From e939e989f8d4f39cb7b650ef145c7fb42652dea4 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Fri, 18 Oct 2019 11:42:22 +0200 Subject: [PATCH 033/184] Revert all changes to x/auth.StdTx --- simapp/test_helpers.go | 4 ++-- x/auth/ante/ante_test.go | 2 +- x/auth/client/cli/tx_multisign.go | 4 ++-- x/auth/client/cli/tx_sign.go | 2 +- x/auth/client/utils/rest.go | 4 ++-- x/auth/client/utils/tx.go | 2 +- x/auth/client/utils/tx_test.go | 8 ++------ x/auth/types/stdsignmsg.go | 15 +++++++-------- x/auth/types/stdtx.go | 18 +++++------------- x/auth/types/stdtx_test.go | 23 +++++++++++------------ x/auth/types/test_common.go | 27 +++++---------------------- x/auth/types/txbuilder.go | 21 ++++----------------- x/auth/types/txbuilder_test.go | 4 +--- x/distribution/client/cli/tx_test.go | 1 - x/genutil/types/genesis_state_test.go | 4 ++-- x/mock/app.go | 4 ++-- 16 files changed, 48 insertions(+), 95 deletions(-) diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 9166d55e1b98..c108d9f9f5e1 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -120,7 +120,7 @@ func GenTx(msgs []sdk.Msg, accnums []uint64, seq []uint64, priv ...crypto.PrivKe for i, p := range priv { // use a empty chainID for ease of testing - sig, err := p.Sign(auth.StdSignBytes("", accnums[i], seq[i], fee, msgs, memo, nil)) + sig, err := p.Sign(auth.StdSignBytes("", accnums[i], seq[i], fee, msgs, memo)) if err != nil { panic(err) } @@ -131,7 +131,7 @@ func GenTx(msgs []sdk.Msg, accnums []uint64, seq []uint64, priv ...crypto.PrivKe } } - return auth.NewStdTx(msgs, fee, sigs, memo, nil) + return auth.NewStdTx(msgs, fee, sigs, memo) } // SignCheckDeliver checks a generated signed transaction and simulates a diff --git a/x/auth/ante/ante_test.go b/x/auth/ante/ante_test.go index 643feccf477b..1cbc7419c6c0 100644 --- a/x/auth/ante/ante_test.go +++ b/x/auth/ante/ante_test.go @@ -513,7 +513,7 @@ func TestAnteHandlerBadSignBytes(t *testing.T) { for _, cs := range cases { tx := types.NewTestTxWithSignBytes( msgs, privs, accnums, seqs, fee, - types.StdSignBytes(cs.chainID, cs.accnum, cs.seq, cs.fee, cs.msgs, "", nil), + types.StdSignBytes(cs.chainID, cs.accnum, cs.seq, cs.fee, cs.msgs, ""), "", ) checkInvalidTx(t, anteHandler, ctx, tx, false, cs.code) diff --git a/x/auth/client/cli/tx_multisign.go b/x/auth/client/cli/tx_multisign.go index ae020f7fcb54..e6d958a5d9cd 100644 --- a/x/auth/client/cli/tx_multisign.go +++ b/x/auth/client/cli/tx_multisign.go @@ -102,7 +102,7 @@ func makeMultiSignCmd(cdc *codec.Codec) func(cmd *cobra.Command, args []string) // Validate each signature sigBytes := types.StdSignBytes( txBldr.ChainID(), txBldr.AccountNumber(), txBldr.Sequence(), - stdTx.Fee, stdTx.GetMsgs(), stdTx.GetMemo(), stdTx.FeeAccount, + stdTx.Fee, stdTx.GetMsgs(), stdTx.GetMemo(), ) if ok := stdSig.PubKey.VerifyBytes(sigBytes, stdSig.Signature); !ok { return fmt.Errorf("couldn't verify signature") @@ -113,7 +113,7 @@ func makeMultiSignCmd(cdc *codec.Codec) func(cmd *cobra.Command, args []string) } newStdSig := types.StdSignature{Signature: cdc.MustMarshalBinaryBare(multisigSig), PubKey: multisigPub} - newTx := types.NewStdTx(stdTx.GetMsgs(), stdTx.Fee, []types.StdSignature{newStdSig}, stdTx.GetMemo(), stdTx.GetFeeAccount()) + newTx := types.NewStdTx(stdTx.GetMsgs(), stdTx.Fee, []types.StdSignature{newStdSig}, stdTx.GetMemo()) sigOnly := viper.GetBool(flagSigOnly) var json []byte diff --git a/x/auth/client/cli/tx_sign.go b/x/auth/client/cli/tx_sign.go index b5fb15031038..d4af880d3e91 100644 --- a/x/auth/client/cli/tx_sign.go +++ b/x/auth/client/cli/tx_sign.go @@ -230,7 +230,7 @@ func printAndValidateSigs( sigBytes := types.StdSignBytes( chainID, acc.GetAccountNumber(), acc.GetSequence(), - stdTx.Fee, stdTx.GetMsgs(), stdTx.GetMemo(), stdTx.GetFeeAccount(), + stdTx.Fee, stdTx.GetMsgs(), stdTx.GetMemo(), ) if ok := sig.VerifyBytes(sigBytes, sig.Signature); !ok { diff --git a/x/auth/client/utils/rest.go b/x/auth/client/utils/rest.go index dce53f67d8c3..9423fe629ee4 100644 --- a/x/auth/client/utils/rest.go +++ b/x/auth/client/utils/rest.go @@ -26,7 +26,7 @@ func WriteGenerateStdTxResponse(w http.ResponseWriter, cliCtx context.CLIContext txBldr := types.NewTxBuilder( GetTxEncoder(cliCtx.Codec), br.AccountNumber, br.Sequence, gas, gasAdj, - br.Simulate, br.ChainID, br.Memo, br.FeeAccount, br.Fees, br.GasPrices, + br.Simulate, br.ChainID, br.Memo, br.Fees, br.GasPrices, ) if br.Simulate || simAndExec { @@ -53,7 +53,7 @@ func WriteGenerateStdTxResponse(w http.ResponseWriter, cliCtx context.CLIContext return } - output, err := cliCtx.Codec.MarshalJSON(types.NewStdTx(stdMsg.Msgs, stdMsg.Fee, nil, stdMsg.Memo, stdMsg.FeeAccount)) + output, err := cliCtx.Codec.MarshalJSON(types.NewStdTx(stdMsg.Msgs, stdMsg.Fee, nil, stdMsg.Memo)) if err != nil { rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) return diff --git a/x/auth/client/utils/tx.go b/x/auth/client/utils/tx.go index a94b96717162..d2212a039ad4 100644 --- a/x/auth/client/utils/tx.go +++ b/x/auth/client/utils/tx.go @@ -349,7 +349,7 @@ func buildUnsignedStdTxOffline(txBldr authtypes.TxBuilder, cliCtx context.CLICon return stdTx, nil } - return authtypes.NewStdTx(stdSignMsg.Msgs, stdSignMsg.Fee, nil, stdSignMsg.Memo, stdSignMsg.FeeAccount), nil + return authtypes.NewStdTx(stdSignMsg.Msgs, stdSignMsg.Fee, nil, stdSignMsg.Memo), nil } func isTxSigner(user sdk.AccAddress, signers []sdk.AccAddress) bool { diff --git a/x/auth/client/utils/tx_test.go b/x/auth/client/utils/tx_test.go index e689d8690cca..cde10cc56029 100644 --- a/x/auth/client/utils/tx_test.go +++ b/x/auth/client/utils/tx_test.go @@ -99,9 +99,7 @@ func TestReadStdTxFromFile(t *testing.T) { // Build a test transaction fee := authtypes.NewStdFee(50000, sdk.Coins{sdk.NewInt64Coin("atom", 150)}) - feeAccount, err := sdk.AccAddressFromBech32("cosmos1zxcxurm8gwp43n4efqms6484gkdnnq763w03t6") - require.NoError(t, err) - stdTx := authtypes.NewStdTx([]sdk.Msg{}, fee, []authtypes.StdSignature{}, "foomemo", feeAccount) + stdTx := authtypes.NewStdTx([]sdk.Msg{}, fee, []authtypes.StdSignature{}, "foomemo") // Write it to the file encodedTx, _ := cdc.MarshalJSON(stdTx) @@ -112,13 +110,11 @@ func TestReadStdTxFromFile(t *testing.T) { decodedTx, err := ReadStdTxFromFile(cdc, jsonTxFile.Name()) require.NoError(t, err) require.Equal(t, decodedTx.Memo, "foomemo") - require.Equal(t, decodedTx.FeeAccount, feeAccount) - require.Equal(t, decodedTx.Fee, fee) } func compareEncoders(t *testing.T, expected sdk.TxEncoder, actual sdk.TxEncoder) { msgs := []sdk.Msg{sdk.NewTestMsg(addr)} - tx := authtypes.NewStdTx(msgs, authtypes.StdFee{}, []authtypes.StdSignature{}, "", nil) + tx := authtypes.NewStdTx(msgs, authtypes.StdFee{}, []authtypes.StdSignature{}, "") defaultEncoderBytes, err := expected(tx) require.NoError(t, err) diff --git a/x/auth/types/stdsignmsg.go b/x/auth/types/stdsignmsg.go index f27b00291fb8..e018dac40048 100644 --- a/x/auth/types/stdsignmsg.go +++ b/x/auth/types/stdsignmsg.go @@ -8,16 +8,15 @@ import ( // a Msg with the other requirements for a StdSignDoc before // it is signed. For use in the CLI. type StdSignMsg struct { - ChainID string `json:"chain_id" yaml:"chain_id"` - AccountNumber uint64 `json:"account_number" yaml:"account_number"` - Sequence uint64 `json:"sequence" yaml:"sequence"` - Fee StdFee `json:"fee" yaml:"fee"` - Msgs []sdk.Msg `json:"msgs" yaml:"msgs"` - Memo string `json:"memo" yaml:"memo"` - FeeAccount sdk.AccAddress `json:"fee_account" yaml:"fee_account"` + ChainID string `json:"chain_id" yaml:"chain_id"` + AccountNumber uint64 `json:"account_number" yaml:"account_number"` + Sequence uint64 `json:"sequence" yaml:"sequence"` + Fee StdFee `json:"fee" yaml:"fee"` + Msgs []sdk.Msg `json:"msgs" yaml:"msgs"` + Memo string `json:"memo" yaml:"memo"` } // get message bytes func (msg StdSignMsg) Bytes() []byte { - return StdSignBytes(msg.ChainID, msg.AccountNumber, msg.Sequence, msg.Fee, msg.Msgs, msg.Memo, msg.FeeAccount) + return StdSignBytes(msg.ChainID, msg.AccountNumber, msg.Sequence, msg.Fee, msg.Msgs, msg.Memo) } diff --git a/x/auth/types/stdtx.go b/x/auth/types/stdtx.go index 713539d2ca2b..fa8b5d100d5f 100644 --- a/x/auth/types/stdtx.go +++ b/x/auth/types/stdtx.go @@ -26,16 +26,14 @@ type StdTx struct { Fee StdFee `json:"fee" yaml:"fee"` Signatures []StdSignature `json:"signatures" yaml:"signatures"` Memo string `json:"memo" yaml:"memo"` - FeeAccount sdk.AccAddress `json:"fee_account" yaml:"fee_account"` } -func NewStdTx(msgs []sdk.Msg, fee StdFee, sigs []StdSignature, memo string, feeAccount sdk.AccAddress) StdTx { +func NewStdTx(msgs []sdk.Msg, fee StdFee, sigs []StdSignature, memo string) StdTx { return StdTx{ Msgs: msgs, Fee: fee, Signatures: sigs, Memo: memo, - FeeAccount: feeAccount, } } @@ -100,9 +98,6 @@ func (tx StdTx) GetSigners() []sdk.AccAddress { // GetMemo returns the memo func (tx StdTx) GetMemo() string { return tx.Memo } -// GetFeeAccount returns the account paying the fees (often nil, default ot first signer) -func (tx StdTx) GetFeeAccount() sdk.AccAddress { return tx.FeeAccount } - // GetSignatures returns the signature of signers who signed the Msg. // CONTRACT: Length returned is same as length of // pubkeys returned from MsgKeySigners, and the order @@ -138,7 +133,7 @@ func (tx StdTx) GetSignBytes(ctx sdk.Context, acc exported.Account) []byte { } return StdSignBytes( - chainID, accNum, acc.GetSequence(), tx.Fee, tx.Msgs, tx.Memo, tx.FeeAccount, + chainID, accNum, acc.GetSequence(), tx.Fee, tx.Msgs, tx.Memo, ) } @@ -215,11 +210,10 @@ type StdSignDoc struct { Memo string `json:"memo" yaml:"memo"` Msgs []json.RawMessage `json:"msgs" yaml:"msgs"` Sequence uint64 `json:"sequence" yaml:"sequence"` - FeeAccount sdk.AccAddress `json:"fee_account" yaml:"fee_account"` } // StdSignBytes returns the bytes to sign for a transaction. -func StdSignBytes(chainID string, accnum uint64, sequence uint64, fee StdFee, msgs []sdk.Msg, memo string, feeAccount sdk.AccAddress) []byte { +func StdSignBytes(chainID string, accnum uint64, sequence uint64, fee StdFee, msgs []sdk.Msg, memo string) []byte { msgsBytes := make([]json.RawMessage, 0, len(msgs)) for _, msg := range msgs { msgsBytes = append(msgsBytes, json.RawMessage(msg.GetSignBytes())) @@ -231,7 +225,6 @@ func StdSignBytes(chainID string, accnum uint64, sequence uint64, fee StdFee, ms Memo: memo, Msgs: msgsBytes, Sequence: sequence, - FeeAccount: feeAccount, }) if err != nil { panic(err) @@ -241,9 +234,8 @@ func StdSignBytes(chainID string, accnum uint64, sequence uint64, fee StdFee, ms // StdSignature represents a sig type StdSignature struct { - // Pubkey is optional - crypto.PubKey `json:"pub_key" yaml:"pub_key"` - Signature []byte `json:"signature" yaml:"signature"` + crypto.PubKey `json:"pub_key" yaml:"pub_key"` // optional + Signature []byte `json:"signature" yaml:"signature"` } // DefaultTxDecoder logic for standard transaction decoding diff --git a/x/auth/types/stdtx_test.go b/x/auth/types/stdtx_test.go index c731b595cff2..375a15c49cc4 100644 --- a/x/auth/types/stdtx_test.go +++ b/x/auth/types/stdtx_test.go @@ -25,7 +25,7 @@ func TestStdTx(t *testing.T) { fee := NewTestStdFee() sigs := []StdSignature{} - tx := NewStdTx(msgs, fee, sigs, "", nil) + tx := NewStdTx(msgs, fee, sigs, "") require.Equal(t, msgs, tx.GetMsgs()) require.Equal(t, sigs, tx.Signatures) @@ -35,13 +35,12 @@ func TestStdTx(t *testing.T) { func TestStdSignBytes(t *testing.T) { type args struct { - chainID string - accnum uint64 - sequence uint64 - fee StdFee - msgs []sdk.Msg - memo string - feeAccount sdk.AccAddress + chainID string + accnum uint64 + sequence uint64 + fee StdFee + msgs []sdk.Msg + memo string } defaultFee := NewTestStdFee() tests := []struct { @@ -49,12 +48,12 @@ func TestStdSignBytes(t *testing.T) { want string }{ { - args{"1234", 3, 6, defaultFee, []sdk.Msg{sdk.NewTestMsg(addr)}, "memo", nil}, - fmt.Sprintf(`{"account_number":"3","chain_id":"1234","fee":{"amount":[{"amount":"150","denom":"atom"}],"gas":"100000"},"fee_account":"","memo":"memo","msgs":[["%s"]],"sequence":"6"}`, addr), + args{"1234", 3, 6, defaultFee, []sdk.Msg{sdk.NewTestMsg(addr)}, "memo"}, + fmt.Sprintf("{\"account_number\":\"3\",\"chain_id\":\"1234\",\"fee\":{\"amount\":[{\"amount\":\"150\",\"denom\":\"atom\"}],\"gas\":\"100000\"},\"memo\":\"memo\",\"msgs\":[[\"%s\"]],\"sequence\":\"6\"}", addr), }, } for i, tc := range tests { - got := string(StdSignBytes(tc.args.chainID, tc.args.accnum, tc.args.sequence, tc.args.fee, tc.args.msgs, tc.args.memo, tc.args.feeAccount)) + got := string(StdSignBytes(tc.args.chainID, tc.args.accnum, tc.args.sequence, tc.args.fee, tc.args.msgs, tc.args.memo)) require.Equal(t, tc.want, got, "Got unexpected result on test case i: %d", i) } } @@ -125,7 +124,7 @@ func TestDefaultTxEncoder(t *testing.T) { fee := NewTestStdFee() sigs := []StdSignature{} - tx := NewStdTx(msgs, fee, sigs, "", nil) + tx := NewStdTx(msgs, fee, sigs, "") cdcBytes, err := cdc.MarshalBinaryLengthPrefixed(tx) diff --git a/x/auth/types/test_common.go b/x/auth/types/test_common.go index 447ae77d1be3..9e2ba20e98d2 100644 --- a/x/auth/types/test_common.go +++ b/x/auth/types/test_common.go @@ -35,7 +35,7 @@ func KeyTestPubAddr() (crypto.PrivKey, crypto.PubKey, sdk.AccAddress) { func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums []uint64, seqs []uint64, fee StdFee) sdk.Tx { sigs := make([]StdSignature, len(privs)) for i, priv := range privs { - signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], fee, msgs, "", nil) + signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], fee, msgs, "") sig, err := priv.Sign(signBytes) if err != nil { @@ -45,14 +45,14 @@ func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums sigs[i] = StdSignature{PubKey: priv.PubKey(), Signature: sig} } - tx := NewStdTx(msgs, fee, sigs, "", nil) + tx := NewStdTx(msgs, fee, sigs, "") return tx } func NewTestTxWithMemo(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums []uint64, seqs []uint64, fee StdFee, memo string) sdk.Tx { sigs := make([]StdSignature, len(privs)) for i, priv := range privs { - signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], fee, msgs, memo, nil) + signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], fee, msgs, memo) sig, err := priv.Sign(signBytes) if err != nil { @@ -62,24 +62,7 @@ func NewTestTxWithMemo(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, sigs[i] = StdSignature{PubKey: priv.PubKey(), Signature: sig} } - tx := NewStdTx(msgs, fee, sigs, memo, nil) - return tx -} - -func NewTestTxWithFeeAccount(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums []uint64, seqs []uint64, fee StdFee, feeAccount sdk.AccAddress) sdk.Tx { - sigs := make([]StdSignature, len(privs)) - for i, priv := range privs { - signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], fee, msgs, "", feeAccount) - - sig, err := priv.Sign(signBytes) - if err != nil { - panic(err) - } - - sigs[i] = StdSignature{PubKey: priv.PubKey(), Signature: sig} - } - - tx := NewStdTx(msgs, fee, sigs, "", feeAccount) + tx := NewStdTx(msgs, fee, sigs, memo) return tx } @@ -94,6 +77,6 @@ func NewTestTxWithSignBytes(msgs []sdk.Msg, privs []crypto.PrivKey, accNums []ui sigs[i] = StdSignature{PubKey: priv.PubKey(), Signature: sig} } - tx := NewStdTx(msgs, fee, sigs, memo, nil) + tx := NewStdTx(msgs, fee, sigs, memo) return tx } diff --git a/x/auth/types/txbuilder.go b/x/auth/types/txbuilder.go index d2852a98e564..7d60086a137d 100644 --- a/x/auth/types/txbuilder.go +++ b/x/auth/types/txbuilder.go @@ -24,7 +24,6 @@ type TxBuilder struct { simulateAndExecute bool chainID string memo string - feeAccount sdk.AccAddress fees sdk.Coins gasPrices sdk.DecCoins } @@ -32,7 +31,7 @@ type TxBuilder struct { // NewTxBuilder returns a new initialized TxBuilder. func NewTxBuilder( txEncoder sdk.TxEncoder, accNumber, seq, gas uint64, gasAdj float64, - simulateAndExecute bool, chainID, memo string, feeAccount sdk.AccAddress, fees sdk.Coins, gasPrices sdk.DecCoins, + simulateAndExecute bool, chainID, memo string, fees sdk.Coins, gasPrices sdk.DecCoins, ) TxBuilder { return TxBuilder{ @@ -45,7 +44,6 @@ func NewTxBuilder( simulateAndExecute: simulateAndExecute, chainID: chainID, memo: memo, - feeAccount: feeAccount, fees: fees, gasPrices: gasPrices, } @@ -103,9 +101,6 @@ func (bldr TxBuilder) ChainID() string { return bldr.chainID } // Memo returns the memo message func (bldr TxBuilder) Memo() string { return bldr.memo } -// FeeAccount returns an alternate account to pay fees -func (bldr *TxBuilder) FeeAccount() sdk.AccAddress { return bldr.feeAccount } - // Fees returns the fees for the transaction func (bldr TxBuilder) Fees() sdk.Coins { return bldr.fees } @@ -130,12 +125,6 @@ func (bldr TxBuilder) WithGas(gas uint64) TxBuilder { return bldr } -// WithFeeAccount returns a copy of the context with an updated FeeAccount. -func (bldr TxBuilder) WithFeeAccount(feeAccount sdk.AccAddress) TxBuilder { - bldr.feeAccount = feeAccount - return bldr -} - // WithFees returns a copy of the context with an updated fee. func (bldr TxBuilder) WithFees(fees string) TxBuilder { parsedFees, err := sdk.ParseCoins(fees) @@ -212,7 +201,6 @@ func (bldr TxBuilder) BuildSignMsg(msgs []sdk.Msg) (StdSignMsg, error) { AccountNumber: bldr.accountNumber, Sequence: bldr.sequence, Memo: bldr.memo, - FeeAccount: bldr.feeAccount, Msgs: msgs, Fee: NewStdFee(bldr.gas, fees), }, nil @@ -226,7 +214,7 @@ func (bldr TxBuilder) Sign(name, passphrase string, msg StdSignMsg) ([]byte, err return nil, err } - return bldr.txEncoder(NewStdTx(msg.Msgs, msg.Fee, []StdSignature{sig}, msg.Memo, msg.FeeAccount)) + return bldr.txEncoder(NewStdTx(msg.Msgs, msg.Fee, []StdSignature{sig}, msg.Memo)) } // BuildAndSign builds a single message to be signed, and signs a transaction @@ -250,7 +238,7 @@ func (bldr TxBuilder) BuildTxForSim(msgs []sdk.Msg) ([]byte, error) { // the ante handler will populate with a sentinel pubkey sigs := []StdSignature{{}} - return bldr.txEncoder(NewStdTx(signMsg.Msgs, signMsg.Fee, sigs, signMsg.Memo, signMsg.FeeAccount)) + return bldr.txEncoder(NewStdTx(signMsg.Msgs, signMsg.Fee, sigs, signMsg.Memo)) } // SignStdTx appends a signature to a StdTx and returns a copy of it. If append @@ -267,7 +255,6 @@ func (bldr TxBuilder) SignStdTx(name, passphrase string, stdTx StdTx, appendSig Fee: stdTx.Fee, Msgs: stdTx.GetMsgs(), Memo: stdTx.GetMemo(), - FeeAccount: stdTx.FeeAccount, }) if err != nil { return @@ -279,7 +266,7 @@ func (bldr TxBuilder) SignStdTx(name, passphrase string, stdTx StdTx, appendSig } else { sigs = append(sigs, stdSignature) } - signedStdTx = NewStdTx(stdTx.GetMsgs(), stdTx.Fee, sigs, stdTx.GetMemo(), bldr.feeAccount) + signedStdTx = NewStdTx(stdTx.GetMsgs(), stdTx.Fee, sigs, stdTx.GetMemo()) return } diff --git a/x/auth/types/txbuilder_test.go b/x/auth/types/txbuilder_test.go index 056b195201a4..c0a0e337a9ab 100644 --- a/x/auth/types/txbuilder_test.go +++ b/x/auth/types/txbuilder_test.go @@ -20,7 +20,6 @@ func TestTxBuilderBuild(t *testing.T) { SimulateGas bool ChainID string Memo string - FeeAccount sdk.AccAddress Fees sdk.Coins GasPrices sdk.DecCoins } @@ -137,8 +136,7 @@ func TestTxBuilderBuild(t *testing.T) { bldr := NewTxBuilder( tt.fields.TxEncoder, tt.fields.AccountNumber, tt.fields.Sequence, tt.fields.Gas, tt.fields.GasAdjustment, tt.fields.SimulateGas, - tt.fields.ChainID, tt.fields.Memo, tt.fields.FeeAccount, - tt.fields.Fees, tt.fields.GasPrices, + tt.fields.ChainID, tt.fields.Memo, tt.fields.Fees, tt.fields.GasPrices, ) got, err := bldr.BuildSignMsg(tt.msgs) require.Equal(t, tt.wantErr, (err != nil)) diff --git a/x/distribution/client/cli/tx_test.go b/x/distribution/client/cli/tx_test.go index 51ae03488d8b..af09d5445a89 100644 --- a/x/distribution/client/cli/tx_test.go +++ b/x/distribution/client/cli/tx_test.go @@ -24,7 +24,6 @@ func createFakeTxBuilder() auth.TxBuilder { false, "test_chain", "hello", - nil, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1))), sdk.DecCoins{sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, sdk.NewDecWithPrec(10000, sdk.Precision))}, ) diff --git a/x/genutil/types/genesis_state_test.go b/x/genutil/types/genesis_state_test.go index 1f9ebf67a1e5..aed7cd7f311e 100644 --- a/x/genutil/types/genesis_state_test.go +++ b/x/genutil/types/genesis_state_test.go @@ -27,7 +27,7 @@ func TestValidateGenesisMultipleMessages(t *testing.T) { msg2 := stakingtypes.NewMsgCreateValidator(sdk.ValAddress(pk2.Address()), pk2, sdk.NewInt64Coin(sdk.DefaultBondDenom, 50), desc, comm, sdk.OneInt()) - genTxs := authtypes.NewStdTx([]sdk.Msg{msg1, msg2}, authtypes.StdFee{}, nil, "", nil) + genTxs := authtypes.NewStdTx([]sdk.Msg{msg1, msg2}, authtypes.StdFee{}, nil, "") genesisState := NewGenesisStateFromStdTx([]authtypes.StdTx{genTxs}) err := ValidateGenesis(genesisState) @@ -39,7 +39,7 @@ func TestValidateGenesisBadMessage(t *testing.T) { msg1 := stakingtypes.NewMsgEditValidator(sdk.ValAddress(pk1.Address()), desc, nil, nil) - genTxs := authtypes.NewStdTx([]sdk.Msg{msg1}, authtypes.StdFee{}, nil, "", nil) + genTxs := authtypes.NewStdTx([]sdk.Msg{msg1}, authtypes.StdFee{}, nil, "") genesisState := NewGenesisStateFromStdTx([]authtypes.StdTx{genTxs}) err := ValidateGenesis(genesisState) diff --git a/x/mock/app.go b/x/mock/app.go index 04e4230ee411..1e59e050507b 100644 --- a/x/mock/app.go +++ b/x/mock/app.go @@ -217,7 +217,7 @@ func GenTx(msgs []sdk.Msg, accnums []uint64, seq []uint64, priv ...crypto.PrivKe memo := "testmemotestmemo" for i, p := range priv { - sig, err := p.Sign(auth.StdSignBytes(chainID, accnums[i], seq[i], fee, msgs, memo, nil)) + sig, err := p.Sign(auth.StdSignBytes(chainID, accnums[i], seq[i], fee, msgs, memo)) if err != nil { panic(err) } @@ -228,7 +228,7 @@ func GenTx(msgs []sdk.Msg, accnums []uint64, seq []uint64, priv ...crypto.PrivKe } } - return auth.NewStdTx(msgs, fee, sigs, memo, nil) + return auth.NewStdTx(msgs, fee, sigs, memo) } // GeneratePrivKeys generates a total n secp256k1 private keys. From 6aef5c88b26b22eeac95486b8d5274a37d775138 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Fri, 18 Oct 2019 11:46:55 +0200 Subject: [PATCH 034/184] Appease scopelint --- simapp/app.go | 2 +- x/subkeys/internal/ante/fee_test.go | 3 ++- x/subkeys/internal/types/basic_fee_test.go | 3 ++- x/subkeys/internal/types/expiration_test.go | 9 ++++++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index 118cda2d0195..db7f52fa715e 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -18,7 +18,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/vesting" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/crisis" - "github.com/cosmos/cosmos-sdk/x/subkeys" distr "github.com/cosmos/cosmos-sdk/x/distribution" "github.com/cosmos/cosmos-sdk/x/genutil" "github.com/cosmos/cosmos-sdk/x/gov" @@ -27,6 +26,7 @@ import ( paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" "github.com/cosmos/cosmos-sdk/x/slashing" "github.com/cosmos/cosmos-sdk/x/staking" + "github.com/cosmos/cosmos-sdk/x/subkeys" "github.com/cosmos/cosmos-sdk/x/supply" ) diff --git a/x/subkeys/internal/ante/fee_test.go b/x/subkeys/internal/ante/fee_test.go index aa091760ad1b..de22d3aeee9a 100644 --- a/x/subkeys/internal/ante/fee_test.go +++ b/x/subkeys/internal/ante/fee_test.go @@ -218,7 +218,8 @@ func TestDeductFeesNoDelegation(t *testing.T) { }, } - for name, tc := range cases { + for name, stc := range cases { + tc := stc // to make scopelint happy t.Run(name, func(t *testing.T) { // msg and signatures fee := tx.NewDelegatedFee(100000, sdk.NewCoins(sdk.NewInt64Coin("atom", tc.fee)), tc.feeAccount) diff --git a/x/subkeys/internal/types/basic_fee_test.go b/x/subkeys/internal/types/basic_fee_test.go index 857153d05cc7..71e640166a90 100644 --- a/x/subkeys/internal/types/basic_fee_test.go +++ b/x/subkeys/internal/types/basic_fee_test.go @@ -82,7 +82,8 @@ func TestBasicFeeValidAllow(t *testing.T) { }, } - for name, tc := range cases { + for name, stc := range cases { + tc := stc // to make scopelint happy t.Run(name, func(t *testing.T) { err := tc.allow.ValidateBasic() if !tc.valid { diff --git a/x/subkeys/internal/types/expiration_test.go b/x/subkeys/internal/types/expiration_test.go index 5b032d204a08..0c154e2bc30f 100644 --- a/x/subkeys/internal/types/expiration_test.go +++ b/x/subkeys/internal/types/expiration_test.go @@ -48,7 +48,8 @@ func TestExpiresAt(t *testing.T) { }, } - for name, tc := range cases { + for name, stc := range cases { + tc := stc // to make scopelint happy t.Run(name, func(t *testing.T) { err := tc.example.ValidateBasic() assert.Equal(t, tc.zero, tc.example.IsZero()) @@ -107,7 +108,8 @@ func TestPeriodValid(t *testing.T) { }, } - for name, tc := range cases { + for name, stc := range cases { + tc := stc // to make scopelint happy t.Run(name, func(t *testing.T) { err := tc.period.ValidateBasic() if !tc.valid { @@ -150,7 +152,8 @@ func TestPeriodStep(t *testing.T) { }, } - for name, tc := range cases { + for name, stc := range cases { + tc := stc // to make scopelint happy t.Run(name, func(t *testing.T) { err := tc.period.ValidateBasic() require.NoError(t, err) From 121277295dca98d9881e8e482c5c13b5cc3e2d88 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Fri, 18 Oct 2019 11:56:02 +0200 Subject: [PATCH 035/184] Register DelegatedTx with codec --- x/subkeys/internal/types/tx/codec.go | 8 ++++++++ x/subkeys/internal/types/tx/tx.go | 2 +- x/subkeys/module.go | 6 +++--- 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 x/subkeys/internal/types/tx/codec.go diff --git a/x/subkeys/internal/types/tx/codec.go b/x/subkeys/internal/types/tx/codec.go new file mode 100644 index 000000000000..90baa93cf075 --- /dev/null +++ b/x/subkeys/internal/types/tx/codec.go @@ -0,0 +1,8 @@ +package tx + +import "github.com/cosmos/cosmos-sdk/codec" + +// RegisterCodec registers concrete types on the codec +func RegisterCodec(cdc *codec.Codec) { + cdc.RegisterConcrete(DelegatedTx{}, "cosmos-sdk/DelegatedTx", nil) +} diff --git a/x/subkeys/internal/types/tx/tx.go b/x/subkeys/internal/types/tx/tx.go index 339983b7e08e..a9a999b32f48 100644 --- a/x/subkeys/internal/types/tx/tx.go +++ b/x/subkeys/internal/types/tx/tx.go @@ -14,7 +14,7 @@ import ( ) var ( - // _ sdk.Tx = (*DelegatedTx)(nil) + _ sdk.Tx = DelegatedTx{} maxGasWanted = uint64((1 << 63) - 1) ) diff --git a/x/subkeys/module.go b/x/subkeys/module.go index b0b32332ea77..0364ee4a4549 100644 --- a/x/subkeys/module.go +++ b/x/subkeys/module.go @@ -12,13 +12,12 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + tx "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types/tx" ) // TODO: -// * cli -// * rest +// * docs // * periodic fee -// -> change StdFee instead of StdTx, etc? var ( _ module.AppModule = AppModule{} @@ -36,6 +35,7 @@ func (AppModuleBasic) Name() string { // RegisterCodec registers the delegation module's types for the given codec. func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { RegisterCodec(cdc) + tx.RegisterCodec(cdc) } // DefaultGenesis returns default genesis state as raw bytes for the delegation From 61df0c694337df04bed306ee8a687ff08488d662 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 21 Oct 2019 10:42:37 +0200 Subject: [PATCH 036/184] Address PR comments --- types/errors.go | 4 +- types/rest/rest.go | 21 +++---- x/subkeys/README.md | 121 ------------------------------------- x/subkeys/doc.go | 17 +++--- x/subkeys/exported/fees.go | 9 ++- x/subkeys/handler.go | 1 + 6 files changed, 28 insertions(+), 145 deletions(-) delete mode 100644 x/subkeys/README.md diff --git a/types/errors.go b/types/errors.go index d23d2e9bb322..bb8c98c54035 100644 --- a/types/errors.go +++ b/types/errors.go @@ -315,8 +315,8 @@ func ConvertError(err error) Error { if err == nil { return nil } - if sdk, ok := err.(Error); ok { - return sdk + if sdkError, ok := err.(Error); ok { + return sdkError } space, code, log := sdkerrors.ABCIInfo(err, false) return NewError(CodespaceType(space), CodeType(code), log) diff --git a/types/rest/rest.go b/types/rest/rest.go index 7a9048522177..89770c944650 100644 --- a/types/rest/rest.go +++ b/types/rest/rest.go @@ -47,17 +47,16 @@ type GasEstimateResponse struct { // BaseReq defines a structure that can be embedded in other request structures // that all share common "base" fields. type BaseReq struct { - From string `json:"from"` - Memo string `json:"memo"` - ChainID string `json:"chain_id"` - AccountNumber uint64 `json:"account_number"` - Sequence uint64 `json:"sequence"` - Fees sdk.Coins `json:"fees"` - FeeAccount sdk.AccAddress `json:"fee_account"` - GasPrices sdk.DecCoins `json:"gas_prices"` - Gas string `json:"gas"` - GasAdjustment string `json:"gas_adjustment"` - Simulate bool `json:"simulate"` + From string `json:"from"` + Memo string `json:"memo"` + ChainID string `json:"chain_id"` + AccountNumber uint64 `json:"account_number"` + Sequence uint64 `json:"sequence"` + Fees sdk.Coins `json:"fees"` + GasPrices sdk.DecCoins `json:"gas_prices"` + Gas string `json:"gas"` + GasAdjustment string `json:"gas_adjustment"` + Simulate bool `json:"simulate"` } // NewBaseReq creates a new basic request instance and sanitizes its values diff --git a/x/subkeys/README.md b/x/subkeys/README.md deleted file mode 100644 index 6a1cb65ca3e3..000000000000 --- a/x/subkeys/README.md +++ /dev/null @@ -1,121 +0,0 @@ -## Fee Delegation Work - -Much of this is ported from an older implementation of fee delegation from aaronc. - -To take a look at this (which had many changes to auth as well, which has been heavily refactored upstream): - -``` -git remote add keys https://github.com/cosmos-cg-key-management/cosmos-sdk.git -git fetch keys -git diff --compact-summary f1b08b85f 980d713f -``` - -This is based on https://gist.github.com/aaronc/b60628017352df5983791cad30babe56#fee-delegation - -In particular the following parts: - --------------------- - -The `delegation` module also allows for fee delegation via some -changes to the `AnteHandler` and `StdTx`. The behavior is similar -to that described above for `Msg` delegations except using -the interface `FeeAllowance` instead of `Capability`: - -```go -// FeeAllowance defines a permission for one account to use another account's balance -// to pay fees -type FeeAllowance interface { - // Accept checks whether this allowance allows the provided fees to be spent, - // and optionally updates the allowance or deletes it entirely - Accept(fee sdk.Coins, block abci.Header) (allow bool, updated FeeAllowance, delete bool) -} -``` - -An example `FeeAllowance` could be created that simply sets a `SpendLimit`: - -```go -type BasicFeeAllowance struct { - // SpendLimit specifies the maximum amount of tokens that can be spent - // by this capability and will be updated as tokens are spent. If it is - // empty, there is no spend limit and any amount of coins can be spent. - SpendLimit sdk.Coins -} - -func (cap BasicFeeAllowance) Accept(fee sdk.Coins, block abci.Header) (allow bool, updated FeeAllowance, delete bool) { - left, invalid := cap.SpendLimit.SafeSub(fee) - if invalid { - return false, nil, false - } - if left.IsZero() { - return true, nil, true - } - return true, BasicFeeAllowance{SpendLimit: left}, false -} - -``` - -Other `FeeAllowance` types could be created such as a daily spend limit. - -## `StdTx` and `AnteHandler` changes - -In order to support delegated fees `StdTx` and the `AnteHandler` needed to be changed. - -The field `FeeAccount` was added to `StdTx`. - -```go -type StdTx struct { - Msgs []sdk.Msg `json:"msg"` - Fee StdFee `json:"fee"` - Signatures []StdSignature `json:"signatures"` - Memo string `json:"memo"` - // FeeAccount is an optional account that fees can be spent from if such - // delegation is enabled - FeeAccount sdk.AccAddress `json:"fee_account"` -} -``` - -An interface `FeeDelegationHandler` (which is implemented by the `delegation` module) was created and a parameter for it was added to the default `AnteHandler`: - -```go -type FeeDelegationHandler interface { - // AllowDelegatedFees checks if the grantee can use the granter's account to spend the specified fees, updating - // any fee allowance in accordance with the provided fees - AllowDelegatedFees(ctx sdk.Context, grantee sdk.AccAddress, granter sdk.AccAddress, fee sdk.Coins) bool -} - -// NewAnteHandler returns an AnteHandler that checks and increments sequence -// numbers, checks signatures & account numbers, and deducts fees from the first -// signer. -func NewAnteHandler(ak AccountKeeper, fck FeeCollectionKeeper, feeDelegationHandler FeeDelegationHandler, sigGasConsumer SignatureVerificationGasConsumer) sdk.AnteHandler { -``` - -Basically if someone sets `FeeAccount` on `StdTx`, the `AnteHandler` will call into the `delegation` module via its `FeeDelegationHandler` and check if the tx's fees have been delegated by that `FeeAccount` to the key actually signing the transaction. - -## Core `FeeAllowance` types - -```go -type BasicFeeAllowance struct { - // SpendLimit specifies the maximum amount of tokens that can be spent - // by this capability and will be updated as tokens are spent. If it is - // empty, there is no spend limit and any amount of coins can be spent. - SpendLimit sdk.Coins - // Expiration specifies an optional time when this allowance expires - Expiration time.Time -} - -type PeriodicFeeAllowance struct { - BasicFeeAllowance - // Period specifies the time duration in which PeriodSpendLimit coins can - // be spent before that allowance is reset - Period time.Duration - // PeriodSpendLimit specifies the maximum number of coins that can be spent - // in the Period - PeriodSpendLimit sdk.Coins - // PeriodCanSpend is the number of coins left to be spend before the PeriodReset time - PeriodCanSpend sdk.Coins - // PeriodReset is the time at which this period resets and a new one begins, - // it is calculated from the start time of the first transaction after the - // last period ended - PeriodReset time.Time -} -``` \ No newline at end of file diff --git a/x/subkeys/doc.go b/x/subkeys/doc.go index d21ec229452e..b644d60de59d 100644 --- a/x/subkeys/doc.go +++ b/x/subkeys/doc.go @@ -14,19 +14,20 @@ A user would delegate fees to a user using MsgDelegateFeeAllowance and revoke that delegation using MsgRevokeFeeAllowance. In both cases Granter is the one who is delegating fees and Grantee is the one who is receiving the delegation. So grantee would correspond to the one who is signing a transaction and the -granter would be the address they place in StdTx.FeeAccount. +granter would be the address they place in DelegatedFee.FeeAccount. The fee allowance that a grantee receives is specified by an implementation of the FeeAllowance interface. Two FeeAllowance implementations are provided in this package: BasicFeeAllowance and PeriodicFeeAllowance. -TODO: update if needed with new modular ante handler +In order to integrate this into an application, we must use the ante handles from +this package instead of the default auth implementations for DeductFee +(adding custom logic) and MempoolFee (updating it to be compatible with DelegatedTx). +An application can do this simply by using `x/delegate_fees/internal/ante.NewAnteHandler()` +when setting up the app instead of the version from auth. -In order to integrate this into an application, the "ante handler" which deducts -fees must call Keeper.AllowDelegatedFees to check if -the provided StdTx.Fee can be delegated from the Std.TxFeeAccount address -to the first signer of the transaction. An example usage would be: - -allow := feeDelegationKeeper.AllowDelegatedFees(ctx, signers[0], stdTx.FeeAccount, stdTx.Fee.Amount) +I did not pull this into the top level package as it pulls in dependencies on the internals +of `x/auth` and if I understand correctly, this is bad practice to depend on other modules +except for the external package. */ package subkeys diff --git a/x/subkeys/exported/fees.go b/x/subkeys/exported/fees.go index a9c57de6c823..9d87600c4b3d 100644 --- a/x/subkeys/exported/fees.go +++ b/x/subkeys/exported/fees.go @@ -7,15 +7,18 @@ import ( ) // FeeAllowance implementations are tied to a given delegator and delegatee, -// and are used to enforce limits on this payment. +// and are used to enforce fee delegation limits. type FeeAllowance interface { // Accept can use fee payment requested as well as timestamp/height of the current block - // to determine whether or not to process this. + // to determine whether or not to process this. This is checked in + // Keeper.UseDelegatedFees and the return values should match how it is handled there. + // // If it returns an error, the fee payment is rejected, otherwise it is accepted. // The FeeAllowance implementation is expected to update it's internal state // and will be saved again after an acceptance. + // // If remove is true (regardless of the error), the FeeAllowance will be deleted from storage - // (eg. when it expires) + // (eg. when it is used up). (See call to RevokeFeeAllowance in Keeper.UseDelegatedFees) Accept(fee sdk.Coins, blockTime time.Time, blockHeight int64) (remove bool, err error) // ValidateBasic should evaluate this FeeAllowance for internal consistency. diff --git a/x/subkeys/handler.go b/x/subkeys/handler.go index a2438a542cf7..6093cc93286f 100644 --- a/x/subkeys/handler.go +++ b/x/subkeys/handler.go @@ -8,6 +8,7 @@ import ( func NewHandler(k Keeper) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) sdk.Result { + ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { case MsgDelegateFeeAllowance: grant := FeeAllowanceGrant(msg) From d684f92188689b6f590bf3c9a2432070adf2ab96 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 21 Oct 2019 10:46:42 +0200 Subject: [PATCH 037/184] Remove unnecessary DelegatedMempoolFeeDecorator --- x/subkeys/internal/ante/ante.go | 2 +- x/subkeys/internal/ante/mempool.go | 55 --------------------- x/subkeys/internal/ante/mempool_test.go | 65 ------------------------- 3 files changed, 1 insertion(+), 121 deletions(-) delete mode 100644 x/subkeys/internal/ante/mempool.go delete mode 100644 x/subkeys/internal/ante/mempool_test.go diff --git a/x/subkeys/internal/ante/ante.go b/x/subkeys/internal/ante/ante.go index 2efe2365192e..35560c713aee 100644 --- a/x/subkeys/internal/ante/ante.go +++ b/x/subkeys/internal/ante/ante.go @@ -13,7 +13,7 @@ import ( func NewAnteHandler(ak authKeeper.AccountKeeper, supplyKeeper authTypes.SupplyKeeper, dk keeper.Keeper, sigGasConsumer authAnte.SignatureVerificationGasConsumer) sdk.AnteHandler { return sdk.ChainAnteDecorators( authAnte.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first - NewDelegatedMempoolFeeDecorator(), + authAnte.NewMempoolFeeDecorator(), authAnte.NewValidateBasicDecorator(), authAnte.NewValidateMemoDecorator(ak), authAnte.NewConsumeGasForTxSizeDecorator(ak), diff --git a/x/subkeys/internal/ante/mempool.go b/x/subkeys/internal/ante/mempool.go deleted file mode 100644 index 7beaa57542be..000000000000 --- a/x/subkeys/internal/ante/mempool.go +++ /dev/null @@ -1,55 +0,0 @@ -package ante - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - // we depend on the auth module internals... maybe some more of this can be exported? - // but things like `x/auth/types/FeeCollectorName` are quite clearly tied to it - - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -// DelegatedMempoolFeeDecorator will check if the transaction's fee is at least as large -// as the local validator's minimum gasFee (defined in validator config). -// If fee is too low, decorator returns error and tx is rejected from mempool. -// Note this only applies when ctx.CheckTx = true -// If fee is high enough or not CheckTx, then call next AnteHandler -// CONTRACT: Tx must implement FeeTx to use DelegatedMempoolFeeDecorator -type DelegatedMempoolFeeDecorator struct{} - -func NewDelegatedMempoolFeeDecorator() DelegatedMempoolFeeDecorator { - return DelegatedMempoolFeeDecorator{} -} - -func (mfd DelegatedMempoolFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { - feeTx, ok := tx.(DelegatedFeeTx) - if !ok { - return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a DelegatedFeeTx") - } - feeCoins := feeTx.GetFee() - gas := feeTx.GetGas() - - // Ensure that the provided fees meet a minimum threshold for the validator, - // if this is a CheckTx. This is only for local mempool purposes, and thus - // is only ran on check tx. - if ctx.IsCheckTx() && !simulate { - minGasPrices := ctx.MinGasPrices() - if !minGasPrices.IsZero() { - requiredFees := make(sdk.Coins, len(minGasPrices)) - - // Determine the required fees by multiplying each required minimum gas - // price by the gas limit, where fee = ceil(minGasPrice * gasLimit). - glDec := sdk.NewDec(int64(gas)) - for i, gp := range minGasPrices { - fee := gp.Amount.Mul(glDec) - requiredFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt()) - } - - if !feeCoins.IsAnyGTE(requiredFees) { - return ctx, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees) - } - } - } - - return next(ctx, tx, simulate) -} diff --git a/x/subkeys/internal/ante/mempool_test.go b/x/subkeys/internal/ante/mempool_test.go deleted file mode 100644 index 347c00dd9215..000000000000 --- a/x/subkeys/internal/ante/mempool_test.go +++ /dev/null @@ -1,65 +0,0 @@ -package ante_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto" - - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - - "github.com/cosmos/cosmos-sdk/x/subkeys/internal/ante" - "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types/tx" -) - -func TestEnsureMempoolFees(t *testing.T) { - // setup - _, ctx := createTestApp(true) - - mfd := ante.NewDelegatedMempoolFeeDecorator() - antehandler := sdk.ChainAnteDecorators(mfd) - - // keys and addresses - priv1, _, addr1 := authtypes.KeyTestPubAddr() - - // msg and signatures - msg1 := authtypes.NewTestMsg(addr1) - // TODO: try this with real delegation - fee := tx.NewDelegatedFee(100000, sdk.NewCoins(sdk.NewInt64Coin("atom", 100)), nil) - - msgs := []sdk.Msg{msg1} - - privs, accNums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} - // TODO - tx := tx.NewTestTx(ctx, msgs, privs, accNums, seqs, fee) - - // Set high gas price so standard test fee fails - atomPrice := sdk.NewDecCoinFromDec("atom", sdk.NewDec(200).Quo(sdk.NewDec(100000))) - highGasPrice := []sdk.DecCoin{atomPrice} - ctx = ctx.WithMinGasPrices(highGasPrice) - - // Set IsCheckTx to true - ctx = ctx.WithIsCheckTx(true) - - // antehandler errors with insufficient fees - _, err := antehandler(ctx, tx, false) - require.NotNil(t, err, "Decorator should have errored on too low fee for local gasPrice") - - // Set IsCheckTx to false - ctx = ctx.WithIsCheckTx(false) - - // antehandler should not error since we do not check minGasPrice in DeliverTx - _, err = antehandler(ctx, tx, false) - require.Nil(t, err, "DelegatedMempoolFeeDecorator returned error in DeliverTx") - - // Set IsCheckTx back to true for testing sufficient mempool fee - ctx = ctx.WithIsCheckTx(true) - - atomPrice = sdk.NewDecCoinFromDec("atom", sdk.NewDec(0).Quo(sdk.NewDec(100000))) - lowGasPrice := []sdk.DecCoin{atomPrice} - ctx = ctx.WithMinGasPrices(lowGasPrice) - - _, err = antehandler(ctx, tx, false) - require.Nil(t, err, "Decorator should not have errored on fee higher than local gasPrice") -} From aacf6fba1ac234f12982612290a12e0f0f7e29d7 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 21 Oct 2019 11:05:11 +0200 Subject: [PATCH 038/184] Cleaned up errors in querier --- x/subkeys/internal/keeper/keeper.go | 13 +++++-------- x/subkeys/internal/keeper/keeper_test.go | 2 +- x/subkeys/internal/keeper/querier.go | 18 ++++++++++++------ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/x/subkeys/internal/keeper/keeper.go b/x/subkeys/internal/keeper/keeper.go index 272d88296fe4..dec90eba6448 100644 --- a/x/subkeys/internal/keeper/keeper.go +++ b/x/subkeys/internal/keeper/keeper.go @@ -31,7 +31,7 @@ func (k Keeper) DelegateFeeAllowance(ctx sdk.Context, grant types.FeeAllowanceGr } // RevokeFeeAllowance removes an existing grant -func (k Keeper) RevokeFeeAllowance(ctx sdk.Context, granter sdk.AccAddress, grantee sdk.AccAddress) { +func (k Keeper) RevokeFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddress) { store := ctx.KVStore(k.storeKey) key := types.FeeAllowanceKey(granter, grantee) store.Delete(key) @@ -40,7 +40,7 @@ func (k Keeper) RevokeFeeAllowance(ctx sdk.Context, granter sdk.AccAddress, gran // GetFeeAllowance returns the allowance between the granter and grantee. // If there is none, it returns nil, nil. // Returns an error on parsing issues -func (k Keeper) GetFeeAllowance(ctx sdk.Context, granter sdk.AccAddress, grantee sdk.AccAddress) (exported.FeeAllowance, error) { +func (k Keeper) GetFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddress) (exported.FeeAllowance, error) { grant, err := k.GetFeeGrant(ctx, granter, grantee) if grant == nil { return nil, err @@ -65,8 +65,8 @@ func (k Keeper) GetFeeGrant(ctx sdk.Context, granter sdk.AccAddress, grantee sdk return &grant, nil } -// GetAllMyFeeAllowances returns a list of all the grants from anyone to the given grantee. -func (k Keeper) GetAllMyFeeAllowances(ctx sdk.Context, grantee sdk.AccAddress) ([]types.FeeAllowanceGrant, error) { +// GetAllGranteeFeeAllowances returns a list of all the grants from anyone to the given grantee. +func (k Keeper) GetAllGranteeFeeAllowances(ctx sdk.Context, grantee sdk.AccAddress) ([]types.FeeAllowanceGrant, error) { store := ctx.KVStore(k.storeKey) var grants []types.FeeAllowanceGrant @@ -106,10 +106,7 @@ func (k Keeper) GetAllFeeAllowances(ctx sdk.Context) ([]types.FeeAllowanceGrant, } // UseDelegatedFees will try to pay the given fee from the granter's account as requested by the grantee -// (true, nil) will update the allowance, and assumes the AnteHandler deducts the given fees -// (false, nil) rejects payment on behalf of grantee -// (?, err) means there was a data parsing error (abort tx and log this info) -func (k Keeper) UseDelegatedFees(ctx sdk.Context, granter sdk.AccAddress, grantee sdk.AccAddress, fee sdk.Coins) bool { +func (k Keeper) UseDelegatedFees(ctx sdk.Context, granter, grantee sdk.AccAddress, fee sdk.Coins) bool { grant, err := k.GetFeeGrant(ctx, granter, grantee) if err != nil { // we should acknowledge a db issue somehow (better?) diff --git a/x/subkeys/internal/keeper/keeper_test.go b/x/subkeys/internal/keeper/keeper_test.go index 1f923c866a2c..159005bb3908 100644 --- a/x/subkeys/internal/keeper/keeper_test.go +++ b/x/subkeys/internal/keeper/keeper_test.go @@ -176,7 +176,7 @@ func TestKeeperCrud(t *testing.T) { for name, tc := range allCases { t.Run(name, func(t *testing.T) { - grants, err := k.GetAllMyFeeAllowances(ctx, tc.grantee) + grants, err := k.GetAllGranteeFeeAllowances(ctx, tc.grantee) require.NoError(t, err) assert.Equal(t, tc.grants, grants) }) diff --git a/x/subkeys/internal/keeper/querier.go b/x/subkeys/internal/keeper/querier.go index 4728c3e2bf2c..33c862ef48c2 100644 --- a/x/subkeys/internal/keeper/querier.go +++ b/x/subkeys/internal/keeper/querier.go @@ -2,6 +2,8 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types" abci "github.com/tendermint/tendermint/abci/types" ) @@ -12,23 +14,27 @@ const ( // NewQuerier creates a new querier func NewQuerier(keeper Keeper) sdk.Querier { return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, sdk.Error) { + var res []byte + var err error switch path[0] { case QueryGetFeeAllowances: - return queryGetFeeAllowances(ctx, path[1:], keeper) + res, err = queryGetFeeAllowances(ctx, path[1:], keeper) default: - return nil, sdk.ErrUnknownRequest("Unknown package subkeys query endpoint") + err = sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, + "Unknown package %s query endpoint", types.ModuleName) } + return res, sdk.ConvertError(err) } } -func queryGetFeeAllowances(ctx sdk.Context, args []string, keeper Keeper) ([]byte, sdk.Error) { +func queryGetFeeAllowances(ctx sdk.Context, args []string, keeper Keeper) ([]byte, error) { grantee := args[0] granteeAddr, err := sdk.AccAddressFromBech32(grantee) if err != nil { - return nil, sdk.ErrInternal(sdk.AppendMsgToErr("invalid address", err.Error())) + return nil, sdkerrors.Wrapf(err, "invalid address") } - fees, err := keeper.GetAllMyFeeAllowances(ctx, granteeAddr) + fees, err := keeper.GetAllGranteeFeeAllowances(ctx, granteeAddr) if err != nil { return nil, sdk.ConvertError(err) } @@ -38,7 +44,7 @@ func queryGetFeeAllowances(ctx sdk.Context, args []string, keeper Keeper) ([]byt bz, err := keeper.cdc.MarshalJSON(fees) if err != nil { - return nil, sdk.ErrInternal(sdk.AppendMsgToErr("could not marshal result to JSON", err.Error())) + return nil, sdkerrors.Wrapf(err, "could not marshal query result to JSON") } return bz, nil } From 92f64ccf87f06d7c9d79c91f78af30355ec19477 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 21 Oct 2019 11:12:48 +0200 Subject: [PATCH 039/184] Clean up message sign bytes --- x/subkeys/internal/types/msgs.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/x/subkeys/internal/types/msgs.go b/x/subkeys/internal/types/msgs.go index 7686f95a3a5a..9444c790a154 100644 --- a/x/subkeys/internal/types/msgs.go +++ b/x/subkeys/internal/types/msgs.go @@ -1,8 +1,6 @@ package types import ( - "encoding/json" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/subkeys/exported" ) @@ -39,11 +37,7 @@ func (msg MsgDelegateFeeAllowance) ValidateBasic() sdk.Error { } func (msg MsgDelegateFeeAllowance) GetSignBytes() []byte { - b, err := json.Marshal(msg) - if err != nil { - panic(err) - } - return sdk.MustSortJSON(b) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) } func (msg MsgDelegateFeeAllowance) GetSigners() []sdk.AccAddress { @@ -79,11 +73,7 @@ func (msg MsgRevokeFeeAllowance) ValidateBasic() sdk.Error { } func (msg MsgRevokeFeeAllowance) GetSignBytes() []byte { - b, err := json.Marshal(msg) - if err != nil { - panic(err) - } - return sdk.MustSortJSON(b) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) } func (msg MsgRevokeFeeAllowance) GetSigners() []sdk.AccAddress { From 4daf4af4d773171f1960cdf59ed9c3fea2e803e4 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 24 Oct 2019 18:06:36 +0200 Subject: [PATCH 040/184] Minor PR comments --- simapp/app.go | 1 - x/subkeys/handler.go | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index db7f52fa715e..bc321bd8bcf2 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -223,7 +223,6 @@ func NewSimApp( distr.NewAppModule(app.DistrKeeper, app.SupplyKeeper), staking.NewAppModule(app.StakingKeeper, app.AccountKeeper, app.SupplyKeeper), slashing.NewAppModule(app.SlashingKeeper, app.StakingKeeper), - // subkeys.NewAppModule(app.DelegationKeeper), ) app.sm.RegisterStoreDecoders() diff --git a/x/subkeys/handler.go b/x/subkeys/handler.go index 6093cc93286f..eb15b7daa79b 100644 --- a/x/subkeys/handler.go +++ b/x/subkeys/handler.go @@ -18,7 +18,7 @@ func NewHandler(k Keeper) sdk.Handler { k.RevokeFeeAllowance(ctx, msg.Granter, msg.Grantee) return sdk.Result{} default: - errMsg := fmt.Sprintf("Unrecognized data Msg type: %v", msg.Type()) + errMsg := fmt.Sprintf("Unrecognized data Msg type: %s", ModuleName) return sdk.ErrUnknownRequest(errMsg).Result() } } From a497575aab16811c0d60a7921f508bc06e6ff87d Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 24 Oct 2019 18:17:42 +0200 Subject: [PATCH 041/184] Replace GetAllFees... with Iterator variants --- x/subkeys/genesis.go | 9 +++++- x/subkeys/internal/keeper/keeper.go | 36 +++++++++++++----------- x/subkeys/internal/keeper/keeper_test.go | 6 +++- x/subkeys/internal/keeper/querier.go | 12 +++++--- 4 files changed, 40 insertions(+), 23 deletions(-) diff --git a/x/subkeys/genesis.go b/x/subkeys/genesis.go index 28b403921fbf..03c3b6169288 100644 --- a/x/subkeys/genesis.go +++ b/x/subkeys/genesis.go @@ -35,5 +35,12 @@ func ExportGenesis(ctx sdk.Context, k Keeper) (GenesisState, error) { // expiry of 1000. It would need a new method on the FeeAllowance interface. // // Currently, we handle expirations naively - return k.GetAllFeeAllowances(ctx) + + var grants []FeeAllowanceGrant + err := k.IterateAllFeeAllowances(ctx, func(grant FeeAllowanceGrant) bool { + // TODO: modify each one + grants = append(grants, grant) + return false + }) + return grants, err } diff --git a/x/subkeys/internal/keeper/keeper.go b/x/subkeys/internal/keeper/keeper.go index dec90eba6448..319e4bbd144e 100644 --- a/x/subkeys/internal/keeper/keeper.go +++ b/x/subkeys/internal/keeper/keeper.go @@ -65,44 +65,46 @@ func (k Keeper) GetFeeGrant(ctx sdk.Context, granter sdk.AccAddress, grantee sdk return &grant, nil } -// GetAllGranteeFeeAllowances returns a list of all the grants from anyone to the given grantee. -func (k Keeper) GetAllGranteeFeeAllowances(ctx sdk.Context, grantee sdk.AccAddress) ([]types.FeeAllowanceGrant, error) { +// IterateAllGranteeFeeAllowances iterates over all the grants from anyone to the given grantee. +// Callback to get all data, returns true to stop, false to keep reading +func (k Keeper) IterateAllGranteeFeeAllowances(ctx sdk.Context, grantee sdk.AccAddress, cb func(types.FeeAllowanceGrant) bool) error { store := ctx.KVStore(k.storeKey) - var grants []types.FeeAllowanceGrant - prefix := types.FeeAllowancePrefixByGrantee(grantee) iter := sdk.KVStorePrefixIterator(store, prefix) defer iter.Close() - for ; iter.Valid(); iter.Next() { + + stop := false + for ; iter.Valid() && !stop; iter.Next() { bz := iter.Value() var grant types.FeeAllowanceGrant err := k.cdc.UnmarshalBinaryBare(bz, &grant) if err != nil { - return nil, err + return err } - grants = append(grants, grant) + stop = cb(grant) } - return grants, nil + return nil } -// GetAllFeeAllowances returns a list of all the grants in the store. -// This is very expensive and only designed for export genesis -func (k Keeper) GetAllFeeAllowances(ctx sdk.Context) ([]types.FeeAllowanceGrant, error) { +// IterateAllFeeAllowances iterates over all the grants in the store. +// Callback to get all data, returns true to stop, false to keep reading +// Calling this without pagination is very expensive and only designed for export genesis +func (k Keeper) IterateAllFeeAllowances(ctx sdk.Context, cb func(types.FeeAllowanceGrant) bool) error { store := ctx.KVStore(k.storeKey) - var grants []types.FeeAllowanceGrant - iter := sdk.KVStorePrefixIterator(store, types.FeeAllowanceKeyPrefix) defer iter.Close() - for ; iter.Valid(); iter.Next() { + + stop := false + for ; iter.Valid() && !stop; iter.Next() { bz := iter.Value() var grant types.FeeAllowanceGrant err := k.cdc.UnmarshalBinaryBare(bz, &grant) if err != nil { - return nil, err + return err } - grants = append(grants, grant) + stop = cb(grant) } - return grants, nil + return nil } // UseDelegatedFees will try to pay the given fee from the granter's account as requested by the grantee diff --git a/x/subkeys/internal/keeper/keeper_test.go b/x/subkeys/internal/keeper/keeper_test.go index 159005bb3908..155b3efac93d 100644 --- a/x/subkeys/internal/keeper/keeper_test.go +++ b/x/subkeys/internal/keeper/keeper_test.go @@ -176,7 +176,11 @@ func TestKeeperCrud(t *testing.T) { for name, tc := range allCases { t.Run(name, func(t *testing.T) { - grants, err := k.GetAllGranteeFeeAllowances(ctx, tc.grantee) + var grants []types.FeeAllowanceGrant + err := k.IterateAllGranteeFeeAllowances(ctx, tc.grantee, func(grant types.FeeAllowanceGrant) bool { + grants = append(grants, grant) + return false + }) require.NoError(t, err) assert.Equal(t, tc.grants, grants) }) diff --git a/x/subkeys/internal/keeper/querier.go b/x/subkeys/internal/keeper/querier.go index 33c862ef48c2..03ce5ea9ffec 100644 --- a/x/subkeys/internal/keeper/querier.go +++ b/x/subkeys/internal/keeper/querier.go @@ -34,15 +34,19 @@ func queryGetFeeAllowances(ctx sdk.Context, args []string, keeper Keeper) ([]byt return nil, sdkerrors.Wrapf(err, "invalid address") } - fees, err := keeper.GetAllGranteeFeeAllowances(ctx, granteeAddr) + var grants []types.FeeAllowanceGrant + err = keeper.IterateAllGranteeFeeAllowances(ctx, granteeAddr, func(grant types.FeeAllowanceGrant) bool { + grants = append(grants, grant) + return false + }) if err != nil { - return nil, sdk.ConvertError(err) + return nil, err } - if fees == nil { + if grants == nil { return []byte("[]"), nil } - bz, err := keeper.cdc.MarshalJSON(fees) + bz, err := keeper.cdc.MarshalJSON(grants) if err != nil { return nil, sdkerrors.Wrapf(err, "could not marshal query result to JSON") } From 73eab922ee78773bcd5c15cc3c5ebd40865f0af5 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 24 Oct 2019 18:26:58 +0200 Subject: [PATCH 042/184] PrepareForExport adjusts grant expiration height --- x/subkeys/exported/fees.go | 5 +++++ x/subkeys/genesis.go | 15 +++++++-------- x/subkeys/internal/types/basic_fee.go | 7 +++++++ x/subkeys/internal/types/expiration.go | 9 +++++++++ x/subkeys/internal/types/grant.go | 9 +++++++++ 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/x/subkeys/exported/fees.go b/x/subkeys/exported/fees.go index 9d87600c4b3d..efe7eb321d7c 100644 --- a/x/subkeys/exported/fees.go +++ b/x/subkeys/exported/fees.go @@ -21,6 +21,11 @@ type FeeAllowance interface { // (eg. when it is used up). (See call to RevokeFeeAllowance in Keeper.UseDelegatedFees) Accept(fee sdk.Coins, blockTime time.Time, blockHeight int64) (remove bool, err error) + // If we export fee allowances the timing info will be quite off (eg. go from height 100000 to 0) + // This callback allows the fee-allowance to change it's state and return a copy that is adjusted + // given the time and height of the actual dump (may safely return self if no changes needed) + PrepareForExport(dumpTime time.Time, dumpHeight int64) FeeAllowance + // ValidateBasic should evaluate this FeeAllowance for internal consistency. // Don't allow negative amounts, or negative periods for example. ValidateBasic() error diff --git a/x/subkeys/genesis.go b/x/subkeys/genesis.go index 03c3b6169288..2d4e1217d372 100644 --- a/x/subkeys/genesis.go +++ b/x/subkeys/genesis.go @@ -28,18 +28,17 @@ func InitGenesis(ctx sdk.Context, k Keeper, gen GenesisState) error { } // ExportGenesis will dump the contents of the keeper into a serializable GenesisState +// +// All expiration heights will be thrown off if we dump state and start at a new +// chain at height 0. Thus, we allow the Allowances to "prepare themselves" +// for export, like if they have exiry at 5000 and current is 4000, they export with +// expiry of 1000. It would need a new method on the FeeAllowance interface. func ExportGenesis(ctx sdk.Context, k Keeper) (GenesisState, error) { - // TODO: all expiration heights will be thrown off if we dump state and start at a new - // chain at height 0. Maybe we need to allow the Allowances to "prepare themselves" - // for export, like if they have exiry at 5000 and current is 4000, they export with - // expiry of 1000. It would need a new method on the FeeAllowance interface. - // - // Currently, we handle expirations naively - + time, height := ctx.BlockTime(), ctx.BlockHeight() var grants []FeeAllowanceGrant err := k.IterateAllFeeAllowances(ctx, func(grant FeeAllowanceGrant) bool { // TODO: modify each one - grants = append(grants, grant) + grants = append(grants, grant.PrepareForExport(time, height)) return false }) return grants, err diff --git a/x/subkeys/internal/types/basic_fee.go b/x/subkeys/internal/types/basic_fee.go index 9a110ff54f16..e1057d532807 100644 --- a/x/subkeys/internal/types/basic_fee.go +++ b/x/subkeys/internal/types/basic_fee.go @@ -35,6 +35,13 @@ func (a *BasicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockHeig return left.IsZero(), nil } +func (a *BasicFeeAllowance) PrepareForExport(dumpTime time.Time, dumpHeight int64) exported.FeeAllowance { + return &BasicFeeAllowance{ + SpendLimit: a.SpendLimit, + Expiration: a.Expiration.PrepareForExport(dumpTime, dumpHeight), + } +} + // ValidateBasic implements FeeAllowance and enforces basic sanity checks func (a BasicFeeAllowance) ValidateBasic() error { if !a.SpendLimit.IsValid() { diff --git a/x/subkeys/internal/types/expiration.go b/x/subkeys/internal/types/expiration.go index 09ae0ec449ad..91320b59c3e3 100644 --- a/x/subkeys/internal/types/expiration.go +++ b/x/subkeys/internal/types/expiration.go @@ -71,6 +71,15 @@ func (e *ExpiresAt) Step(p Period) error { return nil } +// PrepareForExport will deduct the dumpHeight from the expiration, so when this is +// reloaded after a hard fork, the actual number of allowed blocks is constant +func (e ExpiresAt) PrepareForExport(dumpTime time.Time, dumpHeight int64) ExpiresAt { + if e.Height != 0 { + e.Height -= dumpHeight + } + return e +} + // Period is a repeating unit of either clock time or number of blocks. // This is designed to be added to an ExpiresAt struct. type Period struct { diff --git a/x/subkeys/internal/types/grant.go b/x/subkeys/internal/types/grant.go index bb7006ac837f..76e57ec09c5d 100644 --- a/x/subkeys/internal/types/grant.go +++ b/x/subkeys/internal/types/grant.go @@ -1,6 +1,8 @@ package types import ( + "time" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/subkeys/exported" ) @@ -25,3 +27,10 @@ func (a FeeAllowanceGrant) ValidateBasic() error { } return a.Allowance.ValidateBasic() } + +// PrepareForExport will make all needed changes to the allowance to prepare to be +// re-imported at height 0, and return a copy of this grant. +func (a FeeAllowanceGrant) PrepareForExport(dumpTime time.Time, dumpHeight int64) FeeAllowanceGrant { + a.Allowance = a.Allowance.PrepareForExport(dumpTime, dumpHeight) + return a +} From 546fa8fe3447a95c25bae25529bbc40f7e998191 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 24 Oct 2019 18:32:03 +0200 Subject: [PATCH 043/184] Panic on de/serialization error in keeper --- x/subkeys/genesis.go | 8 ++----- x/subkeys/internal/ante/fee_test.go | 9 +++----- x/subkeys/internal/keeper/keeper.go | 19 ++++------------ x/subkeys/internal/keeper/keeper_test.go | 27 ++++++++--------------- x/subkeys/internal/keeper/querier_test.go | 6 ++--- x/subkeys/module.go | 5 +---- 6 files changed, 21 insertions(+), 53 deletions(-) diff --git a/x/subkeys/genesis.go b/x/subkeys/genesis.go index 2d4e1217d372..26287e1018ba 100644 --- a/x/subkeys/genesis.go +++ b/x/subkeys/genesis.go @@ -17,14 +17,10 @@ func (g GenesisState) ValidateBasic() error { } // InitGenesis will initialize the keeper from a *previously validated* GenesisState -func InitGenesis(ctx sdk.Context, k Keeper, gen GenesisState) error { +func InitGenesis(ctx sdk.Context, k Keeper, gen GenesisState) { for _, f := range gen { - err := k.DelegateFeeAllowance(ctx, f) - if err != nil { - return err - } + k.DelegateFeeAllowance(ctx, f) } - return nil } // ExportGenesis will dump the contents of the keeper into a serializable GenesisState diff --git a/x/subkeys/internal/ante/fee_test.go b/x/subkeys/internal/ante/fee_test.go index de22d3aeee9a..cc53e1ca578c 100644 --- a/x/subkeys/internal/ante/fee_test.go +++ b/x/subkeys/internal/ante/fee_test.go @@ -44,34 +44,31 @@ func TestDeductFeesNoDelegation(t *testing.T) { app.AccountKeeper.SetAccount(ctx, acc2) // Set delegation from addr2 to addr3 (plenty to pay) - err := app.DelegationKeeper.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + app.DelegationKeeper.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr2, Grantee: addr3, Allowance: &types.BasicFeeAllowance{ SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 500)), }, }) - require.NoError(t, err) // Set low delegation from addr2 to addr4 (delegation will reject) - err = app.DelegationKeeper.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + app.DelegationKeeper.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr2, Grantee: addr4, Allowance: &types.BasicFeeAllowance{ SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 20)), }, }) - require.NoError(t, err) // Set delegation from addr1 to addr4 (cannot cover this ) - err = app.DelegationKeeper.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + app.DelegationKeeper.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr2, Grantee: addr3, Allowance: &types.BasicFeeAllowance{ SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 500)), }, }) - require.NoError(t, err) cases := map[string]struct { signerKey crypto.PrivKey diff --git a/x/subkeys/internal/keeper/keeper.go b/x/subkeys/internal/keeper/keeper.go index 319e4bbd144e..d436cd0420d0 100644 --- a/x/subkeys/internal/keeper/keeper.go +++ b/x/subkeys/internal/keeper/keeper.go @@ -18,16 +18,11 @@ func NewKeeper(cdc *codec.Codec, storeKey sdk.StoreKey) Keeper { } // DelegateFeeAllowance creates a new grant -func (k Keeper) DelegateFeeAllowance(ctx sdk.Context, grant types.FeeAllowanceGrant) error { +func (k Keeper) DelegateFeeAllowance(ctx sdk.Context, grant types.FeeAllowanceGrant) { store := ctx.KVStore(k.storeKey) key := types.FeeAllowanceKey(grant.Granter, grant.Grantee) - - bz, err := k.cdc.MarshalBinaryBare(grant) - if err != nil { - return err - } + bz := k.cdc.MustMarshalBinaryBare(grant) store.Set(key, bz) - return nil } // RevokeFeeAllowance removes an existing grant @@ -111,9 +106,7 @@ func (k Keeper) IterateAllFeeAllowances(ctx sdk.Context, cb func(types.FeeAllowa func (k Keeper) UseDelegatedFees(ctx sdk.Context, granter, grantee sdk.AccAddress, fee sdk.Coins) bool { grant, err := k.GetFeeGrant(ctx, granter, grantee) if err != nil { - // we should acknowledge a db issue somehow (better?) - ctx.Logger().Error(err.Error()) - return false + panic(err) } if grant == nil || grant.Allowance == nil { return false @@ -129,10 +122,6 @@ func (k Keeper) UseDelegatedFees(ctx sdk.Context, granter, grantee sdk.AccAddres } // if we accepted, store the updated state of the allowance - if err := k.DelegateFeeAllowance(ctx, *grant); err != nil { - // we should acknowledge a db issue somehow (better?) - ctx.Logger().Error(err.Error()) - return false - } + k.DelegateFeeAllowance(ctx, *grant) return true } diff --git a/x/subkeys/internal/keeper/keeper_test.go b/x/subkeys/internal/keeper/keeper_test.go index 155b3efac93d..a4589f3eed79 100644 --- a/x/subkeys/internal/keeper/keeper_test.go +++ b/x/subkeys/internal/keeper/keeper_test.go @@ -77,38 +77,31 @@ func TestKeeperCrud(t *testing.T) { } // let's set up some initial state here - err := k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr, Grantee: addr2, Allowance: &basic, }) - require.NoError(t, err) - err = k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr, Grantee: addr3, Allowance: &basic2, }) - require.NoError(t, err) - err = k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr2, Grantee: addr3, Allowance: &basic, }) - require.NoError(t, err) - err = k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr2, Grantee: addr4, Allowance: &basic, }) - require.NoError(t, err) - err = k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr4, Grantee: addr, Allowance: &basic2, }) - require.NoError(t, err) // remove some, overwrite other k.RevokeFeeAllowance(ctx, addr, addr2) k.RevokeFeeAllowance(ctx, addr, addr3) - err = k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr, Grantee: addr3, Allowance: &basic, }) - require.NoError(t, err) - err = k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr2, Grantee: addr3, Allowance: &basic2, }) - require.NoError(t, err) // end state: // addr -> addr3 (basic) @@ -255,14 +248,12 @@ func TestUseDelegatedFee(t *testing.T) { // let's set up some initial state here // addr -> addr2 (future) // addr -> addr3 (expired) - err := k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr, Grantee: addr2, Allowance: &future, }) - require.NoError(t, err) - err = k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr, Grantee: addr3, Allowance: &expired, }) - require.NoError(t, err) allowed := k.UseDelegatedFees(ctx, tc.granter, tc.grantee, tc.fee) require.Equal(t, tc.allowed, allowed) diff --git a/x/subkeys/internal/keeper/querier_test.go b/x/subkeys/internal/keeper/querier_test.go index e9bc45f68b26..53061eda4245 100644 --- a/x/subkeys/internal/keeper/querier_test.go +++ b/x/subkeys/internal/keeper/querier_test.go @@ -40,10 +40,8 @@ func TestQuery(t *testing.T) { } // let's set up some initial state here - err := k.DelegateFeeAllowance(ctx, grant1) - require.NoError(t, err) - err = k.DelegateFeeAllowance(ctx, grant2) - require.NoError(t, err) + k.DelegateFeeAllowance(ctx, grant1) + k.DelegateFeeAllowance(ctx, grant2) // now try some queries cases := map[string]struct { diff --git a/x/subkeys/module.go b/x/subkeys/module.go index 0364ee4a4549..0136e8d1240a 100644 --- a/x/subkeys/module.go +++ b/x/subkeys/module.go @@ -132,10 +132,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.Va if err != nil { panic(err) } - err = InitGenesis(ctx, am.keeper, genesisState) - if err != nil { - panic(err) - } + InitGenesis(ctx, am.keeper, genesisState) return []abci.ValidatorUpdate{} } From 5f9e391de8f785f9ceebc53682bc9261473987db Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 24 Oct 2019 18:39:58 +0200 Subject: [PATCH 044/184] Move custom ante handler chain to tests, update docs --- x/subkeys/doc.go | 10 +++++----- x/subkeys/internal/ante/ante.go | 29 ----------------------------- x/subkeys/internal/ante/fee_test.go | 27 ++++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 35 deletions(-) delete mode 100644 x/subkeys/internal/ante/ante.go diff --git a/x/subkeys/doc.go b/x/subkeys/doc.go index b644d60de59d..b2d3afaa0952 100644 --- a/x/subkeys/doc.go +++ b/x/subkeys/doc.go @@ -20,11 +20,11 @@ The fee allowance that a grantee receives is specified by an implementation of the FeeAllowance interface. Two FeeAllowance implementations are provided in this package: BasicFeeAllowance and PeriodicFeeAllowance. -In order to integrate this into an application, we must use the ante handles from -this package instead of the default auth implementations for DeductFee -(adding custom logic) and MempoolFee (updating it to be compatible with DelegatedTx). -An application can do this simply by using `x/delegate_fees/internal/ante.NewAnteHandler()` -when setting up the app instead of the version from auth. +In order to integrate this into an application, we must use the DeductDelegatedFeeDecorator +ante handler from this package instead of the default DeductFeeDecorator from auth. +To allow handling txs from empty accounts (with fees paid from an existing account), +we have to re-order the decorators as well. You can see an example in +`x/delegate_fees/internal/ante/fee_test.go:newAnteHandler()` I did not pull this into the top level package as it pulls in dependencies on the internals of `x/auth` and if I understand correctly, this is bad practice to depend on other modules diff --git a/x/subkeys/internal/ante/ante.go b/x/subkeys/internal/ante/ante.go deleted file mode 100644 index 35560c713aee..000000000000 --- a/x/subkeys/internal/ante/ante.go +++ /dev/null @@ -1,29 +0,0 @@ -package ante - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - authAnte "github.com/cosmos/cosmos-sdk/x/auth/ante" - authKeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/subkeys/internal/keeper" -) - -// NewAnteHandler is just like auth.NewAnteHandler, except we use the DeductDelegatedFeeDecorator -// in order to allow payment of fees via a delegation. -func NewAnteHandler(ak authKeeper.AccountKeeper, supplyKeeper authTypes.SupplyKeeper, dk keeper.Keeper, sigGasConsumer authAnte.SignatureVerificationGasConsumer) sdk.AnteHandler { - return sdk.ChainAnteDecorators( - authAnte.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first - authAnte.NewMempoolFeeDecorator(), - authAnte.NewValidateBasicDecorator(), - authAnte.NewValidateMemoDecorator(ak), - authAnte.NewConsumeGasForTxSizeDecorator(ak), - // DeductDelegatedFeeDecorator will create an empty account if we sign with no tokens but valid validation - // This must be before SetPubKey, ValidateSigCount, SigVerification, which error if account doesn't exist yet - NewDeductDelegatedFeeDecorator(ak, supplyKeeper, dk), - authAnte.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators - authAnte.NewValidateSigCountDecorator(ak), - authAnte.NewSigGasConsumeDecorator(ak, sigGasConsumer), - authAnte.NewSigVerificationDecorator(ak), - authAnte.NewIncrementSequenceDecorator(ak), // innermost AnteDecorator - ) -} diff --git a/x/subkeys/internal/ante/fee_test.go b/x/subkeys/internal/ante/fee_test.go index cc53e1ca578c..01c6e429dfdb 100644 --- a/x/subkeys/internal/ante/fee_test.go +++ b/x/subkeys/internal/ante/fee_test.go @@ -10,12 +10,37 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + authante "github.com/cosmos/cosmos-sdk/x/auth/ante" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/subkeys/internal/ante" + "github.com/cosmos/cosmos-sdk/x/subkeys/internal/keeper" "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types" "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types/tx" ) +// newAnteHandler is just like auth.NewAnteHandler, except we use the DeductDelegatedFeeDecorator +// in order to allow payment of fees via a delegation. +// +// This is used for our full-stack tests +func newAnteHandler(ak authkeeper.AccountKeeper, supplyKeeper authtypes.SupplyKeeper, dk keeper.Keeper, sigGasConsumer authante.SignatureVerificationGasConsumer) sdk.AnteHandler { + return sdk.ChainAnteDecorators( + authante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first + authante.NewMempoolFeeDecorator(), + authante.NewValidateBasicDecorator(), + authante.NewValidateMemoDecorator(ak), + authante.NewConsumeGasForTxSizeDecorator(ak), + // DeductDelegatedFeeDecorator will create an empty account if we sign with no tokens but valid validation + // This must be before SetPubKey, ValidateSigCount, SigVerification, which error if account doesn't exist yet + ante.NewDeductDelegatedFeeDecorator(ak, supplyKeeper, dk), + authante.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators + authante.NewValidateSigCountDecorator(ak), + authante.NewSigGasConsumeDecorator(ak, sigGasConsumer), + authante.NewSigVerificationDecorator(ak), + authante.NewIncrementSequenceDecorator(ak), // innermost AnteDecorator + ) +} + func TestDeductFeesNoDelegation(t *testing.T) { // setup app, ctx := createTestApp(true) @@ -25,7 +50,7 @@ func TestDeductFeesNoDelegation(t *testing.T) { ourAnteHandler := sdk.ChainAnteDecorators(dfd) // this tests the whole stack - anteHandlerStack := ante.NewAnteHandler(app.AccountKeeper, app.SupplyKeeper, app.DelegationKeeper, SigGasNoConsumer) + anteHandlerStack := newAnteHandler(app.AccountKeeper, app.SupplyKeeper, app.DelegationKeeper, SigGasNoConsumer) // keys and addresses priv1, _, addr1 := authtypes.KeyTestPubAddr() From c45dc71d354d78f0f2ee268dcdfff61e94650f07 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 24 Oct 2019 18:53:36 +0200 Subject: [PATCH 045/184] More cleanup --- x/subkeys/doc.go | 4 ---- x/subkeys/exported/fees.go | 2 +- x/subkeys/internal/keeper/keeper.go | 16 ++++++++-------- x/subkeys/internal/types/msgs.go | 2 +- x/subkeys/internal/types/tx/tx.go | 2 +- x/subkeys/module.go | 9 +-------- 6 files changed, 12 insertions(+), 23 deletions(-) diff --git a/x/subkeys/doc.go b/x/subkeys/doc.go index b2d3afaa0952..e8aad2a46a99 100644 --- a/x/subkeys/doc.go +++ b/x/subkeys/doc.go @@ -25,9 +25,5 @@ ante handler from this package instead of the default DeductFeeDecorator from au To allow handling txs from empty accounts (with fees paid from an existing account), we have to re-order the decorators as well. You can see an example in `x/delegate_fees/internal/ante/fee_test.go:newAnteHandler()` - -I did not pull this into the top level package as it pulls in dependencies on the internals -of `x/auth` and if I understand correctly, this is bad practice to depend on other modules -except for the external package. */ package subkeys diff --git a/x/subkeys/exported/fees.go b/x/subkeys/exported/fees.go index efe7eb321d7c..1ad02e65182e 100644 --- a/x/subkeys/exported/fees.go +++ b/x/subkeys/exported/fees.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// FeeAllowance implementations are tied to a given delegator and delegatee, +// FeeAllowance implementations are tied to a given fee delegator and delegatee, // and are used to enforce fee delegation limits. type FeeAllowance interface { // Accept can use fee payment requested as well as timestamp/height of the current block diff --git a/x/subkeys/internal/keeper/keeper.go b/x/subkeys/internal/keeper/keeper.go index d436cd0420d0..dd76eb956e51 100644 --- a/x/subkeys/internal/keeper/keeper.go +++ b/x/subkeys/internal/keeper/keeper.go @@ -37,27 +37,27 @@ func (k Keeper) RevokeFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddr // Returns an error on parsing issues func (k Keeper) GetFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddress) (exported.FeeAllowance, error) { grant, err := k.GetFeeGrant(ctx, granter, grantee) - if grant == nil { + if err != nil { return nil, err } - return grant.Allowance, err + return grant.Allowance, nil } // GetFeeGrant returns entire grant between both accounts -func (k Keeper) GetFeeGrant(ctx sdk.Context, granter sdk.AccAddress, grantee sdk.AccAddress) (*types.FeeAllowanceGrant, error) { +func (k Keeper) GetFeeGrant(ctx sdk.Context, granter sdk.AccAddress, grantee sdk.AccAddress) (types.FeeAllowanceGrant, error) { store := ctx.KVStore(k.storeKey) key := types.FeeAllowanceKey(granter, grantee) bz := store.Get(key) if len(bz) == 0 { - return nil, nil + return types.FeeAllowanceGrant{}, nil } var grant types.FeeAllowanceGrant err := k.cdc.UnmarshalBinaryBare(bz, &grant) if err != nil { - return nil, err + return types.FeeAllowanceGrant{}, err } - return &grant, nil + return grant, nil } // IterateAllGranteeFeeAllowances iterates over all the grants from anyone to the given grantee. @@ -108,7 +108,7 @@ func (k Keeper) UseDelegatedFees(ctx sdk.Context, granter, grantee sdk.AccAddres if err != nil { panic(err) } - if grant == nil || grant.Allowance == nil { + if grant.Allowance == nil { return false } @@ -122,6 +122,6 @@ func (k Keeper) UseDelegatedFees(ctx sdk.Context, granter, grantee sdk.AccAddres } // if we accepted, store the updated state of the allowance - k.DelegateFeeAllowance(ctx, *grant) + k.DelegateFeeAllowance(ctx, grant) return true } diff --git a/x/subkeys/internal/types/msgs.go b/x/subkeys/internal/types/msgs.go index 9444c790a154..d8b8add8fbc6 100644 --- a/x/subkeys/internal/types/msgs.go +++ b/x/subkeys/internal/types/msgs.go @@ -19,7 +19,7 @@ func NewMsgDelegateFeeAllowance(granter sdk.AccAddress, grantee sdk.AccAddress, } func (msg MsgDelegateFeeAllowance) Route() string { - return "delegation" + return RouterKey } func (msg MsgDelegateFeeAllowance) Type() string { diff --git a/x/subkeys/internal/types/tx/tx.go b/x/subkeys/internal/types/tx/tx.go index a9a999b32f48..448151b948f1 100644 --- a/x/subkeys/internal/types/tx/tx.go +++ b/x/subkeys/internal/types/tx/tx.go @@ -19,7 +19,7 @@ var ( maxGasWanted = uint64((1 << 63) - 1) ) -// DelegatedTx is wraps a Msg with Fee and Signatures, +// DelegatedTx wraps a Msg with Fee and Signatures, // adding the ability to delegate the fee payment // NOTE: the first signature responsible for paying fees, either directly, // or must be authorized to spend from the provided Fee.FeeAccount diff --git a/x/subkeys/module.go b/x/subkeys/module.go index 0136e8d1240a..e84faa4ec26d 100644 --- a/x/subkeys/module.go +++ b/x/subkeys/module.go @@ -15,10 +15,6 @@ import ( tx "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types/tx" ) -// TODO: -// * docs -// * periodic fee - var ( _ module.AppModule = AppModule{} _ module.AppModuleBasic = AppModuleBasic{} @@ -51,11 +47,8 @@ func (a AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { } func (a AppModuleBasic) getValidatedGenesis(bz json.RawMessage) (GenesisState, error) { - cdc := codec.New() - a.RegisterCodec(cdc) - var data GenesisState - err := cdc.UnmarshalJSON(bz, &data) + err := ModuleCdc.UnmarshalJSON(bz, &data) if err != nil { return nil, err } From 2be48ef718a1dc43ea43ffa7fecc5e1e5e743dd7 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 24 Oct 2019 18:56:45 +0200 Subject: [PATCH 046/184] More doc cleanup --- x/subkeys/genesis.go | 2 +- x/subkeys/internal/keeper/querier.go | 2 +- x/subkeys/internal/types/msgs.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/x/subkeys/genesis.go b/x/subkeys/genesis.go index 26287e1018ba..3274ec9c863a 100644 --- a/x/subkeys/genesis.go +++ b/x/subkeys/genesis.go @@ -27,7 +27,7 @@ func InitGenesis(ctx sdk.Context, k Keeper, gen GenesisState) { // // All expiration heights will be thrown off if we dump state and start at a new // chain at height 0. Thus, we allow the Allowances to "prepare themselves" -// for export, like if they have exiry at 5000 and current is 4000, they export with +// for export, like if they have expiry at 5000 and current is 4000, they export with // expiry of 1000. It would need a new method on the FeeAllowance interface. func ExportGenesis(ctx sdk.Context, k Keeper) (GenesisState, error) { time, height := ctx.BlockTime(), ctx.BlockHeight() diff --git a/x/subkeys/internal/keeper/querier.go b/x/subkeys/internal/keeper/querier.go index 03ce5ea9ffec..32a5ccfd6338 100644 --- a/x/subkeys/internal/keeper/querier.go +++ b/x/subkeys/internal/keeper/querier.go @@ -21,7 +21,7 @@ func NewQuerier(keeper Keeper) sdk.Querier { res, err = queryGetFeeAllowances(ctx, path[1:], keeper) default: err = sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, - "Unknown package %s query endpoint", types.ModuleName) + "unknown package %s query endpoint", types.ModuleName) } return res, sdk.ConvertError(err) } diff --git a/x/subkeys/internal/types/msgs.go b/x/subkeys/internal/types/msgs.go index d8b8add8fbc6..e53a3a76f601 100644 --- a/x/subkeys/internal/types/msgs.go +++ b/x/subkeys/internal/types/msgs.go @@ -55,7 +55,7 @@ func NewMsgRevokeFeeAllowance(granter sdk.AccAddress, grantee sdk.AccAddress) Ms } func (msg MsgRevokeFeeAllowance) Route() string { - return "delegation" + return RouterKey } func (msg MsgRevokeFeeAllowance) Type() string { From e8a624fe3de365444c30eec158cb46630a4fdeb8 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 24 Oct 2019 19:01:47 +0200 Subject: [PATCH 047/184] Renamed subkeys module to fee_grant --- simapp/app.go | 14 +++++++------- x/{subkeys => fee_grant}/alias.go | 10 +++++----- x/{subkeys => fee_grant}/doc.go | 4 ++-- x/{subkeys => fee_grant}/exported/fees.go | 0 x/{subkeys => fee_grant}/genesis.go | 2 +- x/{subkeys => fee_grant}/handler.go | 2 +- x/{subkeys => fee_grant}/internal/ante/fee.go | 4 ++-- x/{subkeys => fee_grant}/internal/ante/fee_test.go | 8 ++++---- x/{subkeys => fee_grant}/internal/keeper/keeper.go | 4 ++-- .../internal/keeper/keeper_test.go | 6 +++--- .../internal/keeper/querier.go | 2 +- .../internal/keeper/querier_test.go | 4 ++-- .../internal/types/basic_fee.go | 2 +- .../internal/types/basic_fee_test.go | 0 x/{subkeys => fee_grant}/internal/types/codec.go | 2 +- x/{subkeys => fee_grant}/internal/types/errors.go | 0 .../internal/types/expiration.go | 0 .../internal/types/expiration_test.go | 0 x/{subkeys => fee_grant}/internal/types/grant.go | 2 +- .../internal/types/grant_test.go | 0 x/{subkeys => fee_grant}/internal/types/key.go | 0 x/{subkeys => fee_grant}/internal/types/msgs.go | 2 +- .../internal/types/tx/codec.go | 0 .../internal/types/tx/test_common.go | 0 x/{subkeys => fee_grant}/internal/types/tx/tx.go | 0 x/{subkeys => fee_grant}/module.go | 4 ++-- 26 files changed, 36 insertions(+), 36 deletions(-) rename x/{subkeys => fee_grant}/alias.go (86%) rename x/{subkeys => fee_grant}/doc.go (94%) rename x/{subkeys => fee_grant}/exported/fees.go (100%) rename x/{subkeys => fee_grant}/genesis.go (98%) rename x/{subkeys => fee_grant}/handler.go (97%) rename x/{subkeys => fee_grant}/internal/ante/fee.go (96%) rename x/{subkeys => fee_grant}/internal/ante/fee_test.go (97%) rename x/{subkeys => fee_grant}/internal/keeper/keeper.go (97%) rename x/{subkeys => fee_grant}/internal/keeper/keeper_test.go (97%) rename x/{subkeys => fee_grant}/internal/keeper/querier.go (95%) rename x/{subkeys => fee_grant}/internal/keeper/querier_test.go (94%) rename x/{subkeys => fee_grant}/internal/types/basic_fee.go (96%) rename x/{subkeys => fee_grant}/internal/types/basic_fee_test.go (100%) rename x/{subkeys => fee_grant}/internal/types/codec.go (90%) rename x/{subkeys => fee_grant}/internal/types/errors.go (100%) rename x/{subkeys => fee_grant}/internal/types/expiration.go (100%) rename x/{subkeys => fee_grant}/internal/types/expiration_test.go (100%) rename x/{subkeys => fee_grant}/internal/types/grant.go (95%) rename x/{subkeys => fee_grant}/internal/types/grant_test.go (100%) rename x/{subkeys => fee_grant}/internal/types/key.go (100%) rename x/{subkeys => fee_grant}/internal/types/msgs.go (97%) rename x/{subkeys => fee_grant}/internal/types/tx/codec.go (100%) rename x/{subkeys => fee_grant}/internal/types/tx/test_common.go (100%) rename x/{subkeys => fee_grant}/internal/types/tx/tx.go (100%) rename x/{subkeys => fee_grant}/module.go (98%) diff --git a/simapp/app.go b/simapp/app.go index bc321bd8bcf2..6a3b9e9d1bf7 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -26,7 +26,7 @@ import ( paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" "github.com/cosmos/cosmos-sdk/x/slashing" "github.com/cosmos/cosmos-sdk/x/staking" - "github.com/cosmos/cosmos-sdk/x/subkeys" + "github.com/cosmos/cosmos-sdk/x/fee_grant" "github.com/cosmos/cosmos-sdk/x/supply" ) @@ -54,7 +54,7 @@ var ( params.AppModuleBasic{}, crisis.AppModuleBasic{}, slashing.AppModuleBasic{}, - subkeys.AppModuleBasic{}, + fee_grant.AppModuleBasic{}, ) // module account permissions @@ -101,7 +101,7 @@ type SimApp struct { DistrKeeper distr.Keeper GovKeeper gov.Keeper CrisisKeeper crisis.Keeper - DelegationKeeper subkeys.Keeper + DelegationKeeper fee_grant.Keeper ParamsKeeper params.Keeper // the module manager @@ -125,7 +125,7 @@ func NewSimApp( keys := sdk.NewKVStoreKeys(bam.MainStoreKey, auth.StoreKey, staking.StoreKey, supply.StoreKey, mint.StoreKey, distr.StoreKey, slashing.StoreKey, - gov.StoreKey, params.StoreKey, subkeys.StoreKey) + gov.StoreKey, params.StoreKey, fee_grant.StoreKey) tkeys := sdk.NewTransientStoreKeys(params.TStoreKey) app := &SimApp{ @@ -159,7 +159,7 @@ func NewSimApp( app.SlashingKeeper = slashing.NewKeeper(app.cdc, keys[slashing.StoreKey], &stakingKeeper, slashingSubspace, slashing.DefaultCodespace) app.CrisisKeeper = crisis.NewKeeper(crisisSubspace, invCheckPeriod, app.SupplyKeeper, auth.FeeCollectorName) - app.DelegationKeeper = subkeys.NewKeeper(app.cdc, keys[subkeys.StoreKey]) + app.DelegationKeeper = fee_grant.NewKeeper(app.cdc, keys[fee_grant.StoreKey]) // register the proposal types govRouter := gov.NewRouter() @@ -188,7 +188,7 @@ func NewSimApp( distr.NewAppModule(app.DistrKeeper, app.SupplyKeeper), slashing.NewAppModule(app.SlashingKeeper, app.StakingKeeper), staking.NewAppModule(app.StakingKeeper, app.AccountKeeper, app.SupplyKeeper), - subkeys.NewAppModule(app.DelegationKeeper), + fee_grant.NewAppModule(app.DelegationKeeper), ) // During begin block slashing happens after distr.BeginBlocker so that @@ -204,7 +204,7 @@ func NewSimApp( auth.ModuleName, distr.ModuleName, staking.ModuleName, bank.ModuleName, slashing.ModuleName, gov.ModuleName, mint.ModuleName, supply.ModuleName, crisis.ModuleName, - genutil.ModuleName, subkeys.ModuleName, + genutil.ModuleName, fee_grant.ModuleName, ) app.mm.RegisterInvariants(&app.CrisisKeeper) diff --git a/x/subkeys/alias.go b/x/fee_grant/alias.go similarity index 86% rename from x/subkeys/alias.go rename to x/fee_grant/alias.go index 9bdce90331f7..6f4011bb6b6b 100644 --- a/x/subkeys/alias.go +++ b/x/fee_grant/alias.go @@ -1,13 +1,13 @@ // nolint // autogenerated code using github.com/rigelrozanski/multitool // aliases generated for the following subdirectories: -// ALIASGEN: github.com/cosmos/cosmos-sdk/x/subkeys/internal/types -// ALIASGEN: github.com/cosmos/cosmos-sdk/x/subkeys/internal/keeper -package subkeys +// ALIASGEN: github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types +// ALIASGEN: github.com/cosmos/cosmos-sdk/x/fee_grant/internal/keeper +package fee_grant import ( - "github.com/cosmos/cosmos-sdk/x/subkeys/internal/keeper" - "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/keeper" + "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types" ) const ( diff --git a/x/subkeys/doc.go b/x/fee_grant/doc.go similarity index 94% rename from x/subkeys/doc.go rename to x/fee_grant/doc.go index e8aad2a46a99..87e9503fcec0 100644 --- a/x/subkeys/doc.go +++ b/x/fee_grant/doc.go @@ -1,5 +1,5 @@ /* -Package subkeys provides functionality for delegating sub-permissions +Package fee_grant provides functionality for delegating sub-permissions from one account (key) to another account (key). The first implementation allows the delegation for the payment of transaction fees. @@ -26,4 +26,4 @@ To allow handling txs from empty accounts (with fees paid from an existing accou we have to re-order the decorators as well. You can see an example in `x/delegate_fees/internal/ante/fee_test.go:newAnteHandler()` */ -package subkeys +package fee_grant diff --git a/x/subkeys/exported/fees.go b/x/fee_grant/exported/fees.go similarity index 100% rename from x/subkeys/exported/fees.go rename to x/fee_grant/exported/fees.go diff --git a/x/subkeys/genesis.go b/x/fee_grant/genesis.go similarity index 98% rename from x/subkeys/genesis.go rename to x/fee_grant/genesis.go index 3274ec9c863a..60259d682f9b 100644 --- a/x/subkeys/genesis.go +++ b/x/fee_grant/genesis.go @@ -1,4 +1,4 @@ -package subkeys +package fee_grant import sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/subkeys/handler.go b/x/fee_grant/handler.go similarity index 97% rename from x/subkeys/handler.go rename to x/fee_grant/handler.go index eb15b7daa79b..7fac0ae6297d 100644 --- a/x/subkeys/handler.go +++ b/x/fee_grant/handler.go @@ -1,4 +1,4 @@ -package subkeys +package fee_grant import ( "fmt" diff --git a/x/subkeys/internal/ante/fee.go b/x/fee_grant/internal/ante/fee.go similarity index 96% rename from x/subkeys/internal/ante/fee.go rename to x/fee_grant/internal/ante/fee.go index af502c7f24df..287ea2a1f279 100644 --- a/x/subkeys/internal/ante/fee.go +++ b/x/fee_grant/internal/ante/fee.go @@ -10,8 +10,8 @@ import ( authAnte "github.com/cosmos/cosmos-sdk/x/auth/ante" authKeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/subkeys/internal/keeper" - "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types/tx" + "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/keeper" + "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types/tx" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) diff --git a/x/subkeys/internal/ante/fee_test.go b/x/fee_grant/internal/ante/fee_test.go similarity index 97% rename from x/subkeys/internal/ante/fee_test.go rename to x/fee_grant/internal/ante/fee_test.go index 01c6e429dfdb..f922c27d4c40 100644 --- a/x/subkeys/internal/ante/fee_test.go +++ b/x/fee_grant/internal/ante/fee_test.go @@ -13,10 +13,10 @@ import ( authante "github.com/cosmos/cosmos-sdk/x/auth/ante" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/subkeys/internal/ante" - "github.com/cosmos/cosmos-sdk/x/subkeys/internal/keeper" - "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types" - "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types/tx" + "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/ante" + "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/keeper" + "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types/tx" ) // newAnteHandler is just like auth.NewAnteHandler, except we use the DeductDelegatedFeeDecorator diff --git a/x/subkeys/internal/keeper/keeper.go b/x/fee_grant/internal/keeper/keeper.go similarity index 97% rename from x/subkeys/internal/keeper/keeper.go rename to x/fee_grant/internal/keeper/keeper.go index dd76eb956e51..72b7ea976339 100644 --- a/x/subkeys/internal/keeper/keeper.go +++ b/x/fee_grant/internal/keeper/keeper.go @@ -3,8 +3,8 @@ package keeper import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/subkeys/exported" - "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" + "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types" ) type Keeper struct { diff --git a/x/subkeys/internal/keeper/keeper_test.go b/x/fee_grant/internal/keeper/keeper_test.go similarity index 97% rename from x/subkeys/internal/keeper/keeper_test.go rename to x/fee_grant/internal/keeper/keeper_test.go index a4589f3eed79..727032405e5b 100644 --- a/x/subkeys/internal/keeper/keeper_test.go +++ b/x/fee_grant/internal/keeper/keeper_test.go @@ -13,9 +13,9 @@ import ( codec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/subkeys/exported" - "github.com/cosmos/cosmos-sdk/x/subkeys/internal/keeper" - "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" + "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/keeper" + "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types" ) type testInput struct { diff --git a/x/subkeys/internal/keeper/querier.go b/x/fee_grant/internal/keeper/querier.go similarity index 95% rename from x/subkeys/internal/keeper/querier.go rename to x/fee_grant/internal/keeper/querier.go index 32a5ccfd6338..4fc64535aee0 100644 --- a/x/subkeys/internal/keeper/querier.go +++ b/x/fee_grant/internal/keeper/querier.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types" abci "github.com/tendermint/tendermint/abci/types" ) diff --git a/x/subkeys/internal/keeper/querier_test.go b/x/fee_grant/internal/keeper/querier_test.go similarity index 94% rename from x/subkeys/internal/keeper/querier_test.go rename to x/fee_grant/internal/keeper/querier_test.go index 53061eda4245..aa2618dbeaad 100644 --- a/x/subkeys/internal/keeper/querier_test.go +++ b/x/fee_grant/internal/keeper/querier_test.go @@ -9,8 +9,8 @@ import ( codec "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/subkeys/internal/keeper" - "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/keeper" + "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types" ) func TestQuery(t *testing.T) { diff --git a/x/subkeys/internal/types/basic_fee.go b/x/fee_grant/internal/types/basic_fee.go similarity index 96% rename from x/subkeys/internal/types/basic_fee.go rename to x/fee_grant/internal/types/basic_fee.go index e1057d532807..3d31a04e8378 100644 --- a/x/subkeys/internal/types/basic_fee.go +++ b/x/fee_grant/internal/types/basic_fee.go @@ -4,7 +4,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/subkeys/exported" + "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" ) // BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens diff --git a/x/subkeys/internal/types/basic_fee_test.go b/x/fee_grant/internal/types/basic_fee_test.go similarity index 100% rename from x/subkeys/internal/types/basic_fee_test.go rename to x/fee_grant/internal/types/basic_fee_test.go diff --git a/x/subkeys/internal/types/codec.go b/x/fee_grant/internal/types/codec.go similarity index 90% rename from x/subkeys/internal/types/codec.go rename to x/fee_grant/internal/types/codec.go index cbc66ed8612f..f3cebd6d371f 100644 --- a/x/subkeys/internal/types/codec.go +++ b/x/fee_grant/internal/types/codec.go @@ -2,7 +2,7 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/x/subkeys/exported" + "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" ) // RegisterCodec registers the account types and interface diff --git a/x/subkeys/internal/types/errors.go b/x/fee_grant/internal/types/errors.go similarity index 100% rename from x/subkeys/internal/types/errors.go rename to x/fee_grant/internal/types/errors.go diff --git a/x/subkeys/internal/types/expiration.go b/x/fee_grant/internal/types/expiration.go similarity index 100% rename from x/subkeys/internal/types/expiration.go rename to x/fee_grant/internal/types/expiration.go diff --git a/x/subkeys/internal/types/expiration_test.go b/x/fee_grant/internal/types/expiration_test.go similarity index 100% rename from x/subkeys/internal/types/expiration_test.go rename to x/fee_grant/internal/types/expiration_test.go diff --git a/x/subkeys/internal/types/grant.go b/x/fee_grant/internal/types/grant.go similarity index 95% rename from x/subkeys/internal/types/grant.go rename to x/fee_grant/internal/types/grant.go index 76e57ec09c5d..962e0f17ac0b 100644 --- a/x/subkeys/internal/types/grant.go +++ b/x/fee_grant/internal/types/grant.go @@ -4,7 +4,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/subkeys/exported" + "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" ) // FeeAllowanceGrant is stored in the KVStore to record a grant with full context diff --git a/x/subkeys/internal/types/grant_test.go b/x/fee_grant/internal/types/grant_test.go similarity index 100% rename from x/subkeys/internal/types/grant_test.go rename to x/fee_grant/internal/types/grant_test.go diff --git a/x/subkeys/internal/types/key.go b/x/fee_grant/internal/types/key.go similarity index 100% rename from x/subkeys/internal/types/key.go rename to x/fee_grant/internal/types/key.go diff --git a/x/subkeys/internal/types/msgs.go b/x/fee_grant/internal/types/msgs.go similarity index 97% rename from x/subkeys/internal/types/msgs.go rename to x/fee_grant/internal/types/msgs.go index e53a3a76f601..a19eb291bd2f 100644 --- a/x/subkeys/internal/types/msgs.go +++ b/x/fee_grant/internal/types/msgs.go @@ -2,7 +2,7 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/subkeys/exported" + "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" ) // MsgDelegateFeeAllowance adds permission for Grantee to spend up to Allowance diff --git a/x/subkeys/internal/types/tx/codec.go b/x/fee_grant/internal/types/tx/codec.go similarity index 100% rename from x/subkeys/internal/types/tx/codec.go rename to x/fee_grant/internal/types/tx/codec.go diff --git a/x/subkeys/internal/types/tx/test_common.go b/x/fee_grant/internal/types/tx/test_common.go similarity index 100% rename from x/subkeys/internal/types/tx/test_common.go rename to x/fee_grant/internal/types/tx/test_common.go diff --git a/x/subkeys/internal/types/tx/tx.go b/x/fee_grant/internal/types/tx/tx.go similarity index 100% rename from x/subkeys/internal/types/tx/tx.go rename to x/fee_grant/internal/types/tx/tx.go diff --git a/x/subkeys/module.go b/x/fee_grant/module.go similarity index 98% rename from x/subkeys/module.go rename to x/fee_grant/module.go index e84faa4ec26d..de061775dc40 100644 --- a/x/subkeys/module.go +++ b/x/fee_grant/module.go @@ -1,4 +1,4 @@ -package subkeys +package fee_grant import ( "encoding/json" @@ -12,7 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - tx "github.com/cosmos/cosmos-sdk/x/subkeys/internal/types/tx" + tx "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types/tx" ) var ( From 67560991f2b21e0df6020cf78c5ed1c7e782d13e Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 24 Oct 2019 19:06:22 +0200 Subject: [PATCH 048/184] Rename subkeys/delegation to fee grant in all strings --- simapp/app.go | 28 ++++++++++---------- x/fee_grant/exported/fees.go | 2 +- x/fee_grant/internal/ante/fee.go | 4 +-- x/fee_grant/internal/ante/fee_test.go | 30 ++++++++++----------- x/fee_grant/internal/types/codec.go | 2 +- x/fee_grant/internal/types/key.go | 2 +- x/fee_grant/internal/types/msgs.go | 2 +- x/fee_grant/module.go | 38 +++++++++++++-------------- 8 files changed, 54 insertions(+), 54 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index 6a3b9e9d1bf7..942c56888ecb 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -19,6 +19,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/crisis" distr "github.com/cosmos/cosmos-sdk/x/distribution" + "github.com/cosmos/cosmos-sdk/x/fee_grant" "github.com/cosmos/cosmos-sdk/x/genutil" "github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/mint" @@ -26,7 +27,6 @@ import ( paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" "github.com/cosmos/cosmos-sdk/x/slashing" "github.com/cosmos/cosmos-sdk/x/staking" - "github.com/cosmos/cosmos-sdk/x/fee_grant" "github.com/cosmos/cosmos-sdk/x/supply" ) @@ -92,17 +92,17 @@ type SimApp struct { tkeys map[string]*sdk.TransientStoreKey // keepers - AccountKeeper auth.AccountKeeper - BankKeeper bank.Keeper - SupplyKeeper supply.Keeper - StakingKeeper staking.Keeper - SlashingKeeper slashing.Keeper - MintKeeper mint.Keeper - DistrKeeper distr.Keeper - GovKeeper gov.Keeper - CrisisKeeper crisis.Keeper - DelegationKeeper fee_grant.Keeper - ParamsKeeper params.Keeper + AccountKeeper auth.AccountKeeper + BankKeeper bank.Keeper + SupplyKeeper supply.Keeper + StakingKeeper staking.Keeper + SlashingKeeper slashing.Keeper + MintKeeper mint.Keeper + DistrKeeper distr.Keeper + GovKeeper gov.Keeper + CrisisKeeper crisis.Keeper + FeeGrantKeeper fee_grant.Keeper + ParamsKeeper params.Keeper // the module manager mm *module.Manager @@ -159,7 +159,7 @@ func NewSimApp( app.SlashingKeeper = slashing.NewKeeper(app.cdc, keys[slashing.StoreKey], &stakingKeeper, slashingSubspace, slashing.DefaultCodespace) app.CrisisKeeper = crisis.NewKeeper(crisisSubspace, invCheckPeriod, app.SupplyKeeper, auth.FeeCollectorName) - app.DelegationKeeper = fee_grant.NewKeeper(app.cdc, keys[fee_grant.StoreKey]) + app.FeeGrantKeeper = fee_grant.NewKeeper(app.cdc, keys[fee_grant.StoreKey]) // register the proposal types govRouter := gov.NewRouter() @@ -188,7 +188,7 @@ func NewSimApp( distr.NewAppModule(app.DistrKeeper, app.SupplyKeeper), slashing.NewAppModule(app.SlashingKeeper, app.StakingKeeper), staking.NewAppModule(app.StakingKeeper, app.AccountKeeper, app.SupplyKeeper), - fee_grant.NewAppModule(app.DelegationKeeper), + fee_grant.NewAppModule(app.FeeGrantKeeper), ) // During begin block slashing happens after distr.BeginBlocker so that diff --git a/x/fee_grant/exported/fees.go b/x/fee_grant/exported/fees.go index 1ad02e65182e..4c217bff6d6e 100644 --- a/x/fee_grant/exported/fees.go +++ b/x/fee_grant/exported/fees.go @@ -7,7 +7,7 @@ import ( ) // FeeAllowance implementations are tied to a given fee delegator and delegatee, -// and are used to enforce fee delegation limits. +// and are used to enforce fee grant limits. type FeeAllowance interface { // Accept can use fee payment requested as well as timestamp/height of the current block // to determine whether or not to process this. This is checked in diff --git a/x/fee_grant/internal/ante/fee.go b/x/fee_grant/internal/ante/fee.go index 287ea2a1f279..75fd2d136d3d 100644 --- a/x/fee_grant/internal/ante/fee.go +++ b/x/fee_grant/internal/ante/fee.go @@ -62,13 +62,13 @@ func (d DeductDelegatedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu feePayer := feeTx.FeePayer() txSigner := feeTx.MainSigner() - // ensure the delegation is allowed, if we request a different fee payer + // ensure the grant is allowed, if we request a different fee payer if !txSigner.Equals(feePayer) { allowed := d.dk.UseDelegatedFees(ctx, feePayer, txSigner, fee) if !allowed { return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s not allowed to pay fees from %s", txSigner, feePayer) } - // if there was a valid delegation, ensure that the txSigner account exists (we create it if needed) + // if there was a valid grant, ensure that the txSigner account exists (we create it if needed) signerAcc := d.ak.GetAccount(ctx, txSigner) if signerAcc == nil { signerAcc = d.ak.NewAccountWithAddress(ctx, txSigner) diff --git a/x/fee_grant/internal/ante/fee_test.go b/x/fee_grant/internal/ante/fee_test.go index f922c27d4c40..2e6b798e37fc 100644 --- a/x/fee_grant/internal/ante/fee_test.go +++ b/x/fee_grant/internal/ante/fee_test.go @@ -20,7 +20,7 @@ import ( ) // newAnteHandler is just like auth.NewAnteHandler, except we use the DeductDelegatedFeeDecorator -// in order to allow payment of fees via a delegation. +// in order to allow payment of fees via a grant. // // This is used for our full-stack tests func newAnteHandler(ak authkeeper.AccountKeeper, supplyKeeper authtypes.SupplyKeeper, dk keeper.Keeper, sigGasConsumer authante.SignatureVerificationGasConsumer) sdk.AnteHandler { @@ -46,11 +46,11 @@ func TestDeductFeesNoDelegation(t *testing.T) { app, ctx := createTestApp(true) // this just tests our handler - dfd := ante.NewDeductDelegatedFeeDecorator(app.AccountKeeper, app.SupplyKeeper, app.DelegationKeeper) + dfd := ante.NewDeductDelegatedFeeDecorator(app.AccountKeeper, app.SupplyKeeper, app.FeeGrantKeeper) ourAnteHandler := sdk.ChainAnteDecorators(dfd) // this tests the whole stack - anteHandlerStack := newAnteHandler(app.AccountKeeper, app.SupplyKeeper, app.DelegationKeeper, SigGasNoConsumer) + anteHandlerStack := newAnteHandler(app.AccountKeeper, app.SupplyKeeper, app.FeeGrantKeeper, SigGasNoConsumer) // keys and addresses priv1, _, addr1 := authtypes.KeyTestPubAddr() @@ -68,8 +68,8 @@ func TestDeductFeesNoDelegation(t *testing.T) { acc2.SetCoins([]sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(99999))}) app.AccountKeeper.SetAccount(ctx, acc2) - // Set delegation from addr2 to addr3 (plenty to pay) - app.DelegationKeeper.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + // Set grant from addr2 to addr3 (plenty to pay) + app.FeeGrantKeeper.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr2, Grantee: addr3, Allowance: &types.BasicFeeAllowance{ @@ -77,8 +77,8 @@ func TestDeductFeesNoDelegation(t *testing.T) { }, }) - // Set low delegation from addr2 to addr4 (delegation will reject) - app.DelegationKeeper.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + // Set low grant from addr2 to addr4 (keeper will reject) + app.FeeGrantKeeper.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr2, Grantee: addr4, Allowance: &types.BasicFeeAllowance{ @@ -86,8 +86,8 @@ func TestDeductFeesNoDelegation(t *testing.T) { }, }) - // Set delegation from addr1 to addr4 (cannot cover this ) - app.DelegationKeeper.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + // Set grant from addr1 to addr4 (cannot cover this ) + app.FeeGrantKeeper.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr2, Grantee: addr3, Allowance: &types.BasicFeeAllowance{ @@ -138,7 +138,7 @@ func TestDeductFeesNoDelegation(t *testing.T) { handler: ourAnteHandler, valid: false, }, - "valid delegation without account (only ours)": { + "valid fee grant without account (only ours)": { signerKey: priv3, signer: addr3, feeAccount: addr2, @@ -146,7 +146,7 @@ func TestDeductFeesNoDelegation(t *testing.T) { handler: ourAnteHandler, valid: true, }, - "no delegation (only ours)": { + "no fee grant (only ours)": { signerKey: priv3, signer: addr3, feeAccount: addr1, @@ -162,7 +162,7 @@ func TestDeductFeesNoDelegation(t *testing.T) { handler: ourAnteHandler, valid: false, }, - "granter cannot cover allowed delegation (only ours)": { + "granter cannot cover allowed fee grant (only ours)": { signerKey: priv4, signer: addr4, feeAccount: addr1, @@ -206,7 +206,7 @@ func TestDeductFeesNoDelegation(t *testing.T) { handler: anteHandlerStack, valid: false, }, - "valid delegation without account (whole stack)": { + "valid fee grant without account (whole stack)": { signerKey: priv3, signer: addr3, feeAccount: addr2, @@ -214,7 +214,7 @@ func TestDeductFeesNoDelegation(t *testing.T) { handler: anteHandlerStack, valid: true, }, - "no delegation (whole stack)": { + "no fee grant (whole stack)": { signerKey: priv3, signer: addr3, feeAccount: addr1, @@ -230,7 +230,7 @@ func TestDeductFeesNoDelegation(t *testing.T) { handler: anteHandlerStack, valid: false, }, - "granter cannot cover allowed delegation (whole stack)": { + "granter cannot cover allowed fee grant (whole stack)": { signerKey: priv4, signer: addr4, feeAccount: addr1, diff --git a/x/fee_grant/internal/types/codec.go b/x/fee_grant/internal/types/codec.go index f3cebd6d371f..44c266be45b1 100644 --- a/x/fee_grant/internal/types/codec.go +++ b/x/fee_grant/internal/types/codec.go @@ -8,7 +8,7 @@ import ( // RegisterCodec registers the account types and interface func RegisterCodec(cdc *codec.Codec) { cdc.RegisterInterface((*exported.FeeAllowance)(nil), nil) - cdc.RegisterConcrete(&BasicFeeAllowance{}, "delegation/BasicFeeAllowance", nil) + cdc.RegisterConcrete(&BasicFeeAllowance{}, "feegrant/BasicFeeAllowance", nil) } // ModuleCdc generic sealed codec to be used throughout module diff --git a/x/fee_grant/internal/types/key.go b/x/fee_grant/internal/types/key.go index 88b2901326c0..675cb41097eb 100644 --- a/x/fee_grant/internal/types/key.go +++ b/x/fee_grant/internal/types/key.go @@ -8,7 +8,7 @@ import ( const ( // ModuleName is the module name constant used in many places - ModuleName = "delegation" + ModuleName = "feegrant" // StoreKey is the store key string for supply StoreKey = ModuleName diff --git a/x/fee_grant/internal/types/msgs.go b/x/fee_grant/internal/types/msgs.go index a19eb291bd2f..f4dea99143af 100644 --- a/x/fee_grant/internal/types/msgs.go +++ b/x/fee_grant/internal/types/msgs.go @@ -7,7 +7,7 @@ import ( // MsgDelegateFeeAllowance adds permission for Grantee to spend up to Allowance // of fees from the account of Granter. -// If there was already an existing delegation, this overwrites it. +// If there was already an existing grant, this overwrites it. type MsgDelegateFeeAllowance struct { Granter sdk.AccAddress `json:"granter" yaml:"granter"` Grantee sdk.AccAddress `json:"grantee" yaml:"grantee"` diff --git a/x/fee_grant/module.go b/x/fee_grant/module.go index de061775dc40..525c918c76fe 100644 --- a/x/fee_grant/module.go +++ b/x/fee_grant/module.go @@ -20,27 +20,27 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) -// AppModuleBasic defines the basic application module used by the delegation module. +// AppModuleBasic defines the basic application module used by the fee_grant module. type AppModuleBasic struct{} -// Name returns the delegation module's name. +// Name returns the fee_grant module's name. func (AppModuleBasic) Name() string { return ModuleName } -// RegisterCodec registers the delegation module's types for the given codec. +// RegisterCodec registers the fee_grant module's types for the given codec. func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { RegisterCodec(cdc) tx.RegisterCodec(cdc) } -// DefaultGenesis returns default genesis state as raw bytes for the delegation +// DefaultGenesis returns default genesis state as raw bytes for the fee_grant // module. func (AppModuleBasic) DefaultGenesis() json.RawMessage { return []byte("[]") } -// ValidateGenesis performs genesis state validation for the delegation module. +// ValidateGenesis performs genesis state validation for the fee_grant module. func (a AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { _, err := a.getValidatedGenesis(bz) return err @@ -55,19 +55,19 @@ func (a AppModuleBasic) getValidatedGenesis(bz json.RawMessage) (GenesisState, e return data, data.ValidateBasic() } -// RegisterRESTRoutes registers the REST routes for the delegation module. +// RegisterRESTRoutes registers the REST routes for the fee_grant module. func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router) { // TODO // rest.RegisterRoutes(ctx, rtr) } -// GetTxCmd returns the root tx command for the delegation module. +// GetTxCmd returns the root tx command for the fee_grant module. func (AppModuleBasic) GetTxCmd(_ *codec.Codec) *cobra.Command { // TODO return nil } -// GetQueryCmd returns no root query command for the delegation module. +// GetQueryCmd returns no root query command for the fee_grant module. func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { // TODO return nil @@ -76,7 +76,7 @@ func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { //____________________________________________________________________________ -// AppModule implements an application module for the delegation module. +// AppModule implements an application module for the fee_grant module. type AppModule struct { AppModuleBasic keeper Keeper @@ -90,35 +90,35 @@ func NewAppModule(keeper Keeper) AppModule { } } -// Name returns the delegation module's name. +// Name returns the fee_grant module's name. func (AppModule) Name() string { return ModuleName } -// RegisterInvariants registers the delegation module invariants. +// RegisterInvariants registers the fee_grant module invariants. func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {} -// Route returns the message routing key for the delegation module. +// Route returns the message routing key for the fee_grant module. func (AppModule) Route() string { return RouterKey } -// NewHandler returns an sdk.Handler for the delegation module. +// NewHandler returns an sdk.Handler for the fee_grant module. func (am AppModule) NewHandler() sdk.Handler { return NewHandler(am.keeper) } -// QuerierRoute returns the delegation module's querier route name. +// QuerierRoute returns the fee_grant module's querier route name. func (AppModule) QuerierRoute() string { return QuerierRoute } -// NewQuerierHandler returns the delegation module sdk.Querier. +// NewQuerierHandler returns the fee_grant module sdk.Querier. func (am AppModule) NewQuerierHandler() sdk.Querier { return NewQuerier(am.keeper) } -// InitGenesis performs genesis initialization for the delegation module. It returns +// InitGenesis performs genesis initialization for the fee_grant module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate { genesisState, err := am.getValidatedGenesis(data) @@ -129,7 +129,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.Va return []abci.ValidatorUpdate{} } -// ExportGenesis returns the exported genesis state as raw bytes for the delegation +// ExportGenesis returns the exported genesis state as raw bytes for the fee_grant // module. func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { gs, err := ExportGenesis(ctx, am.keeper) @@ -139,10 +139,10 @@ func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { return ModuleCdc.MustMarshalJSON(gs) } -// BeginBlock returns the begin blocker for the delegation module. +// BeginBlock returns the begin blocker for the fee_grant module. func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} -// EndBlock returns the end blocker for the delegation module. It returns no validator +// EndBlock returns the end blocker for the fee_grant module. It returns no validator // updates. func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { return []abci.ValidatorUpdate{} From 320bad481365f79a699c96ba461b54afe534ef3a Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 24 Oct 2019 19:08:34 +0200 Subject: [PATCH 049/184] Modify Msg and Keeper methods to use Grant not Delegate --- x/fee_grant/alias.go | 16 +++--- x/fee_grant/exported/fees.go | 4 +- x/fee_grant/genesis.go | 2 +- x/fee_grant/handler.go | 4 +- x/fee_grant/internal/ante/fee.go | 24 ++++---- x/fee_grant/internal/ante/fee_test.go | 16 +++--- x/fee_grant/internal/keeper/keeper.go | 10 ++-- x/fee_grant/internal/keeper/keeper_test.go | 22 ++++---- x/fee_grant/internal/keeper/querier_test.go | 4 +- x/fee_grant/internal/types/msgs.go | 18 +++--- x/fee_grant/internal/types/tx/codec.go | 2 +- x/fee_grant/internal/types/tx/test_common.go | 4 +- x/fee_grant/internal/types/tx/tx.go | 58 ++++++++++---------- 13 files changed, 92 insertions(+), 92 deletions(-) diff --git a/x/fee_grant/alias.go b/x/fee_grant/alias.go index 6f4011bb6b6b..4012d4533f32 100644 --- a/x/fee_grant/alias.go +++ b/x/fee_grant/alias.go @@ -34,7 +34,7 @@ var ( BlockPeriod = types.BlockPeriod FeeAllowanceKey = types.FeeAllowanceKey FeeAllowancePrefixByGrantee = types.FeeAllowancePrefixByGrantee - NewMsgDelegateFeeAllowance = types.NewMsgDelegateFeeAllowance + NewMsgGrantFeeAllowance = types.NewMsgGrantFeeAllowance NewMsgRevokeFeeAllowance = types.NewMsgRevokeFeeAllowance NewKeeper = keeper.NewKeeper NewQuerier = keeper.NewQuerier @@ -45,11 +45,11 @@ var ( ) type ( - BasicFeeAllowance = types.BasicFeeAllowance - ExpiresAt = types.ExpiresAt - Period = types.Period - FeeAllowanceGrant = types.FeeAllowanceGrant - MsgDelegateFeeAllowance = types.MsgDelegateFeeAllowance - MsgRevokeFeeAllowance = types.MsgRevokeFeeAllowance - Keeper = keeper.Keeper + BasicFeeAllowance = types.BasicFeeAllowance + ExpiresAt = types.ExpiresAt + Period = types.Period + FeeAllowanceGrant = types.FeeAllowanceGrant + MsgGrantFeeAllowance = types.MsgGrantFeeAllowance + MsgRevokeFeeAllowance = types.MsgRevokeFeeAllowance + Keeper = keeper.Keeper ) diff --git a/x/fee_grant/exported/fees.go b/x/fee_grant/exported/fees.go index 4c217bff6d6e..7f8a55ab8acf 100644 --- a/x/fee_grant/exported/fees.go +++ b/x/fee_grant/exported/fees.go @@ -11,14 +11,14 @@ import ( type FeeAllowance interface { // Accept can use fee payment requested as well as timestamp/height of the current block // to determine whether or not to process this. This is checked in - // Keeper.UseDelegatedFees and the return values should match how it is handled there. + // Keeper.UseGrantedFees and the return values should match how it is handled there. // // If it returns an error, the fee payment is rejected, otherwise it is accepted. // The FeeAllowance implementation is expected to update it's internal state // and will be saved again after an acceptance. // // If remove is true (regardless of the error), the FeeAllowance will be deleted from storage - // (eg. when it is used up). (See call to RevokeFeeAllowance in Keeper.UseDelegatedFees) + // (eg. when it is used up). (See call to RevokeFeeAllowance in Keeper.UseGrantedFees) Accept(fee sdk.Coins, blockTime time.Time, blockHeight int64) (remove bool, err error) // If we export fee allowances the timing info will be quite off (eg. go from height 100000 to 0) diff --git a/x/fee_grant/genesis.go b/x/fee_grant/genesis.go index 60259d682f9b..20aebe8636f3 100644 --- a/x/fee_grant/genesis.go +++ b/x/fee_grant/genesis.go @@ -19,7 +19,7 @@ func (g GenesisState) ValidateBasic() error { // InitGenesis will initialize the keeper from a *previously validated* GenesisState func InitGenesis(ctx sdk.Context, k Keeper, gen GenesisState) { for _, f := range gen { - k.DelegateFeeAllowance(ctx, f) + k.GrantFeeAllowance(ctx, f) } } diff --git a/x/fee_grant/handler.go b/x/fee_grant/handler.go index 7fac0ae6297d..3e5773069482 100644 --- a/x/fee_grant/handler.go +++ b/x/fee_grant/handler.go @@ -10,9 +10,9 @@ func NewHandler(k Keeper) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) sdk.Result { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { - case MsgDelegateFeeAllowance: + case MsgGrantFeeAllowance: grant := FeeAllowanceGrant(msg) - k.DelegateFeeAllowance(ctx, grant) + k.GrantFeeAllowance(ctx, grant) return sdk.Result{} case MsgRevokeFeeAllowance: k.RevokeFeeAllowance(ctx, msg.Granter, msg.Grantee) diff --git a/x/fee_grant/internal/ante/fee.go b/x/fee_grant/internal/ante/fee.go index 75fd2d136d3d..4ae70f6e0315 100644 --- a/x/fee_grant/internal/ante/fee.go +++ b/x/fee_grant/internal/ante/fee.go @@ -17,11 +17,11 @@ import ( ) var ( - _ DelegatedFeeTx = (*tx.DelegatedTx)(nil) // assert StdTx implements DelegatedFeeTx + _ GrantedFeeTx = (*tx.FeeGrantTx)(nil) // assert StdTx implements GrantedFeeTx ) -// DelegatedFeeTx defines the interface to be implemented by Tx to use the DelegatedFeeDecorator -type DelegatedFeeTx interface { +// GrantedFeeTx defines the interface to be implemented by Tx to use the GrantedFeeDecorator +type GrantedFeeTx interface { sdk.Tx GetGas() uint64 GetFee() sdk.Coins @@ -29,28 +29,28 @@ type DelegatedFeeTx interface { MainSigner() sdk.AccAddress } -// DeductDelegatedFeeDecorator deducts fees from the first signer of the tx +// DeductGrantedFeeDecorator deducts fees from the first signer of the tx // If the first signer does not have the funds to pay for the fees, return with InsufficientFunds error // Call next AnteHandler if fees successfully deducted -// CONTRACT: Tx must implement DelegatedFeeTx interface to use DeductDelegatedFeeDecorator -type DeductDelegatedFeeDecorator struct { +// CONTRACT: Tx must implement GrantedFeeTx interface to use DeductGrantedFeeDecorator +type DeductGrantedFeeDecorator struct { ak authKeeper.AccountKeeper dk keeper.Keeper sk authTypes.SupplyKeeper } -func NewDeductDelegatedFeeDecorator(ak authKeeper.AccountKeeper, sk authTypes.SupplyKeeper, dk keeper.Keeper) DeductDelegatedFeeDecorator { - return DeductDelegatedFeeDecorator{ +func NewDeductGrantedFeeDecorator(ak authKeeper.AccountKeeper, sk authTypes.SupplyKeeper, dk keeper.Keeper) DeductGrantedFeeDecorator { + return DeductGrantedFeeDecorator{ ak: ak, dk: dk, sk: sk, } } -func (d DeductDelegatedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { - feeTx, ok := tx.(DelegatedFeeTx) +func (d DeductGrantedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { + feeTx, ok := tx.(GrantedFeeTx) if !ok { - return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a DelegatedFeeTx") + return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a GrantedFeeTx") } // sanity check from DeductFeeDecorator @@ -64,7 +64,7 @@ func (d DeductDelegatedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu // ensure the grant is allowed, if we request a different fee payer if !txSigner.Equals(feePayer) { - allowed := d.dk.UseDelegatedFees(ctx, feePayer, txSigner, fee) + allowed := d.dk.UseGrantedFees(ctx, feePayer, txSigner, fee) if !allowed { return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s not allowed to pay fees from %s", txSigner, feePayer) } diff --git a/x/fee_grant/internal/ante/fee_test.go b/x/fee_grant/internal/ante/fee_test.go index 2e6b798e37fc..f97350647cee 100644 --- a/x/fee_grant/internal/ante/fee_test.go +++ b/x/fee_grant/internal/ante/fee_test.go @@ -19,7 +19,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types/tx" ) -// newAnteHandler is just like auth.NewAnteHandler, except we use the DeductDelegatedFeeDecorator +// newAnteHandler is just like auth.NewAnteHandler, except we use the DeductGrantedFeeDecorator // in order to allow payment of fees via a grant. // // This is used for our full-stack tests @@ -30,9 +30,9 @@ func newAnteHandler(ak authkeeper.AccountKeeper, supplyKeeper authtypes.SupplyKe authante.NewValidateBasicDecorator(), authante.NewValidateMemoDecorator(ak), authante.NewConsumeGasForTxSizeDecorator(ak), - // DeductDelegatedFeeDecorator will create an empty account if we sign with no tokens but valid validation + // DeductGrantedFeeDecorator will create an empty account if we sign with no tokens but valid validation // This must be before SetPubKey, ValidateSigCount, SigVerification, which error if account doesn't exist yet - ante.NewDeductDelegatedFeeDecorator(ak, supplyKeeper, dk), + ante.NewDeductGrantedFeeDecorator(ak, supplyKeeper, dk), authante.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators authante.NewValidateSigCountDecorator(ak), authante.NewSigGasConsumeDecorator(ak, sigGasConsumer), @@ -46,7 +46,7 @@ func TestDeductFeesNoDelegation(t *testing.T) { app, ctx := createTestApp(true) // this just tests our handler - dfd := ante.NewDeductDelegatedFeeDecorator(app.AccountKeeper, app.SupplyKeeper, app.FeeGrantKeeper) + dfd := ante.NewDeductGrantedFeeDecorator(app.AccountKeeper, app.SupplyKeeper, app.FeeGrantKeeper) ourAnteHandler := sdk.ChainAnteDecorators(dfd) // this tests the whole stack @@ -69,7 +69,7 @@ func TestDeductFeesNoDelegation(t *testing.T) { app.AccountKeeper.SetAccount(ctx, acc2) // Set grant from addr2 to addr3 (plenty to pay) - app.FeeGrantKeeper.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + app.FeeGrantKeeper.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr2, Grantee: addr3, Allowance: &types.BasicFeeAllowance{ @@ -78,7 +78,7 @@ func TestDeductFeesNoDelegation(t *testing.T) { }) // Set low grant from addr2 to addr4 (keeper will reject) - app.FeeGrantKeeper.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + app.FeeGrantKeeper.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr2, Grantee: addr4, Allowance: &types.BasicFeeAllowance{ @@ -87,7 +87,7 @@ func TestDeductFeesNoDelegation(t *testing.T) { }) // Set grant from addr1 to addr4 (cannot cover this ) - app.FeeGrantKeeper.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + app.FeeGrantKeeper.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr2, Grantee: addr3, Allowance: &types.BasicFeeAllowance{ @@ -244,7 +244,7 @@ func TestDeductFeesNoDelegation(t *testing.T) { tc := stc // to make scopelint happy t.Run(name, func(t *testing.T) { // msg and signatures - fee := tx.NewDelegatedFee(100000, sdk.NewCoins(sdk.NewInt64Coin("atom", tc.fee)), tc.feeAccount) + fee := tx.NewGrantedFee(100000, sdk.NewCoins(sdk.NewInt64Coin("atom", tc.fee)), tc.feeAccount) msgs := []sdk.Msg{sdk.NewTestMsg(tc.signer)} privs, accNums, seqs := []crypto.PrivKey{tc.signerKey}, []uint64{0}, []uint64{0} diff --git a/x/fee_grant/internal/keeper/keeper.go b/x/fee_grant/internal/keeper/keeper.go index 72b7ea976339..09d5d7e33867 100644 --- a/x/fee_grant/internal/keeper/keeper.go +++ b/x/fee_grant/internal/keeper/keeper.go @@ -17,8 +17,8 @@ func NewKeeper(cdc *codec.Codec, storeKey sdk.StoreKey) Keeper { return Keeper{cdc: cdc, storeKey: storeKey} } -// DelegateFeeAllowance creates a new grant -func (k Keeper) DelegateFeeAllowance(ctx sdk.Context, grant types.FeeAllowanceGrant) { +// GrantFeeAllowance creates a new grant +func (k Keeper) GrantFeeAllowance(ctx sdk.Context, grant types.FeeAllowanceGrant) { store := ctx.KVStore(k.storeKey) key := types.FeeAllowanceKey(grant.Granter, grant.Grantee) bz := k.cdc.MustMarshalBinaryBare(grant) @@ -102,8 +102,8 @@ func (k Keeper) IterateAllFeeAllowances(ctx sdk.Context, cb func(types.FeeAllowa return nil } -// UseDelegatedFees will try to pay the given fee from the granter's account as requested by the grantee -func (k Keeper) UseDelegatedFees(ctx sdk.Context, granter, grantee sdk.AccAddress, fee sdk.Coins) bool { +// UseGrantedFees will try to pay the given fee from the granter's account as requested by the grantee +func (k Keeper) UseGrantedFees(ctx sdk.Context, granter, grantee sdk.AccAddress, fee sdk.Coins) bool { grant, err := k.GetFeeGrant(ctx, granter, grantee) if err != nil { panic(err) @@ -122,6 +122,6 @@ func (k Keeper) UseDelegatedFees(ctx sdk.Context, granter, grantee sdk.AccAddres } // if we accepted, store the updated state of the allowance - k.DelegateFeeAllowance(ctx, grant) + k.GrantFeeAllowance(ctx, grant) return true } diff --git a/x/fee_grant/internal/keeper/keeper_test.go b/x/fee_grant/internal/keeper/keeper_test.go index 727032405e5b..8919eb2653ea 100644 --- a/x/fee_grant/internal/keeper/keeper_test.go +++ b/x/fee_grant/internal/keeper/keeper_test.go @@ -77,29 +77,29 @@ func TestKeeperCrud(t *testing.T) { } // let's set up some initial state here - k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr, Grantee: addr2, Allowance: &basic, }) - k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr, Grantee: addr3, Allowance: &basic2, }) - k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr2, Grantee: addr3, Allowance: &basic, }) - k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr2, Grantee: addr4, Allowance: &basic, }) - k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr4, Grantee: addr, Allowance: &basic2, }) // remove some, overwrite other k.RevokeFeeAllowance(ctx, addr, addr2) k.RevokeFeeAllowance(ctx, addr, addr3) - k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr, Grantee: addr3, Allowance: &basic, }) - k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr2, Grantee: addr3, Allowance: &basic2, }) @@ -180,7 +180,7 @@ func TestKeeperCrud(t *testing.T) { } } -func TestUseDelegatedFee(t *testing.T) { +func TestUseGrantedFee(t *testing.T) { input := setupTestInput() ctx := input.ctx k := input.dk @@ -248,14 +248,14 @@ func TestUseDelegatedFee(t *testing.T) { // let's set up some initial state here // addr -> addr2 (future) // addr -> addr3 (expired) - k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr, Grantee: addr2, Allowance: &future, }) - k.DelegateFeeAllowance(ctx, types.FeeAllowanceGrant{ + k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr, Grantee: addr3, Allowance: &expired, }) - allowed := k.UseDelegatedFees(ctx, tc.granter, tc.grantee, tc.fee) + allowed := k.UseGrantedFees(ctx, tc.granter, tc.grantee, tc.fee) require.Equal(t, tc.allowed, allowed) loaded, err := k.GetFeeAllowance(ctx, tc.granter, tc.grantee) diff --git a/x/fee_grant/internal/keeper/querier_test.go b/x/fee_grant/internal/keeper/querier_test.go index aa2618dbeaad..c7c9ad676a1f 100644 --- a/x/fee_grant/internal/keeper/querier_test.go +++ b/x/fee_grant/internal/keeper/querier_test.go @@ -40,8 +40,8 @@ func TestQuery(t *testing.T) { } // let's set up some initial state here - k.DelegateFeeAllowance(ctx, grant1) - k.DelegateFeeAllowance(ctx, grant2) + k.GrantFeeAllowance(ctx, grant1) + k.GrantFeeAllowance(ctx, grant2) // now try some queries cases := map[string]struct { diff --git a/x/fee_grant/internal/types/msgs.go b/x/fee_grant/internal/types/msgs.go index f4dea99143af..9a9b370b4a5c 100644 --- a/x/fee_grant/internal/types/msgs.go +++ b/x/fee_grant/internal/types/msgs.go @@ -5,28 +5,28 @@ import ( "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" ) -// MsgDelegateFeeAllowance adds permission for Grantee to spend up to Allowance +// MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance // of fees from the account of Granter. // If there was already an existing grant, this overwrites it. -type MsgDelegateFeeAllowance struct { +type MsgGrantFeeAllowance struct { Granter sdk.AccAddress `json:"granter" yaml:"granter"` Grantee sdk.AccAddress `json:"grantee" yaml:"grantee"` Allowance exported.FeeAllowance `json:"allowance" yaml:"allowance"` } -func NewMsgDelegateFeeAllowance(granter sdk.AccAddress, grantee sdk.AccAddress, allowance exported.FeeAllowance) MsgDelegateFeeAllowance { - return MsgDelegateFeeAllowance{Granter: granter, Grantee: grantee, Allowance: allowance} +func NewMsgGrantFeeAllowance(granter sdk.AccAddress, grantee sdk.AccAddress, allowance exported.FeeAllowance) MsgGrantFeeAllowance { + return MsgGrantFeeAllowance{Granter: granter, Grantee: grantee, Allowance: allowance} } -func (msg MsgDelegateFeeAllowance) Route() string { +func (msg MsgGrantFeeAllowance) Route() string { return RouterKey } -func (msg MsgDelegateFeeAllowance) Type() string { +func (msg MsgGrantFeeAllowance) Type() string { return "delegate-fee-allowance" } -func (msg MsgDelegateFeeAllowance) ValidateBasic() sdk.Error { +func (msg MsgGrantFeeAllowance) ValidateBasic() sdk.Error { if msg.Granter.Empty() { return sdk.ErrInvalidAddress("missing granter address") } @@ -36,11 +36,11 @@ func (msg MsgDelegateFeeAllowance) ValidateBasic() sdk.Error { return sdk.ConvertError(msg.Allowance.ValidateBasic()) } -func (msg MsgDelegateFeeAllowance) GetSignBytes() []byte { +func (msg MsgGrantFeeAllowance) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) } -func (msg MsgDelegateFeeAllowance) GetSigners() []sdk.AccAddress { +func (msg MsgGrantFeeAllowance) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Granter} } diff --git a/x/fee_grant/internal/types/tx/codec.go b/x/fee_grant/internal/types/tx/codec.go index 90baa93cf075..50e482b48bd3 100644 --- a/x/fee_grant/internal/types/tx/codec.go +++ b/x/fee_grant/internal/types/tx/codec.go @@ -4,5 +4,5 @@ import "github.com/cosmos/cosmos-sdk/codec" // RegisterCodec registers concrete types on the codec func RegisterCodec(cdc *codec.Codec) { - cdc.RegisterConcrete(DelegatedTx{}, "cosmos-sdk/DelegatedTx", nil) + cdc.RegisterConcrete(FeeGrantTx{}, "cosmos-sdk/FeeGrantTx", nil) } diff --git a/x/fee_grant/internal/types/tx/test_common.go b/x/fee_grant/internal/types/tx/test_common.go index cda6ae55e8ea..f33e1c222879 100644 --- a/x/fee_grant/internal/types/tx/test_common.go +++ b/x/fee_grant/internal/types/tx/test_common.go @@ -8,7 +8,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) -func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums []uint64, seqs []uint64, fee DelegatedFee) sdk.Tx { +func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums []uint64, seqs []uint64, fee GrantedFee) sdk.Tx { sigs := make([]authtypes.StdSignature, len(privs)) for i, priv := range privs { signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], fee, msgs, "") @@ -21,6 +21,6 @@ func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums sigs[i] = authtypes.StdSignature{PubKey: priv.PubKey(), Signature: sig} } - tx := NewDelegatedTx(msgs, fee, sigs, "") + tx := NewFeeGrantTx(msgs, fee, sigs, "") return tx } diff --git a/x/fee_grant/internal/types/tx/tx.go b/x/fee_grant/internal/types/tx/tx.go index 448151b948f1..a02eb73ab95d 100644 --- a/x/fee_grant/internal/types/tx/tx.go +++ b/x/fee_grant/internal/types/tx/tx.go @@ -14,25 +14,25 @@ import ( ) var ( - _ sdk.Tx = DelegatedTx{} + _ sdk.Tx = FeeGrantTx{} maxGasWanted = uint64((1 << 63) - 1) ) -// DelegatedTx wraps a Msg with Fee and Signatures, +// FeeGrantTx wraps a Msg with Fee and Signatures, // adding the ability to delegate the fee payment // NOTE: the first signature responsible for paying fees, either directly, // or must be authorized to spend from the provided Fee.FeeAccount -type DelegatedTx struct { +type FeeGrantTx struct { Msgs []sdk.Msg `json:"msg" yaml:"msg"` - Fee DelegatedFee `json:"fee" yaml:"fee"` + Fee GrantedFee `json:"fee" yaml:"fee"` Signatures []authtypes.StdSignature `json:"signatures" yaml:"signatures"` Memo string `json:"memo" yaml:"memo"` FeeAccount sdk.AccAddress `json:"fee_account" yaml:"fee_account"` } -func NewDelegatedTx(msgs []sdk.Msg, fee DelegatedFee, sigs []authtypes.StdSignature, memo string) DelegatedTx { - return DelegatedTx{ +func NewFeeGrantTx(msgs []sdk.Msg, fee GrantedFee, sigs []authtypes.StdSignature, memo string) FeeGrantTx { + return FeeGrantTx{ Msgs: msgs, Fee: fee, Signatures: sigs, @@ -41,11 +41,11 @@ func NewDelegatedTx(msgs []sdk.Msg, fee DelegatedFee, sigs []authtypes.StdSignat } // GetMsgs returns the all the transaction's messages. -func (tx DelegatedTx) GetMsgs() []sdk.Msg { return tx.Msgs } +func (tx FeeGrantTx) GetMsgs() []sdk.Msg { return tx.Msgs } // ValidateBasic does a simple and lightweight validation check that doesn't // require access to any other information. -func (tx DelegatedTx) ValidateBasic() sdk.Error { +func (tx FeeGrantTx) ValidateBasic() sdk.Error { stdSigs := tx.GetSignatures() if tx.Fee.Gas > maxGasWanted { @@ -84,7 +84,7 @@ func CountSubKeys(pub crypto.PubKey) int { // They are accumulated from the GetSigners method for each Msg // in the order they appear in tx.GetMsgs(). // Duplicate addresses will be omitted. -func (tx DelegatedTx) GetSigners() []sdk.AccAddress { +func (tx FeeGrantTx) GetSigners() []sdk.AccAddress { seen := map[string]bool{} var signers []sdk.AccAddress for _, msg := range tx.GetMsgs() { @@ -99,7 +99,7 @@ func (tx DelegatedTx) GetSigners() []sdk.AccAddress { } // GetMemo returns the memo -func (tx DelegatedTx) GetMemo() string { return tx.Memo } +func (tx FeeGrantTx) GetMemo() string { return tx.Memo } // GetSignatures returns the signature of signers who signed the Msg. // CONTRACT: Length returned is same as length of @@ -108,7 +108,7 @@ func (tx DelegatedTx) GetMemo() string { return tx.Memo } // CONTRACT: If the signature is missing (ie the Msg is // invalid), then the corresponding signature is // .Empty(). -func (tx DelegatedTx) GetSignatures() [][]byte { +func (tx FeeGrantTx) GetSignatures() [][]byte { sigs := make([][]byte, len(tx.Signatures)) for i, stdSig := range tx.Signatures { sigs[i] = stdSig.Signature @@ -118,7 +118,7 @@ func (tx DelegatedTx) GetSignatures() [][]byte { // GetPubkeys returns the pubkeys of signers if the pubkey is included in the signature // If pubkey is not included in the signature, then nil is in the slice instead -func (tx DelegatedTx) GetPubKeys() []crypto.PubKey { +func (tx FeeGrantTx) GetPubKeys() []crypto.PubKey { pks := make([]crypto.PubKey, len(tx.Signatures)) for i, stdSig := range tx.Signatures { pks[i] = stdSig.PubKey @@ -127,7 +127,7 @@ func (tx DelegatedTx) GetPubKeys() []crypto.PubKey { } // GetSignBytes returns the signBytes of the tx for a given signer -func (tx DelegatedTx) GetSignBytes(ctx sdk.Context, acc exported.Account) []byte { +func (tx FeeGrantTx) GetSignBytes(ctx sdk.Context, acc exported.Account) []byte { genesis := ctx.BlockHeight() == 0 chainID := ctx.ChainID() var accNum uint64 @@ -137,15 +137,15 @@ func (tx DelegatedTx) GetSignBytes(ctx sdk.Context, acc exported.Account) []byte return StdSignBytes(chainID, accNum, acc.GetSequence(), tx.Fee, tx.Msgs, tx.Memo) } -// GetGas returns the Gas in DelegatedFee -func (tx DelegatedTx) GetGas() uint64 { return tx.Fee.Gas } +// GetGas returns the Gas in GrantedFee +func (tx FeeGrantTx) GetGas() uint64 { return tx.Fee.Gas } -// GetFee returns the FeeAmount in DelegatedFee -func (tx DelegatedTx) GetFee() sdk.Coins { return tx.Fee.Amount } +// GetFee returns the FeeAmount in GrantedFee +func (tx FeeGrantTx) GetFee() sdk.Coins { return tx.Fee.Amount } // FeePayer returns the address that is responsible for paying fee -// This can be explicily set in DelegatedFee, or defaults to MainSigner -func (tx DelegatedTx) FeePayer() sdk.AccAddress { +// This can be explicily set in GrantedFee, or defaults to MainSigner +func (tx FeeGrantTx) FeePayer() sdk.AccAddress { if len(tx.Fee.FeeAccount) != 0 { return tx.Fee.FeeAccount } @@ -154,25 +154,25 @@ func (tx DelegatedTx) FeePayer() sdk.AccAddress { // MainSigner returns the first signer of the tx, by default this // account is responsible for fees, if not explicitly set. -func (tx DelegatedTx) MainSigner() sdk.AccAddress { +func (tx FeeGrantTx) MainSigner() sdk.AccAddress { if len(tx.GetSigners()) != 0 { return tx.GetSigners()[0] } return sdk.AccAddress{} } -// DelegatedFee includes the amount of coins paid in fees and the maximum +// GrantedFee includes the amount of coins paid in fees and the maximum // gas to be used by the transaction. The ratio yields an effective "gasprice", // which must be above some miminum to be accepted into the mempool. -type DelegatedFee struct { +type GrantedFee struct { Amount sdk.Coins `json:"amount" yaml:"amount"` Gas uint64 `json:"gas" yaml:"gas"` FeeAccount sdk.AccAddress `json:"fee_account,omitempty" yaml:"fee_account"` } -// NewDelegatedFee returns a new instance of DelegatedFee -func NewDelegatedFee(gas uint64, amount sdk.Coins, feeAccount sdk.AccAddress) DelegatedFee { - return DelegatedFee{ +// NewGrantedFee returns a new instance of GrantedFee +func NewGrantedFee(gas uint64, amount sdk.Coins, feeAccount sdk.AccAddress) GrantedFee { + return GrantedFee{ Amount: amount, Gas: gas, FeeAccount: feeAccount, @@ -180,7 +180,7 @@ func NewDelegatedFee(gas uint64, amount sdk.Coins, feeAccount sdk.AccAddress) De } // Bytes for signing later -func (fee DelegatedFee) Bytes() []byte { +func (fee GrantedFee) Bytes() []byte { // normalize. XXX // this is a sign of something ugly // (in the lcd_test, client side its null, @@ -196,12 +196,12 @@ func (fee DelegatedFee) Bytes() []byte { return bz } -// GasPrices returns the gas prices for a DelegatedFee. +// GasPrices returns the gas prices for a GrantedFee. // // NOTE: The gas prices returned are not the true gas prices that were // originally part of the submitted transaction because the fee is computed // as fee = ceil(gasWanted * gasPrices). -func (fee DelegatedFee) GasPrices() sdk.DecCoins { +func (fee GrantedFee) GasPrices() sdk.DecCoins { return sdk.NewDecCoins(fee.Amount).QuoDec(sdk.NewDec(int64(fee.Gas))) } @@ -220,7 +220,7 @@ type DelegatedSignDoc struct { } // StdSignBytes returns the bytes to sign for a transaction. -func StdSignBytes(chainID string, accnum uint64, sequence uint64, fee DelegatedFee, msgs []sdk.Msg, memo string) []byte { +func StdSignBytes(chainID string, accnum uint64, sequence uint64, fee GrantedFee, msgs []sdk.Msg, memo string) []byte { cdc := codec.New() msgsBytes := make([]json.RawMessage, 0, len(msgs)) for _, msg := range msgs { From 4b4391bcac9500bfc2c5bf45bbdde84cc7a32200 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Tue, 29 Oct 2019 14:22:30 +0100 Subject: [PATCH 050/184] Add PeriodicFeeAllowance --- x/fee_grant/internal/types/errors.go | 8 +- x/fee_grant/internal/types/expiration.go | 60 ++++++---- x/fee_grant/internal/types/expiration_test.go | 30 ++--- x/fee_grant/internal/types/periodic_fee.go | 113 ++++++++++++++++++ 4 files changed, 171 insertions(+), 40 deletions(-) create mode 100644 x/fee_grant/internal/types/periodic_fee.go diff --git a/x/fee_grant/internal/types/errors.go b/x/fee_grant/internal/types/errors.go index 1d5c57115030..d07db5c31557 100644 --- a/x/fee_grant/internal/types/errors.go +++ b/x/fee_grant/internal/types/errors.go @@ -10,7 +10,7 @@ const ( CodeFeeLimitExceeded sdk.CodeType = 1 CodeFeeLimitExpired sdk.CodeType = 2 - CodeInvalidPeriod sdk.CodeType = 3 + CodeInvalidDuration sdk.CodeType = 3 ) // ErrFeeLimitExceeded error if there are not enough allowance to cover the fees @@ -23,7 +23,7 @@ func ErrFeeLimitExpired() sdk.Error { return sdk.NewError(DefaultCodespace, CodeFeeLimitExpired, "fee limit expired") } -// ErrInvalidPeriod error if the period is invalid or doesn't match the expiration -func ErrInvalidPeriod(reason string) sdk.Error { - return sdk.NewError(DefaultCodespace, CodeInvalidPeriod, reason) +// ErrInvalidDuration error if the Duration is invalid or doesn't match the expiration +func ErrInvalidDuration(reason string) sdk.Error { + return sdk.NewError(DefaultCodespace, CodeInvalidDuration, reason) } diff --git a/x/fee_grant/internal/types/expiration.go b/x/fee_grant/internal/types/expiration.go index 91320b59c3e3..20be853eeb65 100644 --- a/x/fee_grant/internal/types/expiration.go +++ b/x/fee_grant/internal/types/expiration.go @@ -23,10 +23,10 @@ func ExpiresAtHeight(h int64) ExpiresAt { // Note that empty expiration is allowed func (e ExpiresAt) ValidateBasic() error { if !e.Time.IsZero() && e.Height != 0 { - return ErrInvalidPeriod("both time and height are set") + return ErrInvalidDuration("both time and height are set") } if e.Height < 0 { - return ErrInvalidPeriod("negative height") + return ErrInvalidDuration("negative height") } return nil } @@ -36,6 +36,15 @@ func (e ExpiresAt) IsZero() bool { return e.Time.IsZero() && e.Height == 0 } +// FastForward produces a new Expiration with the time or height set to the +// new value, depending on what was set on the original expiration +func (e ExpiresAt) FastForward(t time.Time, h int64) ExpiresAt { + if !e.Time.IsZero() { + return ExpiresAtTime(t) + } + return ExpiresAtHeight(h) +} + // IsExpired returns if the time or height is *equal to* or greater // than the defined expiration point. Note that it is expired upon // an exact match. @@ -50,25 +59,34 @@ func (e ExpiresAt) IsExpired(t time.Time, h int64) bool { // IsCompatible returns true iff the two use the same units. // If false, they cannot be added. -func (e ExpiresAt) IsCompatible(p Period) bool { +func (e ExpiresAt) IsCompatible(p Duration) bool { if !e.Time.IsZero() { return p.Clock > 0 } return p.Block > 0 } -// Step will increase the expiration point by one period -// It returns an error if the period is incompatible -func (e *ExpiresAt) Step(p Period) error { +// Step will increase the expiration point by one Duration +// It returns an error if the Duration is incompatible +func (e ExpiresAt) Step(p Duration) (ExpiresAt, error) { if !e.IsCompatible(p) { - return ErrInvalidPeriod("expires_at and period have different units") + return ExpiresAt{}, ErrInvalidDuration("expires_at and Duration have different units") } if !e.Time.IsZero() { e.Time = e.Time.Add(p.Clock) } else { e.Height += p.Block } - return nil + return e, nil +} + +// MustStep is like Step, but panics on error +func (e ExpiresAt) MustStep(p Duration) ExpiresAt { + res, err := e.Step(p) + if err != nil { + panic(err) + } + return res } // PrepareForExport will deduct the dumpHeight from the expiration, so when this is @@ -80,37 +98,37 @@ func (e ExpiresAt) PrepareForExport(dumpTime time.Time, dumpHeight int64) Expire return e } -// Period is a repeating unit of either clock time or number of blocks. +// Duration is a repeating unit of either clock time or number of blocks. // This is designed to be added to an ExpiresAt struct. -type Period struct { +type Duration struct { Clock time.Duration `json:"clock" yaml:"clock"` Block int64 `json:"block" yaml:"block"` } -// ClockPeriod creates an period by clock time -func ClockPeriod(d time.Duration) Period { - return Period{Clock: d} +// ClockDuration creates an Duration by clock time +func ClockDuration(d time.Duration) Duration { + return Duration{Clock: d} } -// BlockPeriod creates an period by block height -func BlockPeriod(h int64) Period { - return Period{Block: h} +// BlockDuration creates an Duration by block height +func BlockDuration(h int64) Duration { + return Duration{Block: h} } // ValidateBasic performs basic sanity checks // Note that exactly one must be set and it must be positive -func (p Period) ValidateBasic() error { +func (p Duration) ValidateBasic() error { if p.Block == 0 && p.Clock == 0 { - return ErrInvalidPeriod("neither time and height are set") + return ErrInvalidDuration("neither time and height are set") } if p.Block != 0 && p.Clock != 0 { - return ErrInvalidPeriod("both time and height are set") + return ErrInvalidDuration("both time and height are set") } if p.Block < 0 { - return ErrInvalidPeriod("negative block step") + return ErrInvalidDuration("negative block step") } if p.Clock < 0 { - return ErrInvalidPeriod("negative clock step") + return ErrInvalidDuration("negative clock step") } return nil } diff --git a/x/fee_grant/internal/types/expiration_test.go b/x/fee_grant/internal/types/expiration_test.go index 0c154e2bc30f..ab475fdf6312 100644 --- a/x/fee_grant/internal/types/expiration_test.go +++ b/x/fee_grant/internal/types/expiration_test.go @@ -69,41 +69,41 @@ func TestExpiresAt(t *testing.T) { } } -func TestPeriodValid(t *testing.T) { +func TestDurationValid(t *testing.T) { now := time.Now() cases := map[string]struct { - period Period + period Duration valid bool compatible ExpiresAt incompatible ExpiresAt }{ "basic height": { - period: BlockPeriod(100), + period: BlockDuration(100), valid: true, compatible: ExpiresAtHeight(50), incompatible: ExpiresAtTime(now), }, "basic time": { - period: ClockPeriod(time.Hour), + period: ClockDuration(time.Hour), valid: true, compatible: ExpiresAtTime(now), incompatible: ExpiresAtHeight(50), }, "zero": { - period: Period{}, + period: Duration{}, valid: false, }, "double": { - period: Period{Block: 100, Clock: time.Hour}, + period: Duration{Block: 100, Clock: time.Hour}, valid: false, }, "negative clock": { - period: ClockPeriod(-1 * time.Hour), + period: ClockDuration(-1 * time.Hour), valid: false, }, "negative block": { - period: BlockPeriod(-5), + period: BlockDuration(-5), valid: false, }, } @@ -124,30 +124,30 @@ func TestPeriodValid(t *testing.T) { } } -func TestPeriodStep(t *testing.T) { +func TestDurationStep(t *testing.T) { now := time.Now() cases := map[string]struct { expires ExpiresAt - period Period + period Duration valid bool result ExpiresAt }{ "add height": { expires: ExpiresAtHeight(789), - period: BlockPeriod(100), + period: BlockDuration(100), valid: true, result: ExpiresAtHeight(889), }, "add time": { expires: ExpiresAtTime(now), - period: ClockPeriod(time.Hour), + period: ClockDuration(time.Hour), valid: true, result: ExpiresAtTime(now.Add(time.Hour)), }, "mismatch": { expires: ExpiresAtHeight(789), - period: ClockPeriod(time.Hour), + period: ClockDuration(time.Hour), valid: false, }, } @@ -160,13 +160,13 @@ func TestPeriodStep(t *testing.T) { err = tc.expires.ValidateBasic() require.NoError(t, err) - err = tc.expires.Step(tc.period) + next, err := tc.expires.Step(tc.period) if !tc.valid { require.Error(t, err) return } require.NoError(t, err) - require.Equal(t, tc.result, tc.expires) + require.Equal(t, tc.result, next) }) } } diff --git a/x/fee_grant/internal/types/periodic_fee.go b/x/fee_grant/internal/types/periodic_fee.go new file mode 100644 index 000000000000..453fa8e85d15 --- /dev/null +++ b/x/fee_grant/internal/types/periodic_fee.go @@ -0,0 +1,113 @@ +package types + +import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" +) + +// PeriodicFeeAllowance extends FeeAllowance to allow for both a maximum cap, +// as well as a limit per time period. +type PeriodicFeeAllowance struct { + Basic BasicFeeAllowance + + // Period is the duration of one period + Period Duration + // PeriodSpendLimit is the maximum amount of tokens to be spent in this period + PeriodSpendLimit sdk.Coins + + // PeriodCanSpend is how much is available until PeriodReset + PeriodCanSpend sdk.Coins + + // PeriodRest is when the PeriodCanSpend is updated + PeriodReset ExpiresAt +} + +var _ exported.FeeAllowance = (*PeriodicFeeAllowance)(nil) + +// Accept implements FeeAllowance and deducts the fees from the SpendLimit if possible +func (a *PeriodicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockHeight int64) (remove bool, err error) { + if a.Basic.Expiration.IsExpired(blockTime, blockHeight) { + return true, ErrFeeLimitExpired() + } + + a.TryResetPeriod(blockTime, blockHeight) + + // deduct from both the current period and the max amount + var isNeg bool + a.PeriodSpendLimit, isNeg = a.PeriodSpendLimit.SafeSub(fee) + if isNeg { + return false, ErrFeeLimitExceeded() + } + a.Basic.SpendLimit, isNeg = a.Basic.SpendLimit.SafeSub(fee) + if isNeg { + return false, ErrFeeLimitExceeded() + } + + return a.Basic.SpendLimit.IsZero(), nil +} + +// TryResetPeriod will reset the period if we hit the conditions +func (a *PeriodicFeeAllowance) TryResetPeriod(blockTime time.Time, blockHeight int64) { + if !a.PeriodReset.IsExpired(blockTime, blockHeight) { + return + } + // set CanSpend to the lesser of PeriodSpendLimit and the TotalLimit + if _, isNeg := a.Basic.SpendLimit.SafeSub(a.PeriodSpendLimit); isNeg { + a.PeriodCanSpend = a.Basic.SpendLimit + } else { + a.PeriodCanSpend = a.PeriodSpendLimit + } + + // If we are within the period, step from expiration (eg. if you always do one tx per day, it will always reset the same time) + // If we are more then one period out (eg. no activity in a week), reset is one period from this time + a.PeriodReset = a.PeriodReset.MustStep(a.Period) + if a.PeriodReset.IsExpired(blockTime, blockHeight) { + a.PeriodReset = a.PeriodReset.FastForward(blockTime, blockHeight).MustStep(a.Period) + } +} + +// PrepareForExport adjusts all absolute block height (period reset, basic.expiration) +// with the dump height so they make sense after dump +func (a *PeriodicFeeAllowance) PrepareForExport(dumpTime time.Time, dumpHeight int64) exported.FeeAllowance { + return &PeriodicFeeAllowance{ + Basic: BasicFeeAllowance{ + SpendLimit: a.Basic.SpendLimit, + Expiration: a.Basic.Expiration.PrepareForExport(dumpTime, dumpHeight), + }, + PeriodSpendLimit: a.PeriodSpendLimit, + PeriodCanSpend: a.PeriodCanSpend, + Period: a.Period, + PeriodReset: a.PeriodReset.PrepareForExport(dumpTime, dumpHeight), + } +} + +// ValidateBasic implements FeeAllowance and enforces basic sanity checks +func (a PeriodicFeeAllowance) ValidateBasic() error { + if err := a.Basic.ValidateBasic(); err != nil { + return err + } + + if !a.PeriodSpendLimit.IsValid() { + return sdk.ErrInvalidCoins("spend amount is invalid: " + a.PeriodSpendLimit.String()) + } + if !a.PeriodSpendLimit.IsAllPositive() { + return sdk.ErrInvalidCoins("spend limit must be positive") + } + if !a.PeriodCanSpend.IsValid() { + return sdk.ErrInvalidCoins("can spend amount is invalid: " + a.PeriodCanSpend.String()) + } + // We allow 0 for CanSpend + if a.PeriodCanSpend.IsAnyNegative() { + return sdk.ErrInvalidCoins("can spend must not be negative") + } + + // TODO: ensure PeriodSpendLimit can be subtracted from total (same coin types) + + // check times + if err := a.Period.ValidateBasic(); err != nil { + return err + } + return a.PeriodReset.ValidateBasic() +} From 9ec284b10ce6c92c96b71085ff0e074fbd3398e7 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Tue, 29 Oct 2019 14:23:40 +0100 Subject: [PATCH 051/184] Update aliases --- x/fee_grant/alias.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/x/fee_grant/alias.go b/x/fee_grant/alias.go index 4012d4533f32..d1134fa1f056 100644 --- a/x/fee_grant/alias.go +++ b/x/fee_grant/alias.go @@ -14,7 +14,7 @@ const ( DefaultCodespace = types.DefaultCodespace CodeFeeLimitExceeded = types.CodeFeeLimitExceeded CodeFeeLimitExpired = types.CodeFeeLimitExpired - CodeInvalidPeriod = types.CodeInvalidPeriod + CodeInvalidDuration = types.CodeInvalidDuration ModuleName = types.ModuleName StoreKey = types.StoreKey RouterKey = types.RouterKey @@ -27,11 +27,11 @@ var ( RegisterCodec = types.RegisterCodec ErrFeeLimitExceeded = types.ErrFeeLimitExceeded ErrFeeLimitExpired = types.ErrFeeLimitExpired - ErrInvalidPeriod = types.ErrInvalidPeriod + ErrInvalidDuration = types.ErrInvalidDuration ExpiresAtTime = types.ExpiresAtTime ExpiresAtHeight = types.ExpiresAtHeight - ClockPeriod = types.ClockPeriod - BlockPeriod = types.BlockPeriod + ClockDuration = types.ClockDuration + BlockDuration = types.BlockDuration FeeAllowanceKey = types.FeeAllowanceKey FeeAllowancePrefixByGrantee = types.FeeAllowancePrefixByGrantee NewMsgGrantFeeAllowance = types.NewMsgGrantFeeAllowance @@ -47,9 +47,10 @@ var ( type ( BasicFeeAllowance = types.BasicFeeAllowance ExpiresAt = types.ExpiresAt - Period = types.Period + Duration = types.Duration FeeAllowanceGrant = types.FeeAllowanceGrant MsgGrantFeeAllowance = types.MsgGrantFeeAllowance MsgRevokeFeeAllowance = types.MsgRevokeFeeAllowance + PeriodicFeeAllowance = types.PeriodicFeeAllowance Keeper = keeper.Keeper ) From 4b34cf633881468c15d8790c801f987241e125b5 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Tue, 29 Oct 2019 14:55:22 +0100 Subject: [PATCH 052/184] Cover all accept cases for PeriodicFeeAllowance --- x/fee_grant/internal/types/periodic_fee.go | 4 +- .../internal/types/periodic_fee_test.go | 187 ++++++++++++++++++ 2 files changed, 189 insertions(+), 2 deletions(-) create mode 100644 x/fee_grant/internal/types/periodic_fee_test.go diff --git a/x/fee_grant/internal/types/periodic_fee.go b/x/fee_grant/internal/types/periodic_fee.go index 453fa8e85d15..cfa13966f2b5 100644 --- a/x/fee_grant/internal/types/periodic_fee.go +++ b/x/fee_grant/internal/types/periodic_fee.go @@ -36,7 +36,7 @@ func (a *PeriodicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockH // deduct from both the current period and the max amount var isNeg bool - a.PeriodSpendLimit, isNeg = a.PeriodSpendLimit.SafeSub(fee) + a.PeriodCanSpend, isNeg = a.PeriodCanSpend.SafeSub(fee) if isNeg { return false, ErrFeeLimitExceeded() } @@ -50,7 +50,7 @@ func (a *PeriodicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockH // TryResetPeriod will reset the period if we hit the conditions func (a *PeriodicFeeAllowance) TryResetPeriod(blockTime time.Time, blockHeight int64) { - if !a.PeriodReset.IsExpired(blockTime, blockHeight) { + if !a.PeriodReset.IsZero() && !a.PeriodReset.IsExpired(blockTime, blockHeight) { return } // set CanSpend to the lesser of PeriodSpendLimit and the TotalLimit diff --git a/x/fee_grant/internal/types/periodic_fee_test.go b/x/fee_grant/internal/types/periodic_fee_test.go new file mode 100644 index 000000000000..940983d3037b --- /dev/null +++ b/x/fee_grant/internal/types/periodic_fee_test.go @@ -0,0 +1,187 @@ +package types + +import ( + "testing" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestPeriodicFeeValidAllow(t *testing.T) { + atom := sdk.NewCoins(sdk.NewInt64Coin("atom", 555)) + smallAtom := sdk.NewCoins(sdk.NewInt64Coin("atom", 43)) + leftAtom := sdk.NewCoins(sdk.NewInt64Coin("atom", 512)) + oneAtom := sdk.NewCoins(sdk.NewInt64Coin("atom", 1)) + + cases := map[string]struct { + allow PeriodicFeeAllowance + // all other checks are ignored if valid=false + fee sdk.Coins + blockTime time.Time + blockHeight int64 + valid bool + accept bool + remove bool + remains sdk.Coins + remainsPeriod sdk.Coins + periodReset ExpiresAt + }{ + "empty": { + allow: PeriodicFeeAllowance{}, + valid: false, + }, + "only basic": { + allow: PeriodicFeeAllowance{ + Basic: BasicFeeAllowance{ + SpendLimit: atom, + Expiration: ExpiresAtHeight(100), + }, + }, + valid: false, + }, + "empty basic": { + allow: PeriodicFeeAllowance{ + Period: BlockDuration(50), + PeriodSpendLimit: smallAtom, + }, + valid: false, + }, + "first time": { + allow: PeriodicFeeAllowance{ + Basic: BasicFeeAllowance{ + SpendLimit: atom, + Expiration: ExpiresAtHeight(100), + }, + Period: BlockDuration(10), + PeriodSpendLimit: smallAtom, + }, + valid: true, + fee: smallAtom, + blockHeight: 75, + accept: true, + remove: false, + remainsPeriod: nil, + remains: leftAtom, + periodReset: ExpiresAtHeight(85), + }, + "same period": { + allow: PeriodicFeeAllowance{ + Basic: BasicFeeAllowance{ + SpendLimit: atom, + Expiration: ExpiresAtHeight(100), + }, + Period: BlockDuration(10), + PeriodReset: ExpiresAtHeight(80), + PeriodSpendLimit: leftAtom, + PeriodCanSpend: smallAtom, + }, + valid: true, + fee: smallAtom, + blockHeight: 75, + accept: true, + remove: false, + remainsPeriod: nil, + remains: leftAtom, + periodReset: ExpiresAtHeight(80), + }, + "step one period": { + allow: PeriodicFeeAllowance{ + Basic: BasicFeeAllowance{ + SpendLimit: atom, + Expiration: ExpiresAtHeight(100), + }, + Period: BlockDuration(10), + PeriodReset: ExpiresAtHeight(70), + PeriodSpendLimit: leftAtom, + }, + valid: true, + fee: leftAtom, + blockHeight: 75, + accept: true, + remove: false, + remainsPeriod: nil, + remains: smallAtom, + periodReset: ExpiresAtHeight(80), // one step from last reset, not now + }, + "step limited by global allowance": { + allow: PeriodicFeeAllowance{ + Basic: BasicFeeAllowance{ + SpendLimit: smallAtom, + Expiration: ExpiresAtHeight(100), + }, + Period: BlockDuration(10), + PeriodReset: ExpiresAtHeight(70), + PeriodSpendLimit: atom, + }, + valid: true, + fee: oneAtom, + blockHeight: 75, + accept: true, + remove: false, + remainsPeriod: smallAtom.Sub(oneAtom), + remains: smallAtom.Sub(oneAtom), + periodReset: ExpiresAtHeight(80), // one step from last reset, not now + }, + "expired": { + allow: PeriodicFeeAllowance{ + Basic: BasicFeeAllowance{ + SpendLimit: atom, + Expiration: ExpiresAtHeight(100), + }, + Period: BlockDuration(10), + PeriodSpendLimit: smallAtom, + }, + valid: true, + fee: smallAtom, + blockHeight: 101, + accept: false, + remove: true, + }, + "over period limit": { + allow: PeriodicFeeAllowance{ + Basic: BasicFeeAllowance{ + SpendLimit: atom, + Expiration: ExpiresAtHeight(100), + }, + Period: BlockDuration(10), + PeriodReset: ExpiresAtHeight(80), + PeriodSpendLimit: leftAtom, + PeriodCanSpend: smallAtom, + }, + valid: true, + fee: leftAtom, + blockHeight: 70, + accept: false, + remove: true, + }, + } + + for name, stc := range cases { + tc := stc // to make scopelint happy + t.Run(name, func(t *testing.T) { + err := tc.allow.ValidateBasic() + if !tc.valid { + require.Error(t, err) + return + } + require.NoError(t, err) + + // now try to deduct + remove, err := tc.allow.Accept(tc.fee, tc.blockTime, tc.blockHeight) + if !tc.accept { + require.Error(t, err) + return + } + require.NoError(t, err) + + require.Equal(t, tc.remove, remove) + if !remove { + assert.Equal(t, tc.remains, tc.allow.Basic.SpendLimit) + assert.Equal(t, tc.remainsPeriod, tc.allow.PeriodCanSpend) + assert.Equal(t, tc.periodReset, tc.allow.PeriodReset) + } + }) + } +} From 78f1f7ad1a1c3fee59d7be84082b17bf95ced0d8 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Tue, 29 Oct 2019 14:56:53 +0100 Subject: [PATCH 053/184] Et tu scopelint? --- x/fee_grant/internal/types/grant_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/fee_grant/internal/types/grant_test.go b/x/fee_grant/internal/types/grant_test.go index 527806f1bccd..3a07559e27e1 100644 --- a/x/fee_grant/internal/types/grant_test.go +++ b/x/fee_grant/internal/types/grant_test.go @@ -74,6 +74,7 @@ func TestGrant(t *testing.T) { } for name, tc := range cases { + tc := tc t.Run(name, func(t *testing.T) { err := tc.grant.ValidateBasic() if !tc.valid { From a1951b444d48a80ae9ed4c97c2367ced858f87e0 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 7 Nov 2019 10:55:44 +0100 Subject: [PATCH 054/184] Update docs as requested --- x/fee_grant/doc.go | 3 +-- x/fee_grant/genesis.go | 4 ++-- x/fee_grant/handler.go | 3 +++ x/fee_grant/internal/ante/fee.go | 20 ++++++++++---------- x/fee_grant/internal/types/basic_fee.go | 3 +++ x/fee_grant/internal/types/periodic_fee.go | 13 ++++++++++--- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/x/fee_grant/doc.go b/x/fee_grant/doc.go index 87e9503fcec0..0400ec9226c1 100644 --- a/x/fee_grant/doc.go +++ b/x/fee_grant/doc.go @@ -1,8 +1,7 @@ /* -Package fee_grant provides functionality for delegating sub-permissions +Package fee_grant provides functionality for delegating the payment of transaction fees from one account (key) to another account (key). -The first implementation allows the delegation for the payment of transaction fees. Effectively, this allows for a user to pay fees using the balance of an account different from their own. Example use cases would be allowing a key on a device to pay for fees using a master wallet, or a third party service allowing users to diff --git a/x/fee_grant/genesis.go b/x/fee_grant/genesis.go index 20aebe8636f3..79e581c96403 100644 --- a/x/fee_grant/genesis.go +++ b/x/fee_grant/genesis.go @@ -28,12 +28,12 @@ func InitGenesis(ctx sdk.Context, k Keeper, gen GenesisState) { // All expiration heights will be thrown off if we dump state and start at a new // chain at height 0. Thus, we allow the Allowances to "prepare themselves" // for export, like if they have expiry at 5000 and current is 4000, they export with -// expiry of 1000. It would need a new method on the FeeAllowance interface. +// expiry of 1000. Every FeeAllowance has a method `PrepareForExport` that allows +// them to perform any changes needed prior to export. func ExportGenesis(ctx sdk.Context, k Keeper) (GenesisState, error) { time, height := ctx.BlockTime(), ctx.BlockHeight() var grants []FeeAllowanceGrant err := k.IterateAllFeeAllowances(ctx, func(grant FeeAllowanceGrant) bool { - // TODO: modify each one grants = append(grants, grant.PrepareForExport(time, height)) return false }) diff --git a/x/fee_grant/handler.go b/x/fee_grant/handler.go index 3e5773069482..5dd49ca0239a 100644 --- a/x/fee_grant/handler.go +++ b/x/fee_grant/handler.go @@ -9,14 +9,17 @@ import ( func NewHandler(k Keeper) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) sdk.Result { ctx = ctx.WithEventManager(sdk.NewEventManager()) + switch msg := msg.(type) { case MsgGrantFeeAllowance: grant := FeeAllowanceGrant(msg) k.GrantFeeAllowance(ctx, grant) return sdk.Result{} + case MsgRevokeFeeAllowance: k.RevokeFeeAllowance(ctx, msg.Granter, msg.Grantee) return sdk.Result{} + default: errMsg := fmt.Sprintf("Unrecognized data Msg type: %s", ModuleName) return sdk.ErrUnknownRequest(errMsg).Result() diff --git a/x/fee_grant/internal/ante/fee.go b/x/fee_grant/internal/ante/fee.go index 4ae70f6e0315..6f20d6a1336f 100644 --- a/x/fee_grant/internal/ante/fee.go +++ b/x/fee_grant/internal/ante/fee.go @@ -7,9 +7,9 @@ import ( // we depend on the auth module internals... maybe some more of this can be exported? // but things like `x/auth/types/FeeCollectorName` are quite clearly tied to it - authAnte "github.com/cosmos/cosmos-sdk/x/auth/ante" - authKeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" + authante "github.com/cosmos/cosmos-sdk/x/auth/ante" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/keeper" "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types/tx" @@ -17,7 +17,7 @@ import ( ) var ( - _ GrantedFeeTx = (*tx.FeeGrantTx)(nil) // assert StdTx implements GrantedFeeTx + _ GrantedFeeTx = (*tx.FeeGrantTx)(nil) // assert FeeGrantTx implements GrantedFeeTx ) // GrantedFeeTx defines the interface to be implemented by Tx to use the GrantedFeeDecorator @@ -34,12 +34,12 @@ type GrantedFeeTx interface { // Call next AnteHandler if fees successfully deducted // CONTRACT: Tx must implement GrantedFeeTx interface to use DeductGrantedFeeDecorator type DeductGrantedFeeDecorator struct { - ak authKeeper.AccountKeeper + ak authkeeper.AccountKeeper dk keeper.Keeper - sk authTypes.SupplyKeeper + sk authtypes.SupplyKeeper } -func NewDeductGrantedFeeDecorator(ak authKeeper.AccountKeeper, sk authTypes.SupplyKeeper, dk keeper.Keeper) DeductGrantedFeeDecorator { +func NewDeductGrantedFeeDecorator(ak authkeeper.AccountKeeper, sk authtypes.SupplyKeeper, dk keeper.Keeper) DeductGrantedFeeDecorator { return DeductGrantedFeeDecorator{ ak: ak, dk: dk, @@ -54,8 +54,8 @@ func (d DeductGrantedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula } // sanity check from DeductFeeDecorator - if addr := d.sk.GetModuleAddress(authTypes.FeeCollectorName); addr == nil { - panic(fmt.Sprintf("%s module account has not been set", authTypes.FeeCollectorName)) + if addr := d.sk.GetModuleAddress(authtypes.FeeCollectorName); addr == nil { + panic(fmt.Sprintf("%s module account has not been set", authtypes.FeeCollectorName)) } fee := feeTx.GetFee() @@ -86,7 +86,7 @@ func (d DeductGrantedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula if fee.IsZero() { return next(ctx, tx, simulate) } - err = authAnte.DeductFees(d.sk, ctx, feePayerAcc, fee) + err = authante.DeductFees(d.sk, ctx, feePayerAcc, fee) if err != nil { return ctx, err } diff --git a/x/fee_grant/internal/types/basic_fee.go b/x/fee_grant/internal/types/basic_fee.go index 3d31a04e8378..fc5a9397ff38 100644 --- a/x/fee_grant/internal/types/basic_fee.go +++ b/x/fee_grant/internal/types/basic_fee.go @@ -35,6 +35,9 @@ func (a *BasicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockHeig return left.IsZero(), nil } +// PrepareForExport will adjust the expiration based on export time. In particular, +// it will subtract the dumpHeight from any height-based expiration to ensure that +// the elapsed number of blocks this allowance is valid for is fixed. func (a *BasicFeeAllowance) PrepareForExport(dumpTime time.Time, dumpHeight int64) exported.FeeAllowance { return &BasicFeeAllowance{ SpendLimit: a.SpendLimit, diff --git a/x/fee_grant/internal/types/periodic_fee.go b/x/fee_grant/internal/types/periodic_fee.go index cfa13966f2b5..b5243a1a2b88 100644 --- a/x/fee_grant/internal/types/periodic_fee.go +++ b/x/fee_grant/internal/types/periodic_fee.go @@ -48,7 +48,12 @@ func (a *PeriodicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockH return a.Basic.SpendLimit.IsZero(), nil } -// TryResetPeriod will reset the period if we hit the conditions +// TryResetPeriod will check if the PeriodReset has been hit. If not, it is a no-op. +// If we hit the reset period, it will top up the PeriodCanSpend amount to +// min(PeriodicSpendLimit, a.Basic.SpendLimit) so it is never more than the maximum allowed. +// It will also update the PeriodReset. If we are within one Period, it will update from the +// last PeriodReset (eg. if you always do one tx per day, it will always reset the same time) +// If we are more then one period out (eg. no activity in a week), reset is one Period from the execution of this method func (a *PeriodicFeeAllowance) TryResetPeriod(blockTime time.Time, blockHeight int64) { if !a.PeriodReset.IsZero() && !a.PeriodReset.IsExpired(blockTime, blockHeight) { return @@ -68,8 +73,10 @@ func (a *PeriodicFeeAllowance) TryResetPeriod(blockTime time.Time, blockHeight i } } -// PrepareForExport adjusts all absolute block height (period reset, basic.expiration) -// with the dump height so they make sense after dump +// PrepareForExport will adjust the expiration based on export time. In particular, +// it will subtract the dumpHeight from any height-based expiration to ensure that +// the elapsed number of blocks this allowance is valid for is fixed. +// (For PeriodReset and Basic.Expiration) func (a *PeriodicFeeAllowance) PrepareForExport(dumpTime time.Time, dumpHeight int64) exported.FeeAllowance { return &PeriodicFeeAllowance{ Basic: BasicFeeAllowance{ From 17c39ca7b1f8717743534efb474248cc3d037997 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 7 Nov 2019 10:59:35 +0100 Subject: [PATCH 055/184] Remove error return from GetFeeGrant --- x/fee_grant/internal/keeper/keeper.go | 28 +++++++++------------- x/fee_grant/internal/keeper/keeper_test.go | 6 ++--- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/x/fee_grant/internal/keeper/keeper.go b/x/fee_grant/internal/keeper/keeper.go index 09d5d7e33867..d99786022408 100644 --- a/x/fee_grant/internal/keeper/keeper.go +++ b/x/fee_grant/internal/keeper/keeper.go @@ -35,29 +35,26 @@ func (k Keeper) RevokeFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddr // GetFeeAllowance returns the allowance between the granter and grantee. // If there is none, it returns nil, nil. // Returns an error on parsing issues -func (k Keeper) GetFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddress) (exported.FeeAllowance, error) { - grant, err := k.GetFeeGrant(ctx, granter, grantee) - if err != nil { - return nil, err +func (k Keeper) GetFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddress) exported.FeeAllowance { + grant, found := k.GetFeeGrant(ctx, granter, grantee) + if !found { + return nil } - return grant.Allowance, nil + return grant.Allowance } // GetFeeGrant returns entire grant between both accounts -func (k Keeper) GetFeeGrant(ctx sdk.Context, granter sdk.AccAddress, grantee sdk.AccAddress) (types.FeeAllowanceGrant, error) { +func (k Keeper) GetFeeGrant(ctx sdk.Context, granter sdk.AccAddress, grantee sdk.AccAddress) (types.FeeAllowanceGrant, bool) { store := ctx.KVStore(k.storeKey) key := types.FeeAllowanceKey(granter, grantee) bz := store.Get(key) if len(bz) == 0 { - return types.FeeAllowanceGrant{}, nil + return types.FeeAllowanceGrant{}, false } var grant types.FeeAllowanceGrant - err := k.cdc.UnmarshalBinaryBare(bz, &grant) - if err != nil { - return types.FeeAllowanceGrant{}, err - } - return grant, nil + k.cdc.MustUnmarshalBinaryBare(bz, &grant) + return grant, true } // IterateAllGranteeFeeAllowances iterates over all the grants from anyone to the given grantee. @@ -104,11 +101,8 @@ func (k Keeper) IterateAllFeeAllowances(ctx sdk.Context, cb func(types.FeeAllowa // UseGrantedFees will try to pay the given fee from the granter's account as requested by the grantee func (k Keeper) UseGrantedFees(ctx sdk.Context, granter, grantee sdk.AccAddress, fee sdk.Coins) bool { - grant, err := k.GetFeeGrant(ctx, granter, grantee) - if err != nil { - panic(err) - } - if grant.Allowance == nil { + grant, found := k.GetFeeGrant(ctx, granter, grantee) + if !found || grant.Allowance == nil { return false } diff --git a/x/fee_grant/internal/keeper/keeper_test.go b/x/fee_grant/internal/keeper/keeper_test.go index 8919eb2653ea..af2e685104ed 100644 --- a/x/fee_grant/internal/keeper/keeper_test.go +++ b/x/fee_grant/internal/keeper/keeper_test.go @@ -136,8 +136,7 @@ func TestKeeperCrud(t *testing.T) { for name, tc := range cases { t.Run(name, func(t *testing.T) { - allow, err := k.GetFeeAllowance(ctx, tc.granter, tc.grantee) - require.NoError(t, err) + allow := k.GetFeeAllowance(ctx, tc.granter, tc.grantee) if tc.allowance == nil { require.Nil(t, allow) return @@ -258,8 +257,7 @@ func TestUseGrantedFee(t *testing.T) { allowed := k.UseGrantedFees(ctx, tc.granter, tc.grantee, tc.fee) require.Equal(t, tc.allowed, allowed) - loaded, err := k.GetFeeAllowance(ctx, tc.granter, tc.grantee) - require.NoError(t, err) + loaded := k.GetFeeAllowance(ctx, tc.granter, tc.grantee) require.Equal(t, tc.final, loaded) }) } From 9c399bbab7137db897e7569f6566bfb591b9d725 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 7 Nov 2019 11:05:33 +0100 Subject: [PATCH 056/184] Code cleanup as requested by PR --- x/fee_grant/internal/keeper/querier.go | 6 ++++-- x/fee_grant/internal/types/basic_fee.go | 13 +++++++++++-- x/fee_grant/internal/types/periodic_fee.go | 13 +++++++++++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/x/fee_grant/internal/keeper/querier.go b/x/fee_grant/internal/keeper/querier.go index 4fc64535aee0..ba5303f56f02 100644 --- a/x/fee_grant/internal/keeper/querier.go +++ b/x/fee_grant/internal/keeper/querier.go @@ -14,8 +14,10 @@ const ( // NewQuerier creates a new querier func NewQuerier(keeper Keeper) sdk.Querier { return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, sdk.Error) { - var res []byte - var err error + var ( + res []byte + err error + ) switch path[0] { case QueryGetFeeAllowances: res, err = queryGetFeeAllowances(ctx, path[1:], keeper) diff --git a/x/fee_grant/internal/types/basic_fee.go b/x/fee_grant/internal/types/basic_fee.go index fc5a9397ff38..94f83960c79a 100644 --- a/x/fee_grant/internal/types/basic_fee.go +++ b/x/fee_grant/internal/types/basic_fee.go @@ -20,8 +20,17 @@ type BasicFeeAllowance struct { var _ exported.FeeAllowance = (*BasicFeeAllowance)(nil) -// Accept implements FeeAllowance and deducts the fees from the SpendLimit if possible -func (a *BasicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockHeight int64) (remove bool, err error) { +// Accept can use fee payment requested as well as timestamp/height of the current block +// to determine whether or not to process this. This is checked in +// Keeper.UseGrantedFees and the return values should match how it is handled there. +// +// If it returns an error, the fee payment is rejected, otherwise it is accepted. +// The FeeAllowance implementation is expected to update it's internal state +// and will be saved again after an acceptance. +// +// If remove is true (regardless of the error), the FeeAllowance will be deleted from storage +// (eg. when it is used up). (See call to RevokeFeeAllowance in Keeper.UseGrantedFees) +func (a *BasicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockHeight int64) (bool, error) { if a.Expiration.IsExpired(blockTime, blockHeight) { return true, ErrFeeLimitExpired() } diff --git a/x/fee_grant/internal/types/periodic_fee.go b/x/fee_grant/internal/types/periodic_fee.go index b5243a1a2b88..96ae81554e67 100644 --- a/x/fee_grant/internal/types/periodic_fee.go +++ b/x/fee_grant/internal/types/periodic_fee.go @@ -26,8 +26,17 @@ type PeriodicFeeAllowance struct { var _ exported.FeeAllowance = (*PeriodicFeeAllowance)(nil) -// Accept implements FeeAllowance and deducts the fees from the SpendLimit if possible -func (a *PeriodicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockHeight int64) (remove bool, err error) { +// Accept can use fee payment requested as well as timestamp/height of the current block +// to determine whether or not to process this. This is checked in +// Keeper.UseGrantedFees and the return values should match how it is handled there. +// +// If it returns an error, the fee payment is rejected, otherwise it is accepted. +// The FeeAllowance implementation is expected to update it's internal state +// and will be saved again after an acceptance. +// +// If remove is true (regardless of the error), the FeeAllowance will be deleted from storage +// (eg. when it is used up). (See call to RevokeFeeAllowance in Keeper.UseGrantedFees) +func (a *PeriodicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockHeight int64) (bool, error) { if a.Basic.Expiration.IsExpired(blockTime, blockHeight) { return true, ErrFeeLimitExpired() } From 21b0ac574f7d9e938a79d49a8699edadf8243e62 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 7 Nov 2019 11:24:38 +0100 Subject: [PATCH 057/184] Updated all errors to use new sdk/errors package --- x/fee_grant/alias.go | 19 +++++++-------- x/fee_grant/internal/types/basic_fee.go | 9 +++---- x/fee_grant/internal/types/errors.go | 28 ++++++++-------------- x/fee_grant/internal/types/expiration.go | 20 +++++++++------- x/fee_grant/internal/types/periodic_fee.go | 7 +++--- 5 files changed, 39 insertions(+), 44 deletions(-) diff --git a/x/fee_grant/alias.go b/x/fee_grant/alias.go index d1134fa1f056..8736c2f7e6cf 100644 --- a/x/fee_grant/alias.go +++ b/x/fee_grant/alias.go @@ -1,8 +1,8 @@ // nolint // autogenerated code using github.com/rigelrozanski/multitool // aliases generated for the following subdirectories: -// ALIASGEN: github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types // ALIASGEN: github.com/cosmos/cosmos-sdk/x/fee_grant/internal/keeper +// ALIASGEN: github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types package fee_grant import ( @@ -11,23 +11,19 @@ import ( ) const ( + QueryGetFeeAllowances = keeper.QueryGetFeeAllowances DefaultCodespace = types.DefaultCodespace - CodeFeeLimitExceeded = types.CodeFeeLimitExceeded - CodeFeeLimitExpired = types.CodeFeeLimitExpired - CodeInvalidDuration = types.CodeInvalidDuration ModuleName = types.ModuleName StoreKey = types.StoreKey RouterKey = types.RouterKey QuerierRoute = types.QuerierRoute - QueryGetFeeAllowances = keeper.QueryGetFeeAllowances ) var ( // functions aliases + NewKeeper = keeper.NewKeeper + NewQuerier = keeper.NewQuerier RegisterCodec = types.RegisterCodec - ErrFeeLimitExceeded = types.ErrFeeLimitExceeded - ErrFeeLimitExpired = types.ErrFeeLimitExpired - ErrInvalidDuration = types.ErrInvalidDuration ExpiresAtTime = types.ExpiresAtTime ExpiresAtHeight = types.ExpiresAtHeight ClockDuration = types.ClockDuration @@ -36,15 +32,17 @@ var ( FeeAllowancePrefixByGrantee = types.FeeAllowancePrefixByGrantee NewMsgGrantFeeAllowance = types.NewMsgGrantFeeAllowance NewMsgRevokeFeeAllowance = types.NewMsgRevokeFeeAllowance - NewKeeper = keeper.NewKeeper - NewQuerier = keeper.NewQuerier // variable aliases ModuleCdc = types.ModuleCdc + ErrFeeLimitExceeded = types.ErrFeeLimitExceeded + ErrFeeLimitExpired = types.ErrFeeLimitExpired + ErrInvalidDuration = types.ErrInvalidDuration FeeAllowanceKeyPrefix = types.FeeAllowanceKeyPrefix ) type ( + Keeper = keeper.Keeper BasicFeeAllowance = types.BasicFeeAllowance ExpiresAt = types.ExpiresAt Duration = types.Duration @@ -52,5 +50,4 @@ type ( MsgGrantFeeAllowance = types.MsgGrantFeeAllowance MsgRevokeFeeAllowance = types.MsgRevokeFeeAllowance PeriodicFeeAllowance = types.PeriodicFeeAllowance - Keeper = keeper.Keeper ) diff --git a/x/fee_grant/internal/types/basic_fee.go b/x/fee_grant/internal/types/basic_fee.go index 94f83960c79a..4ce41be4a65b 100644 --- a/x/fee_grant/internal/types/basic_fee.go +++ b/x/fee_grant/internal/types/basic_fee.go @@ -4,6 +4,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" ) @@ -32,12 +33,12 @@ var _ exported.FeeAllowance = (*BasicFeeAllowance)(nil) // (eg. when it is used up). (See call to RevokeFeeAllowance in Keeper.UseGrantedFees) func (a *BasicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockHeight int64) (bool, error) { if a.Expiration.IsExpired(blockTime, blockHeight) { - return true, ErrFeeLimitExpired() + return true, sdkerrors.Wrap(ErrFeeLimitExpired, "basic allowance") } left, invalid := a.SpendLimit.SafeSub(fee) if invalid { - return false, ErrFeeLimitExceeded() + return false, sdkerrors.Wrap(ErrFeeLimitExceeded, "basic allowance") } a.SpendLimit = left @@ -57,10 +58,10 @@ func (a *BasicFeeAllowance) PrepareForExport(dumpTime time.Time, dumpHeight int6 // ValidateBasic implements FeeAllowance and enforces basic sanity checks func (a BasicFeeAllowance) ValidateBasic() error { if !a.SpendLimit.IsValid() { - return sdk.ErrInvalidCoins("send amount is invalid: " + a.SpendLimit.String()) + return sdkerrors.Wrapf(sdkerrors.ErrInvalidCoins, "send amount is invalid: %s", a.SpendLimit) } if !a.SpendLimit.IsAllPositive() { - return sdk.ErrInvalidCoins("spend limit must be positive") + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "spend limit must be positive") } return a.Expiration.ValidateBasic() } diff --git a/x/fee_grant/internal/types/errors.go b/x/fee_grant/internal/types/errors.go index d07db5c31557..01dbe87a727d 100644 --- a/x/fee_grant/internal/types/errors.go +++ b/x/fee_grant/internal/types/errors.go @@ -1,29 +1,21 @@ package types import ( - sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) // Codes for governance errors const ( - DefaultCodespace sdk.CodespaceType = ModuleName - - CodeFeeLimitExceeded sdk.CodeType = 1 - CodeFeeLimitExpired sdk.CodeType = 2 - CodeInvalidDuration sdk.CodeType = 3 + DefaultCodespace = ModuleName ) -// ErrFeeLimitExceeded error if there are not enough allowance to cover the fees -func ErrFeeLimitExceeded() sdk.Error { - return sdk.NewError(DefaultCodespace, CodeFeeLimitExceeded, "fee limit exceeded") -} +var ( + // ErrFeeLimitExceeded error if there are not enough allowance to cover the fees + ErrFeeLimitExceeded = sdkerrors.Register(DefaultCodespace, 1, "fee limit exceeded") -// ErrFeeLimitExpired error if the allowance has expired -func ErrFeeLimitExpired() sdk.Error { - return sdk.NewError(DefaultCodespace, CodeFeeLimitExpired, "fee limit expired") -} + // ErrFeeLimitExpired error if the allowance has expired + ErrFeeLimitExpired = sdkerrors.Register(DefaultCodespace, 2, "fee limit expired") -// ErrInvalidDuration error if the Duration is invalid or doesn't match the expiration -func ErrInvalidDuration(reason string) sdk.Error { - return sdk.NewError(DefaultCodespace, CodeInvalidDuration, reason) -} + // ErrInvalidDuration error if the Duration is invalid or doesn't match the expiration + ErrInvalidDuration = sdkerrors.Register(DefaultCodespace, 3, "invalid duration") +) diff --git a/x/fee_grant/internal/types/expiration.go b/x/fee_grant/internal/types/expiration.go index 20be853eeb65..5a048eee2d0c 100644 --- a/x/fee_grant/internal/types/expiration.go +++ b/x/fee_grant/internal/types/expiration.go @@ -1,6 +1,10 @@ package types -import "time" +import ( + "time" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) // ExpiresAt is a point in time where something expires. // It may be *either* block time or block height @@ -23,10 +27,10 @@ func ExpiresAtHeight(h int64) ExpiresAt { // Note that empty expiration is allowed func (e ExpiresAt) ValidateBasic() error { if !e.Time.IsZero() && e.Height != 0 { - return ErrInvalidDuration("both time and height are set") + return sdkerrors.Wrap(ErrInvalidDuration, "both time and height are set") } if e.Height < 0 { - return ErrInvalidDuration("negative height") + return sdkerrors.Wrap(ErrInvalidDuration, "negative height") } return nil } @@ -70,7 +74,7 @@ func (e ExpiresAt) IsCompatible(p Duration) bool { // It returns an error if the Duration is incompatible func (e ExpiresAt) Step(p Duration) (ExpiresAt, error) { if !e.IsCompatible(p) { - return ExpiresAt{}, ErrInvalidDuration("expires_at and Duration have different units") + return ExpiresAt{}, sdkerrors.Wrap(ErrInvalidDuration, "expires_at and Duration have different units") } if !e.Time.IsZero() { e.Time = e.Time.Add(p.Clock) @@ -119,16 +123,16 @@ func BlockDuration(h int64) Duration { // Note that exactly one must be set and it must be positive func (p Duration) ValidateBasic() error { if p.Block == 0 && p.Clock == 0 { - return ErrInvalidDuration("neither time and height are set") + return sdkerrors.Wrap(ErrInvalidDuration, "neither time and height are set") } if p.Block != 0 && p.Clock != 0 { - return ErrInvalidDuration("both time and height are set") + return sdkerrors.Wrap(ErrInvalidDuration, "both time and height are set") } if p.Block < 0 { - return ErrInvalidDuration("negative block step") + return sdkerrors.Wrap(ErrInvalidDuration, "negative block step") } if p.Clock < 0 { - return ErrInvalidDuration("negative clock step") + return sdkerrors.Wrap(ErrInvalidDuration, "negative clock step") } return nil } diff --git a/x/fee_grant/internal/types/periodic_fee.go b/x/fee_grant/internal/types/periodic_fee.go index 96ae81554e67..dfc8b93fadd6 100644 --- a/x/fee_grant/internal/types/periodic_fee.go +++ b/x/fee_grant/internal/types/periodic_fee.go @@ -4,6 +4,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" ) @@ -38,7 +39,7 @@ var _ exported.FeeAllowance = (*PeriodicFeeAllowance)(nil) // (eg. when it is used up). (See call to RevokeFeeAllowance in Keeper.UseGrantedFees) func (a *PeriodicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockHeight int64) (bool, error) { if a.Basic.Expiration.IsExpired(blockTime, blockHeight) { - return true, ErrFeeLimitExpired() + return true, sdkerrors.Wrap(ErrFeeLimitExpired, "absolute limit") } a.TryResetPeriod(blockTime, blockHeight) @@ -47,11 +48,11 @@ func (a *PeriodicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockH var isNeg bool a.PeriodCanSpend, isNeg = a.PeriodCanSpend.SafeSub(fee) if isNeg { - return false, ErrFeeLimitExceeded() + return false, sdkerrors.Wrap(ErrFeeLimitExceeded, "period limit") } a.Basic.SpendLimit, isNeg = a.Basic.SpendLimit.SafeSub(fee) if isNeg { - return false, ErrFeeLimitExceeded() + return false, sdkerrors.Wrap(ErrFeeLimitExceeded, "absolute limit") } return a.Basic.SpendLimit.IsZero(), nil From 2222d0eb811066494da0758e416d200c9583639a Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 7 Nov 2019 11:38:54 +0100 Subject: [PATCH 058/184] Use test suite for keeper tests --- x/fee_grant/internal/keeper/keeper_test.go | 111 ++++++++++---------- x/fee_grant/internal/keeper/querier_test.go | 15 ++- 2 files changed, 64 insertions(+), 62 deletions(-) diff --git a/x/fee_grant/internal/keeper/keeper_test.go b/x/fee_grant/internal/keeper/keeper_test.go index af2e685104ed..dbff579c80b9 100644 --- a/x/fee_grant/internal/keeper/keeper_test.go +++ b/x/fee_grant/internal/keeper/keeper_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" dbm "github.com/tendermint/tm-db" @@ -18,18 +19,26 @@ import ( "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types" ) -type testInput struct { +type KeeperTestSuite struct { + suite.Suite + cdc *codec.Codec ctx sdk.Context dk keeper.Keeper + + addr sdk.AccAddress + addr2 sdk.AccAddress + addr3 sdk.AccAddress + addr4 sdk.AccAddress } -func setupTestInput() testInput { +func (suite *KeeperTestSuite) SetupTest() { db := dbm.NewMemDB() cdc := codec.New() types.RegisterCodec(cdc) sdk.RegisterCodec(cdc) + suite.cdc = cdc delCapKey := sdk.NewKVStoreKey("delKey") @@ -37,19 +46,15 @@ func setupTestInput() testInput { ms.MountStoreWithDB(delCapKey, sdk.StoreTypeIAVL, db) ms.LoadLatestVersion() - dk := keeper.NewKeeper(cdc, delCapKey) + suite.dk = keeper.NewKeeper(cdc, delCapKey) + suite.ctx = sdk.NewContext(ms, abci.Header{ChainID: "test-chain-id", Time: time.Now().UTC(), Height: 1234}, false, log.NewNopLogger()) - ctx := sdk.NewContext(ms, abci.Header{ChainID: "test-chain-id", Time: time.Now().UTC(), Height: 1234}, false, log.NewNopLogger()) - return testInput{cdc: cdc, ctx: ctx, dk: dk} -} + suite.addr = mustAddr("cosmos157ez5zlaq0scm9aycwphhqhmg3kws4qusmekll") + suite.addr2 = mustAddr("cosmos1rjxwm0rwyuldsg00qf5lt26wxzzppjzxs2efdw") + suite.addr3 = mustAddr("cosmos1qk93t4j0yyzgqgt6k5qf8deh8fq6smpn3ntu3x") + suite.addr4 = mustAddr("cosmos1p9qh4ldfd6n0qehujsal4k7g0e37kel90rc4ts") -var ( - // some valid cosmos keys.... - addr = mustAddr("cosmos157ez5zlaq0scm9aycwphhqhmg3kws4qusmekll") - addr2 = mustAddr("cosmos1rjxwm0rwyuldsg00qf5lt26wxzzppjzxs2efdw") - addr3 = mustAddr("cosmos1qk93t4j0yyzgqgt6k5qf8deh8fq6smpn3ntu3x") - addr4 = mustAddr("cosmos1p9qh4ldfd6n0qehujsal4k7g0e37kel90rc4ts") -) +} func mustAddr(acc string) sdk.AccAddress { addr, err := sdk.AccAddressFromBech32(acc) @@ -59,10 +64,9 @@ func mustAddr(acc string) sdk.AccAddress { return addr } -func TestKeeperCrud(t *testing.T) { - input := setupTestInput() - ctx := input.ctx - k := input.dk +func (suite *KeeperTestSuite) TestKeeperCrud(t *testing.T) { + ctx := suite.ctx + k := suite.dk // some helpers atom := sdk.NewCoins(sdk.NewInt64Coin("atom", 555)) @@ -78,29 +82,29 @@ func TestKeeperCrud(t *testing.T) { // let's set up some initial state here k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: addr, Grantee: addr2, Allowance: &basic, + Granter: suite.addr, Grantee: suite.addr2, Allowance: &basic, }) k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: addr, Grantee: addr3, Allowance: &basic2, + Granter: suite.addr, Grantee: suite.addr3, Allowance: &basic2, }) k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: addr2, Grantee: addr3, Allowance: &basic, + Granter: suite.addr2, Grantee: suite.addr3, Allowance: &basic, }) k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: addr2, Grantee: addr4, Allowance: &basic, + Granter: suite.addr2, Grantee: suite.addr4, Allowance: &basic, }) k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: addr4, Grantee: addr, Allowance: &basic2, + Granter: suite.addr4, Grantee: suite.addr, Allowance: &basic2, }) // remove some, overwrite other - k.RevokeFeeAllowance(ctx, addr, addr2) - k.RevokeFeeAllowance(ctx, addr, addr3) + k.RevokeFeeAllowance(ctx, suite.addr, suite.addr2) + k.RevokeFeeAllowance(ctx, suite.addr, suite.addr3) k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: addr, Grantee: addr3, Allowance: &basic, + Granter: suite.addr, Grantee: suite.addr3, Allowance: &basic, }) k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: addr2, Grantee: addr3, Allowance: &basic2, + Granter: suite.addr2, Grantee: suite.addr3, Allowance: &basic2, }) // end state: @@ -115,21 +119,21 @@ func TestKeeperCrud(t *testing.T) { allowance exported.FeeAllowance }{ "addr revoked": { - granter: addr, - grantee: addr2, + granter: suite.addr, + grantee: suite.addr2, }, "addr revoked and added": { - granter: addr, - grantee: addr3, + granter: suite.addr, + grantee: suite.addr3, allowance: &basic, }, "addr never there": { - granter: addr, - grantee: addr4, + granter: suite.addr, + grantee: suite.addr4, }, "addr modified": { - granter: addr2, - grantee: addr3, + granter: suite.addr2, + grantee: suite.addr3, allowance: &basic2, }, } @@ -151,17 +155,17 @@ func TestKeeperCrud(t *testing.T) { grants []types.FeeAllowanceGrant }{ "addr2 has none": { - grantee: addr2, + grantee: suite.addr2, }, "addr has one": { - grantee: addr, - grants: []types.FeeAllowanceGrant{{Granter: addr4, Grantee: addr, Allowance: &basic2}}, + grantee: suite.addr, + grants: []types.FeeAllowanceGrant{{Granter: suite.addr4, Grantee: suite.addr, Allowance: &basic2}}, }, "addr3 has two": { - grantee: addr3, + grantee: suite.addr3, grants: []types.FeeAllowanceGrant{ - {Granter: addr, Grantee: addr3, Allowance: &basic}, - {Granter: addr2, Grantee: addr3, Allowance: &basic2}, + {Granter: suite.addr, Grantee: suite.addr3, Allowance: &basic}, + {Granter: suite.addr2, Grantee: suite.addr3, Allowance: &basic2}, }, }, } @@ -179,10 +183,9 @@ func TestKeeperCrud(t *testing.T) { } } -func TestUseGrantedFee(t *testing.T) { - input := setupTestInput() - ctx := input.ctx - k := input.dk +func (suite *KeeperTestSuite) TestUseGrantedFee(t *testing.T) { + ctx := suite.ctx + k := suite.dk // some helpers atom := sdk.NewCoins(sdk.NewInt64Coin("atom", 555)) @@ -213,29 +216,29 @@ func TestUseGrantedFee(t *testing.T) { final exported.FeeAllowance }{ "use entire pot": { - granter: addr, - grantee: addr2, + granter: suite.addr, + grantee: suite.addr2, fee: atom, allowed: true, final: nil, }, "expired and removed": { - granter: addr, - grantee: addr3, + granter: suite.addr, + grantee: suite.addr3, fee: eth, allowed: false, final: nil, }, "too high": { - granter: addr, - grantee: addr2, + granter: suite.addr, + grantee: suite.addr2, fee: hugeAtom, allowed: false, final: &future, }, "use a little": { - granter: addr, - grantee: addr2, + granter: suite.addr, + grantee: suite.addr2, fee: smallAtom, allowed: true, final: &futureAfterSmall, @@ -248,10 +251,10 @@ func TestUseGrantedFee(t *testing.T) { // addr -> addr2 (future) // addr -> addr3 (expired) k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: addr, Grantee: addr2, Allowance: &future, + Granter: suite.addr, Grantee: suite.addr2, Allowance: &future, }) k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: addr, Grantee: addr3, Allowance: &expired, + Granter: suite.addr, Grantee: suite.addr3, Allowance: &expired, }) allowed := k.UseGrantedFees(ctx, tc.granter, tc.grantee, tc.fee) diff --git a/x/fee_grant/internal/keeper/querier_test.go b/x/fee_grant/internal/keeper/querier_test.go index c7c9ad676a1f..ea6d76c4441c 100644 --- a/x/fee_grant/internal/keeper/querier_test.go +++ b/x/fee_grant/internal/keeper/querier_test.go @@ -13,26 +13,25 @@ import ( "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types" ) -func TestQuery(t *testing.T) { - input := setupTestInput() - ctx := input.ctx - k := input.dk +func (suite *KeeperTestSuite) TestQuery(t *testing.T) { + ctx := suite.ctx + k := suite.dk cdc := codec.New() types.RegisterCodec(cdc) // some helpers grant1 := types.FeeAllowanceGrant{ - Granter: addr, - Grantee: addr3, + Granter: suite.addr, + Grantee: suite.addr3, Allowance: &types.BasicFeeAllowance{ SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 555)), Expiration: types.ExpiresAtHeight(334455), }, } grant2 := types.FeeAllowanceGrant{ - Granter: addr2, - Grantee: addr3, + Granter: suite.addr2, + Grantee: suite.addr3, Allowance: &types.BasicFeeAllowance{ SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("eth", 123)), Expiration: types.ExpiresAtHeight(334455), From eda42d4fe08d1dfda9c42a86b0aa1ace1a363f25 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 7 Nov 2019 12:12:33 +0100 Subject: [PATCH 059/184] Clean up alias.go file --- x/fee_grant/alias.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x/fee_grant/alias.go b/x/fee_grant/alias.go index 8736c2f7e6cf..c91f79291ab1 100644 --- a/x/fee_grant/alias.go +++ b/x/fee_grant/alias.go @@ -1,9 +1,10 @@ +package fee_grant + // nolint // autogenerated code using github.com/rigelrozanski/multitool // aliases generated for the following subdirectories: // ALIASGEN: github.com/cosmos/cosmos-sdk/x/fee_grant/internal/keeper // ALIASGEN: github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types -package fee_grant import ( "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/keeper" From a56b472b1f5a07e185c85aaf4ca741411b4c74ab Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 7 Nov 2019 12:19:54 +0100 Subject: [PATCH 060/184] Define expected interfaces in exported, rather than importing from account --- x/fee_grant/exported/external.go | 21 +++++++++++++++++++++ x/fee_grant/internal/ante/fee.go | 9 +++++---- 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 x/fee_grant/exported/external.go diff --git a/x/fee_grant/exported/external.go b/x/fee_grant/exported/external.go new file mode 100644 index 000000000000..df0e9625ae24 --- /dev/null +++ b/x/fee_grant/exported/external.go @@ -0,0 +1,21 @@ +package exported + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + auth "github.com/cosmos/cosmos-sdk/x/auth/exported" + supply "github.com/cosmos/cosmos-sdk/x/supply/exported" +) + +// SupplyKeeper defines the expected supply Keeper (noalias) +type SupplyKeeper interface { + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) sdk.Error + GetModuleAccount(ctx sdk.Context, moduleName string) supply.ModuleAccountI + GetModuleAddress(moduleName string) sdk.AccAddress +} + +// SupplyKeeper defines the expected auth Account Keeper (noalias) +type AccountKeeper interface { + NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) auth.Account + GetAccount(ctx sdk.Context, addr sdk.AccAddress) auth.Account + SetAccount(ctx sdk.Context, acc auth.Account) +} diff --git a/x/fee_grant/internal/ante/fee.go b/x/fee_grant/internal/ante/fee.go index 6f20d6a1336f..c4abba0fb961 100644 --- a/x/fee_grant/internal/ante/fee.go +++ b/x/fee_grant/internal/ante/fee.go @@ -8,8 +8,9 @@ import ( // we depend on the auth module internals... maybe some more of this can be exported? // but things like `x/auth/types/FeeCollectorName` are quite clearly tied to it authante "github.com/cosmos/cosmos-sdk/x/auth/ante" - authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + + "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/keeper" "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types/tx" @@ -34,12 +35,12 @@ type GrantedFeeTx interface { // Call next AnteHandler if fees successfully deducted // CONTRACT: Tx must implement GrantedFeeTx interface to use DeductGrantedFeeDecorator type DeductGrantedFeeDecorator struct { - ak authkeeper.AccountKeeper + ak exported.AccountKeeper dk keeper.Keeper - sk authtypes.SupplyKeeper + sk exported.SupplyKeeper } -func NewDeductGrantedFeeDecorator(ak authkeeper.AccountKeeper, sk authtypes.SupplyKeeper, dk keeper.Keeper) DeductGrantedFeeDecorator { +func NewDeductGrantedFeeDecorator(ak exported.AccountKeeper, sk exported.SupplyKeeper, dk keeper.Keeper) DeductGrantedFeeDecorator { return DeductGrantedFeeDecorator{ ak: ak, dk: dk, From be29328098e3f1c0b2071e4ebbaddef1954554a4 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 7 Nov 2019 12:21:54 +0100 Subject: [PATCH 061/184] Remove dependency on auth/ante --- x/fee_grant/internal/ante/fee.go | 38 ++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/x/fee_grant/internal/ante/fee.go b/x/fee_grant/internal/ante/fee.go index c4abba0fb961..42af0f78f35a 100644 --- a/x/fee_grant/internal/ante/fee.go +++ b/x/fee_grant/internal/ante/fee.go @@ -7,7 +7,7 @@ import ( // we depend on the auth module internals... maybe some more of this can be exported? // but things like `x/auth/types/FeeCollectorName` are quite clearly tied to it - authante "github.com/cosmos/cosmos-sdk/x/auth/ante" + auth "github.com/cosmos/cosmos-sdk/x/auth/exported" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" @@ -87,9 +87,43 @@ func (d DeductGrantedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula if fee.IsZero() { return next(ctx, tx, simulate) } - err = authante.DeductFees(d.sk, ctx, feePayerAcc, fee) + err = DeductFees(d.sk, ctx, feePayerAcc, fee) if err != nil { return ctx, err } return next(ctx, tx, simulate) } + +// DeductFees deducts fees from the given account. +// +// Copied from auth/ante to avoid the import +func DeductFees(supplyKeeper exported.SupplyKeeper, ctx sdk.Context, acc auth.Account, fees sdk.Coins) error { + blockTime := ctx.BlockHeader().Time + coins := acc.GetCoins() + + if !fees.IsValid() { + return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "invalid fee amount: %s", fees) + } + + // verify the account has enough funds to pay for fees + _, hasNeg := coins.SafeSub(fees) + if hasNeg { + return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, + "insufficient funds to pay for fees; %s < %s", coins, fees) + } + + // Validate the account has enough "spendable" coins as this will cover cases + // such as vesting accounts. + spendableCoins := acc.SpendableCoins(blockTime) + if _, hasNeg := spendableCoins.SafeSub(fees); hasNeg { + return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, + "insufficient funds to pay for fees; %s < %s", spendableCoins, fees) + } + + err := supplyKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), authtypes.FeeCollectorName, fees) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error()) + } + + return nil +} From 786bf0199d7288df641ff895590b1e9a22825c97 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 7 Nov 2019 12:29:43 +0100 Subject: [PATCH 062/184] Improve godoc, Logger --- x/fee_grant/internal/keeper/keeper.go | 13 ++++++++++++- x/fee_grant/internal/types/codec.go | 1 + x/fee_grant/internal/types/msgs.go | 2 +- x/fee_grant/internal/types/periodic_fee.go | 3 +++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/x/fee_grant/internal/keeper/keeper.go b/x/fee_grant/internal/keeper/keeper.go index d99786022408..e1b55fb541bd 100644 --- a/x/fee_grant/internal/keeper/keeper.go +++ b/x/fee_grant/internal/keeper/keeper.go @@ -1,22 +1,33 @@ package keeper import ( + "fmt" + + "github.com/tendermint/tendermint/libs/log" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types" ) +// Keeper manages state of all fee grants, as well as calculating approval. +// It must have a codec with all available allowances registered. type Keeper struct { cdc *codec.Codec storeKey sdk.StoreKey } -// NewKeeper creates a DelegationKeeper +// NewKeeper creates a fee grant Keeper func NewKeeper(cdc *codec.Codec, storeKey sdk.StoreKey) Keeper { return Keeper{cdc: cdc, storeKey: storeKey} } +// Logger returns a module-specific logger. +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + // GrantFeeAllowance creates a new grant func (k Keeper) GrantFeeAllowance(ctx sdk.Context, grant types.FeeAllowanceGrant) { store := ctx.KVStore(k.storeKey) diff --git a/x/fee_grant/internal/types/codec.go b/x/fee_grant/internal/types/codec.go index 44c266be45b1..91457c313327 100644 --- a/x/fee_grant/internal/types/codec.go +++ b/x/fee_grant/internal/types/codec.go @@ -9,6 +9,7 @@ import ( func RegisterCodec(cdc *codec.Codec) { cdc.RegisterInterface((*exported.FeeAllowance)(nil), nil) cdc.RegisterConcrete(&BasicFeeAllowance{}, "feegrant/BasicFeeAllowance", nil) + cdc.RegisterConcrete(&PeriodicFeeAllowance{}, "feegrant/PeriodicFeeAllowance", nil) } // ModuleCdc generic sealed codec to be used throughout module diff --git a/x/fee_grant/internal/types/msgs.go b/x/fee_grant/internal/types/msgs.go index 9a9b370b4a5c..885914d4626b 100644 --- a/x/fee_grant/internal/types/msgs.go +++ b/x/fee_grant/internal/types/msgs.go @@ -23,7 +23,7 @@ func (msg MsgGrantFeeAllowance) Route() string { } func (msg MsgGrantFeeAllowance) Type() string { - return "delegate-fee-allowance" + return "grant-fee-allowance" } func (msg MsgGrantFeeAllowance) ValidateBasic() sdk.Error { diff --git a/x/fee_grant/internal/types/periodic_fee.go b/x/fee_grant/internal/types/periodic_fee.go index dfc8b93fadd6..9f4211c039fd 100644 --- a/x/fee_grant/internal/types/periodic_fee.go +++ b/x/fee_grant/internal/types/periodic_fee.go @@ -11,6 +11,9 @@ import ( // PeriodicFeeAllowance extends FeeAllowance to allow for both a maximum cap, // as well as a limit per time period. type PeriodicFeeAllowance struct { + // Basic contains the absolute limits over all time. + // These limit (total and expiration) are enforced in addition to the + // periodic limits defined below (which renew every period) Basic BasicFeeAllowance // Period is the duration of one period From 5f2bcb5b5d9f7adf44a1af0ae3ac6d8e2a334499 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 7 Nov 2019 12:34:19 +0100 Subject: [PATCH 063/184] Cleaned up ExpiresAt --- x/fee_grant/internal/types/expiration.go | 30 ++++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/x/fee_grant/internal/types/expiration.go b/x/fee_grant/internal/types/expiration.go index 5a048eee2d0c..7c552f02e8d9 100644 --- a/x/fee_grant/internal/types/expiration.go +++ b/x/fee_grant/internal/types/expiration.go @@ -63,30 +63,30 @@ func (e ExpiresAt) IsExpired(t time.Time, h int64) bool { // IsCompatible returns true iff the two use the same units. // If false, they cannot be added. -func (e ExpiresAt) IsCompatible(p Duration) bool { +func (e ExpiresAt) IsCompatible(d Duration) bool { if !e.Time.IsZero() { - return p.Clock > 0 + return d.Clock > 0 } - return p.Block > 0 + return d.Block > 0 } // Step will increase the expiration point by one Duration // It returns an error if the Duration is incompatible -func (e ExpiresAt) Step(p Duration) (ExpiresAt, error) { - if !e.IsCompatible(p) { - return ExpiresAt{}, sdkerrors.Wrap(ErrInvalidDuration, "expires_at and Duration have different units") +func (e ExpiresAt) Step(d Duration) (ExpiresAt, error) { + if !e.IsCompatible(d) { + return ExpiresAt{}, sdkerrors.Wrap(ErrInvalidDuration, "expiration time and provided duration have different units") } if !e.Time.IsZero() { - e.Time = e.Time.Add(p.Clock) + e.Time = e.Time.Add(d.Clock) } else { - e.Height += p.Block + e.Height += d.Block } return e, nil } // MustStep is like Step, but panics on error -func (e ExpiresAt) MustStep(p Duration) ExpiresAt { - res, err := e.Step(p) +func (e ExpiresAt) MustStep(d Duration) ExpiresAt { + res, err := e.Step(d) if err != nil { panic(err) } @@ -121,17 +121,17 @@ func BlockDuration(h int64) Duration { // ValidateBasic performs basic sanity checks // Note that exactly one must be set and it must be positive -func (p Duration) ValidateBasic() error { - if p.Block == 0 && p.Clock == 0 { +func (d Duration) ValidateBasic() error { + if d.Block == 0 && d.Clock == 0 { return sdkerrors.Wrap(ErrInvalidDuration, "neither time and height are set") } - if p.Block != 0 && p.Clock != 0 { + if d.Block != 0 && d.Clock != 0 { return sdkerrors.Wrap(ErrInvalidDuration, "both time and height are set") } - if p.Block < 0 { + if d.Block < 0 { return sdkerrors.Wrap(ErrInvalidDuration, "negative block step") } - if p.Clock < 0 { + if d.Clock < 0 { return sdkerrors.Wrap(ErrInvalidDuration, "negative clock step") } return nil From 314b099b44222e71c2a084f0999db346216f8269 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 7 Nov 2019 12:42:40 +0100 Subject: [PATCH 064/184] Improve error reporting with UseGrantedFee --- x/fee_grant/internal/ante/fee.go | 6 +++--- x/fee_grant/internal/keeper/keeper.go | 12 +++++++----- x/fee_grant/internal/types/errors.go | 3 +++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/x/fee_grant/internal/ante/fee.go b/x/fee_grant/internal/ante/fee.go index 42af0f78f35a..365b904d81e3 100644 --- a/x/fee_grant/internal/ante/fee.go +++ b/x/fee_grant/internal/ante/fee.go @@ -65,9 +65,9 @@ func (d DeductGrantedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula // ensure the grant is allowed, if we request a different fee payer if !txSigner.Equals(feePayer) { - allowed := d.dk.UseGrantedFees(ctx, feePayer, txSigner, fee) - if !allowed { - return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s not allowed to pay fees from %s", txSigner, feePayer) + err := d.dk.UseGrantedFees(ctx, feePayer, txSigner, fee) + if err != nil { + return ctx, sdkerrors.Wrapf(err, "%s not allowed to pay fees from %s", txSigner, feePayer) } // if there was a valid grant, ensure that the txSigner account exists (we create it if needed) signerAcc := d.ak.GetAccount(ctx, txSigner) diff --git a/x/fee_grant/internal/keeper/keeper.go b/x/fee_grant/internal/keeper/keeper.go index e1b55fb541bd..6ebb4c9d8c32 100644 --- a/x/fee_grant/internal/keeper/keeper.go +++ b/x/fee_grant/internal/keeper/keeper.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types" ) @@ -111,22 +112,23 @@ func (k Keeper) IterateAllFeeAllowances(ctx sdk.Context, cb func(types.FeeAllowa } // UseGrantedFees will try to pay the given fee from the granter's account as requested by the grantee -func (k Keeper) UseGrantedFees(ctx sdk.Context, granter, grantee sdk.AccAddress, fee sdk.Coins) bool { +func (k Keeper) UseGrantedFees(ctx sdk.Context, granter, grantee sdk.AccAddress, fee sdk.Coins) error { grant, found := k.GetFeeGrant(ctx, granter, grantee) if !found || grant.Allowance == nil { - return false + return sdkerrors.Wrapf(types.ErrNoAllowance, "grant missing") } remove, err := grant.Allowance.Accept(fee, ctx.BlockTime(), ctx.BlockHeight()) if remove { k.RevokeFeeAllowance(ctx, granter, grantee) - return err == nil + // note this returns nil if err == nil + return sdkerrors.Wrap(err, "removed grant") } if err != nil { - return false + return sdkerrors.Wrap(err, "invalid grant") } // if we accepted, store the updated state of the allowance k.GrantFeeAllowance(ctx, grant) - return true + return nil } diff --git a/x/fee_grant/internal/types/errors.go b/x/fee_grant/internal/types/errors.go index 01dbe87a727d..cea99327f440 100644 --- a/x/fee_grant/internal/types/errors.go +++ b/x/fee_grant/internal/types/errors.go @@ -18,4 +18,7 @@ var ( // ErrInvalidDuration error if the Duration is invalid or doesn't match the expiration ErrInvalidDuration = sdkerrors.Register(DefaultCodespace, 3, "invalid duration") + + // ErrNoAllowance error if there is no allowance for that pair + ErrNoAllowance = sdkerrors.Register(DefaultCodespace, 4, "no allowance") ) From 29958e0d9ba8df1afd684c608a72ef4d236185cd Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 7 Nov 2019 12:48:23 +0100 Subject: [PATCH 065/184] Enforce period limit subset of basic limit --- x/fee_grant/internal/types/periodic_fee.go | 13 ++++++++----- x/fee_grant/internal/types/periodic_fee_test.go | 12 ++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/x/fee_grant/internal/types/periodic_fee.go b/x/fee_grant/internal/types/periodic_fee.go index 9f4211c039fd..459deb41c776 100644 --- a/x/fee_grant/internal/types/periodic_fee.go +++ b/x/fee_grant/internal/types/periodic_fee.go @@ -110,20 +110,23 @@ func (a PeriodicFeeAllowance) ValidateBasic() error { } if !a.PeriodSpendLimit.IsValid() { - return sdk.ErrInvalidCoins("spend amount is invalid: " + a.PeriodSpendLimit.String()) + return sdkerrors.Wrapf(sdkerrors.ErrInvalidCoins, "spend amount is invalid: %s", a.PeriodSpendLimit) } if !a.PeriodSpendLimit.IsAllPositive() { - return sdk.ErrInvalidCoins("spend limit must be positive") + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "spend limit must be positive") } if !a.PeriodCanSpend.IsValid() { - return sdk.ErrInvalidCoins("can spend amount is invalid: " + a.PeriodCanSpend.String()) + return sdkerrors.Wrapf(sdkerrors.ErrInvalidCoins, "can spend amount is invalid: %s", a.PeriodCanSpend) } // We allow 0 for CanSpend if a.PeriodCanSpend.IsAnyNegative() { - return sdk.ErrInvalidCoins("can spend must not be negative") + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "can spend must not be negative") } - // TODO: ensure PeriodSpendLimit can be subtracted from total (same coin types) + // ensure PeriodSpendLimit can be subtracted from total (same coin types) + if !a.PeriodSpendLimit.DenomsSubsetOf(a.Basic.SpendLimit) { + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "period spend limit has different currency than basic spend limit") + } // check times if err := a.Period.ValidateBasic(); err != nil { diff --git a/x/fee_grant/internal/types/periodic_fee_test.go b/x/fee_grant/internal/types/periodic_fee_test.go index 940983d3037b..40a8ca864184 100644 --- a/x/fee_grant/internal/types/periodic_fee_test.go +++ b/x/fee_grant/internal/types/periodic_fee_test.go @@ -14,6 +14,7 @@ func TestPeriodicFeeValidAllow(t *testing.T) { smallAtom := sdk.NewCoins(sdk.NewInt64Coin("atom", 43)) leftAtom := sdk.NewCoins(sdk.NewInt64Coin("atom", 512)) oneAtom := sdk.NewCoins(sdk.NewInt64Coin("atom", 1)) + eth := sdk.NewCoins(sdk.NewInt64Coin("eth", 1)) cases := map[string]struct { allow PeriodicFeeAllowance @@ -48,6 +49,17 @@ func TestPeriodicFeeValidAllow(t *testing.T) { }, valid: false, }, + "mismatched currencies": { + allow: PeriodicFeeAllowance{ + Basic: BasicFeeAllowance{ + SpendLimit: atom, + Expiration: ExpiresAtHeight(100), + }, + Period: BlockDuration(10), + PeriodSpendLimit: eth, + }, + valid: false, + }, "first time": { allow: PeriodicFeeAllowance{ Basic: BasicFeeAllowance{ From fb5b97ab78ac1a14dc76c19c2f84706b2afd0aac Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 7 Nov 2019 13:00:59 +0100 Subject: [PATCH 066/184] Add events --- x/fee_grant/handler.go | 18 +++++++++++++----- x/fee_grant/internal/keeper/keeper.go | 23 +++++++++++++++++++++++ x/fee_grant/internal/types/events.go | 11 +++++++++++ 3 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 x/fee_grant/internal/types/events.go diff --git a/x/fee_grant/handler.go b/x/fee_grant/handler.go index 5dd49ca0239a..7382b5d04cad 100644 --- a/x/fee_grant/handler.go +++ b/x/fee_grant/handler.go @@ -12,13 +12,10 @@ func NewHandler(k Keeper) sdk.Handler { switch msg := msg.(type) { case MsgGrantFeeAllowance: - grant := FeeAllowanceGrant(msg) - k.GrantFeeAllowance(ctx, grant) - return sdk.Result{} + return handleGrantFee(ctx, k, msg) case MsgRevokeFeeAllowance: - k.RevokeFeeAllowance(ctx, msg.Granter, msg.Grantee) - return sdk.Result{} + return handleRevokeFee(ctx, k, msg) default: errMsg := fmt.Sprintf("Unrecognized data Msg type: %s", ModuleName) @@ -26,3 +23,14 @@ func NewHandler(k Keeper) sdk.Handler { } } } + +func handleGrantFee(ctx sdk.Context, k Keeper, msg MsgGrantFeeAllowance) sdk.Result { + grant := FeeAllowanceGrant(msg) + k.GrantFeeAllowance(ctx, grant) + return sdk.Result{} +} + +func handleRevokeFee(ctx sdk.Context, k Keeper, msg MsgRevokeFeeAllowance) sdk.Result { + k.RevokeFeeAllowance(ctx, msg.Granter, msg.Grantee) + return sdk.Result{} +} diff --git a/x/fee_grant/internal/keeper/keeper.go b/x/fee_grant/internal/keeper/keeper.go index 6ebb4c9d8c32..d5bc7c63f3ba 100644 --- a/x/fee_grant/internal/keeper/keeper.go +++ b/x/fee_grant/internal/keeper/keeper.go @@ -35,6 +35,13 @@ func (k Keeper) GrantFeeAllowance(ctx sdk.Context, grant types.FeeAllowanceGrant key := types.FeeAllowanceKey(grant.Granter, grant.Grantee) bz := k.cdc.MustMarshalBinaryBare(grant) store.Set(key, bz) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeSetFeeGrant, + sdk.NewAttribute(types.AttributeKeyGranter, grant.Granter.String()), + sdk.NewAttribute(types.AttributeKeyGrantee, grant.Grantee.String()), + ), + ) } // RevokeFeeAllowance removes an existing grant @@ -42,6 +49,13 @@ func (k Keeper) RevokeFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddr store := ctx.KVStore(k.storeKey) key := types.FeeAllowanceKey(granter, grantee) store.Delete(key) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeRevokeFeeGrant, + sdk.NewAttribute(types.AttributeKeyGranter, granter.String()), + sdk.NewAttribute(types.AttributeKeyGrantee, grantee.String()), + ), + ) } // GetFeeAllowance returns the allowance between the granter and grantee. @@ -119,6 +133,15 @@ func (k Keeper) UseGrantedFees(ctx sdk.Context, granter, grantee sdk.AccAddress, } remove, err := grant.Allowance.Accept(fee, ctx.BlockTime(), ctx.BlockHeight()) + if err == nil { + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeUseFeeGrant, + sdk.NewAttribute(types.AttributeKeyGranter, granter.String()), + sdk.NewAttribute(types.AttributeKeyGrantee, grantee.String()), + ), + ) + } if remove { k.RevokeFeeAllowance(ctx, granter, grantee) // note this returns nil if err == nil diff --git a/x/fee_grant/internal/types/events.go b/x/fee_grant/internal/types/events.go new file mode 100644 index 000000000000..34e5ad9882ee --- /dev/null +++ b/x/fee_grant/internal/types/events.go @@ -0,0 +1,11 @@ +package types + +// evidence module events +const ( + EventTypeUseFeeGrant = "use_fee_grant" + EventTypeRevokeFeeGrant = "revoke_fee_grant" + EventTypeSetFeeGrant = "set_fee_grant" + + AttributeKeyGranter = "granter" + AttributeKeyGrantee = "grantee" +) From eedb8d8047e4e13d54686fad28ccfa4d6bfecbb0 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 7 Nov 2019 13:03:46 +0100 Subject: [PATCH 067/184] Rename fee_grant to feegrant --- simapp/app.go | 16 +++---- x/fee_grant/internal/types/events.go | 11 ----- x/{fee_grant => feegrant}/alias.go | 10 ++--- x/{fee_grant => feegrant}/doc.go | 4 +- .../exported/external.go | 0 x/{fee_grant => feegrant}/exported/fees.go | 0 x/{fee_grant => feegrant}/genesis.go | 2 +- x/{fee_grant => feegrant}/handler.go | 2 +- .../internal/ante/fee.go | 6 +-- .../internal/ante/fee_test.go | 8 ++-- .../internal/keeper/keeper.go | 4 +- .../internal/keeper/keeper_test.go | 6 +-- .../internal/keeper/querier.go | 2 +- .../internal/keeper/querier_test.go | 4 +- .../internal/types/basic_fee.go | 2 +- .../internal/types/basic_fee_test.go | 0 .../internal/types/codec.go | 2 +- .../internal/types/errors.go | 0 x/feegrant/internal/types/events.go | 11 +++++ .../internal/types/expiration.go | 0 .../internal/types/expiration_test.go | 0 .../internal/types/grant.go | 2 +- .../internal/types/grant_test.go | 0 .../internal/types/key.go | 0 .../internal/types/msgs.go | 2 +- .../internal/types/periodic_fee.go | 2 +- .../internal/types/periodic_fee_test.go | 0 .../internal/types/tx/codec.go | 0 .../internal/types/tx/test_common.go | 0 .../internal/types/tx/tx.go | 0 x/{fee_grant => feegrant}/module.go | 42 +++++++++---------- 31 files changed, 69 insertions(+), 69 deletions(-) delete mode 100644 x/fee_grant/internal/types/events.go rename x/{fee_grant => feegrant}/alias.go (86%) rename x/{fee_grant => feegrant}/doc.go (93%) rename x/{fee_grant => feegrant}/exported/external.go (100%) rename x/{fee_grant => feegrant}/exported/fees.go (100%) rename x/{fee_grant => feegrant}/genesis.go (98%) rename x/{fee_grant => feegrant}/handler.go (97%) rename x/{fee_grant => feegrant}/internal/ante/fee.go (95%) rename x/{fee_grant => feegrant}/internal/ante/fee_test.go (97%) rename x/{fee_grant => feegrant}/internal/keeper/keeper.go (97%) rename x/{fee_grant => feegrant}/internal/keeper/keeper_test.go (97%) rename x/{fee_grant => feegrant}/internal/keeper/querier.go (95%) rename x/{fee_grant => feegrant}/internal/keeper/querier_test.go (94%) rename x/{fee_grant => feegrant}/internal/types/basic_fee.go (97%) rename x/{fee_grant => feegrant}/internal/types/basic_fee_test.go (100%) rename x/{fee_grant => feegrant}/internal/types/codec.go (91%) rename x/{fee_grant => feegrant}/internal/types/errors.go (100%) create mode 100644 x/feegrant/internal/types/events.go rename x/{fee_grant => feegrant}/internal/types/expiration.go (100%) rename x/{fee_grant => feegrant}/internal/types/expiration_test.go (100%) rename x/{fee_grant => feegrant}/internal/types/grant.go (95%) rename x/{fee_grant => feegrant}/internal/types/grant_test.go (100%) rename x/{fee_grant => feegrant}/internal/types/key.go (100%) rename x/{fee_grant => feegrant}/internal/types/msgs.go (97%) rename x/{fee_grant => feegrant}/internal/types/periodic_fee.go (99%) rename x/{fee_grant => feegrant}/internal/types/periodic_fee_test.go (100%) rename x/{fee_grant => feegrant}/internal/types/tx/codec.go (100%) rename x/{fee_grant => feegrant}/internal/types/tx/test_common.go (100%) rename x/{fee_grant => feegrant}/internal/types/tx/tx.go (100%) rename x/{fee_grant => feegrant}/module.go (72%) diff --git a/simapp/app.go b/simapp/app.go index 98ff544c1ba5..818fb3029bd8 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -21,7 +21,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/crisis" distr "github.com/cosmos/cosmos-sdk/x/distribution" "github.com/cosmos/cosmos-sdk/x/evidence" - "github.com/cosmos/cosmos-sdk/x/fee_grant" + "github.com/cosmos/cosmos-sdk/x/feegrant" "github.com/cosmos/cosmos-sdk/x/genutil" "github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/mint" @@ -56,7 +56,7 @@ var ( params.AppModuleBasic{}, crisis.AppModuleBasic{}, slashing.AppModuleBasic{}, - fee_grant.AppModuleBasic{}, + feegrant.AppModuleBasic{}, evidence.AppModuleBasic{}, ) @@ -107,7 +107,7 @@ type SimApp struct { DistrKeeper distr.Keeper GovKeeper gov.Keeper CrisisKeeper crisis.Keeper - FeeGrantKeeper fee_grant.Keeper + FeeGrantKeeper feegrant.Keeper ParamsKeeper params.Keeper EvidenceKeeper evidence.Keeper @@ -133,7 +133,7 @@ func NewSimApp( keys := sdk.NewKVStoreKeys( bam.MainStoreKey, auth.StoreKey, staking.StoreKey, supply.StoreKey, mint.StoreKey, distr.StoreKey, slashing.StoreKey, gov.StoreKey, params.StoreKey, evidence.StoreKey, - fee_grant.StoreKey, + feegrant.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(params.TStoreKey) @@ -186,8 +186,8 @@ func NewSimApp( app.CrisisKeeper = crisis.NewKeeper( app.subspaces[crisis.ModuleName], invCheckPeriod, app.SupplyKeeper, auth.FeeCollectorName, ) - app.FeeGrantKeeper = fee_grant.NewKeeper( - app.cdc, keys[fee_grant.StoreKey], + app.FeeGrantKeeper = feegrant.NewKeeper( + app.cdc, keys[feegrant.StoreKey], ) // create evidence keeper with router @@ -228,7 +228,7 @@ func NewSimApp( distr.NewAppModule(app.DistrKeeper, app.SupplyKeeper), slashing.NewAppModule(app.SlashingKeeper, app.StakingKeeper), staking.NewAppModule(app.StakingKeeper, app.AccountKeeper, app.SupplyKeeper), - fee_grant.NewAppModule(app.FeeGrantKeeper), + feegrant.NewAppModule(app.FeeGrantKeeper), evidence.NewAppModule(app.EvidenceKeeper), ) @@ -243,7 +243,7 @@ func NewSimApp( app.mm.SetOrderInitGenesis( auth.ModuleName, distr.ModuleName, staking.ModuleName, bank.ModuleName, slashing.ModuleName, gov.ModuleName, mint.ModuleName, supply.ModuleName, - crisis.ModuleName, genutil.ModuleName, evidence.ModuleName, fee_grant.ModuleName, + crisis.ModuleName, genutil.ModuleName, evidence.ModuleName, feegrant.ModuleName, ) app.mm.RegisterInvariants(&app.CrisisKeeper) diff --git a/x/fee_grant/internal/types/events.go b/x/fee_grant/internal/types/events.go deleted file mode 100644 index 34e5ad9882ee..000000000000 --- a/x/fee_grant/internal/types/events.go +++ /dev/null @@ -1,11 +0,0 @@ -package types - -// evidence module events -const ( - EventTypeUseFeeGrant = "use_fee_grant" - EventTypeRevokeFeeGrant = "revoke_fee_grant" - EventTypeSetFeeGrant = "set_fee_grant" - - AttributeKeyGranter = "granter" - AttributeKeyGrantee = "grantee" -) diff --git a/x/fee_grant/alias.go b/x/feegrant/alias.go similarity index 86% rename from x/fee_grant/alias.go rename to x/feegrant/alias.go index c91f79291ab1..98122746f185 100644 --- a/x/fee_grant/alias.go +++ b/x/feegrant/alias.go @@ -1,14 +1,14 @@ -package fee_grant +package feegrant // nolint // autogenerated code using github.com/rigelrozanski/multitool // aliases generated for the following subdirectories: -// ALIASGEN: github.com/cosmos/cosmos-sdk/x/fee_grant/internal/keeper -// ALIASGEN: github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types +// ALIASGEN: github.com/cosmos/cosmos-sdk/x/feegrant/internal/keeper +// ALIASGEN: github.com/cosmos/cosmos-sdk/x/feegrant/internal/types import ( - "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/keeper" - "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/internal/keeper" + "github.com/cosmos/cosmos-sdk/x/feegrant/internal/types" ) const ( diff --git a/x/fee_grant/doc.go b/x/feegrant/doc.go similarity index 93% rename from x/fee_grant/doc.go rename to x/feegrant/doc.go index 0400ec9226c1..2c08f07ec3a4 100644 --- a/x/fee_grant/doc.go +++ b/x/feegrant/doc.go @@ -1,5 +1,5 @@ /* -Package fee_grant provides functionality for delegating the payment of transaction fees +Package feegrant provides functionality for delegating the payment of transaction fees from one account (key) to another account (key). Effectively, this allows for a user to pay fees using the balance of an account @@ -25,4 +25,4 @@ To allow handling txs from empty accounts (with fees paid from an existing accou we have to re-order the decorators as well. You can see an example in `x/delegate_fees/internal/ante/fee_test.go:newAnteHandler()` */ -package fee_grant +package feegrant diff --git a/x/fee_grant/exported/external.go b/x/feegrant/exported/external.go similarity index 100% rename from x/fee_grant/exported/external.go rename to x/feegrant/exported/external.go diff --git a/x/fee_grant/exported/fees.go b/x/feegrant/exported/fees.go similarity index 100% rename from x/fee_grant/exported/fees.go rename to x/feegrant/exported/fees.go diff --git a/x/fee_grant/genesis.go b/x/feegrant/genesis.go similarity index 98% rename from x/fee_grant/genesis.go rename to x/feegrant/genesis.go index 79e581c96403..1c888689f107 100644 --- a/x/fee_grant/genesis.go +++ b/x/feegrant/genesis.go @@ -1,4 +1,4 @@ -package fee_grant +package feegrant import sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/fee_grant/handler.go b/x/feegrant/handler.go similarity index 97% rename from x/fee_grant/handler.go rename to x/feegrant/handler.go index 7382b5d04cad..1d790e681bd3 100644 --- a/x/fee_grant/handler.go +++ b/x/feegrant/handler.go @@ -1,4 +1,4 @@ -package fee_grant +package feegrant import ( "fmt" diff --git a/x/fee_grant/internal/ante/fee.go b/x/feegrant/internal/ante/fee.go similarity index 95% rename from x/fee_grant/internal/ante/fee.go rename to x/feegrant/internal/ante/fee.go index 365b904d81e3..a91c3dfd6bd8 100644 --- a/x/fee_grant/internal/ante/fee.go +++ b/x/feegrant/internal/ante/fee.go @@ -10,9 +10,9 @@ import ( auth "github.com/cosmos/cosmos-sdk/x/auth/exported" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" - "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/keeper" - "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types/tx" + "github.com/cosmos/cosmos-sdk/x/feegrant/exported" + "github.com/cosmos/cosmos-sdk/x/feegrant/internal/keeper" + "github.com/cosmos/cosmos-sdk/x/feegrant/internal/types/tx" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) diff --git a/x/fee_grant/internal/ante/fee_test.go b/x/feegrant/internal/ante/fee_test.go similarity index 97% rename from x/fee_grant/internal/ante/fee_test.go rename to x/feegrant/internal/ante/fee_test.go index f97350647cee..1db9491d005d 100644 --- a/x/fee_grant/internal/ante/fee_test.go +++ b/x/feegrant/internal/ante/fee_test.go @@ -13,10 +13,10 @@ import ( authante "github.com/cosmos/cosmos-sdk/x/auth/ante" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/ante" - "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/keeper" - "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types" - "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types/tx" + "github.com/cosmos/cosmos-sdk/x/feegrant/internal/ante" + "github.com/cosmos/cosmos-sdk/x/feegrant/internal/keeper" + "github.com/cosmos/cosmos-sdk/x/feegrant/internal/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/internal/types/tx" ) // newAnteHandler is just like auth.NewAnteHandler, except we use the DeductGrantedFeeDecorator diff --git a/x/fee_grant/internal/keeper/keeper.go b/x/feegrant/internal/keeper/keeper.go similarity index 97% rename from x/fee_grant/internal/keeper/keeper.go rename to x/feegrant/internal/keeper/keeper.go index d5bc7c63f3ba..66b1b32b6eb7 100644 --- a/x/fee_grant/internal/keeper/keeper.go +++ b/x/feegrant/internal/keeper/keeper.go @@ -8,8 +8,8 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" - "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/exported" + "github.com/cosmos/cosmos-sdk/x/feegrant/internal/types" ) // Keeper manages state of all fee grants, as well as calculating approval. diff --git a/x/fee_grant/internal/keeper/keeper_test.go b/x/feegrant/internal/keeper/keeper_test.go similarity index 97% rename from x/fee_grant/internal/keeper/keeper_test.go rename to x/feegrant/internal/keeper/keeper_test.go index dbff579c80b9..980594b7db9d 100644 --- a/x/fee_grant/internal/keeper/keeper_test.go +++ b/x/feegrant/internal/keeper/keeper_test.go @@ -14,9 +14,9 @@ import ( codec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" - "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/keeper" - "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/exported" + "github.com/cosmos/cosmos-sdk/x/feegrant/internal/keeper" + "github.com/cosmos/cosmos-sdk/x/feegrant/internal/types" ) type KeeperTestSuite struct { diff --git a/x/fee_grant/internal/keeper/querier.go b/x/feegrant/internal/keeper/querier.go similarity index 95% rename from x/fee_grant/internal/keeper/querier.go rename to x/feegrant/internal/keeper/querier.go index ba5303f56f02..9310b04091ec 100644 --- a/x/fee_grant/internal/keeper/querier.go +++ b/x/feegrant/internal/keeper/querier.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/internal/types" abci "github.com/tendermint/tendermint/abci/types" ) diff --git a/x/fee_grant/internal/keeper/querier_test.go b/x/feegrant/internal/keeper/querier_test.go similarity index 94% rename from x/fee_grant/internal/keeper/querier_test.go rename to x/feegrant/internal/keeper/querier_test.go index ea6d76c4441c..a136ca2a1f98 100644 --- a/x/fee_grant/internal/keeper/querier_test.go +++ b/x/feegrant/internal/keeper/querier_test.go @@ -9,8 +9,8 @@ import ( codec "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/keeper" - "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/internal/keeper" + "github.com/cosmos/cosmos-sdk/x/feegrant/internal/types" ) func (suite *KeeperTestSuite) TestQuery(t *testing.T) { diff --git a/x/fee_grant/internal/types/basic_fee.go b/x/feegrant/internal/types/basic_fee.go similarity index 97% rename from x/fee_grant/internal/types/basic_fee.go rename to x/feegrant/internal/types/basic_fee.go index 4ce41be4a65b..bc39194421f1 100644 --- a/x/fee_grant/internal/types/basic_fee.go +++ b/x/feegrant/internal/types/basic_fee.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" + "github.com/cosmos/cosmos-sdk/x/feegrant/exported" ) // BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens diff --git a/x/fee_grant/internal/types/basic_fee_test.go b/x/feegrant/internal/types/basic_fee_test.go similarity index 100% rename from x/fee_grant/internal/types/basic_fee_test.go rename to x/feegrant/internal/types/basic_fee_test.go diff --git a/x/fee_grant/internal/types/codec.go b/x/feegrant/internal/types/codec.go similarity index 91% rename from x/fee_grant/internal/types/codec.go rename to x/feegrant/internal/types/codec.go index 91457c313327..c9de87a827b2 100644 --- a/x/fee_grant/internal/types/codec.go +++ b/x/feegrant/internal/types/codec.go @@ -2,7 +2,7 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" + "github.com/cosmos/cosmos-sdk/x/feegrant/exported" ) // RegisterCodec registers the account types and interface diff --git a/x/fee_grant/internal/types/errors.go b/x/feegrant/internal/types/errors.go similarity index 100% rename from x/fee_grant/internal/types/errors.go rename to x/feegrant/internal/types/errors.go diff --git a/x/feegrant/internal/types/events.go b/x/feegrant/internal/types/events.go new file mode 100644 index 000000000000..28caa2e6c9f8 --- /dev/null +++ b/x/feegrant/internal/types/events.go @@ -0,0 +1,11 @@ +package types + +// evidence module events +const ( + EventTypeUseFeeGrant = "use_feegrant" + EventTypeRevokeFeeGrant = "revoke_feegrant" + EventTypeSetFeeGrant = "set_feegrant" + + AttributeKeyGranter = "granter" + AttributeKeyGrantee = "grantee" +) diff --git a/x/fee_grant/internal/types/expiration.go b/x/feegrant/internal/types/expiration.go similarity index 100% rename from x/fee_grant/internal/types/expiration.go rename to x/feegrant/internal/types/expiration.go diff --git a/x/fee_grant/internal/types/expiration_test.go b/x/feegrant/internal/types/expiration_test.go similarity index 100% rename from x/fee_grant/internal/types/expiration_test.go rename to x/feegrant/internal/types/expiration_test.go diff --git a/x/fee_grant/internal/types/grant.go b/x/feegrant/internal/types/grant.go similarity index 95% rename from x/fee_grant/internal/types/grant.go rename to x/feegrant/internal/types/grant.go index 962e0f17ac0b..8c04aab7505b 100644 --- a/x/fee_grant/internal/types/grant.go +++ b/x/feegrant/internal/types/grant.go @@ -4,7 +4,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" + "github.com/cosmos/cosmos-sdk/x/feegrant/exported" ) // FeeAllowanceGrant is stored in the KVStore to record a grant with full context diff --git a/x/fee_grant/internal/types/grant_test.go b/x/feegrant/internal/types/grant_test.go similarity index 100% rename from x/fee_grant/internal/types/grant_test.go rename to x/feegrant/internal/types/grant_test.go diff --git a/x/fee_grant/internal/types/key.go b/x/feegrant/internal/types/key.go similarity index 100% rename from x/fee_grant/internal/types/key.go rename to x/feegrant/internal/types/key.go diff --git a/x/fee_grant/internal/types/msgs.go b/x/feegrant/internal/types/msgs.go similarity index 97% rename from x/fee_grant/internal/types/msgs.go rename to x/feegrant/internal/types/msgs.go index 885914d4626b..98e2d3e3c5dc 100644 --- a/x/fee_grant/internal/types/msgs.go +++ b/x/feegrant/internal/types/msgs.go @@ -2,7 +2,7 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" + "github.com/cosmos/cosmos-sdk/x/feegrant/exported" ) // MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance diff --git a/x/fee_grant/internal/types/periodic_fee.go b/x/feegrant/internal/types/periodic_fee.go similarity index 99% rename from x/fee_grant/internal/types/periodic_fee.go rename to x/feegrant/internal/types/periodic_fee.go index 459deb41c776..9716dbf3a7cc 100644 --- a/x/fee_grant/internal/types/periodic_fee.go +++ b/x/feegrant/internal/types/periodic_fee.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/fee_grant/exported" + "github.com/cosmos/cosmos-sdk/x/feegrant/exported" ) // PeriodicFeeAllowance extends FeeAllowance to allow for both a maximum cap, diff --git a/x/fee_grant/internal/types/periodic_fee_test.go b/x/feegrant/internal/types/periodic_fee_test.go similarity index 100% rename from x/fee_grant/internal/types/periodic_fee_test.go rename to x/feegrant/internal/types/periodic_fee_test.go diff --git a/x/fee_grant/internal/types/tx/codec.go b/x/feegrant/internal/types/tx/codec.go similarity index 100% rename from x/fee_grant/internal/types/tx/codec.go rename to x/feegrant/internal/types/tx/codec.go diff --git a/x/fee_grant/internal/types/tx/test_common.go b/x/feegrant/internal/types/tx/test_common.go similarity index 100% rename from x/fee_grant/internal/types/tx/test_common.go rename to x/feegrant/internal/types/tx/test_common.go diff --git a/x/fee_grant/internal/types/tx/tx.go b/x/feegrant/internal/types/tx/tx.go similarity index 100% rename from x/fee_grant/internal/types/tx/tx.go rename to x/feegrant/internal/types/tx/tx.go diff --git a/x/fee_grant/module.go b/x/feegrant/module.go similarity index 72% rename from x/fee_grant/module.go rename to x/feegrant/module.go index 525c918c76fe..ebb217878976 100644 --- a/x/fee_grant/module.go +++ b/x/feegrant/module.go @@ -1,4 +1,4 @@ -package fee_grant +package feegrant import ( "encoding/json" @@ -12,7 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - tx "github.com/cosmos/cosmos-sdk/x/fee_grant/internal/types/tx" + tx "github.com/cosmos/cosmos-sdk/x/feegrant/internal/types/tx" ) var ( @@ -20,27 +20,27 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) -// AppModuleBasic defines the basic application module used by the fee_grant module. +// AppModuleBasic defines the basic application module used by the feegrant module. type AppModuleBasic struct{} -// Name returns the fee_grant module's name. +// Name returns the feegrant module's name. func (AppModuleBasic) Name() string { return ModuleName } -// RegisterCodec registers the fee_grant module's types for the given codec. +// RegisterCodec registers the feegrant module's types for the given codec. func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { RegisterCodec(cdc) tx.RegisterCodec(cdc) } -// DefaultGenesis returns default genesis state as raw bytes for the fee_grant +// DefaultGenesis returns default genesis state as raw bytes for the feegrant // module. func (AppModuleBasic) DefaultGenesis() json.RawMessage { return []byte("[]") } -// ValidateGenesis performs genesis state validation for the fee_grant module. +// ValidateGenesis performs genesis state validation for the feegrant module. func (a AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { _, err := a.getValidatedGenesis(bz) return err @@ -55,19 +55,19 @@ func (a AppModuleBasic) getValidatedGenesis(bz json.RawMessage) (GenesisState, e return data, data.ValidateBasic() } -// RegisterRESTRoutes registers the REST routes for the fee_grant module. +// RegisterRESTRoutes registers the REST routes for the feegrant module. func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router) { // TODO // rest.RegisterRoutes(ctx, rtr) } -// GetTxCmd returns the root tx command for the fee_grant module. +// GetTxCmd returns the root tx command for the feegrant module. func (AppModuleBasic) GetTxCmd(_ *codec.Codec) *cobra.Command { // TODO return nil } -// GetQueryCmd returns no root query command for the fee_grant module. +// GetQueryCmd returns no root query command for the feegrant module. func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { // TODO return nil @@ -76,7 +76,7 @@ func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { //____________________________________________________________________________ -// AppModule implements an application module for the fee_grant module. +// AppModule implements an application module for the feegrant module. type AppModule struct { AppModuleBasic keeper Keeper @@ -90,35 +90,35 @@ func NewAppModule(keeper Keeper) AppModule { } } -// Name returns the fee_grant module's name. +// Name returns the feegrant module's name. func (AppModule) Name() string { return ModuleName } -// RegisterInvariants registers the fee_grant module invariants. +// RegisterInvariants registers the feegrant module invariants. func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {} -// Route returns the message routing key for the fee_grant module. +// Route returns the message routing key for the feegrant module. func (AppModule) Route() string { return RouterKey } -// NewHandler returns an sdk.Handler for the fee_grant module. +// NewHandler returns an sdk.Handler for the feegrant module. func (am AppModule) NewHandler() sdk.Handler { return NewHandler(am.keeper) } -// QuerierRoute returns the fee_grant module's querier route name. +// QuerierRoute returns the feegrant module's querier route name. func (AppModule) QuerierRoute() string { return QuerierRoute } -// NewQuerierHandler returns the fee_grant module sdk.Querier. +// NewQuerierHandler returns the feegrant module sdk.Querier. func (am AppModule) NewQuerierHandler() sdk.Querier { return NewQuerier(am.keeper) } -// InitGenesis performs genesis initialization for the fee_grant module. It returns +// InitGenesis performs genesis initialization for the feegrant module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate { genesisState, err := am.getValidatedGenesis(data) @@ -129,7 +129,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.Va return []abci.ValidatorUpdate{} } -// ExportGenesis returns the exported genesis state as raw bytes for the fee_grant +// ExportGenesis returns the exported genesis state as raw bytes for the feegrant // module. func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { gs, err := ExportGenesis(ctx, am.keeper) @@ -139,10 +139,10 @@ func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { return ModuleCdc.MustMarshalJSON(gs) } -// BeginBlock returns the begin blocker for the fee_grant module. +// BeginBlock returns the begin blocker for the feegrant module. func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} -// EndBlock returns the end blocker for the fee_grant module. It returns no validator +// EndBlock returns the end blocker for the feegrant module. It returns no validator // updates. func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { return []abci.ValidatorUpdate{} From 88df2559e6d2e96c4a0ad5aef357a1be579db2fd Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 7 Nov 2019 13:12:51 +0100 Subject: [PATCH 068/184] Ensure KeeperTestSuite actually runs --- x/feegrant/internal/keeper/keeper_test.go | 39 +++++++++++++--------- x/feegrant/internal/keeper/querier_test.go | 17 ++++------ 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/x/feegrant/internal/keeper/keeper_test.go b/x/feegrant/internal/keeper/keeper_test.go index 980594b7db9d..890d0bab71cc 100644 --- a/x/feegrant/internal/keeper/keeper_test.go +++ b/x/feegrant/internal/keeper/keeper_test.go @@ -4,8 +4,6 @@ import ( "testing" "time" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" @@ -32,6 +30,10 @@ type KeeperTestSuite struct { addr4 sdk.AccAddress } +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} + func (suite *KeeperTestSuite) SetupTest() { db := dbm.NewMemDB() @@ -64,7 +66,7 @@ func mustAddr(acc string) sdk.AccAddress { return addr } -func (suite *KeeperTestSuite) TestKeeperCrud(t *testing.T) { +func (suite *KeeperTestSuite) TestKeeperCrud() { ctx := suite.ctx k := suite.dk @@ -139,14 +141,15 @@ func (suite *KeeperTestSuite) TestKeeperCrud(t *testing.T) { } for name, tc := range cases { - t.Run(name, func(t *testing.T) { + tc := tc + suite.Run(name, func() { allow := k.GetFeeAllowance(ctx, tc.granter, tc.grantee) if tc.allowance == nil { - require.Nil(t, allow) + suite.Nil(allow) return } - require.NotNil(t, allow) - require.Equal(t, tc.allowance, allow) + suite.NotNil(allow) + suite.Equal(tc.allowance, allow) }) } @@ -171,19 +174,20 @@ func (suite *KeeperTestSuite) TestKeeperCrud(t *testing.T) { } for name, tc := range allCases { - t.Run(name, func(t *testing.T) { + tc := tc + suite.Run(name, func() { var grants []types.FeeAllowanceGrant err := k.IterateAllGranteeFeeAllowances(ctx, tc.grantee, func(grant types.FeeAllowanceGrant) bool { grants = append(grants, grant) return false }) - require.NoError(t, err) - assert.Equal(t, tc.grants, grants) + suite.NoError(err) + suite.Equal(tc.grants, grants) }) } } -func (suite *KeeperTestSuite) TestUseGrantedFee(t *testing.T) { +func (suite *KeeperTestSuite) TestUseGrantedFee() { ctx := suite.ctx k := suite.dk @@ -246,7 +250,8 @@ func (suite *KeeperTestSuite) TestUseGrantedFee(t *testing.T) { } for name, tc := range cases { - t.Run(name, func(t *testing.T) { + tc := tc + suite.Run(name, func() { // let's set up some initial state here // addr -> addr2 (future) // addr -> addr3 (expired) @@ -257,11 +262,15 @@ func (suite *KeeperTestSuite) TestUseGrantedFee(t *testing.T) { Granter: suite.addr, Grantee: suite.addr3, Allowance: &expired, }) - allowed := k.UseGrantedFees(ctx, tc.granter, tc.grantee, tc.fee) - require.Equal(t, tc.allowed, allowed) + err := k.UseGrantedFees(ctx, tc.granter, tc.grantee, tc.fee) + if tc.allowed { + suite.NoError(err) + } else { + suite.Error(err) + } loaded := k.GetFeeAllowance(ctx, tc.granter, tc.grantee) - require.Equal(t, tc.final, loaded) + suite.Equal(tc.final, loaded) }) } } diff --git a/x/feegrant/internal/keeper/querier_test.go b/x/feegrant/internal/keeper/querier_test.go index a136ca2a1f98..0df0044a70f7 100644 --- a/x/feegrant/internal/keeper/querier_test.go +++ b/x/feegrant/internal/keeper/querier_test.go @@ -1,10 +1,6 @@ package keeper_test import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" codec "github.com/cosmos/cosmos-sdk/codec" @@ -13,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/feegrant/internal/types" ) -func (suite *KeeperTestSuite) TestQuery(t *testing.T) { +func (suite *KeeperTestSuite) TestQuery() { ctx := suite.ctx k := suite.dk @@ -66,19 +62,20 @@ func (suite *KeeperTestSuite) TestQuery(t *testing.T) { querier := keeper.NewQuerier(k) for name, tc := range cases { - t.Run(name, func(t *testing.T) { + tc := tc + suite.Run(name, func() { bz, err := querier(ctx, tc.path, abci.RequestQuery{}) if !tc.valid { - require.Error(t, err) + suite.Error(err) return } - require.NoError(t, err) + suite.NoError(err) var grants []types.FeeAllowanceGrant serr := cdc.UnmarshalJSON(bz, &grants) - require.NoError(t, serr) + suite.NoError(serr) - assert.Equal(t, tc.res, grants) + suite.Equal(tc.res, grants) }) } From dbf357832551f77dbfd3696d353ba9498a8b8c4e Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 7 Nov 2019 14:04:17 +0100 Subject: [PATCH 069/184] Move types/tx to types --- x/feegrant/internal/ante/fee.go | 4 ++-- x/feegrant/internal/ante/fee_test.go | 5 ++--- x/feegrant/internal/types/codec.go | 2 ++ x/feegrant/internal/types/{tx => }/test_common.go | 3 ++- x/feegrant/internal/types/{tx => }/tx.go | 2 +- x/feegrant/internal/types/tx/codec.go | 8 -------- x/feegrant/module.go | 2 -- 7 files changed, 9 insertions(+), 17 deletions(-) rename x/feegrant/internal/types/{tx => }/test_common.go (97%) rename x/feegrant/internal/types/{tx => }/tx.go (99%) delete mode 100644 x/feegrant/internal/types/tx/codec.go diff --git a/x/feegrant/internal/ante/fee.go b/x/feegrant/internal/ante/fee.go index a91c3dfd6bd8..296e152122a4 100644 --- a/x/feegrant/internal/ante/fee.go +++ b/x/feegrant/internal/ante/fee.go @@ -12,13 +12,13 @@ import ( "github.com/cosmos/cosmos-sdk/x/feegrant/exported" "github.com/cosmos/cosmos-sdk/x/feegrant/internal/keeper" - "github.com/cosmos/cosmos-sdk/x/feegrant/internal/types/tx" + "github.com/cosmos/cosmos-sdk/x/feegrant/internal/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) var ( - _ GrantedFeeTx = (*tx.FeeGrantTx)(nil) // assert FeeGrantTx implements GrantedFeeTx + _ GrantedFeeTx = (*types.FeeGrantTx)(nil) // assert FeeGrantTx implements GrantedFeeTx ) // GrantedFeeTx defines the interface to be implemented by Tx to use the GrantedFeeDecorator diff --git a/x/feegrant/internal/ante/fee_test.go b/x/feegrant/internal/ante/fee_test.go index 1db9491d005d..bcc6d1859b9a 100644 --- a/x/feegrant/internal/ante/fee_test.go +++ b/x/feegrant/internal/ante/fee_test.go @@ -16,7 +16,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/feegrant/internal/ante" "github.com/cosmos/cosmos-sdk/x/feegrant/internal/keeper" "github.com/cosmos/cosmos-sdk/x/feegrant/internal/types" - "github.com/cosmos/cosmos-sdk/x/feegrant/internal/types/tx" ) // newAnteHandler is just like auth.NewAnteHandler, except we use the DeductGrantedFeeDecorator @@ -244,11 +243,11 @@ func TestDeductFeesNoDelegation(t *testing.T) { tc := stc // to make scopelint happy t.Run(name, func(t *testing.T) { // msg and signatures - fee := tx.NewGrantedFee(100000, sdk.NewCoins(sdk.NewInt64Coin("atom", tc.fee)), tc.feeAccount) + fee := types.NewGrantedFee(100000, sdk.NewCoins(sdk.NewInt64Coin("atom", tc.fee)), tc.feeAccount) msgs := []sdk.Msg{sdk.NewTestMsg(tc.signer)} privs, accNums, seqs := []crypto.PrivKey{tc.signerKey}, []uint64{0}, []uint64{0} - tx := tx.NewTestTx(ctx, msgs, privs, accNums, seqs, fee) + tx := types.NewTestTx(ctx, msgs, privs, accNums, seqs, fee) _, err := tc.handler(ctx, tx, false) if tc.valid { diff --git a/x/feegrant/internal/types/codec.go b/x/feegrant/internal/types/codec.go index c9de87a827b2..68460bde3537 100644 --- a/x/feegrant/internal/types/codec.go +++ b/x/feegrant/internal/types/codec.go @@ -10,6 +10,8 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterInterface((*exported.FeeAllowance)(nil), nil) cdc.RegisterConcrete(&BasicFeeAllowance{}, "feegrant/BasicFeeAllowance", nil) cdc.RegisterConcrete(&PeriodicFeeAllowance{}, "feegrant/PeriodicFeeAllowance", nil) + + cdc.RegisterConcrete(FeeGrantTx{}, "cosmos-sdk/FeeGrantTx", nil) } // ModuleCdc generic sealed codec to be used throughout module diff --git a/x/feegrant/internal/types/tx/test_common.go b/x/feegrant/internal/types/test_common.go similarity index 97% rename from x/feegrant/internal/types/tx/test_common.go rename to x/feegrant/internal/types/test_common.go index f33e1c222879..bb3686650c48 100644 --- a/x/feegrant/internal/types/tx/test_common.go +++ b/x/feegrant/internal/types/test_common.go @@ -1,5 +1,6 @@ // noalias -package tx + +package types import ( "github.com/tendermint/tendermint/crypto" diff --git a/x/feegrant/internal/types/tx/tx.go b/x/feegrant/internal/types/tx.go similarity index 99% rename from x/feegrant/internal/types/tx/tx.go rename to x/feegrant/internal/types/tx.go index a02eb73ab95d..72a6b6d8ab6e 100644 --- a/x/feegrant/internal/types/tx/tx.go +++ b/x/feegrant/internal/types/tx.go @@ -1,4 +1,4 @@ -package tx +package types import ( "encoding/json" diff --git a/x/feegrant/internal/types/tx/codec.go b/x/feegrant/internal/types/tx/codec.go deleted file mode 100644 index 50e482b48bd3..000000000000 --- a/x/feegrant/internal/types/tx/codec.go +++ /dev/null @@ -1,8 +0,0 @@ -package tx - -import "github.com/cosmos/cosmos-sdk/codec" - -// RegisterCodec registers concrete types on the codec -func RegisterCodec(cdc *codec.Codec) { - cdc.RegisterConcrete(FeeGrantTx{}, "cosmos-sdk/FeeGrantTx", nil) -} diff --git a/x/feegrant/module.go b/x/feegrant/module.go index ebb217878976..6406b74961f7 100644 --- a/x/feegrant/module.go +++ b/x/feegrant/module.go @@ -12,7 +12,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - tx "github.com/cosmos/cosmos-sdk/x/feegrant/internal/types/tx" ) var ( @@ -31,7 +30,6 @@ func (AppModuleBasic) Name() string { // RegisterCodec registers the feegrant module's types for the given codec. func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { RegisterCodec(cdc) - tx.RegisterCodec(cdc) } // DefaultGenesis returns default genesis state as raw bytes for the feegrant From 375f114b1c9c6906747015e92c1e793ced1e3b9d Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 7 Nov 2019 14:05:20 +0100 Subject: [PATCH 070/184] Update alias file, include ante --- x/feegrant/alias.go | 81 ++++++++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 31 deletions(-) diff --git a/x/feegrant/alias.go b/x/feegrant/alias.go index 98122746f185..66f6023a8fd4 100644 --- a/x/feegrant/alias.go +++ b/x/feegrant/alias.go @@ -1,54 +1,73 @@ package feegrant -// nolint -// autogenerated code using github.com/rigelrozanski/multitool -// aliases generated for the following subdirectories: -// ALIASGEN: github.com/cosmos/cosmos-sdk/x/feegrant/internal/keeper -// ALIASGEN: github.com/cosmos/cosmos-sdk/x/feegrant/internal/types - import ( + "github.com/cosmos/cosmos-sdk/x/feegrant/internal/ante" "github.com/cosmos/cosmos-sdk/x/feegrant/internal/keeper" "github.com/cosmos/cosmos-sdk/x/feegrant/internal/types" ) +// nolint +// autogenerated code using github.com/rigelrozanski/multitool +// aliases generated for the following subdirectories: +// ALIASGEN: github.com/cosmos/cosmos-sdk/x/feegrant/internal/ante +// ALIASGEN: github.com/cosmos/cosmos-sdk/x/feegrant/internal/types +// ALIASGEN: github.com/cosmos/cosmos-sdk/x/feegrant/internal/keeper + const ( - QueryGetFeeAllowances = keeper.QueryGetFeeAllowances - DefaultCodespace = types.DefaultCodespace - ModuleName = types.ModuleName - StoreKey = types.StoreKey - RouterKey = types.RouterKey - QuerierRoute = types.QuerierRoute + DefaultCodespace = types.DefaultCodespace + EventTypeUseFeeGrant = types.EventTypeUseFeeGrant + EventTypeRevokeFeeGrant = types.EventTypeRevokeFeeGrant + EventTypeSetFeeGrant = types.EventTypeSetFeeGrant + AttributeKeyGranter = types.AttributeKeyGranter + AttributeKeyGrantee = types.AttributeKeyGrantee + ModuleName = types.ModuleName + StoreKey = types.StoreKey + RouterKey = types.RouterKey + QuerierRoute = types.QuerierRoute + QueryGetFeeAllowances = keeper.QueryGetFeeAllowances ) var ( // functions aliases - NewKeeper = keeper.NewKeeper - NewQuerier = keeper.NewQuerier - RegisterCodec = types.RegisterCodec - ExpiresAtTime = types.ExpiresAtTime - ExpiresAtHeight = types.ExpiresAtHeight - ClockDuration = types.ClockDuration - BlockDuration = types.BlockDuration - FeeAllowanceKey = types.FeeAllowanceKey - FeeAllowancePrefixByGrantee = types.FeeAllowancePrefixByGrantee - NewMsgGrantFeeAllowance = types.NewMsgGrantFeeAllowance - NewMsgRevokeFeeAllowance = types.NewMsgRevokeFeeAllowance + NewDeductGrantedFeeDecorator = ante.NewDeductGrantedFeeDecorator + DeductFees = ante.DeductFees + RegisterCodec = types.RegisterCodec + ExpiresAtTime = types.ExpiresAtTime + ExpiresAtHeight = types.ExpiresAtHeight + ClockDuration = types.ClockDuration + BlockDuration = types.BlockDuration + FeeAllowanceKey = types.FeeAllowanceKey + FeeAllowancePrefixByGrantee = types.FeeAllowancePrefixByGrantee + NewMsgGrantFeeAllowance = types.NewMsgGrantFeeAllowance + NewMsgRevokeFeeAllowance = types.NewMsgRevokeFeeAllowance + NewFeeGrantTx = types.NewFeeGrantTx + CountSubKeys = types.CountSubKeys + NewGrantedFee = types.NewGrantedFee + StdSignBytes = types.StdSignBytes + NewKeeper = keeper.NewKeeper + NewQuerier = keeper.NewQuerier // variable aliases ModuleCdc = types.ModuleCdc ErrFeeLimitExceeded = types.ErrFeeLimitExceeded ErrFeeLimitExpired = types.ErrFeeLimitExpired ErrInvalidDuration = types.ErrInvalidDuration + ErrNoAllowance = types.ErrNoAllowance FeeAllowanceKeyPrefix = types.FeeAllowanceKeyPrefix ) type ( - Keeper = keeper.Keeper - BasicFeeAllowance = types.BasicFeeAllowance - ExpiresAt = types.ExpiresAt - Duration = types.Duration - FeeAllowanceGrant = types.FeeAllowanceGrant - MsgGrantFeeAllowance = types.MsgGrantFeeAllowance - MsgRevokeFeeAllowance = types.MsgRevokeFeeAllowance - PeriodicFeeAllowance = types.PeriodicFeeAllowance + GrantedFeeTx = ante.GrantedFeeTx + DeductGrantedFeeDecorator = ante.DeductGrantedFeeDecorator + BasicFeeAllowance = types.BasicFeeAllowance + ExpiresAt = types.ExpiresAt + Duration = types.Duration + FeeAllowanceGrant = types.FeeAllowanceGrant + MsgGrantFeeAllowance = types.MsgGrantFeeAllowance + MsgRevokeFeeAllowance = types.MsgRevokeFeeAllowance + PeriodicFeeAllowance = types.PeriodicFeeAllowance + FeeGrantTx = types.FeeGrantTx + GrantedFee = types.GrantedFee + DelegatedSignDoc = types.DelegatedSignDoc + Keeper = keeper.Keeper ) From 9af9f43261a07ff5648d3434d4c2a494e9ac5538 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 7 Nov 2019 14:12:19 +0100 Subject: [PATCH 071/184] I do need nolint in alias.go --- x/feegrant/alias.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/feegrant/alias.go b/x/feegrant/alias.go index 66f6023a8fd4..4abfe46fe13a 100644 --- a/x/feegrant/alias.go +++ b/x/feegrant/alias.go @@ -1,3 +1,4 @@ +// nolint package feegrant import ( @@ -6,7 +7,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/feegrant/internal/types" ) -// nolint // autogenerated code using github.com/rigelrozanski/multitool // aliases generated for the following subdirectories: // ALIASGEN: github.com/cosmos/cosmos-sdk/x/feegrant/internal/ante From 3c390e5000d8d92b1ceaf3dcbe18ffd0103ade9d Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 7 Nov 2019 18:21:06 +0100 Subject: [PATCH 072/184] Properly emit events in the handler. Use cosmos-sdk in amino types --- x/feegrant/handler.go | 4 ++-- x/feegrant/internal/types/codec.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x/feegrant/handler.go b/x/feegrant/handler.go index 1d790e681bd3..b383c14b0f66 100644 --- a/x/feegrant/handler.go +++ b/x/feegrant/handler.go @@ -27,10 +27,10 @@ func NewHandler(k Keeper) sdk.Handler { func handleGrantFee(ctx sdk.Context, k Keeper, msg MsgGrantFeeAllowance) sdk.Result { grant := FeeAllowanceGrant(msg) k.GrantFeeAllowance(ctx, grant) - return sdk.Result{} + return sdk.Result{Events: ctx.EventManager().Events()} } func handleRevokeFee(ctx sdk.Context, k Keeper, msg MsgRevokeFeeAllowance) sdk.Result { k.RevokeFeeAllowance(ctx, msg.Granter, msg.Grantee) - return sdk.Result{} + return sdk.Result{Events: ctx.EventManager().Events()} } diff --git a/x/feegrant/internal/types/codec.go b/x/feegrant/internal/types/codec.go index 68460bde3537..541bf6d325a6 100644 --- a/x/feegrant/internal/types/codec.go +++ b/x/feegrant/internal/types/codec.go @@ -8,8 +8,8 @@ import ( // RegisterCodec registers the account types and interface func RegisterCodec(cdc *codec.Codec) { cdc.RegisterInterface((*exported.FeeAllowance)(nil), nil) - cdc.RegisterConcrete(&BasicFeeAllowance{}, "feegrant/BasicFeeAllowance", nil) - cdc.RegisterConcrete(&PeriodicFeeAllowance{}, "feegrant/PeriodicFeeAllowance", nil) + cdc.RegisterConcrete(&BasicFeeAllowance{}, "cosmos-sdk/BasicFeeAllowance", nil) + cdc.RegisterConcrete(&PeriodicFeeAllowance{}, "cosmos-sdk/PeriodicFeeAllowance", nil) cdc.RegisterConcrete(FeeGrantTx{}, "cosmos-sdk/FeeGrantTx", nil) } From 720e9f4b241ab6830a5061b57b5ea46c83891ecf Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 9 Mar 2020 15:13:56 -0400 Subject: [PATCH 073/184] Update godoc --- x/feegrant/ante/fee.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/x/feegrant/ante/fee.go b/x/feegrant/ante/fee.go index 158a4dfb0445..454a3f406fa2 100644 --- a/x/feegrant/ante/fee.go +++ b/x/feegrant/ante/fee.go @@ -35,7 +35,7 @@ type DeductGrantedFeeDecorator struct { sk exported.SupplyKeeper } -func NewDeductGrantedFeeDecorator(ak exported.AccountKeeper, sk exported.SupplyKeeper, K keeper.Keeper) DeductGrantedFeeDecorator { +func NewDeductGrantedFeeDecorator(ak exported.AccountKeeper, sk exported.SupplyKeeper, k keeper.Keeper) DeductGrantedFeeDecorator { return DeductGrantedFeeDecorator{ ak: ak, k: k, @@ -43,6 +43,11 @@ func NewDeductGrantedFeeDecorator(ak exported.AccountKeeper, sk exported.SupplyK } } +// AnteHandle performs a decorated ante-handler responsible for deducting transaction +// fees. Fees will be deducted from the account designated by the FeePayer on a +// transaction by default. However, if the fee payer differs from the transaction +// signer, the handler will check if a fee grant has been authorized. If the +// transaction's signer does not exist, it will be created. func (d DeductGrantedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { feeTx, ok := tx.(GrantedFeeTx) if !ok { @@ -79,11 +84,12 @@ func (d DeductGrantedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "fee payer address: %s does not exist", feePayer) } - // deduct fee if non-zero + // move on if there is no fee to deduct if fee.IsZero() { return next(ctx, tx, simulate) } + // deduct fee if non-zero err = auth.DeductFees(d.sk, ctx, feePayerAcc, fee) if err != nil { return ctx, err From eb46dd00f50f908c963934c515040d7681063718 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 9 Mar 2020 15:18:23 -0400 Subject: [PATCH 074/184] Linting... --- x/feegrant/keeper/keeper.go | 11 +++++++++++ x/feegrant/module.go | 8 +++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/x/feegrant/keeper/keeper.go b/x/feegrant/keeper/keeper.go index 142b9549b18d..263b5faabadb 100644 --- a/x/feegrant/keeper/keeper.go +++ b/x/feegrant/keeper/keeper.go @@ -34,7 +34,9 @@ func (k Keeper) GrantFeeAllowance(ctx sdk.Context, grant types.FeeAllowanceGrant store := ctx.KVStore(k.storeKey) key := types.FeeAllowanceKey(grant.Granter, grant.Grantee) bz := k.cdc.MustMarshalBinaryBare(grant) + store.Set(key, bz) + ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeSetFeeGrant, @@ -48,7 +50,9 @@ func (k Keeper) GrantFeeAllowance(ctx sdk.Context, grant types.FeeAllowanceGrant func (k Keeper) RevokeFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddress) { store := ctx.KVStore(k.storeKey) key := types.FeeAllowanceKey(granter, grantee) + store.Delete(key) + ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeRevokeFeeGrant, @@ -66,6 +70,7 @@ func (k Keeper) GetFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddress if !found { return nil } + return grant.Allowance } @@ -80,6 +85,7 @@ func (k Keeper) GetFeeGrant(ctx sdk.Context, granter sdk.AccAddress, grantee sdk var grant types.FeeAllowanceGrant k.cdc.MustUnmarshalBinaryBare(bz, &grant) + return grant, true } @@ -95,12 +101,15 @@ func (k Keeper) IterateAllGranteeFeeAllowances(ctx sdk.Context, grantee sdk.AccA for ; iter.Valid() && !stop; iter.Next() { bz := iter.Value() var grant types.FeeAllowanceGrant + err := k.cdc.UnmarshalBinaryBare(bz, &grant) if err != nil { return err } + stop = cb(grant) } + return nil } @@ -145,11 +154,13 @@ func (k Keeper) UseGrantedFees(ctx sdk.Context, granter, grantee sdk.AccAddress, ), ) } + if remove { k.RevokeFeeAllowance(ctx, granter, grantee) // note this returns nil if err == nil return sdkerrors.Wrap(err, "removed grant") } + if err != nil { return sdkerrors.Wrap(err, "invalid grant") } diff --git a/x/feegrant/module.go b/x/feegrant/module.go index ff6ceae44e18..72699c3c5043 100644 --- a/x/feegrant/module.go +++ b/x/feegrant/module.go @@ -19,6 +19,10 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + // AppModuleBasic defines the basic application module used by the feegrant module. type AppModuleBasic struct{} @@ -73,7 +77,9 @@ func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { return nil } -//____________________________________________________________________________ +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- // AppModule implements an application module for the feegrant module. type AppModule struct { From 63cca04cb95c4e68e6de3ccf68944805192b5943 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 9 Mar 2020 15:19:07 -0400 Subject: [PATCH 075/184] Update errors --- x/feegrant/types/errors.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/x/feegrant/types/errors.go b/x/feegrant/types/errors.go index cea99327f440..9b824253ae9d 100644 --- a/x/feegrant/types/errors.go +++ b/x/feegrant/types/errors.go @@ -11,14 +11,11 @@ const ( var ( // ErrFeeLimitExceeded error if there are not enough allowance to cover the fees - ErrFeeLimitExceeded = sdkerrors.Register(DefaultCodespace, 1, "fee limit exceeded") - + ErrFeeLimitExceeded = sdkerrors.Register(DefaultCodespace, 2, "fee limit exceeded") // ErrFeeLimitExpired error if the allowance has expired - ErrFeeLimitExpired = sdkerrors.Register(DefaultCodespace, 2, "fee limit expired") - + ErrFeeLimitExpired = sdkerrors.Register(DefaultCodespace, 3, "fee limit expired") // ErrInvalidDuration error if the Duration is invalid or doesn't match the expiration - ErrInvalidDuration = sdkerrors.Register(DefaultCodespace, 3, "invalid duration") - + ErrInvalidDuration = sdkerrors.Register(DefaultCodespace, 4, "invalid duration") // ErrNoAllowance error if there is no allowance for that pair - ErrNoAllowance = sdkerrors.Register(DefaultCodespace, 4, "no allowance") + ErrNoAllowance = sdkerrors.Register(DefaultCodespace, 5, "no allowance") ) From 8eddbb7636021631402226b961b0b7e82a876814 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 9 Mar 2020 15:40:38 -0400 Subject: [PATCH 076/184] Update pkg doc and fix ante-handler order --- simapp/ante.go | 5 ++++- x/feegrant/doc.go | 27 ++++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/simapp/ante.go b/simapp/ante.go index f3f01803529f..f7db7f20f811 100644 --- a/simapp/ante.go +++ b/simapp/ante.go @@ -23,9 +23,12 @@ func NewAnteHandler( authante.NewValidateBasicDecorator(), authante.NewValidateMemoDecorator(ak), authante.NewConsumeGasForTxSizeDecorator(ak), + // DeductGrantedFeeDecorator will create an empty account if we sign with no + // tokens but valid validation. This must be before SetPubKey, ValidateSigCount, + // SigVerification, which error if account doesn't exist yet. + feegrantante.NewDeductGrantedFeeDecorator(ak, supplyKeeper, feeGrantKeeper), authante.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators authante.NewValidateSigCountDecorator(ak), - feegrantante.NewDeductGrantedFeeDecorator(ak, supplyKeeper, feeGrantKeeper), authante.NewSigGasConsumeDecorator(ak, sigGasConsumer), authante.NewSigVerificationDecorator(ak), authante.NewIncrementSequenceDecorator(ak), // innermost AnteDecorator diff --git a/x/feegrant/doc.go b/x/feegrant/doc.go index 2c08f07ec3a4..4f190e3140c7 100644 --- a/x/feegrant/doc.go +++ b/x/feegrant/doc.go @@ -1,28 +1,29 @@ /* -Package feegrant provides functionality for delegating the payment of transaction fees -from one account (key) to another account (key). +Package feegrant provides functionality for authorizing the payment of transaction +fees from one account (key) to another account (key). Effectively, this allows for a user to pay fees using the balance of an account different from their own. Example use cases would be allowing a key on a device to pay for fees using a master wallet, or a third party service allowing users to pay for transactions without ever really holding their own tokens. This package -provides ways for specifying fee allowances such that delegating fees -to another account can be done with clear and safe restrictions. +provides ways for specifying fee allowances such that authorizing fee payment to +another account can be done with clear and safe restrictions. -A user would delegate fees to a user using MsgDelegateFeeAllowance and revoke -that delegation using MsgRevokeFeeAllowance. In both cases Granter is the one -who is delegating fees and Grantee is the one who is receiving the delegation. -So grantee would correspond to the one who is signing a transaction and the -granter would be the address they place in DelegatedFee.FeeAccount. +A user would authorize granting fee payment to another user using +MsgDelegateFeeAllowance and revoke that delegation using MsgRevokeFeeAllowance. +In both cases, Granter is the one who is authorizing fee payment and Grantee is +the one who is receiving the fee payment authorization. So grantee would correspond +to the one who is signing a transaction and the granter would be the address that +pays the fees. The fee allowance that a grantee receives is specified by an implementation of the FeeAllowance interface. Two FeeAllowance implementations are provided in this package: BasicFeeAllowance and PeriodicFeeAllowance. -In order to integrate this into an application, we must use the DeductDelegatedFeeDecorator -ante handler from this package instead of the default DeductFeeDecorator from auth. +In order to integrate this into an application, we must use the DeductGrantedFeeDecorator +ante handler from this package instead of the default DeductFeeDecorator from x/auth. + To allow handling txs from empty accounts (with fees paid from an existing account), -we have to re-order the decorators as well. You can see an example in -`x/delegate_fees/internal/ante/fee_test.go:newAnteHandler()` +we have to re-order the decorators as well. */ package feegrant From f32db1d2a7d5094fb32a12604e5bfa25f5006cf8 Mon Sep 17 00:00:00 2001 From: SaReN Date: Tue, 7 Apr 2020 19:10:00 +0530 Subject: [PATCH 077/184] Merge PR #5782: Migrate x/feegrant to proto --- simapp/ante.go | 3 +- simapp/app.go | 2 +- x/feegrant/alias.go | 3 +- x/feegrant/ante/fee.go | 7 +- x/feegrant/ante/fee_test.go | 12 +- x/feegrant/genesis.go | 6 +- x/feegrant/handler.go | 5 +- x/feegrant/keeper/keeper.go | 39 +- x/feegrant/keeper/keeper_test.go | 83 +- x/feegrant/keeper/querier.go | 3 +- x/feegrant/keeper/querier_test.go | 10 +- x/feegrant/types/basic_fee.go | 16 +- x/feegrant/types/basic_fee_test.go | 14 +- x/feegrant/types/codec.go | 20 +- .../external.go => types/expected_keepers.go} | 2 +- x/feegrant/types/expiration.go | 14 - x/feegrant/types/expiration_test.go | 22 +- x/feegrant/{exported => types}/fees.go | 6 +- x/feegrant/types/grant.go | 25 +- x/feegrant/types/grant_test.go | 22 +- x/feegrant/types/msgs.go | 26 +- x/feegrant/types/periodic_fee.go | 25 +- x/feegrant/types/types.pb.go | 2531 +++++++++++++++++ x/feegrant/types/types.proto | 105 + 24 files changed, 2812 insertions(+), 189 deletions(-) rename x/feegrant/{exported/external.go => types/expected_keepers.go} (97%) rename x/feegrant/{exported => types}/fees.go (96%) create mode 100644 x/feegrant/types/types.pb.go create mode 100644 x/feegrant/types/types.proto diff --git a/simapp/ante.go b/simapp/ante.go index f7db7f20f811..e53f8638d577 100644 --- a/simapp/ante.go +++ b/simapp/ante.go @@ -6,14 +6,13 @@ import ( authante "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/cosmos/cosmos-sdk/x/feegrant" feegrantante "github.com/cosmos/cosmos-sdk/x/feegrant/ante" - feegrantexported "github.com/cosmos/cosmos-sdk/x/feegrant/exported" ) // NewAnteHandler returns an AnteHandler that checks and increments sequence // numbers, checks signatures & account numbers, and deducts fees from the first // signer. func NewAnteHandler( - ak auth.AccountKeeper, supplyKeeper feegrantexported.SupplyKeeper, feeGrantKeeper feegrant.Keeper, + ak auth.AccountKeeper, supplyKeeper feegrant.SupplyKeeper, feeGrantKeeper feegrant.Keeper, sigGasConsumer auth.SignatureVerificationGasConsumer, ) sdk.AnteHandler { diff --git a/simapp/app.go b/simapp/app.go index c50ee95dba5b..28e5603290b2 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -190,7 +190,7 @@ func NewSimApp( app.CrisisKeeper = crisis.NewKeeper( app.subspaces[crisis.ModuleName], invCheckPeriod, app.SupplyKeeper, auth.FeeCollectorName, ) - app.FeeGrantKeeper = feegrant.NewKeeper(app.cdc, keys[feegrant.StoreKey]) + app.FeeGrantKeeper = feegrant.NewKeeper(appCodec, keys[feegrant.StoreKey]) app.UpgradeKeeper = upgrade.NewKeeper(skipUpgradeHeights, keys[upgrade.StoreKey], appCodec, homePath) // create evidence keeper with router diff --git a/x/feegrant/alias.go b/x/feegrant/alias.go index cb0ce18183db..74ea930daf17 100644 --- a/x/feegrant/alias.go +++ b/x/feegrant/alias.go @@ -31,7 +31,6 @@ var ( BlockDuration = types.BlockDuration FeeAllowanceKey = types.FeeAllowanceKey FeeAllowancePrefixByGrantee = types.FeeAllowancePrefixByGrantee - NewMsgGrantFeeAllowance = types.NewMsgGrantFeeAllowance NewMsgRevokeFeeAllowance = types.NewMsgRevokeFeeAllowance NewFeeGrantTx = types.NewFeeGrantTx CountSubKeys = types.CountSubKeys @@ -54,6 +53,7 @@ type ( BasicFeeAllowance = types.BasicFeeAllowance ExpiresAt = types.ExpiresAt Duration = types.Duration + FeeAllowance = types.FeeAllowance FeeAllowanceGrant = types.FeeAllowanceGrant MsgGrantFeeAllowance = types.MsgGrantFeeAllowance MsgRevokeFeeAllowance = types.MsgRevokeFeeAllowance @@ -61,5 +61,6 @@ type ( FeeGrantTx = types.FeeGrantTx GrantedFee = types.GrantedFee DelegatedSignDoc = types.DelegatedSignDoc + SupplyKeeper = types.SupplyKeeper Keeper = keeper.Keeper ) diff --git a/x/feegrant/ante/fee.go b/x/feegrant/ante/fee.go index 454a3f406fa2..af3cf51852a8 100644 --- a/x/feegrant/ante/fee.go +++ b/x/feegrant/ante/fee.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth" - "github.com/cosmos/cosmos-sdk/x/feegrant/exported" "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) @@ -30,12 +29,12 @@ type GrantedFeeTx interface { // Call next AnteHandler if fees successfully deducted // CONTRACT: Tx must implement GrantedFeeTx interface to use DeductGrantedFeeDecorator type DeductGrantedFeeDecorator struct { - ak exported.AccountKeeper + ak types.AccountKeeper k keeper.Keeper - sk exported.SupplyKeeper + sk types.SupplyKeeper } -func NewDeductGrantedFeeDecorator(ak exported.AccountKeeper, sk exported.SupplyKeeper, k keeper.Keeper) DeductGrantedFeeDecorator { +func NewDeductGrantedFeeDecorator(ak types.AccountKeeper, sk types.SupplyKeeper, k keeper.Keeper) DeductGrantedFeeDecorator { return DeductGrantedFeeDecorator{ ak: ak, k: k, diff --git a/x/feegrant/ante/fee_test.go b/x/feegrant/ante/fee_test.go index de682db87816..de1773f0c4c3 100644 --- a/x/feegrant/ante/fee_test.go +++ b/x/feegrant/ante/fee_test.go @@ -70,27 +70,33 @@ func TestDeductFeesNoDelegation(t *testing.T) { app.FeeGrantKeeper.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr2, Grantee: addr3, - Allowance: &types.BasicFeeAllowance{ + Allowance: &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 500)), }, + }, + }, }) // Set low grant from addr2 to addr4 (keeper will reject) app.FeeGrantKeeper.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr2, Grantee: addr4, - Allowance: &types.BasicFeeAllowance{ + Allowance: &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 20)), }, + }, + }, }) // Set grant from addr1 to addr4 (cannot cover this ) app.FeeGrantKeeper.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ Granter: addr2, Grantee: addr3, - Allowance: &types.BasicFeeAllowance{ + Allowance: &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 500)), }, + }, + }, }) cases := map[string]struct { diff --git a/x/feegrant/genesis.go b/x/feegrant/genesis.go index 8d5b53e4bbb4..d32598a6e167 100644 --- a/x/feegrant/genesis.go +++ b/x/feegrant/genesis.go @@ -1,6 +1,8 @@ package feegrant -import sdk "github.com/cosmos/cosmos-sdk/types" +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) // GenesisState contains a set of fee allowances, persisted from the store type GenesisState []FeeAllowanceGrant @@ -8,7 +10,7 @@ type GenesisState []FeeAllowanceGrant // ValidateBasic ensures all grants in the genesis state are valid func (g GenesisState) ValidateBasic() error { for _, f := range g { - err := f.ValidateBasic() + err := f.GetFeeGrant().ValidateBasic() if err != nil { return err } diff --git a/x/feegrant/handler.go b/x/feegrant/handler.go index dd513898594c..40d483a41790 100644 --- a/x/feegrant/handler.go +++ b/x/feegrant/handler.go @@ -23,8 +23,9 @@ func NewHandler(k Keeper) sdk.Handler { } func handleGrantFee(ctx sdk.Context, k Keeper, msg MsgGrantFeeAllowance) (*sdk.Result, error) { - grant := FeeAllowanceGrant(msg) - k.GrantFeeAllowance(ctx, grant) + feegrant := FeeAllowanceGrant(msg) + + k.GrantFeeAllowance(ctx, feegrant) return &sdk.Result{Events: ctx.EventManager().Events()}, nil } diff --git a/x/feegrant/keeper/keeper.go b/x/feegrant/keeper/keeper.go index 263b5faabadb..d3fb815f06a5 100644 --- a/x/feegrant/keeper/keeper.go +++ b/x/feegrant/keeper/keeper.go @@ -8,19 +8,18 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/feegrant/exported" "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) // Keeper manages state of all fee grants, as well as calculating approval. // It must have a codec with all available allowances registered. type Keeper struct { - cdc *codec.Codec + cdc codec.Marshaler storeKey sdk.StoreKey } // NewKeeper creates a fee grant Keeper -func NewKeeper(cdc *codec.Codec, storeKey sdk.StoreKey) Keeper { +func NewKeeper(cdc codec.Marshaler, storeKey sdk.StoreKey) Keeper { return Keeper{cdc: cdc, storeKey: storeKey} } @@ -33,8 +32,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { func (k Keeper) GrantFeeAllowance(ctx sdk.Context, grant types.FeeAllowanceGrant) { store := ctx.KVStore(k.storeKey) key := types.FeeAllowanceKey(grant.Granter, grant.Grantee) - bz := k.cdc.MustMarshalBinaryBare(grant) - + bz := k.cdc.MustMarshalBinaryBare(&grant) store.Set(key, bz) ctx.EventManager().EmitEvent( @@ -65,7 +63,7 @@ func (k Keeper) RevokeFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddr // GetFeeAllowance returns the allowance between the granter and grantee. // If there is none, it returns nil, nil. // Returns an error on parsing issues -func (k Keeper) GetFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddress) exported.FeeAllowance { +func (k Keeper) GetFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddress) *types.FeeAllowance { grant, found := k.GetFeeGrant(ctx, granter, grantee) if !found { return nil @@ -83,10 +81,10 @@ func (k Keeper) GetFeeGrant(ctx sdk.Context, granter sdk.AccAddress, grantee sdk return types.FeeAllowanceGrant{}, false } - var grant types.FeeAllowanceGrant - k.cdc.MustUnmarshalBinaryBare(bz, &grant) + var feegrant types.FeeAllowanceGrant + k.cdc.MustUnmarshalBinaryBare(bz, &feegrant) - return grant, true + return feegrant, true } // IterateAllGranteeFeeAllowances iterates over all the grants from anyone to the given grantee. @@ -100,14 +98,11 @@ func (k Keeper) IterateAllGranteeFeeAllowances(ctx sdk.Context, grantee sdk.AccA stop := false for ; iter.Valid() && !stop; iter.Next() { bz := iter.Value() - var grant types.FeeAllowanceGrant - err := k.cdc.UnmarshalBinaryBare(bz, &grant) - if err != nil { - return err - } + var feeGrant types.FeeAllowanceGrant + k.cdc.MustUnmarshalBinaryBare(bz, &feeGrant) - stop = cb(grant) + stop = cb(feeGrant) } return nil @@ -124,14 +119,10 @@ func (k Keeper) IterateAllFeeAllowances(ctx sdk.Context, cb func(types.FeeAllowa stop := false for ; iter.Valid() && !stop; iter.Next() { bz := iter.Value() - var grant types.FeeAllowanceGrant - - err := k.cdc.UnmarshalBinaryBare(bz, &grant) - if err != nil { - return err - } + var feeGrant types.FeeAllowanceGrant + k.cdc.MustUnmarshalBinaryBare(bz, &feeGrant) - stop = cb(grant) + stop = cb(feeGrant) } return nil @@ -140,11 +131,11 @@ func (k Keeper) IterateAllFeeAllowances(ctx sdk.Context, cb func(types.FeeAllowa // UseGrantedFees will try to pay the given fee from the granter's account as requested by the grantee func (k Keeper) UseGrantedFees(ctx sdk.Context, granter, grantee sdk.AccAddress, fee sdk.Coins) error { grant, found := k.GetFeeGrant(ctx, granter, grantee) - if !found || grant.Allowance == nil { + if !found || grant.GetFeeGrant() == nil { return sdkerrors.Wrapf(types.ErrNoAllowance, "grant missing") } - remove, err := grant.Allowance.Accept(fee, ctx.BlockTime(), ctx.BlockHeight()) + remove, err := grant.GetFeeGrant().Accept(fee, ctx.BlockTime(), ctx.BlockHeight()) if err == nil { ctx.EventManager().EmitEvent( sdk.NewEvent( diff --git a/x/feegrant/keeper/keeper_test.go b/x/feegrant/keeper/keeper_test.go index 754266ba9768..e579922999b6 100644 --- a/x/feegrant/keeper/keeper_test.go +++ b/x/feegrant/keeper/keeper_test.go @@ -10,9 +10,9 @@ import ( dbm "github.com/tendermint/tm-db" codec "github.com/cosmos/cosmos-sdk/codec" + codecstd "github.com/cosmos/cosmos-sdk/codec/std" "github.com/cosmos/cosmos-sdk/store" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/feegrant/exported" "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) @@ -41,14 +41,14 @@ func (suite *KeeperTestSuite) SetupTest() { types.RegisterCodec(cdc) sdk.RegisterCodec(cdc) suite.cdc = cdc - + appCodec := codecstd.NewAppCodec(cdc) delCapKey := sdk.NewKVStoreKey("delKey") ms := store.NewCommitMultiStore(db) ms.MountStoreWithDB(delCapKey, sdk.StoreTypeIAVL, db) ms.LoadLatestVersion() - suite.dk = keeper.NewKeeper(cdc, delCapKey) + suite.dk = keeper.NewKeeper(appCodec, delCapKey) suite.ctx = sdk.NewContext(ms, abci.Header{ChainID: "test-chain-id", Time: time.Now().UTC(), Height: 1234}, false, log.NewNopLogger()) suite.addr = mustAddr("cosmos157ez5zlaq0scm9aycwphhqhmg3kws4qusmekll") @@ -73,40 +73,58 @@ func (suite *KeeperTestSuite) TestKeeperCrud() { // some helpers atom := sdk.NewCoins(sdk.NewInt64Coin("atom", 555)) eth := sdk.NewCoins(sdk.NewInt64Coin("eth", 123)) - basic := types.BasicFeeAllowance{ + basic := &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ SpendLimit: atom, Expiration: types.ExpiresAtHeight(334455), + }, + }, } - basic2 := types.BasicFeeAllowance{ + basic2 := &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ SpendLimit: eth, Expiration: types.ExpiresAtHeight(172436), + }, + }, } // let's set up some initial state here k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: suite.addr, Grantee: suite.addr2, Allowance: &basic, + Granter: suite.addr, + Grantee: suite.addr2, + Allowance: basic, }) k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: suite.addr, Grantee: suite.addr3, Allowance: &basic2, + Granter: suite.addr, + Grantee: suite.addr3, + Allowance: basic2, }) k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: suite.addr2, Grantee: suite.addr3, Allowance: &basic, + Granter: suite.addr2, + Grantee: suite.addr3, + Allowance: basic, }) k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: suite.addr2, Grantee: suite.addr4, Allowance: &basic, + Granter: suite.addr2, + Grantee: suite.addr4, + Allowance: basic, }) k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: suite.addr4, Grantee: suite.addr, Allowance: &basic2, + Granter: suite.addr4, + Grantee: suite.addr, + Allowance: basic2, }) // remove some, overwrite other k.RevokeFeeAllowance(ctx, suite.addr, suite.addr2) k.RevokeFeeAllowance(ctx, suite.addr, suite.addr3) k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: suite.addr, Grantee: suite.addr3, Allowance: &basic, + Granter: suite.addr, + Grantee: suite.addr3, + Allowance: basic, }) k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: suite.addr2, Grantee: suite.addr3, Allowance: &basic2, + Granter: suite.addr2, + Grantee: suite.addr3, + Allowance: basic2, }) // end state: @@ -118,7 +136,7 @@ func (suite *KeeperTestSuite) TestKeeperCrud() { cases := map[string]struct { grantee sdk.AccAddress granter sdk.AccAddress - allowance exported.FeeAllowance + allowance *types.FeeAllowance }{ "addr revoked": { granter: suite.addr, @@ -127,7 +145,7 @@ func (suite *KeeperTestSuite) TestKeeperCrud() { "addr revoked and added": { granter: suite.addr, grantee: suite.addr3, - allowance: &basic, + allowance: basic, }, "addr never there": { granter: suite.addr, @@ -136,7 +154,7 @@ func (suite *KeeperTestSuite) TestKeeperCrud() { "addr modified": { granter: suite.addr2, grantee: suite.addr3, - allowance: &basic2, + allowance: basic2, }, } @@ -162,13 +180,13 @@ func (suite *KeeperTestSuite) TestKeeperCrud() { }, "addr has one": { grantee: suite.addr, - grants: []types.FeeAllowanceGrant{{Granter: suite.addr4, Grantee: suite.addr, Allowance: &basic2}}, + grants: []types.FeeAllowanceGrant{{Granter: suite.addr4, Grantee: suite.addr, Allowance: basic2}}, }, "addr3 has two": { grantee: suite.addr3, grants: []types.FeeAllowanceGrant{ - {Granter: suite.addr, Grantee: suite.addr3, Allowance: &basic}, - {Granter: suite.addr2, Grantee: suite.addr3, Allowance: &basic2}, + {Granter: suite.addr, Grantee: suite.addr3, Allowance: basic}, + {Granter: suite.addr2, Grantee: suite.addr3, Allowance: basic2}, }, }, } @@ -194,21 +212,28 @@ func (suite *KeeperTestSuite) TestUseGrantedFee() { // some helpers atom := sdk.NewCoins(sdk.NewInt64Coin("atom", 555)) eth := sdk.NewCoins(sdk.NewInt64Coin("eth", 123)) - future := types.BasicFeeAllowance{ + future := &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ SpendLimit: atom, Expiration: types.ExpiresAtHeight(5678), + }, + }, } - expired := types.BasicFeeAllowance{ + + expired := &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ SpendLimit: eth, Expiration: types.ExpiresAtHeight(55), + }, + }, } // for testing limits of the contract hugeAtom := sdk.NewCoins(sdk.NewInt64Coin("atom", 9999)) smallAtom := sdk.NewCoins(sdk.NewInt64Coin("atom", 1)) - futureAfterSmall := types.BasicFeeAllowance{ + futureAfterSmall := &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 554)), Expiration: types.ExpiresAtHeight(5678), + }, + }, } // then lots of queries @@ -217,7 +242,7 @@ func (suite *KeeperTestSuite) TestUseGrantedFee() { granter sdk.AccAddress fee sdk.Coins allowed bool - final exported.FeeAllowance + final *types.FeeAllowance }{ "use entire pot": { granter: suite.addr, @@ -238,14 +263,14 @@ func (suite *KeeperTestSuite) TestUseGrantedFee() { grantee: suite.addr2, fee: hugeAtom, allowed: false, - final: &future, + final: future, }, "use a little": { granter: suite.addr, grantee: suite.addr2, fee: smallAtom, allowed: true, - final: &futureAfterSmall, + final: futureAfterSmall, }, } @@ -255,11 +280,16 @@ func (suite *KeeperTestSuite) TestUseGrantedFee() { // let's set up some initial state here // addr -> addr2 (future) // addr -> addr3 (expired) + k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: suite.addr, Grantee: suite.addr2, Allowance: &future, + Granter: suite.addr, + Grantee: suite.addr2, + Allowance: future, }) k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: suite.addr, Grantee: suite.addr3, Allowance: &expired, + Granter: suite.addr, + Grantee: suite.addr3, + Allowance: expired, }) err := k.UseGrantedFees(ctx, tc.granter, tc.grantee, tc.fee) @@ -270,6 +300,7 @@ func (suite *KeeperTestSuite) TestUseGrantedFee() { } loaded := k.GetFeeAllowance(ctx, tc.granter, tc.grantee) + suite.Equal(tc.final, loaded) }) } diff --git a/x/feegrant/keeper/querier.go b/x/feegrant/keeper/querier.go index 1ebe5dfdfe6b..41b0ab7970c4 100644 --- a/x/feegrant/keeper/querier.go +++ b/x/feegrant/keeper/querier.go @@ -3,6 +3,7 @@ package keeper import ( abci "github.com/tendermint/tendermint/abci/types" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/feegrant/types" @@ -52,7 +53,7 @@ func queryGetFeeAllowances(ctx sdk.Context, args []string, keeper Keeper) ([]byt return []byte("[]"), nil } - bz, err := keeper.cdc.MarshalJSON(grants) + bz, err := codec.MarshalJSONIndent(keeper.cdc, grants) if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) } diff --git a/x/feegrant/keeper/querier_test.go b/x/feegrant/keeper/querier_test.go index 8a3e21ad423d..3efd772b33f7 100644 --- a/x/feegrant/keeper/querier_test.go +++ b/x/feegrant/keeper/querier_test.go @@ -20,20 +20,20 @@ func (suite *KeeperTestSuite) TestQuery() { grant1 := types.FeeAllowanceGrant{ Granter: suite.addr, Grantee: suite.addr3, - Allowance: &types.BasicFeeAllowance{ + Allowance: &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 555)), Expiration: types.ExpiresAtHeight(334455), }, + }, + }, } grant2 := types.FeeAllowanceGrant{ Granter: suite.addr2, Grantee: suite.addr3, - Allowance: &types.BasicFeeAllowance{ + Allowance: &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("eth", 123)), - Expiration: types.ExpiresAtHeight(334455), - }, + Expiration: types.ExpiresAtHeight(334455)}}}, } - // let's set up some initial state here k.GrantFeeAllowance(ctx, grant1) k.GrantFeeAllowance(ctx, grant2) diff --git a/x/feegrant/types/basic_fee.go b/x/feegrant/types/basic_fee.go index bc39194421f1..52c079ca64ee 100644 --- a/x/feegrant/types/basic_fee.go +++ b/x/feegrant/types/basic_fee.go @@ -5,21 +5,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/feegrant/exported" ) -// BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens -// that optionally expires. The delegatee can use up to SpendLimit to cover fees. -type BasicFeeAllowance struct { - // SpendLimit is the maximum amount of tokens to be spent - SpendLimit sdk.Coins - - // Expiration specifies an optional time or height when this allowance expires. - // If Expiration.IsZero() then it never expires - Expiration ExpiresAt -} - -var _ exported.FeeAllowance = (*BasicFeeAllowance)(nil) +var _ FeeAllowanceI = (*BasicFeeAllowance)(nil) // Accept can use fee payment requested as well as timestamp/height of the current block // to determine whether or not to process this. This is checked in @@ -48,7 +36,7 @@ func (a *BasicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockHeig // PrepareForExport will adjust the expiration based on export time. In particular, // it will subtract the dumpHeight from any height-based expiration to ensure that // the elapsed number of blocks this allowance is valid for is fixed. -func (a *BasicFeeAllowance) PrepareForExport(dumpTime time.Time, dumpHeight int64) exported.FeeAllowance { +func (a *BasicFeeAllowance) PrepareForExport(dumpTime time.Time, dumpHeight int64) FeeAllowanceI { return &BasicFeeAllowance{ SpendLimit: a.SpendLimit, Expiration: a.Expiration.PrepareForExport(dumpTime, dumpHeight), diff --git a/x/feegrant/types/basic_fee_test.go b/x/feegrant/types/basic_fee_test.go index 71e640166a90..887fa5fbf3c5 100644 --- a/x/feegrant/types/basic_fee_test.go +++ b/x/feegrant/types/basic_fee_test.go @@ -16,7 +16,7 @@ func TestBasicFeeValidAllow(t *testing.T) { leftAtom := sdk.NewCoins(sdk.NewInt64Coin("atom", 512)) cases := map[string]struct { - allow BasicFeeAllowance + allow *BasicFeeAllowance // all other checks are ignored if valid=false fee sdk.Coins blockTime time.Time @@ -27,11 +27,11 @@ func TestBasicFeeValidAllow(t *testing.T) { remains sdk.Coins }{ "empty": { - allow: BasicFeeAllowance{}, + allow: &BasicFeeAllowance{}, valid: false, }, "small fee": { - allow: BasicFeeAllowance{ + allow: &BasicFeeAllowance{ SpendLimit: atom, }, valid: true, @@ -41,7 +41,7 @@ func TestBasicFeeValidAllow(t *testing.T) { remains: leftAtom, }, "all fee": { - allow: BasicFeeAllowance{ + allow: &BasicFeeAllowance{ SpendLimit: smallAtom, }, valid: true, @@ -50,7 +50,7 @@ func TestBasicFeeValidAllow(t *testing.T) { remove: true, }, "wrong fee": { - allow: BasicFeeAllowance{ + allow: &BasicFeeAllowance{ SpendLimit: smallAtom, }, valid: true, @@ -58,7 +58,7 @@ func TestBasicFeeValidAllow(t *testing.T) { accept: false, }, "non-expired": { - allow: BasicFeeAllowance{ + allow: &BasicFeeAllowance{ SpendLimit: atom, Expiration: ExpiresAtHeight(100), }, @@ -70,7 +70,7 @@ func TestBasicFeeValidAllow(t *testing.T) { remains: leftAtom, }, "expired": { - allow: BasicFeeAllowance{ + allow: &BasicFeeAllowance{ SpendLimit: atom, Expiration: ExpiresAtHeight(100), }, diff --git a/x/feegrant/types/codec.go b/x/feegrant/types/codec.go index 541bf6d325a6..a051889d6b2d 100644 --- a/x/feegrant/types/codec.go +++ b/x/feegrant/types/codec.go @@ -2,24 +2,26 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/x/feegrant/exported" ) // RegisterCodec registers the account types and interface func RegisterCodec(cdc *codec.Codec) { - cdc.RegisterInterface((*exported.FeeAllowance)(nil), nil) + cdc.RegisterInterface((*isFeeAllowance_Sum)(nil), nil) + cdc.RegisterInterface((*FeeAllowanceI)(nil), nil) + cdc.RegisterConcrete(&FeeAllowance_BasicFeeAllowance{}, "cosmos-sdk/ProtoBasicFeeAllowance", nil) cdc.RegisterConcrete(&BasicFeeAllowance{}, "cosmos-sdk/BasicFeeAllowance", nil) cdc.RegisterConcrete(&PeriodicFeeAllowance{}, "cosmos-sdk/PeriodicFeeAllowance", nil) - cdc.RegisterConcrete(FeeGrantTx{}, "cosmos-sdk/FeeGrantTx", nil) } -// ModuleCdc generic sealed codec to be used throughout module -var ModuleCdc *codec.Codec +var ( + amino = codec.New() + + ModuleCdc = codec.NewHybridCodec(amino) +) func init() { - cdc := codec.New() - RegisterCodec(cdc) - codec.RegisterCrypto(cdc) - ModuleCdc = cdc.Seal() + RegisterCodec(amino) + codec.RegisterCrypto(amino) + amino.Seal() } diff --git a/x/feegrant/exported/external.go b/x/feegrant/types/expected_keepers.go similarity index 97% rename from x/feegrant/exported/external.go rename to x/feegrant/types/expected_keepers.go index 1713ecb500f3..e60e5ad08171 100644 --- a/x/feegrant/exported/external.go +++ b/x/feegrant/types/expected_keepers.go @@ -1,4 +1,4 @@ -package exported +package types import ( sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/feegrant/types/expiration.go b/x/feegrant/types/expiration.go index 7c552f02e8d9..2bfdc3e412d0 100644 --- a/x/feegrant/types/expiration.go +++ b/x/feegrant/types/expiration.go @@ -6,13 +6,6 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -// ExpiresAt is a point in time where something expires. -// It may be *either* block time or block height -type ExpiresAt struct { - Time time.Time `json:"time" yaml:"time"` - Height int64 `json:"height" yaml:"height"` -} - // ExpiresAtTime creates an expiration at the given time func ExpiresAtTime(t time.Time) ExpiresAt { return ExpiresAt{Time: t} @@ -102,13 +95,6 @@ func (e ExpiresAt) PrepareForExport(dumpTime time.Time, dumpHeight int64) Expire return e } -// Duration is a repeating unit of either clock time or number of blocks. -// This is designed to be added to an ExpiresAt struct. -type Duration struct { - Clock time.Duration `json:"clock" yaml:"clock"` - Block int64 `json:"block" yaml:"block"` -} - // ClockDuration creates an Duration by clock time func ClockDuration(d time.Duration) Duration { return Duration{Clock: d} diff --git a/x/feegrant/types/expiration_test.go b/x/feegrant/types/expiration_test.go index ab475fdf6312..6cab366eabdc 100644 --- a/x/feegrant/types/expiration_test.go +++ b/x/feegrant/types/expiration_test.go @@ -15,20 +15,20 @@ func TestExpiresAt(t *testing.T) { example ExpiresAt valid bool zero bool - before *ExpiresAt - after *ExpiresAt + before ExpiresAt + after ExpiresAt }{ "basic": { example: ExpiresAtHeight(100), valid: true, - before: &ExpiresAt{Height: 50, Time: now}, - after: &ExpiresAt{Height: 122, Time: now}, + before: ExpiresAt{Height: 50, Time: now}, + after: ExpiresAt{Height: 122, Time: now}, }, "zero": { example: ExpiresAt{}, zero: true, valid: true, - before: &ExpiresAt{Height: 1}, + before: ExpiresAt{Height: 1}, }, "double": { example: ExpiresAt{Height: 100, Time: now}, @@ -37,14 +37,14 @@ func TestExpiresAt(t *testing.T) { "match height": { example: ExpiresAtHeight(1000), valid: true, - before: &ExpiresAt{Height: 999, Time: now}, - after: &ExpiresAt{Height: 1000, Time: now}, + before: ExpiresAt{Height: 999, Time: now}, + after: ExpiresAt{Height: 1000, Time: now}, }, "match time": { example: ExpiresAtTime(now), valid: true, - before: &ExpiresAt{Height: 43, Time: now.Add(-1 * time.Second)}, - after: &ExpiresAt{Height: 76, Time: now}, + before: ExpiresAt{Height: 43, Time: now.Add(-1 * time.Second)}, + after: ExpiresAt{Height: 76, Time: now}, }, } @@ -59,10 +59,10 @@ func TestExpiresAt(t *testing.T) { } require.NoError(t, err) - if tc.before != nil { + if !tc.before.IsZero() { assert.Equal(t, false, tc.example.IsExpired(tc.before.Time, tc.before.Height)) } - if tc.after != nil { + if !tc.after.IsZero() { assert.Equal(t, true, tc.example.IsExpired(tc.after.Time, tc.after.Height)) } }) diff --git a/x/feegrant/exported/fees.go b/x/feegrant/types/fees.go similarity index 96% rename from x/feegrant/exported/fees.go rename to x/feegrant/types/fees.go index 7f8a55ab8acf..cc526628f5f9 100644 --- a/x/feegrant/exported/fees.go +++ b/x/feegrant/types/fees.go @@ -1,4 +1,4 @@ -package exported +package types import ( "time" @@ -8,7 +8,7 @@ import ( // FeeAllowance implementations are tied to a given fee delegator and delegatee, // and are used to enforce fee grant limits. -type FeeAllowance interface { +type FeeAllowanceI interface { // Accept can use fee payment requested as well as timestamp/height of the current block // to determine whether or not to process this. This is checked in // Keeper.UseGrantedFees and the return values should match how it is handled there. @@ -24,7 +24,7 @@ type FeeAllowance interface { // If we export fee allowances the timing info will be quite off (eg. go from height 100000 to 0) // This callback allows the fee-allowance to change it's state and return a copy that is adjusted // given the time and height of the actual dump (may safely return self if no changes needed) - PrepareForExport(dumpTime time.Time, dumpHeight int64) FeeAllowance + PrepareForExport(dumpTime time.Time, dumpHeight int64) FeeAllowanceI // ValidateBasic should evaluate this FeeAllowance for internal consistency. // Don't allow negative amounts, or negative periods for example. diff --git a/x/feegrant/types/grant.go b/x/feegrant/types/grant.go index 08c872b24ca7..a3c6b142ef49 100644 --- a/x/feegrant/types/grant.go +++ b/x/feegrant/types/grant.go @@ -3,19 +3,11 @@ package types import ( "time" - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/feegrant/exported" ) -// FeeAllowanceGrant is stored in the KVStore to record a grant with full context -type FeeAllowanceGrant struct { - Granter sdk.AccAddress `json:"granter" yaml:"granter"` - Grantee sdk.AccAddress `json:"grantee" yaml:"grantee"` - Allowance exported.FeeAllowance `json:"allowance" yaml:"allowance"` -} - -// ValidateBasic ensures that +// ValidateBasic performs basic validation on +// FeeAllowanceGrant func (a FeeAllowanceGrant) ValidateBasic() error { if a.Granter.Empty() { return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "missing granter address") @@ -27,12 +19,19 @@ func (a FeeAllowanceGrant) ValidateBasic() error { return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "cannot self-grant fee authorization") } - return a.Allowance.ValidateBasic() + return a.GetFeeGrant().ValidateBasic() } -// PrepareForExport will make all needed changes to the allowance to prepare to be +func (a FeeAllowanceGrant) GetFeeGrant() FeeAllowanceI { + return a.Allowance.GetFeeAllowanceI() +} + +// PrepareForExport will m ake all needed changes to the allowance to prepare to be // re-imported at height 0, and return a copy of this grant. func (a FeeAllowanceGrant) PrepareForExport(dumpTime time.Time, dumpHeight int64) FeeAllowanceGrant { - a.Allowance = a.Allowance.PrepareForExport(dumpTime, dumpHeight) + err := a.GetFeeGrant().PrepareForExport(dumpTime, dumpHeight) + if err != nil { + return FeeAllowanceGrant{} + } return a } diff --git a/x/feegrant/types/grant_test.go b/x/feegrant/types/grant_test.go index 3a07559e27e1..a82b15ecd9f1 100644 --- a/x/feegrant/types/grant_test.go +++ b/x/feegrant/types/grant_test.go @@ -27,47 +27,57 @@ func TestGrant(t *testing.T) { grant: FeeAllowanceGrant{ Grantee: addr, Granter: addr2, - Allowance: &BasicFeeAllowance{ + Allowance: &FeeAllowance{Sum: &FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &BasicFeeAllowance{ SpendLimit: atom, Expiration: ExpiresAtHeight(100), }, + }, + }, }, valid: true, }, "no grantee": { grant: FeeAllowanceGrant{ Granter: addr2, - Allowance: &BasicFeeAllowance{ + Allowance: &FeeAllowance{Sum: &FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &BasicFeeAllowance{ SpendLimit: atom, Expiration: ExpiresAtHeight(100), }, + }, + }, }, }, "no granter": { grant: FeeAllowanceGrant{ Grantee: addr2, - Allowance: &BasicFeeAllowance{ + Allowance: &FeeAllowance{Sum: &FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &BasicFeeAllowance{ SpendLimit: atom, Expiration: ExpiresAtHeight(100), }, + }, + }, }, }, "self-grant": { grant: FeeAllowanceGrant{ Grantee: addr2, Granter: addr2, - Allowance: &BasicFeeAllowance{ + Allowance: &FeeAllowance{Sum: &FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &BasicFeeAllowance{ SpendLimit: atom, Expiration: ExpiresAtHeight(100), }, + }, + }, }, }, "bad allowance": { grant: FeeAllowanceGrant{ Grantee: addr, Granter: addr2, - Allowance: &BasicFeeAllowance{ - Expiration: ExpiresAtHeight(100), + Allowance: &FeeAllowance{Sum: &FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &BasicFeeAllowance{ + Expiration: ExpiresAtHeight(0), + }, + }, }, }, }, diff --git a/x/feegrant/types/msgs.go b/x/feegrant/types/msgs.go index 54e4c374efff..3f7f1690cd36 100644 --- a/x/feegrant/types/msgs.go +++ b/x/feegrant/types/msgs.go @@ -3,20 +3,18 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/feegrant/exported" ) -// MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance -// of fees from the account of Granter. -// If there was already an existing grant, this overwrites it. -type MsgGrantFeeAllowance struct { - Granter sdk.AccAddress `json:"granter" yaml:"granter"` - Grantee sdk.AccAddress `json:"grantee" yaml:"grantee"` - Allowance exported.FeeAllowance `json:"allowance" yaml:"allowance"` +func (msg MsgGrantFeeAllowance) NewMsgGrantFeeAllowance(feeAllowance *FeeAllowance, granter, grantee sdk.AccAddress) (MsgGrantFeeAllowance, error) { + return MsgGrantFeeAllowance{ + Granter: granter, + Grantee: grantee, + Allowance: feeAllowance, + }, nil } -func NewMsgGrantFeeAllowance(granter sdk.AccAddress, grantee sdk.AccAddress, allowance exported.FeeAllowance) MsgGrantFeeAllowance { - return MsgGrantFeeAllowance{Granter: granter, Grantee: grantee, Allowance: allowance} +func (msg MsgGrantFeeAllowance) GetFeeGrant() FeeAllowanceI { + return msg.Allowance.GetFeeAllowanceI() } func (msg MsgGrantFeeAllowance) Route() string { @@ -35,7 +33,7 @@ func (msg MsgGrantFeeAllowance) ValidateBasic() error { return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "missing grantee address") } - return msg.Allowance.ValidateBasic() + return nil } func (msg MsgGrantFeeAllowance) GetSignBytes() []byte { @@ -46,12 +44,6 @@ func (msg MsgGrantFeeAllowance) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Granter} } -// MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee. -type MsgRevokeFeeAllowance struct { - Granter sdk.AccAddress `json:"granter" yaml:"granter"` - Grantee sdk.AccAddress `json:"grantee" yaml:"granter"` -} - func NewMsgRevokeFeeAllowance(granter sdk.AccAddress, grantee sdk.AccAddress) MsgRevokeFeeAllowance { return MsgRevokeFeeAllowance{Granter: granter, Grantee: grantee} } diff --git a/x/feegrant/types/periodic_fee.go b/x/feegrant/types/periodic_fee.go index 9716dbf3a7cc..8108a70f4402 100644 --- a/x/feegrant/types/periodic_fee.go +++ b/x/feegrant/types/periodic_fee.go @@ -5,30 +5,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/feegrant/exported" ) -// PeriodicFeeAllowance extends FeeAllowance to allow for both a maximum cap, -// as well as a limit per time period. -type PeriodicFeeAllowance struct { - // Basic contains the absolute limits over all time. - // These limit (total and expiration) are enforced in addition to the - // periodic limits defined below (which renew every period) - Basic BasicFeeAllowance - - // Period is the duration of one period - Period Duration - // PeriodSpendLimit is the maximum amount of tokens to be spent in this period - PeriodSpendLimit sdk.Coins - - // PeriodCanSpend is how much is available until PeriodReset - PeriodCanSpend sdk.Coins - - // PeriodRest is when the PeriodCanSpend is updated - PeriodReset ExpiresAt -} - -var _ exported.FeeAllowance = (*PeriodicFeeAllowance)(nil) +var _ FeeAllowanceI = (*PeriodicFeeAllowance)(nil) // Accept can use fee payment requested as well as timestamp/height of the current block // to determine whether or not to process this. This is checked in @@ -90,7 +69,7 @@ func (a *PeriodicFeeAllowance) TryResetPeriod(blockTime time.Time, blockHeight i // it will subtract the dumpHeight from any height-based expiration to ensure that // the elapsed number of blocks this allowance is valid for is fixed. // (For PeriodReset and Basic.Expiration) -func (a *PeriodicFeeAllowance) PrepareForExport(dumpTime time.Time, dumpHeight int64) exported.FeeAllowance { +func (a *PeriodicFeeAllowance) PrepareForExport(dumpTime time.Time, dumpHeight int64) FeeAllowanceI { return &PeriodicFeeAllowance{ Basic: BasicFeeAllowance{ SpendLimit: a.Basic.SpendLimit, diff --git a/x/feegrant/types/types.pb.go b/x/feegrant/types/types.pb.go new file mode 100644 index 000000000000..79c6e9672521 --- /dev/null +++ b/x/feegrant/types/types.pb.go @@ -0,0 +1,2531 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: x/feegrant/types/types.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + _ "github.com/golang/protobuf/ptypes/timestamp" + _ "github.com/regen-network/cosmos-proto" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// 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 + +// FeeAllowance defines the application-level fee allowance to be used in +// feegrant module +type FeeAllowance struct { + // sum defines a set of all acceptable concrete feeallowance implementations. + // + // Types that are valid to be assigned to Sum: + // *FeeAllowance_BasicFeeAllowance + // *FeeAllowance_PeriodicFeeAllowance + Sum isFeeAllowance_Sum `protobuf_oneof:"sum"` +} + +func (m *FeeAllowance) Reset() { *m = FeeAllowance{} } +func (m *FeeAllowance) String() string { return proto.CompactTextString(m) } +func (*FeeAllowance) ProtoMessage() {} +func (*FeeAllowance) Descriptor() ([]byte, []int) { + return fileDescriptor_86c534389d2c5768, []int{0} +} +func (m *FeeAllowance) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FeeAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FeeAllowance.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 *FeeAllowance) XXX_Merge(src proto.Message) { + xxx_messageInfo_FeeAllowance.Merge(m, src) +} +func (m *FeeAllowance) XXX_Size() int { + return m.Size() +} +func (m *FeeAllowance) XXX_DiscardUnknown() { + xxx_messageInfo_FeeAllowance.DiscardUnknown(m) +} + +var xxx_messageInfo_FeeAllowance proto.InternalMessageInfo + +type isFeeAllowance_Sum interface { + isFeeAllowance_Sum() + Equal(interface{}) bool + MarshalTo([]byte) (int, error) + Size() int +} + +type FeeAllowance_BasicFeeAllowance struct { + BasicFeeAllowance *BasicFeeAllowance `protobuf:"bytes,1,opt,name=basic_fee_allowance,json=basicFeeAllowance,proto3,oneof" json:"basic_fee_allowance,omitempty"` +} +type FeeAllowance_PeriodicFeeAllowance struct { + PeriodicFeeAllowance *PeriodicFeeAllowance `protobuf:"bytes,2,opt,name=periodic_fee_allowance,json=periodicFeeAllowance,proto3,oneof" json:"periodic_fee_allowance,omitempty"` +} + +func (*FeeAllowance_BasicFeeAllowance) isFeeAllowance_Sum() {} +func (*FeeAllowance_PeriodicFeeAllowance) isFeeAllowance_Sum() {} + +func (m *FeeAllowance) GetSum() isFeeAllowance_Sum { + if m != nil { + return m.Sum + } + return nil +} + +func (m *FeeAllowance) GetBasicFeeAllowance() *BasicFeeAllowance { + if x, ok := m.GetSum().(*FeeAllowance_BasicFeeAllowance); ok { + return x.BasicFeeAllowance + } + return nil +} + +func (m *FeeAllowance) GetPeriodicFeeAllowance() *PeriodicFeeAllowance { + if x, ok := m.GetSum().(*FeeAllowance_PeriodicFeeAllowance); ok { + return x.PeriodicFeeAllowance + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*FeeAllowance) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*FeeAllowance_BasicFeeAllowance)(nil), + (*FeeAllowance_PeriodicFeeAllowance)(nil), + } +} + +// MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance +// of fees from the account of Granter. +type MsgGrantFeeAllowance struct { + Granter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=granter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"granter,omitempty"` + Grantee github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=grantee,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"grantee,omitempty"` + Allowance *FeeAllowance `protobuf:"bytes,3,opt,name=allowance,proto3" json:"allowance,omitempty"` +} + +func (m *MsgGrantFeeAllowance) Reset() { *m = MsgGrantFeeAllowance{} } +func (m *MsgGrantFeeAllowance) String() string { return proto.CompactTextString(m) } +func (*MsgGrantFeeAllowance) ProtoMessage() {} +func (*MsgGrantFeeAllowance) Descriptor() ([]byte, []int) { + return fileDescriptor_86c534389d2c5768, []int{1} +} +func (m *MsgGrantFeeAllowance) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgGrantFeeAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgGrantFeeAllowance.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 *MsgGrantFeeAllowance) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgGrantFeeAllowance.Merge(m, src) +} +func (m *MsgGrantFeeAllowance) XXX_Size() int { + return m.Size() +} +func (m *MsgGrantFeeAllowance) XXX_DiscardUnknown() { + xxx_messageInfo_MsgGrantFeeAllowance.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgGrantFeeAllowance proto.InternalMessageInfo + +// MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee. +type MsgRevokeFeeAllowance struct { + Granter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=granter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"granter,omitempty"` + Grantee github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=grantee,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"grantee,omitempty"` +} + +func (m *MsgRevokeFeeAllowance) Reset() { *m = MsgRevokeFeeAllowance{} } +func (m *MsgRevokeFeeAllowance) String() string { return proto.CompactTextString(m) } +func (*MsgRevokeFeeAllowance) ProtoMessage() {} +func (*MsgRevokeFeeAllowance) Descriptor() ([]byte, []int) { + return fileDescriptor_86c534389d2c5768, []int{2} +} +func (m *MsgRevokeFeeAllowance) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRevokeFeeAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRevokeFeeAllowance.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 *MsgRevokeFeeAllowance) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRevokeFeeAllowance.Merge(m, src) +} +func (m *MsgRevokeFeeAllowance) XXX_Size() int { + return m.Size() +} +func (m *MsgRevokeFeeAllowance) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRevokeFeeAllowance.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRevokeFeeAllowance proto.InternalMessageInfo + +func (m *MsgRevokeFeeAllowance) GetGranter() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Granter + } + return nil +} + +func (m *MsgRevokeFeeAllowance) GetGrantee() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Grantee + } + return nil +} + +// BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens +// that optionally expires. The delegatee can use up to SpendLimit to cover fees. +type BasicFeeAllowance struct { + SpendLimit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=spend_limit,json=spendLimit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"spend_limit" yaml:"spend_limit"` + Expiration ExpiresAt `protobuf:"bytes,2,opt,name=expiration,proto3" json:"expiration"` +} + +func (m *BasicFeeAllowance) Reset() { *m = BasicFeeAllowance{} } +func (m *BasicFeeAllowance) String() string { return proto.CompactTextString(m) } +func (*BasicFeeAllowance) ProtoMessage() {} +func (*BasicFeeAllowance) Descriptor() ([]byte, []int) { + return fileDescriptor_86c534389d2c5768, []int{3} +} +func (m *BasicFeeAllowance) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BasicFeeAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BasicFeeAllowance.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 *BasicFeeAllowance) XXX_Merge(src proto.Message) { + xxx_messageInfo_BasicFeeAllowance.Merge(m, src) +} +func (m *BasicFeeAllowance) XXX_Size() int { + return m.Size() +} +func (m *BasicFeeAllowance) XXX_DiscardUnknown() { + xxx_messageInfo_BasicFeeAllowance.DiscardUnknown(m) +} + +var xxx_messageInfo_BasicFeeAllowance proto.InternalMessageInfo + +// PeriodicFeeAllowance extends FeeAllowance to allow for both a maximum cap, +// as well as a limit per time period. +type PeriodicFeeAllowance struct { + Basic BasicFeeAllowance `protobuf:"bytes,1,opt,name=basic,proto3" json:"basic"` + Period Duration `protobuf:"bytes,2,opt,name=period,proto3" json:"period"` + PeriodSpendLimit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=period_spend_limit,json=periodSpendLimit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"period_spend_limit" yaml:"period_spend_limit"` + PeriodCanSpend github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=period_can_spend,json=periodCanSpend,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"period_can_spend" yaml:"period_can_spend"` + PeriodReset ExpiresAt `protobuf:"bytes,5,opt,name=period_reset,json=periodReset,proto3" json:"period_reset" yaml:"period_reset"` +} + +func (m *PeriodicFeeAllowance) Reset() { *m = PeriodicFeeAllowance{} } +func (m *PeriodicFeeAllowance) String() string { return proto.CompactTextString(m) } +func (*PeriodicFeeAllowance) ProtoMessage() {} +func (*PeriodicFeeAllowance) Descriptor() ([]byte, []int) { + return fileDescriptor_86c534389d2c5768, []int{4} +} +func (m *PeriodicFeeAllowance) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PeriodicFeeAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PeriodicFeeAllowance.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 *PeriodicFeeAllowance) XXX_Merge(src proto.Message) { + xxx_messageInfo_PeriodicFeeAllowance.Merge(m, src) +} +func (m *PeriodicFeeAllowance) XXX_Size() int { + return m.Size() +} +func (m *PeriodicFeeAllowance) XXX_DiscardUnknown() { + xxx_messageInfo_PeriodicFeeAllowance.DiscardUnknown(m) +} + +var xxx_messageInfo_PeriodicFeeAllowance proto.InternalMessageInfo + +// Duration is a repeating unit of either clock time or number of blocks. +// This is designed to be added to an ExpiresAt struct. +type Duration struct { + Clock time.Duration `protobuf:"bytes,1,opt,name=clock,proto3,stdduration" json:"clock"` + Block int64 `protobuf:"varint,2,opt,name=block,proto3" json:"block,omitempty"` +} + +func (m *Duration) Reset() { *m = Duration{} } +func (m *Duration) String() string { return proto.CompactTextString(m) } +func (*Duration) ProtoMessage() {} +func (*Duration) Descriptor() ([]byte, []int) { + return fileDescriptor_86c534389d2c5768, []int{5} +} +func (m *Duration) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Duration) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Duration.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 *Duration) XXX_Merge(src proto.Message) { + xxx_messageInfo_Duration.Merge(m, src) +} +func (m *Duration) XXX_Size() int { + return m.Size() +} +func (m *Duration) XXX_DiscardUnknown() { + xxx_messageInfo_Duration.DiscardUnknown(m) +} + +var xxx_messageInfo_Duration proto.InternalMessageInfo + +func (m *Duration) GetClock() time.Duration { + if m != nil { + return m.Clock + } + return 0 +} + +func (m *Duration) GetBlock() int64 { + if m != nil { + return m.Block + } + return 0 +} + +// ExpiresAt is a point in time where something expires. +// It may be *either* block time or block height +type ExpiresAt struct { + Time time.Time `protobuf:"bytes,1,opt,name=time,proto3,stdtime" json:"time"` + Height int64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` +} + +func (m *ExpiresAt) Reset() { *m = ExpiresAt{} } +func (m *ExpiresAt) String() string { return proto.CompactTextString(m) } +func (*ExpiresAt) ProtoMessage() {} +func (*ExpiresAt) Descriptor() ([]byte, []int) { + return fileDescriptor_86c534389d2c5768, []int{6} +} +func (m *ExpiresAt) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ExpiresAt) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ExpiresAt.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 *ExpiresAt) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExpiresAt.Merge(m, src) +} +func (m *ExpiresAt) XXX_Size() int { + return m.Size() +} +func (m *ExpiresAt) XXX_DiscardUnknown() { + xxx_messageInfo_ExpiresAt.DiscardUnknown(m) +} + +var xxx_messageInfo_ExpiresAt proto.InternalMessageInfo + +func (m *ExpiresAt) GetTime() time.Time { + if m != nil { + return m.Time + } + return time.Time{} +} + +func (m *ExpiresAt) GetHeight() int64 { + if m != nil { + return m.Height + } + return 0 +} + +// FeeAllowanceGrant is stored in the KVStore to record a grant with full context +type FeeAllowanceGrant struct { + Granter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=granter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"granter,omitempty"` + Grantee github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=grantee,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"grantee,omitempty"` + Allowance *FeeAllowance `protobuf:"bytes,3,opt,name=allowance,proto3" json:"allowance,omitempty"` +} + +func (m *FeeAllowanceGrant) Reset() { *m = FeeAllowanceGrant{} } +func (m *FeeAllowanceGrant) String() string { return proto.CompactTextString(m) } +func (*FeeAllowanceGrant) ProtoMessage() {} +func (*FeeAllowanceGrant) Descriptor() ([]byte, []int) { + return fileDescriptor_86c534389d2c5768, []int{7} +} +func (m *FeeAllowanceGrant) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FeeAllowanceGrant) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FeeAllowanceGrant.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 *FeeAllowanceGrant) XXX_Merge(src proto.Message) { + xxx_messageInfo_FeeAllowanceGrant.Merge(m, src) +} +func (m *FeeAllowanceGrant) XXX_Size() int { + return m.Size() +} +func (m *FeeAllowanceGrant) XXX_DiscardUnknown() { + xxx_messageInfo_FeeAllowanceGrant.DiscardUnknown(m) +} + +var xxx_messageInfo_FeeAllowanceGrant proto.InternalMessageInfo + +func init() { + proto.RegisterType((*FeeAllowance)(nil), "cosmos_sdk.x.feegrant.v1.FeeAllowance") + proto.RegisterType((*MsgGrantFeeAllowance)(nil), "cosmos_sdk.x.feegrant.v1.MsgGrantFeeAllowance") + proto.RegisterType((*MsgRevokeFeeAllowance)(nil), "cosmos_sdk.x.feegrant.v1.MsgRevokeFeeAllowance") + proto.RegisterType((*BasicFeeAllowance)(nil), "cosmos_sdk.x.feegrant.v1.BasicFeeAllowance") + proto.RegisterType((*PeriodicFeeAllowance)(nil), "cosmos_sdk.x.feegrant.v1.PeriodicFeeAllowance") + proto.RegisterType((*Duration)(nil), "cosmos_sdk.x.feegrant.v1.Duration") + proto.RegisterType((*ExpiresAt)(nil), "cosmos_sdk.x.feegrant.v1.ExpiresAt") + proto.RegisterType((*FeeAllowanceGrant)(nil), "cosmos_sdk.x.feegrant.v1.FeeAllowanceGrant") +} + +func init() { proto.RegisterFile("x/feegrant/types/types.proto", fileDescriptor_86c534389d2c5768) } + +var fileDescriptor_86c534389d2c5768 = []byte{ + // 735 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x56, 0xcd, 0x4f, 0x13, 0x4d, + 0x18, 0xef, 0xbc, 0x6d, 0x79, 0x61, 0x4a, 0xc8, 0xdb, 0xa1, 0x2f, 0xd6, 0x6a, 0xba, 0x64, 0x4d, + 0x08, 0x91, 0xb0, 0x0d, 0x78, 0x31, 0x3d, 0xd9, 0x05, 0x41, 0x82, 0x24, 0x66, 0xf5, 0x64, 0x62, + 0x36, 0xfb, 0x31, 0xdd, 0x6e, 0xda, 0xdd, 0xd9, 0xec, 0x6c, 0x11, 0x12, 0xff, 0x00, 0xe3, 0x89, + 0xa3, 0x47, 0xce, 0x9e, 0x34, 0xf1, 0x8f, 0x20, 0x9e, 0x38, 0x7a, 0x02, 0x03, 0x89, 0xf1, 0x6c, + 0xbc, 0x68, 0x3c, 0x98, 0x9d, 0x99, 0xa5, 0x0b, 0x65, 0x0d, 0xe8, 0xc9, 0x78, 0x69, 0x76, 0x9e, + 0x3c, 0xbf, 0x8f, 0xe7, 0x63, 0x77, 0x0a, 0xaf, 0x6f, 0x35, 0xda, 0x18, 0x3b, 0xa1, 0xe1, 0x47, + 0x8d, 0x68, 0x3b, 0xc0, 0x94, 0xff, 0x2a, 0x41, 0x48, 0x22, 0x82, 0xaa, 0x16, 0xa1, 0x1e, 0xa1, + 0x3a, 0xb5, 0xbb, 0xca, 0x96, 0x92, 0x24, 0x2a, 0x9b, 0x0b, 0xb5, 0xb9, 0xa8, 0xe3, 0x86, 0xb6, + 0x1e, 0x18, 0x61, 0xb4, 0xdd, 0x60, 0xc9, 0x0d, 0x9e, 0x3b, 0x9f, 0x3e, 0x70, 0x9a, 0xda, 0xcc, + 0x70, 0xb2, 0x43, 0x1c, 0x32, 0x78, 0x12, 0x79, 0xe5, 0x21, 0x07, 0x35, 0xc9, 0x21, 0xc4, 0xe9, + 0x61, 0x8e, 0x32, 0xfb, 0xed, 0x46, 0xe4, 0x7a, 0x98, 0x46, 0x86, 0x17, 0xf0, 0x04, 0xf9, 0x0b, + 0x80, 0xe3, 0x2b, 0x18, 0xb7, 0x7a, 0x3d, 0xf2, 0xd4, 0xf0, 0x2d, 0x8c, 0x9e, 0xc0, 0x49, 0xd3, + 0xa0, 0xae, 0xa5, 0xb7, 0x31, 0xd6, 0x8d, 0x24, 0x5c, 0x05, 0xd3, 0x60, 0xb6, 0xb4, 0x38, 0xa7, + 0x64, 0x55, 0xa4, 0xa8, 0x31, 0x28, 0xcd, 0x74, 0x2f, 0xa7, 0x95, 0xcd, 0xb3, 0x41, 0xd4, 0x86, + 0x53, 0x01, 0x0e, 0x5d, 0x62, 0x0f, 0x29, 0xfc, 0xc3, 0x14, 0x94, 0x6c, 0x85, 0x07, 0x02, 0x77, + 0x46, 0xa4, 0x12, 0x9c, 0x13, 0x6f, 0x4e, 0x7d, 0xda, 0x95, 0xc0, 0xbb, 0xb7, 0xf3, 0x13, 0x37, + 0xd3, 0xe1, 0x35, 0xb5, 0x08, 0xf3, 0xb4, 0xef, 0xc9, 0xdf, 0x01, 0xac, 0x6c, 0x50, 0x67, 0x35, + 0xe6, 0x3e, 0xe5, 0x6f, 0x1d, 0xfe, 0xcb, 0x04, 0x71, 0xc8, 0x4a, 0x1e, 0x57, 0x17, 0xbe, 0x1d, + 0x48, 0xf3, 0x8e, 0x1b, 0x75, 0xfa, 0xa6, 0x62, 0x11, 0x4f, 0x4c, 0x26, 0x99, 0x16, 0xb5, 0xbb, + 0xa2, 0xdf, 0x2d, 0xcb, 0x6a, 0xd9, 0x76, 0x88, 0x29, 0xd5, 0x12, 0x86, 0x01, 0x19, 0xaf, 0xee, + 0x77, 0xc8, 0x30, 0x5a, 0x86, 0x63, 0x83, 0x66, 0xe5, 0x59, 0xb3, 0x66, 0xb2, 0x9b, 0x95, 0x2e, + 0x4a, 0x1b, 0x00, 0x9b, 0x85, 0xe7, 0xbb, 0x52, 0x4e, 0x7e, 0x03, 0xe0, 0xff, 0x1b, 0xd4, 0xd1, + 0xf0, 0x26, 0xe9, 0xe2, 0x3f, 0xa3, 0x7e, 0xf9, 0x23, 0x80, 0xe5, 0xa1, 0x25, 0x43, 0xcf, 0x60, + 0x89, 0x06, 0xd8, 0xb7, 0xf5, 0x9e, 0xeb, 0xb9, 0x51, 0x15, 0x4c, 0xe7, 0x67, 0x4b, 0x8b, 0x93, + 0xe9, 0xbe, 0x6c, 0x2e, 0x28, 0x4b, 0xc4, 0xf5, 0xd5, 0x95, 0xbd, 0x03, 0x29, 0xf7, 0xf9, 0x40, + 0x42, 0xdb, 0x86, 0xd7, 0x6b, 0xca, 0x29, 0x94, 0xfc, 0xea, 0x50, 0x9a, 0xbd, 0x80, 0xab, 0x98, + 0x86, 0x6a, 0x90, 0x21, 0xef, 0xc7, 0x40, 0xb4, 0x06, 0x21, 0xde, 0x0a, 0xdc, 0xd0, 0x88, 0x5c, + 0xe2, 0x8b, 0x0d, 0xbe, 0x91, 0x3d, 0x94, 0xbb, 0x71, 0x2e, 0xa6, 0xad, 0x48, 0x2d, 0xc4, 0x66, + 0xb4, 0x14, 0xb8, 0x39, 0x1a, 0x0f, 0x26, 0x5e, 0x5a, 0xf9, 0x75, 0x01, 0x56, 0xce, 0xdb, 0x75, + 0xb4, 0x0a, 0x8b, 0xec, 0x85, 0xfa, 0x85, 0x97, 0x51, 0x08, 0x72, 0x3c, 0xba, 0x03, 0x47, 0xf8, + 0x4b, 0x23, 0x2c, 0xcb, 0xd9, 0x4c, 0xcb, 0x7d, 0xee, 0x4f, 0x10, 0x08, 0x1c, 0xda, 0x01, 0x10, + 0xf1, 0x47, 0x3d, 0xdd, 0xfe, 0x7c, 0x76, 0xfb, 0x37, 0x44, 0xfb, 0xaf, 0xf2, 0xf6, 0x0f, 0x83, + 0x2f, 0x37, 0x85, 0xff, 0x38, 0xc1, 0xc3, 0xc1, 0x2c, 0x5e, 0x00, 0x28, 0x82, 0xba, 0x65, 0xf8, + 0x9c, 0xb9, 0x5a, 0xc8, 0x36, 0xb4, 0x2e, 0x0c, 0x5d, 0x39, 0x65, 0xe8, 0x04, 0x7a, 0x39, 0x3b, + 0x13, 0x1c, 0xbe, 0x64, 0xf8, 0xcc, 0x11, 0xb2, 0xe0, 0xb8, 0x20, 0x0c, 0x31, 0xc5, 0x51, 0xb5, + 0x78, 0xf1, 0xd5, 0xb8, 0x26, 0x7c, 0x4d, 0x9e, 0xf2, 0xc5, 0x68, 0x64, 0xad, 0xc4, 0x8f, 0x5a, + 0x7c, 0x4a, 0xad, 0x8c, 0x09, 0x47, 0x93, 0x41, 0xa1, 0x26, 0x2c, 0x5a, 0x3d, 0x62, 0x75, 0xc5, + 0x96, 0xd4, 0x14, 0x7e, 0x05, 0x28, 0xc9, 0x15, 0xa0, 0x3c, 0x4a, 0xae, 0x00, 0x75, 0x34, 0x96, + 0x7a, 0x79, 0x28, 0x01, 0x8d, 0x43, 0x50, 0x05, 0x16, 0x4d, 0x86, 0x8d, 0xf7, 0x22, 0xaf, 0xf1, + 0x43, 0xb3, 0xc0, 0x34, 0x2c, 0x38, 0x76, 0x62, 0x12, 0xdd, 0x86, 0x85, 0xf8, 0x26, 0xb9, 0xa8, + 0xc6, 0x4e, 0xac, 0xc1, 0x10, 0x68, 0x0a, 0x8e, 0x74, 0xb0, 0xeb, 0x74, 0x22, 0xa1, 0x21, 0x4e, + 0x42, 0xe4, 0x2b, 0x80, 0xe5, 0xf4, 0xde, 0xb2, 0x0f, 0xf4, 0xdf, 0xf1, 0x51, 0x56, 0x57, 0xf7, + 0x8e, 0xea, 0x60, 0xff, 0xa8, 0x0e, 0x3e, 0x1c, 0xd5, 0xc1, 0xce, 0x71, 0x3d, 0xb7, 0x7f, 0x5c, + 0xcf, 0xbd, 0x3f, 0xae, 0xe7, 0x1e, 0xff, 0xdc, 0xdd, 0xd9, 0xbf, 0x20, 0xe6, 0x08, 0x1b, 0xc3, + 0xad, 0x1f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x60, 0xf1, 0xd1, 0x21, 0x9d, 0x08, 0x00, 0x00, +} + +func (this *FeeAllowance) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*FeeAllowance) + if !ok { + that2, ok := that.(FeeAllowance) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if that1.Sum == nil { + if this.Sum != nil { + return false + } + } else if this.Sum == nil { + return false + } else if !this.Sum.Equal(that1.Sum) { + return false + } + return true +} +func (this *FeeAllowance_BasicFeeAllowance) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*FeeAllowance_BasicFeeAllowance) + if !ok { + that2, ok := that.(FeeAllowance_BasicFeeAllowance) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.BasicFeeAllowance.Equal(that1.BasicFeeAllowance) { + return false + } + return true +} +func (this *FeeAllowance_PeriodicFeeAllowance) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*FeeAllowance_PeriodicFeeAllowance) + if !ok { + that2, ok := that.(FeeAllowance_PeriodicFeeAllowance) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.PeriodicFeeAllowance.Equal(that1.PeriodicFeeAllowance) { + return false + } + return true +} +func (this *BasicFeeAllowance) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*BasicFeeAllowance) + if !ok { + that2, ok := that.(BasicFeeAllowance) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.SpendLimit) != len(that1.SpendLimit) { + return false + } + for i := range this.SpendLimit { + if !this.SpendLimit[i].Equal(&that1.SpendLimit[i]) { + return false + } + } + if !this.Expiration.Equal(&that1.Expiration) { + return false + } + return true +} +func (this *PeriodicFeeAllowance) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*PeriodicFeeAllowance) + if !ok { + that2, ok := that.(PeriodicFeeAllowance) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Basic.Equal(&that1.Basic) { + return false + } + if !this.Period.Equal(&that1.Period) { + return false + } + if len(this.PeriodSpendLimit) != len(that1.PeriodSpendLimit) { + return false + } + for i := range this.PeriodSpendLimit { + if !this.PeriodSpendLimit[i].Equal(&that1.PeriodSpendLimit[i]) { + return false + } + } + if len(this.PeriodCanSpend) != len(that1.PeriodCanSpend) { + return false + } + for i := range this.PeriodCanSpend { + if !this.PeriodCanSpend[i].Equal(&that1.PeriodCanSpend[i]) { + return false + } + } + if !this.PeriodReset.Equal(&that1.PeriodReset) { + return false + } + return true +} +func (this *Duration) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Duration) + if !ok { + that2, ok := that.(Duration) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Clock != that1.Clock { + return false + } + if this.Block != that1.Block { + return false + } + return true +} +func (this *ExpiresAt) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ExpiresAt) + if !ok { + that2, ok := that.(ExpiresAt) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Time.Equal(that1.Time) { + return false + } + if this.Height != that1.Height { + return false + } + return true +} +func (this *FeeAllowance) GetFeeAllowanceI() FeeAllowanceI { + if x := this.GetBasicFeeAllowance(); x != nil { + return x + } + if x := this.GetPeriodicFeeAllowance(); x != nil { + return x + } + return nil +} + +func (this *FeeAllowance) SetFeeAllowanceI(value FeeAllowanceI) error { + if value == nil { + this.Sum = nil + return nil + } + switch vt := value.(type) { + case *BasicFeeAllowance: + this.Sum = &FeeAllowance_BasicFeeAllowance{vt} + return nil + case *PeriodicFeeAllowance: + this.Sum = &FeeAllowance_PeriodicFeeAllowance{vt} + return nil + } + return fmt.Errorf("can't encode value of type %T as message FeeAllowance", value) +} + +func (m *FeeAllowance) 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 *FeeAllowance) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Sum != nil { + { + size := m.Sum.Size() + i -= size + if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *FeeAllowance_BasicFeeAllowance) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FeeAllowance_BasicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.BasicFeeAllowance != nil { + { + size, err := m.BasicFeeAllowance.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *FeeAllowance_PeriodicFeeAllowance) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FeeAllowance_PeriodicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.PeriodicFeeAllowance != nil { + { + size, err := m.PeriodicFeeAllowance.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func (m *MsgGrantFeeAllowance) 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 *MsgGrantFeeAllowance) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgGrantFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Allowance != nil { + { + size, err := m.Allowance.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.Grantee) > 0 { + i -= len(m.Grantee) + copy(dAtA[i:], m.Grantee) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Grantee))) + i-- + dAtA[i] = 0x12 + } + if len(m.Granter) > 0 { + i -= len(m.Granter) + copy(dAtA[i:], m.Granter) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Granter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRevokeFeeAllowance) 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 *MsgRevokeFeeAllowance) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRevokeFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Grantee) > 0 { + i -= len(m.Grantee) + copy(dAtA[i:], m.Grantee) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Grantee))) + i-- + dAtA[i] = 0x12 + } + if len(m.Granter) > 0 { + i -= len(m.Granter) + copy(dAtA[i:], m.Granter) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Granter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *BasicFeeAllowance) 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 *BasicFeeAllowance) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BasicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Expiration.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.SpendLimit) > 0 { + for iNdEx := len(m.SpendLimit) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SpendLimit[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *PeriodicFeeAllowance) 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 *PeriodicFeeAllowance) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PeriodicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.PeriodReset.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + if len(m.PeriodCanSpend) > 0 { + for iNdEx := len(m.PeriodCanSpend) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PeriodCanSpend[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.PeriodSpendLimit) > 0 { + for iNdEx := len(m.PeriodSpendLimit) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PeriodSpendLimit[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + { + size, err := m.Period.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.Basic.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *Duration) 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 *Duration) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Duration) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Block != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Block)) + i-- + dAtA[i] = 0x10 + } + n8, err8 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.Clock, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.Clock):]) + if err8 != nil { + return 0, err8 + } + i -= n8 + i = encodeVarintTypes(dAtA, i, uint64(n8)) + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *ExpiresAt) 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 *ExpiresAt) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ExpiresAt) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Height != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x10 + } + n9, err9 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Time):]) + if err9 != nil { + return 0, err9 + } + i -= n9 + i = encodeVarintTypes(dAtA, i, uint64(n9)) + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *FeeAllowanceGrant) 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 *FeeAllowanceGrant) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FeeAllowanceGrant) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Allowance != nil { + { + size, err := m.Allowance.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.Grantee) > 0 { + i -= len(m.Grantee) + copy(dAtA[i:], m.Grantee) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Grantee))) + i-- + dAtA[i] = 0x12 + } + if len(m.Granter) > 0 { + i -= len(m.Granter) + copy(dAtA[i:], m.Granter) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Granter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { + offset -= sovTypes(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *FeeAllowance) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Sum != nil { + n += m.Sum.Size() + } + return n +} + +func (m *FeeAllowance_BasicFeeAllowance) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BasicFeeAllowance != nil { + l = m.BasicFeeAllowance.Size() + n += 1 + l + sovTypes(uint64(l)) + } + return n +} +func (m *FeeAllowance_PeriodicFeeAllowance) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PeriodicFeeAllowance != nil { + l = m.PeriodicFeeAllowance.Size() + n += 1 + l + sovTypes(uint64(l)) + } + return n +} +func (m *MsgGrantFeeAllowance) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Granter) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Grantee) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if m.Allowance != nil { + l = m.Allowance.Size() + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *MsgRevokeFeeAllowance) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Granter) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Grantee) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *BasicFeeAllowance) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.SpendLimit) > 0 { + for _, e := range m.SpendLimit { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + l = m.Expiration.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *PeriodicFeeAllowance) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Basic.Size() + n += 1 + l + sovTypes(uint64(l)) + l = m.Period.Size() + n += 1 + l + sovTypes(uint64(l)) + if len(m.PeriodSpendLimit) > 0 { + for _, e := range m.PeriodSpendLimit { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + if len(m.PeriodCanSpend) > 0 { + for _, e := range m.PeriodCanSpend { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + l = m.PeriodReset.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *Duration) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.Clock) + n += 1 + l + sovTypes(uint64(l)) + if m.Block != 0 { + n += 1 + sovTypes(uint64(m.Block)) + } + return n +} + +func (m *ExpiresAt) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Time) + n += 1 + l + sovTypes(uint64(l)) + if m.Height != 0 { + n += 1 + sovTypes(uint64(m.Height)) + } + return n +} + +func (m *FeeAllowanceGrant) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Granter) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Grantee) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if m.Allowance != nil { + l = m.Allowance.Size() + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func sovTypes(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTypes(x uint64) (n int) { + return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *FeeAllowance) 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 ErrIntOverflowTypes + } + 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: FeeAllowance: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FeeAllowance: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BasicFeeAllowance", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &BasicFeeAllowance{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Sum = &FeeAllowance_BasicFeeAllowance{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PeriodicFeeAllowance", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &PeriodicFeeAllowance{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Sum = &FeeAllowance_PeriodicFeeAllowance{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgGrantFeeAllowance) 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 ErrIntOverflowTypes + } + 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: MsgGrantFeeAllowance: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgGrantFeeAllowance: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Granter", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Granter = append(m.Granter[:0], dAtA[iNdEx:postIndex]...) + if m.Granter == nil { + m.Granter = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Grantee = append(m.Grantee[:0], dAtA[iNdEx:postIndex]...) + if m.Grantee == nil { + m.Grantee = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Allowance", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Allowance == nil { + m.Allowance = &FeeAllowance{} + } + if err := m.Allowance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRevokeFeeAllowance) 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 ErrIntOverflowTypes + } + 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: MsgRevokeFeeAllowance: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRevokeFeeAllowance: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Granter", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Granter = append(m.Granter[:0], dAtA[iNdEx:postIndex]...) + if m.Granter == nil { + m.Granter = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Grantee = append(m.Grantee[:0], dAtA[iNdEx:postIndex]...) + if m.Grantee == nil { + m.Grantee = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BasicFeeAllowance) 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 ErrIntOverflowTypes + } + 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: BasicFeeAllowance: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BasicFeeAllowance: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpendLimit", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpendLimit = append(m.SpendLimit, types.Coin{}) + if err := m.SpendLimit[len(m.SpendLimit)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Expiration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Expiration.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PeriodicFeeAllowance) 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 ErrIntOverflowTypes + } + 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: PeriodicFeeAllowance: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PeriodicFeeAllowance: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Basic", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Basic.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Period", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Period.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PeriodSpendLimit", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PeriodSpendLimit = append(m.PeriodSpendLimit, types.Coin{}) + if err := m.PeriodSpendLimit[len(m.PeriodSpendLimit)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PeriodCanSpend", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PeriodCanSpend = append(m.PeriodCanSpend, types.Coin{}) + if err := m.PeriodCanSpend[len(m.PeriodCanSpend)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PeriodReset", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PeriodReset.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Duration) 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 ErrIntOverflowTypes + } + 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: Duration: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Duration: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Clock", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.Clock, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) + } + m.Block = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Block |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ExpiresAt) 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 ErrIntOverflowTypes + } + 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: ExpiresAt: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ExpiresAt: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.Time, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FeeAllowanceGrant) 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 ErrIntOverflowTypes + } + 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: FeeAllowanceGrant: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FeeAllowanceGrant: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Granter", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Granter = append(m.Granter[:0], dAtA[iNdEx:postIndex]...) + if m.Granter == nil { + m.Granter = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Grantee = append(m.Grantee[:0], dAtA[iNdEx:postIndex]...) + if m.Grantee == nil { + m.Grantee = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Allowance", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Allowance == nil { + m.Allowance = &FeeAllowance{} + } + if err := m.Allowance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTypes(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, ErrIntOverflowTypes + } + 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, ErrIntOverflowTypes + } + 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, ErrIntOverflowTypes + } + 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, ErrInvalidLengthTypes + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTypes + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTypes + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/feegrant/types/types.proto b/x/feegrant/types/types.proto new file mode 100644 index 000000000000..69eab22c1e70 --- /dev/null +++ b/x/feegrant/types/types.proto @@ -0,0 +1,105 @@ +syntax = "proto3"; +package cosmos_sdk.x.feegrant.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; + +import "third_party/proto/cosmos-proto/cosmos.proto"; +import "third_party/proto/gogoproto/gogo.proto"; +import "types/types.proto"; +import "google/protobuf/timestamp.proto"; + +// FeeAllowance defines the application-level fee allowance to be used in +// feegrant module +message FeeAllowance { + option (gogoproto.equal) = true; + option (cosmos_proto.interface_type) = "*FeeAllowanceI"; + + // sum defines a set of all acceptable concrete feeallowance implementations. + oneof sum{ + BasicFeeAllowance basic_fee_allowance= 1; + PeriodicFeeAllowance periodic_fee_allowance= 2; + } +} +// MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance +// of fees from the account of Granter. +message MsgGrantFeeAllowance{ + option (gogoproto.goproto_getters) = false; + + bytes granter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + bytes grantee = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + FeeAllowance allowance = 3; +} + +// MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee. +message MsgRevokeFeeAllowance{ + bytes granter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + bytes grantee = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +} + +// BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens +// that optionally expires. The delegatee can use up to SpendLimit to cover fees. +message BasicFeeAllowance{ + option (gogoproto.equal) = true; + option (gogoproto.goproto_getters) = false; + + repeated cosmos_sdk.v1.Coin spend_limit = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"spend_limit\"" + ]; + ExpiresAt expiration = 2 [(gogoproto.nullable) = false]; +} + +// PeriodicFeeAllowance extends FeeAllowance to allow for both a maximum cap, +// as well as a limit per time period. +message PeriodicFeeAllowance{ + option (gogoproto.equal) = true; + option (gogoproto.goproto_getters) = false; + + BasicFeeAllowance basic = 1[(gogoproto.nullable) = false]; + Duration period = 2[(gogoproto.nullable) = false]; + repeated cosmos_sdk.v1.Coin period_spend_limit = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"period_spend_limit\"" + ]; + repeated cosmos_sdk.v1.Coin period_can_spend = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"period_can_spend\"" + ]; + + ExpiresAt period_reset = 5 [(gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"period_reset\""]; +} + +// Duration is a repeating unit of either clock time or number of blocks. +// This is designed to be added to an ExpiresAt struct. +message Duration{ + option (gogoproto.equal) = true; + google.protobuf.Timestamp clock = 1[(gogoproto.stdduration) = true, + (gogoproto.nullable) = false + ]; + int64 block = 2; +} + +// ExpiresAt is a point in time where something expires. +// It may be *either* block time or block height +message ExpiresAt{ + option (gogoproto.equal) = true; + google.protobuf.Timestamp time = 1 [(gogoproto.stdtime) = true, + (gogoproto.nullable) = false + ]; + int64 height = 2; +} + + + +// FeeAllowanceGrant is stored in the KVStore to record a grant with full context +message FeeAllowanceGrant{ + option (gogoproto.goproto_getters) = false; + + bytes granter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + bytes grantee = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + FeeAllowance allowance = 3; +} \ No newline at end of file From bd0443c4df26512295ad04c6b7fb2894fde181b1 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 25 Nov 2020 14:40:11 +0530 Subject: [PATCH 078/184] fix errors --- x/feegrant/module.go | 70 +++++++++++++++++------- x/feegrant/types/expected_keepers.go | 12 ++-- x/feegrant/types/tx.go | 40 +++++++------- x/feegrant/types/types.proto | 82 ++++++++++++++++------------ 4 files changed, 123 insertions(+), 81 deletions(-) diff --git a/x/feegrant/module.go b/x/feegrant/module.go index 72699c3c5043..588abc2bd10e 100644 --- a/x/feegrant/module.go +++ b/x/feegrant/module.go @@ -4,14 +4,18 @@ import ( "encoding/json" "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" - "github.com/cosmos/cosmos-sdk/client/context" + sdkclient "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) var ( @@ -31,9 +35,28 @@ func (AppModuleBasic) Name() string { return ModuleName } -// RegisterCodec registers the feegrant module's types for the given codec. -func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { - RegisterCodec(cdc) +// RegisterServices registers a gRPC query service to respond to the +// module-specific gRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + // TODO + // types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterLegacyAminoCodec registers the feegrant module's types for the given codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + // TODO + // types.RegisterLegacyAminoCodec(cdc) +} + +// RegisterInterfaces registers the feegrant module's interface types +func (AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + // TODO + // types.RegisterInterfaces(registry) +} + +// LegacyQuerierHandler returns the feegrant module sdk.Querier. +func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { + return keeper.NewQuerier(am.keeper) } // DefaultGenesis returns default genesis state as raw bytes for the feegrant @@ -43,7 +66,7 @@ func (AppModuleBasic) DefaultGenesis(_ codec.JSONMarshaler) json.RawMessage { } // ValidateGenesis performs genesis state validation for the feegrant module. -func (a AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, bz json.RawMessage) error { +func (a AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, config sdkclient.TxEncodingConfig, bz json.RawMessage) error { _, err := a.getValidatedGenesis(cdc, bz) return err } @@ -51,28 +74,35 @@ func (a AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, bz json.RawMess func (a AppModuleBasic) getValidatedGenesis(cdc codec.JSONMarshaler, bz json.RawMessage) (GenesisState, error) { var data GenesisState - err := cdc.UnmarshalJSON(bz, &data) - if err != nil { - return nil, err - } + // TODO migrate genesis types to proto + // err := cdc.UnmarshalJSON(bz, &data) + // if err != nil { + // return nil, err + // } return data, data.ValidateBasic() } // RegisterRESTRoutes registers the REST routes for the feegrant module. -func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router) { +func (AppModuleBasic) RegisterRESTRoutes(ctx sdkclient.Context, rtr *mux.Router) { // TODO // rest.RegisterRoutes(ctx, rtr) } +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the feegrant module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) { + // TODO add grpc gateway in proto files + // types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) +} + // GetTxCmd returns the root tx command for the feegrant module. -func (AppModuleBasic) GetTxCmd(_ *codec.Codec) *cobra.Command { +func (AppModuleBasic) GetTxCmd() *cobra.Command { // TODO return nil } // GetQueryCmd returns no root query command for the feegrant module. -func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { +func (AppModuleBasic) GetQueryCmd() *cobra.Command { // TODO return nil } @@ -104,8 +134,8 @@ func (AppModule) Name() string { func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {} // Route returns the message routing key for the feegrant module. -func (AppModule) Route() string { - return RouterKey +func (am AppModule) Route() sdk.Route { + return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) } // NewHandler returns an sdk.Handler for the feegrant module. @@ -138,12 +168,14 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, bz jso // ExportGenesis returns the exported genesis state as raw bytes for the feegrant // module. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONMarshaler) json.RawMessage { - gs, err := ExportGenesis(ctx, am.keeper) - if err != nil { - panic(err) - } + // TODO + // gs, err := ExportGenesis(ctx, am.keeper) + // if err != nil { + // panic(err) + // } - return cdc.MustMarshalJSON(gs) + // return cdc.MustMarshalJSON(gs) + return nil } // BeginBlock returns the begin blocker for the feegrant module. diff --git a/x/feegrant/types/expected_keepers.go b/x/feegrant/types/expected_keepers.go index e60e5ad08171..b7c6c6fe6596 100644 --- a/x/feegrant/types/expected_keepers.go +++ b/x/feegrant/types/expected_keepers.go @@ -2,20 +2,20 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" - auth "github.com/cosmos/cosmos-sdk/x/auth/exported" - supply "github.com/cosmos/cosmos-sdk/x/supply/exported" + auth "github.com/cosmos/cosmos-sdk/x/auth/types" + // supply "github.com/cosmos/cosmos-sdk/x/supply/exported" ) // SupplyKeeper defines the expected supply Keeper (noalias) type SupplyKeeper interface { SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error - GetModuleAccount(ctx sdk.Context, moduleName string) supply.ModuleAccountI + GetModuleAccount(ctx sdk.Context, moduleName string) auth.ModuleAccountI GetModuleAddress(moduleName string) sdk.AccAddress } // SupplyKeeper defines the expected auth Account Keeper (noalias) type AccountKeeper interface { - NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) auth.Account - GetAccount(ctx sdk.Context, addr sdk.AccAddress) auth.Account - SetAccount(ctx sdk.Context, acc auth.Account) + NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) auth.AccountI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) auth.AccountI + SetAccount(ctx sdk.Context, acc auth.AccountI) } diff --git a/x/feegrant/types/tx.go b/x/feegrant/types/tx.go index d2c5c94c62b4..6d757ee8a492 100644 --- a/x/feegrant/types/tx.go +++ b/x/feegrant/types/tx.go @@ -3,13 +3,13 @@ package types import ( "encoding/json" - "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/multisig" + kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/codec" + legacycodec "github.com/cosmos/cosmos-sdk/codec/legacy" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/auth/exported" + "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) @@ -24,14 +24,14 @@ var ( // NOTE: the first signature responsible for paying fees, either directly, // or must be authorized to spend from the provided Fee.FeeAccount type FeeGrantTx struct { - Msgs []sdk.Msg `json:"msg" yaml:"msg"` - Fee GrantedFee `json:"fee" yaml:"fee"` - Signatures []authtypes.StdSignature `json:"signatures" yaml:"signatures"` - Memo string `json:"memo" yaml:"memo"` - FeeAccount sdk.AccAddress `json:"fee_account" yaml:"fee_account"` + Msgs []sdk.Msg `json:"msg" yaml:"msg"` + Fee GrantedFee `json:"fee" yaml:"fee"` + Signatures []legacytx.StdSignature `json:"signatures" yaml:"signatures"` + Memo string `json:"memo" yaml:"memo"` + FeeAccount sdk.AccAddress `json:"fee_account" yaml:"fee_account"` } -func NewFeeGrantTx(msgs []sdk.Msg, fee GrantedFee, sigs []authtypes.StdSignature, memo string) FeeGrantTx { +func NewFeeGrantTx(msgs []sdk.Msg, fee GrantedFee, sigs []legacytx.StdSignature, memo string) FeeGrantTx { return FeeGrantTx{ Msgs: msgs, Fee: fee, @@ -74,8 +74,8 @@ func (tx FeeGrantTx) ValidateBasic() error { } // CountSubKeys counts the total number of keys for a multi-sig public key. -func CountSubKeys(pub crypto.PubKey) int { - v, ok := pub.(multisig.PubKeyMultisigThreshold) +func CountSubKeys(pub cryptotypes.PubKey) int { + v, ok := pub.(*kmultisig.LegacyAminoPubKey) if !ok { return 1 } @@ -127,16 +127,17 @@ func (tx FeeGrantTx) GetSignatures() [][]byte { // GetPubkeys returns the pubkeys of signers if the pubkey is included in the signature // If pubkey is not included in the signature, then nil is in the slice instead -func (tx FeeGrantTx) GetPubKeys() []crypto.PubKey { - pks := make([]crypto.PubKey, len(tx.Signatures)) +func (tx FeeGrantTx) GetPubKeys() []cryptotypes.PubKey { + pks := make([]cryptotypes.PubKey, len(tx.Signatures)) + for i, stdSig := range tx.Signatures { - pks[i] = stdSig.PubKey + pks[i] = stdSig.GetPubKey() } return pks } // GetSignBytes returns the signBytes of the tx for a given signer -func (tx FeeGrantTx) GetSignBytes(ctx sdk.Context, acc exported.Account) []byte { +func (tx FeeGrantTx) GetSignBytes(ctx sdk.Context, acc authtypes.AccountI) []byte { genesis := ctx.BlockHeight() == 0 chainID := ctx.ChainID() var accNum uint64 @@ -197,8 +198,8 @@ func (fee GrantedFee) Bytes() []byte { if len(fee.Amount) == 0 { fee.Amount = sdk.NewCoins() } - cdc := codec.New() - bz, err := cdc.MarshalJSON(fee) + + bz, err := legacycodec.Cdc.MarshalJSON(fee) if err != nil { panic(err) } @@ -230,12 +231,11 @@ type DelegatedSignDoc struct { // StdSignBytes returns the bytes to sign for a transaction. func StdSignBytes(chainID string, accnum uint64, sequence uint64, fee GrantedFee, msgs []sdk.Msg, memo string) []byte { - cdc := codec.New() msgsBytes := make([]json.RawMessage, 0, len(msgs)) for _, msg := range msgs { msgsBytes = append(msgsBytes, json.RawMessage(msg.GetSignBytes())) } - bz, err := cdc.MarshalJSON(DelegatedSignDoc{ + bz, err := legacycodec.Cdc.MarshalJSON(DelegatedSignDoc{ AccountNumber: accnum, ChainID: chainID, Fee: json.RawMessage(fee.Bytes()), diff --git a/x/feegrant/types/types.proto b/x/feegrant/types/types.proto index 69eab22c1e70..4b69bf19b0cb 100644 --- a/x/feegrant/types/types.proto +++ b/x/feegrant/types/types.proto @@ -7,19 +7,21 @@ import "third_party/proto/cosmos-proto/cosmos.proto"; import "third_party/proto/gogoproto/gogo.proto"; import "types/types.proto"; import "google/protobuf/timestamp.proto"; +import "google/protobuf/any.proto"; // FeeAllowance defines the application-level fee allowance to be used in // feegrant module -message FeeAllowance { - option (gogoproto.equal) = true; - option (cosmos_proto.interface_type) = "*FeeAllowanceI"; - - // sum defines a set of all acceptable concrete feeallowance implementations. - oneof sum{ - BasicFeeAllowance basic_fee_allowance= 1; - PeriodicFeeAllowance periodic_fee_allowance= 2; - } -} +// message FeeAllowance { +// option (gogoproto.equal) = true; +// option (cosmos_proto.interface_type) = "*FeeAllowanceI"; + +// // sum defines a set of all acceptable concrete feeallowance implementations. +// oneof sum{ +// BasicFeeAllowance basic_fee_allowance= 1; +// PeriodicFeeAllowance periodic_fee_allowance= 2; +// } +// } + // MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance // of fees from the account of Granter. message MsgGrantFeeAllowance{ @@ -27,7 +29,9 @@ message MsgGrantFeeAllowance{ bytes granter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; bytes grantee = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - FeeAllowance allowance = 3; + google.protobuf.Any allowance = 3 [ + (cosmos_proto.accepts_interface) = "FeeAllowanceI" + ]; } // MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee. @@ -41,12 +45,13 @@ message MsgRevokeFeeAllowance{ message BasicFeeAllowance{ option (gogoproto.equal) = true; option (gogoproto.goproto_getters) = false; + option (cosmos_proto.implements_interface) = "FeeAllowanceI"; repeated cosmos_sdk.v1.Coin spend_limit = 1 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"spend_limit\"" - ]; + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"spend_limit\"" + ]; ExpiresAt expiration = 2 [(gogoproto.nullable) = false]; } @@ -55,31 +60,35 @@ message BasicFeeAllowance{ message PeriodicFeeAllowance{ option (gogoproto.equal) = true; option (gogoproto.goproto_getters) = false; + option (cosmos_proto.implements_interface) = "FeeAllowanceI"; BasicFeeAllowance basic = 1[(gogoproto.nullable) = false]; Duration period = 2[(gogoproto.nullable) = false]; repeated cosmos_sdk.v1.Coin period_spend_limit = 3 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"period_spend_limit\"" - ]; + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"period_spend_limit\"" + ]; repeated cosmos_sdk.v1.Coin period_can_spend = 4 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"period_can_spend\"" - ]; - - ExpiresAt period_reset = 5 [(gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"period_reset\""]; + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"period_can_spend\"" + ]; + + ExpiresAt period_reset = 5 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"period_reset\"" + ]; } // Duration is a repeating unit of either clock time or number of blocks. // This is designed to be added to an ExpiresAt struct. message Duration{ option (gogoproto.equal) = true; - google.protobuf.Timestamp clock = 1[(gogoproto.stdduration) = true, - (gogoproto.nullable) = false - ]; + google.protobuf.Timestamp clock = 1 [ + (gogoproto.stdduration) = true, + (gogoproto.nullable) = false + ]; int64 block = 2; } @@ -87,19 +96,20 @@ message Duration{ // It may be *either* block time or block height message ExpiresAt{ option (gogoproto.equal) = true; - google.protobuf.Timestamp time = 1 [(gogoproto.stdtime) = true, - (gogoproto.nullable) = false - ]; + google.protobuf.Timestamp time = 1 [ + (gogoproto.stdtime) = true, + (gogoproto.nullable) = false + ]; int64 height = 2; } - - // FeeAllowanceGrant is stored in the KVStore to record a grant with full context message FeeAllowanceGrant{ option (gogoproto.goproto_getters) = false; bytes granter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; bytes grantee = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - FeeAllowance allowance = 3; -} \ No newline at end of file + google.protobuf.Any allowance = 3 [ + (cosmos_proto.accepts_interface) = "FeeAllowanceI" + ]; +} From 3d72df89344e0c1101b72debdacb8f8d66283bcb Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 26 Nov 2020 13:24:15 +0530 Subject: [PATCH 079/184] proto changes --- proto/cosmos/feegrant/v1beta1/feegrant.proto | 90 + x/feegrant/types/feegrant.pb.go | 2106 ++++++++++++++++++ x/feegrant/types/types.proto | 115 - 3 files changed, 2196 insertions(+), 115 deletions(-) create mode 100644 proto/cosmos/feegrant/v1beta1/feegrant.proto create mode 100644 x/feegrant/types/feegrant.pb.go delete mode 100644 x/feegrant/types/types.proto diff --git a/proto/cosmos/feegrant/v1beta1/feegrant.proto b/proto/cosmos/feegrant/v1beta1/feegrant.proto new file mode 100644 index 000000000000..39d22cc508c5 --- /dev/null +++ b/proto/cosmos/feegrant/v1beta1/feegrant.proto @@ -0,0 +1,90 @@ +syntax = "proto3"; +package cosmos.feegrant.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "tendermint/types/types.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; + +// MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance +// of fees from the account of Granter. +message MsgGrantFeeAllowance { + option (gogoproto.goproto_getters) = false; + + bytes granter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + bytes grantee = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + google.protobuf.Any allowance = 3 [(cosmos_proto.accepts_interface) = "FeeAllowanceI"]; +} + +// MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee. +message MsgRevokeFeeAllowance { + bytes granter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + bytes grantee = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +} + +// BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens +// that optionally expires. The delegatee can use up to SpendLimit to cover fees. +message BasicFeeAllowance { + option (gogoproto.equal) = true; + option (gogoproto.goproto_getters) = false; + option (cosmos_proto.implements_interface) = "FeeAllowanceI"; + + repeated cosmos.base.v1beta1.Coin spend_limit = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"spend_limit\"" + ]; + ExpiresAt expiration = 2 [(gogoproto.nullable) = false]; +} + +// PeriodicFeeAllowance extends FeeAllowance to allow for both a maximum cap, +// as well as a limit per time period. +message PeriodicFeeAllowance { + option (gogoproto.equal) = true; + option (gogoproto.goproto_getters) = false; + option (cosmos_proto.implements_interface) = "FeeAllowanceI"; + + BasicFeeAllowance basic = 1 [(gogoproto.nullable) = false]; + Duration period = 2 [(gogoproto.nullable) = false]; + repeated cosmos.base.v1beta1.Coin period_spend_limit = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"period_spend_limit\"" + ]; + repeated cosmos.base.v1beta1.Coin period_can_spend = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"period_can_spend\"" + ]; + + ExpiresAt period_reset = 5 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"period_reset\""]; +} + +// Duration is a repeating unit of either clock time or number of blocks. +// This is designed to be added to an ExpiresAt struct. +message Duration { + option (gogoproto.equal) = true; + google.protobuf.Timestamp clock = 1 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + int64 block = 2; +} + +// ExpiresAt is a point in time where something expires. +// It may be *either* block time or block height +message ExpiresAt { + option (gogoproto.equal) = true; + google.protobuf.Timestamp time = 1 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; + int64 height = 2; +} + +// FeeAllowanceGrant is stored in the KVStore to record a grant with full context +message FeeAllowanceGrant { + option (gogoproto.goproto_getters) = false; + + bytes granter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + bytes grantee = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + google.protobuf.Any allowance = 3 [(cosmos_proto.accepts_interface) = "FeeAllowanceI"]; +} diff --git a/x/feegrant/types/feegrant.pb.go b/x/feegrant/types/feegrant.pb.go new file mode 100644 index 000000000000..8abef53df106 --- /dev/null +++ b/x/feegrant/types/feegrant.pb.go @@ -0,0 +1,2106 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/feegrant/v1beta1/feegrant.proto + +package types + +import ( + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/codec/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types1 "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + _ "github.com/golang/protobuf/ptypes/timestamp" + _ "github.com/regen-network/cosmos-proto" + _ "github.com/tendermint/tendermint/proto/tendermint/types" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// 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 + +// MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance +// of fees from the account of Granter. +type MsgGrantFeeAllowance struct { + Granter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=granter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"granter,omitempty"` + Grantee github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=grantee,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"grantee,omitempty"` + Allowance *types.Any `protobuf:"bytes,3,opt,name=allowance,proto3" json:"allowance,omitempty"` +} + +func (m *MsgGrantFeeAllowance) Reset() { *m = MsgGrantFeeAllowance{} } +func (m *MsgGrantFeeAllowance) String() string { return proto.CompactTextString(m) } +func (*MsgGrantFeeAllowance) ProtoMessage() {} +func (*MsgGrantFeeAllowance) Descriptor() ([]byte, []int) { + return fileDescriptor_7279582900c30aea, []int{0} +} +func (m *MsgGrantFeeAllowance) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgGrantFeeAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgGrantFeeAllowance.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 *MsgGrantFeeAllowance) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgGrantFeeAllowance.Merge(m, src) +} +func (m *MsgGrantFeeAllowance) XXX_Size() int { + return m.Size() +} +func (m *MsgGrantFeeAllowance) XXX_DiscardUnknown() { + xxx_messageInfo_MsgGrantFeeAllowance.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgGrantFeeAllowance proto.InternalMessageInfo + +// MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee. +type MsgRevokeFeeAllowance struct { + Granter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=granter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"granter,omitempty"` + Grantee github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=grantee,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"grantee,omitempty"` +} + +func (m *MsgRevokeFeeAllowance) Reset() { *m = MsgRevokeFeeAllowance{} } +func (m *MsgRevokeFeeAllowance) String() string { return proto.CompactTextString(m) } +func (*MsgRevokeFeeAllowance) ProtoMessage() {} +func (*MsgRevokeFeeAllowance) Descriptor() ([]byte, []int) { + return fileDescriptor_7279582900c30aea, []int{1} +} +func (m *MsgRevokeFeeAllowance) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRevokeFeeAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRevokeFeeAllowance.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 *MsgRevokeFeeAllowance) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRevokeFeeAllowance.Merge(m, src) +} +func (m *MsgRevokeFeeAllowance) XXX_Size() int { + return m.Size() +} +func (m *MsgRevokeFeeAllowance) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRevokeFeeAllowance.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRevokeFeeAllowance proto.InternalMessageInfo + +func (m *MsgRevokeFeeAllowance) GetGranter() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Granter + } + return nil +} + +func (m *MsgRevokeFeeAllowance) GetGrantee() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Grantee + } + return nil +} + +// BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens +// that optionally expires. The delegatee can use up to SpendLimit to cover fees. +type BasicFeeAllowance struct { + SpendLimit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=spend_limit,json=spendLimit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"spend_limit" yaml:"spend_limit"` + Expiration ExpiresAt `protobuf:"bytes,2,opt,name=expiration,proto3" json:"expiration"` +} + +func (m *BasicFeeAllowance) Reset() { *m = BasicFeeAllowance{} } +func (m *BasicFeeAllowance) String() string { return proto.CompactTextString(m) } +func (*BasicFeeAllowance) ProtoMessage() {} +func (*BasicFeeAllowance) Descriptor() ([]byte, []int) { + return fileDescriptor_7279582900c30aea, []int{2} +} +func (m *BasicFeeAllowance) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BasicFeeAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BasicFeeAllowance.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 *BasicFeeAllowance) XXX_Merge(src proto.Message) { + xxx_messageInfo_BasicFeeAllowance.Merge(m, src) +} +func (m *BasicFeeAllowance) XXX_Size() int { + return m.Size() +} +func (m *BasicFeeAllowance) XXX_DiscardUnknown() { + xxx_messageInfo_BasicFeeAllowance.DiscardUnknown(m) +} + +var xxx_messageInfo_BasicFeeAllowance proto.InternalMessageInfo + +// PeriodicFeeAllowance extends FeeAllowance to allow for both a maximum cap, +// as well as a limit per time period. +type PeriodicFeeAllowance struct { + Basic BasicFeeAllowance `protobuf:"bytes,1,opt,name=basic,proto3" json:"basic"` + Period Duration `protobuf:"bytes,2,opt,name=period,proto3" json:"period"` + PeriodSpendLimit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=period_spend_limit,json=periodSpendLimit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"period_spend_limit" yaml:"period_spend_limit"` + PeriodCanSpend github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=period_can_spend,json=periodCanSpend,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"period_can_spend" yaml:"period_can_spend"` + PeriodReset ExpiresAt `protobuf:"bytes,5,opt,name=period_reset,json=periodReset,proto3" json:"period_reset" yaml:"period_reset"` +} + +func (m *PeriodicFeeAllowance) Reset() { *m = PeriodicFeeAllowance{} } +func (m *PeriodicFeeAllowance) String() string { return proto.CompactTextString(m) } +func (*PeriodicFeeAllowance) ProtoMessage() {} +func (*PeriodicFeeAllowance) Descriptor() ([]byte, []int) { + return fileDescriptor_7279582900c30aea, []int{3} +} +func (m *PeriodicFeeAllowance) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PeriodicFeeAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PeriodicFeeAllowance.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 *PeriodicFeeAllowance) XXX_Merge(src proto.Message) { + xxx_messageInfo_PeriodicFeeAllowance.Merge(m, src) +} +func (m *PeriodicFeeAllowance) XXX_Size() int { + return m.Size() +} +func (m *PeriodicFeeAllowance) XXX_DiscardUnknown() { + xxx_messageInfo_PeriodicFeeAllowance.DiscardUnknown(m) +} + +var xxx_messageInfo_PeriodicFeeAllowance proto.InternalMessageInfo + +// Duration is a repeating unit of either clock time or number of blocks. +// This is designed to be added to an ExpiresAt struct. +type Duration struct { + Clock time.Duration `protobuf:"bytes,1,opt,name=clock,proto3,stdduration" json:"clock"` + Block int64 `protobuf:"varint,2,opt,name=block,proto3" json:"block,omitempty"` +} + +func (m *Duration) Reset() { *m = Duration{} } +func (m *Duration) String() string { return proto.CompactTextString(m) } +func (*Duration) ProtoMessage() {} +func (*Duration) Descriptor() ([]byte, []int) { + return fileDescriptor_7279582900c30aea, []int{4} +} +func (m *Duration) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Duration) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Duration.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 *Duration) XXX_Merge(src proto.Message) { + xxx_messageInfo_Duration.Merge(m, src) +} +func (m *Duration) XXX_Size() int { + return m.Size() +} +func (m *Duration) XXX_DiscardUnknown() { + xxx_messageInfo_Duration.DiscardUnknown(m) +} + +var xxx_messageInfo_Duration proto.InternalMessageInfo + +func (m *Duration) GetClock() time.Duration { + if m != nil { + return m.Clock + } + return 0 +} + +func (m *Duration) GetBlock() int64 { + if m != nil { + return m.Block + } + return 0 +} + +// ExpiresAt is a point in time where something expires. +// It may be *either* block time or block height +type ExpiresAt struct { + Time time.Time `protobuf:"bytes,1,opt,name=time,proto3,stdtime" json:"time"` + Height int64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` +} + +func (m *ExpiresAt) Reset() { *m = ExpiresAt{} } +func (m *ExpiresAt) String() string { return proto.CompactTextString(m) } +func (*ExpiresAt) ProtoMessage() {} +func (*ExpiresAt) Descriptor() ([]byte, []int) { + return fileDescriptor_7279582900c30aea, []int{5} +} +func (m *ExpiresAt) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ExpiresAt) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ExpiresAt.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 *ExpiresAt) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExpiresAt.Merge(m, src) +} +func (m *ExpiresAt) XXX_Size() int { + return m.Size() +} +func (m *ExpiresAt) XXX_DiscardUnknown() { + xxx_messageInfo_ExpiresAt.DiscardUnknown(m) +} + +var xxx_messageInfo_ExpiresAt proto.InternalMessageInfo + +func (m *ExpiresAt) GetTime() time.Time { + if m != nil { + return m.Time + } + return time.Time{} +} + +func (m *ExpiresAt) GetHeight() int64 { + if m != nil { + return m.Height + } + return 0 +} + +// FeeAllowanceGrant is stored in the KVStore to record a grant with full context +type FeeAllowanceGrant struct { + Granter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=granter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"granter,omitempty"` + Grantee github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=grantee,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"grantee,omitempty"` + Allowance *types.Any `protobuf:"bytes,3,opt,name=allowance,proto3" json:"allowance,omitempty"` +} + +func (m *FeeAllowanceGrant) Reset() { *m = FeeAllowanceGrant{} } +func (m *FeeAllowanceGrant) String() string { return proto.CompactTextString(m) } +func (*FeeAllowanceGrant) ProtoMessage() {} +func (*FeeAllowanceGrant) Descriptor() ([]byte, []int) { + return fileDescriptor_7279582900c30aea, []int{6} +} +func (m *FeeAllowanceGrant) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FeeAllowanceGrant) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FeeAllowanceGrant.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 *FeeAllowanceGrant) XXX_Merge(src proto.Message) { + xxx_messageInfo_FeeAllowanceGrant.Merge(m, src) +} +func (m *FeeAllowanceGrant) XXX_Size() int { + return m.Size() +} +func (m *FeeAllowanceGrant) XXX_DiscardUnknown() { + xxx_messageInfo_FeeAllowanceGrant.DiscardUnknown(m) +} + +var xxx_messageInfo_FeeAllowanceGrant proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgGrantFeeAllowance)(nil), "cosmos.feegrant.v1beta1.MsgGrantFeeAllowance") + proto.RegisterType((*MsgRevokeFeeAllowance)(nil), "cosmos.feegrant.v1beta1.MsgRevokeFeeAllowance") + proto.RegisterType((*BasicFeeAllowance)(nil), "cosmos.feegrant.v1beta1.BasicFeeAllowance") + proto.RegisterType((*PeriodicFeeAllowance)(nil), "cosmos.feegrant.v1beta1.PeriodicFeeAllowance") + proto.RegisterType((*Duration)(nil), "cosmos.feegrant.v1beta1.Duration") + proto.RegisterType((*ExpiresAt)(nil), "cosmos.feegrant.v1beta1.ExpiresAt") + proto.RegisterType((*FeeAllowanceGrant)(nil), "cosmos.feegrant.v1beta1.FeeAllowanceGrant") +} + +func init() { + proto.RegisterFile("cosmos/feegrant/v1beta1/feegrant.proto", fileDescriptor_7279582900c30aea) +} + +var fileDescriptor_7279582900c30aea = []byte{ + // 706 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x55, 0xbf, 0x4f, 0x13, 0x51, + 0x1c, 0xef, 0xb3, 0x2d, 0xc2, 0x2b, 0x1a, 0x39, 0xab, 0xb4, 0x68, 0xee, 0xf0, 0x06, 0xd3, 0x98, + 0x70, 0x0d, 0x75, 0x31, 0x5d, 0x4c, 0x0f, 0x01, 0x0d, 0x92, 0x98, 0xd3, 0xc9, 0xa5, 0xb9, 0xbb, + 0x7e, 0x39, 0x2e, 0xf4, 0xee, 0x35, 0xf7, 0x1e, 0x48, 0x57, 0x27, 0x47, 0x26, 0xe3, 0xc8, 0xec, + 0x66, 0xe2, 0x1f, 0x41, 0x98, 0x88, 0x93, 0x13, 0x18, 0x58, 0x9c, 0x1d, 0x49, 0x4c, 0xcc, 0xfb, + 0x71, 0x6d, 0x81, 0x00, 0x25, 0x4e, 0xc6, 0xa5, 0xbd, 0x77, 0xef, 0xfb, 0xf9, 0xf1, 0x7d, 0x9f, + 0x6f, 0x5f, 0xf1, 0x43, 0x9f, 0xd0, 0x88, 0xd0, 0xea, 0x0a, 0x40, 0x90, 0xb8, 0x31, 0xab, 0x6e, + 0xcc, 0x7a, 0xc0, 0xdc, 0xd9, 0xde, 0x0b, 0xab, 0x93, 0x10, 0x46, 0xb4, 0x49, 0x59, 0x67, 0xf5, + 0x5e, 0xab, 0xba, 0xa9, 0x62, 0x40, 0x02, 0x22, 0x6a, 0xaa, 0xfc, 0x49, 0x96, 0x4f, 0x95, 0x03, + 0x42, 0x82, 0x36, 0x54, 0xc5, 0xca, 0x5b, 0x5f, 0xa9, 0xba, 0x71, 0x37, 0xdd, 0x92, 0x4c, 0x4d, + 0x89, 0x51, 0xb4, 0x72, 0x4b, 0x57, 0x66, 0x3c, 0x97, 0x42, 0xcf, 0x88, 0x4f, 0xc2, 0x58, 0xed, + 0xdf, 0x67, 0x10, 0xb7, 0x20, 0x89, 0xc2, 0x98, 0x55, 0x59, 0xb7, 0x03, 0x54, 0x7e, 0xaa, 0x5d, + 0xe3, 0xb4, 0x26, 0x0b, 0x23, 0xa0, 0xcc, 0x8d, 0x3a, 0xb2, 0xc0, 0xfc, 0x8d, 0x70, 0x71, 0x99, + 0x06, 0x8b, 0xdc, 0xff, 0x02, 0x40, 0xa3, 0xdd, 0x26, 0xef, 0xdc, 0xd8, 0x07, 0x6d, 0x09, 0x5f, + 0x17, 0x4d, 0x41, 0x52, 0x42, 0xd3, 0xa8, 0x32, 0x6e, 0xcf, 0x1e, 0xef, 0x1b, 0x33, 0x41, 0xc8, + 0x56, 0xd7, 0x3d, 0xcb, 0x27, 0x91, 0x72, 0xa9, 0xbe, 0x66, 0x68, 0x6b, 0x4d, 0x09, 0x37, 0x7c, + 0xbf, 0xd1, 0x6a, 0x25, 0x40, 0xa9, 0x93, 0x32, 0xf4, 0xc9, 0xa0, 0x74, 0xed, 0x2f, 0xc9, 0x40, + 0x9b, 0xc7, 0x63, 0x6e, 0x6a, 0xb3, 0x94, 0x9d, 0x46, 0x95, 0x42, 0xad, 0x68, 0xc9, 0x3e, 0xad, + 0xb4, 0x4f, 0xab, 0x11, 0x77, 0xed, 0x89, 0xdd, 0xaf, 0x33, 0x37, 0x06, 0x9b, 0x7a, 0xe1, 0xf4, + 0x91, 0xf5, 0xdc, 0x87, 0x6d, 0x23, 0x63, 0x7e, 0x41, 0xf8, 0xce, 0x32, 0x0d, 0x1c, 0xd8, 0x20, + 0x6b, 0xf0, 0x6f, 0x1c, 0x00, 0xcf, 0x6c, 0xc2, 0x76, 0x69, 0xe8, 0x9f, 0xf0, 0xfb, 0x1e, 0xe1, + 0x02, 0xed, 0x40, 0xdc, 0x6a, 0xb6, 0xc3, 0x28, 0x64, 0x25, 0x34, 0x9d, 0xad, 0x14, 0x6a, 0x65, + 0x4b, 0x4d, 0x13, 0x9f, 0x9f, 0x74, 0x40, 0xad, 0x39, 0x12, 0xc6, 0xf6, 0xc2, 0xce, 0xbe, 0x91, + 0xf9, 0xb5, 0x6f, 0x68, 0x5d, 0x37, 0x6a, 0xd7, 0xcd, 0x01, 0xac, 0xf9, 0xf9, 0xc0, 0xa8, 0x0c, + 0x61, 0x8e, 0xd3, 0x50, 0x07, 0x0b, 0xe4, 0x4b, 0x0e, 0xd4, 0x9e, 0x63, 0x0c, 0x9b, 0x9d, 0x30, + 0x71, 0x59, 0x48, 0x62, 0xd1, 0x6a, 0xa1, 0x66, 0x5a, 0xe7, 0xfc, 0x4e, 0xac, 0x79, 0x5e, 0x0a, + 0xb4, 0xc1, 0xec, 0x1c, 0xf7, 0xe2, 0x0c, 0x60, 0xeb, 0x65, 0x1e, 0xcf, 0xcf, 0x6d, 0x03, 0x7d, + 0x3b, 0x1d, 0xa2, 0xb9, 0x9b, 0xc3, 0xc5, 0x57, 0x90, 0x84, 0xa4, 0x75, 0xea, 0x08, 0x16, 0x70, + 0xde, 0xe3, 0xe7, 0x22, 0x02, 0x2b, 0xd4, 0x1e, 0x9d, 0x2b, 0x7c, 0xe6, 0xf4, 0x94, 0x01, 0x09, + 0xd7, 0x9e, 0xe2, 0x91, 0x8e, 0xe0, 0x57, 0x1d, 0x3c, 0x38, 0x97, 0xe8, 0xd9, 0xba, 0xb4, 0xab, + 0xf0, 0x0a, 0xa6, 0x7d, 0x44, 0x58, 0x93, 0x8f, 0xcd, 0xc1, 0x48, 0xb2, 0x97, 0x45, 0xb2, 0xac, + 0x22, 0x29, 0xcb, 0x48, 0xce, 0x52, 0x5c, 0x2d, 0x99, 0x5b, 0x92, 0xe0, 0x75, 0x3f, 0x9f, 0x2d, + 0x84, 0xd5, 0xcb, 0xa6, 0xef, 0xc6, 0x92, 0xb9, 0x94, 0xbb, 0xcc, 0xd6, 0x92, 0xb2, 0x35, 0x79, + 0xc2, 0x56, 0x8f, 0xe0, 0x6a, 0xa6, 0x6e, 0x4a, 0xf8, 0x9c, 0x1b, 0x0b, 0x5f, 0x9a, 0x87, 0xc7, + 0x15, 0x61, 0x02, 0x14, 0x58, 0x29, 0x3f, 0xf4, 0xd0, 0xdc, 0x53, 0xb6, 0x6e, 0x9f, 0xb0, 0x25, + 0x58, 0x4c, 0xa7, 0x20, 0x97, 0x0e, 0x5f, 0x5d, 0x34, 0x4c, 0x1e, 0x1e, 0x4d, 0x43, 0xd4, 0xea, + 0x38, 0xef, 0xb7, 0x89, 0xbf, 0xa6, 0xe6, 0x67, 0xea, 0xcc, 0xad, 0xf2, 0x26, 0xbd, 0x3d, 0xed, + 0x51, 0xae, 0xfd, 0xe9, 0xc0, 0x40, 0x8e, 0x84, 0x68, 0x45, 0x9c, 0xf7, 0x04, 0x96, 0x8f, 0x4c, + 0xd6, 0x91, 0x8b, 0x7a, 0x8e, 0x8b, 0x9a, 0x3e, 0x1e, 0xeb, 0xb9, 0xd6, 0x9e, 0xe0, 0x1c, 0xbf, + 0x84, 0x87, 0xd5, 0xd8, 0xe2, 0x1a, 0x02, 0xa1, 0xdd, 0xc5, 0x23, 0xab, 0x10, 0x06, 0xab, 0x4c, + 0x69, 0xa8, 0x95, 0x12, 0x39, 0x46, 0x78, 0x62, 0xb0, 0x35, 0x71, 0xa5, 0xff, 0x27, 0xd7, 0xb8, + 0xbd, 0xb8, 0x73, 0xa8, 0xa3, 0xbd, 0x43, 0x1d, 0xfd, 0x38, 0xd4, 0xd1, 0xd6, 0x91, 0x9e, 0xd9, + 0x3b, 0xd2, 0x33, 0xdf, 0x8f, 0xf4, 0xcc, 0xdb, 0x8b, 0xed, 0x6d, 0xf6, 0xff, 0xe4, 0x85, 0x53, + 0x6f, 0x44, 0x48, 0x3f, 0xfe, 0x13, 0x00, 0x00, 0xff, 0xff, 0xc7, 0xdf, 0x09, 0xbc, 0x04, 0x08, + 0x00, 0x00, +} + +func (this *BasicFeeAllowance) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*BasicFeeAllowance) + if !ok { + that2, ok := that.(BasicFeeAllowance) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.SpendLimit) != len(that1.SpendLimit) { + return false + } + for i := range this.SpendLimit { + if !this.SpendLimit[i].Equal(&that1.SpendLimit[i]) { + return false + } + } + if !this.Expiration.Equal(&that1.Expiration) { + return false + } + return true +} +func (this *PeriodicFeeAllowance) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*PeriodicFeeAllowance) + if !ok { + that2, ok := that.(PeriodicFeeAllowance) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Basic.Equal(&that1.Basic) { + return false + } + if !this.Period.Equal(&that1.Period) { + return false + } + if len(this.PeriodSpendLimit) != len(that1.PeriodSpendLimit) { + return false + } + for i := range this.PeriodSpendLimit { + if !this.PeriodSpendLimit[i].Equal(&that1.PeriodSpendLimit[i]) { + return false + } + } + if len(this.PeriodCanSpend) != len(that1.PeriodCanSpend) { + return false + } + for i := range this.PeriodCanSpend { + if !this.PeriodCanSpend[i].Equal(&that1.PeriodCanSpend[i]) { + return false + } + } + if !this.PeriodReset.Equal(&that1.PeriodReset) { + return false + } + return true +} +func (this *Duration) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Duration) + if !ok { + that2, ok := that.(Duration) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Clock != that1.Clock { + return false + } + if this.Block != that1.Block { + return false + } + return true +} +func (this *ExpiresAt) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ExpiresAt) + if !ok { + that2, ok := that.(ExpiresAt) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Time.Equal(that1.Time) { + return false + } + if this.Height != that1.Height { + return false + } + return true +} +func (m *MsgGrantFeeAllowance) 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 *MsgGrantFeeAllowance) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgGrantFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Allowance != nil { + { + size, err := m.Allowance.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFeegrant(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.Grantee) > 0 { + i -= len(m.Grantee) + copy(dAtA[i:], m.Grantee) + i = encodeVarintFeegrant(dAtA, i, uint64(len(m.Grantee))) + i-- + dAtA[i] = 0x12 + } + if len(m.Granter) > 0 { + i -= len(m.Granter) + copy(dAtA[i:], m.Granter) + i = encodeVarintFeegrant(dAtA, i, uint64(len(m.Granter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRevokeFeeAllowance) 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 *MsgRevokeFeeAllowance) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRevokeFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Grantee) > 0 { + i -= len(m.Grantee) + copy(dAtA[i:], m.Grantee) + i = encodeVarintFeegrant(dAtA, i, uint64(len(m.Grantee))) + i-- + dAtA[i] = 0x12 + } + if len(m.Granter) > 0 { + i -= len(m.Granter) + copy(dAtA[i:], m.Granter) + i = encodeVarintFeegrant(dAtA, i, uint64(len(m.Granter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *BasicFeeAllowance) 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 *BasicFeeAllowance) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BasicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Expiration.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFeegrant(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.SpendLimit) > 0 { + for iNdEx := len(m.SpendLimit) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SpendLimit[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFeegrant(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *PeriodicFeeAllowance) 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 *PeriodicFeeAllowance) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PeriodicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.PeriodReset.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFeegrant(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + if len(m.PeriodCanSpend) > 0 { + for iNdEx := len(m.PeriodCanSpend) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PeriodCanSpend[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFeegrant(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.PeriodSpendLimit) > 0 { + for iNdEx := len(m.PeriodSpendLimit) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PeriodSpendLimit[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFeegrant(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + { + size, err := m.Period.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFeegrant(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.Basic.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFeegrant(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *Duration) 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 *Duration) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Duration) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Block != 0 { + i = encodeVarintFeegrant(dAtA, i, uint64(m.Block)) + i-- + dAtA[i] = 0x10 + } + n6, err6 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.Clock, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.Clock):]) + if err6 != nil { + return 0, err6 + } + i -= n6 + i = encodeVarintFeegrant(dAtA, i, uint64(n6)) + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *ExpiresAt) 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 *ExpiresAt) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ExpiresAt) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Height != 0 { + i = encodeVarintFeegrant(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x10 + } + n7, err7 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Time):]) + if err7 != nil { + return 0, err7 + } + i -= n7 + i = encodeVarintFeegrant(dAtA, i, uint64(n7)) + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *FeeAllowanceGrant) 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 *FeeAllowanceGrant) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FeeAllowanceGrant) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Allowance != nil { + { + size, err := m.Allowance.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFeegrant(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.Grantee) > 0 { + i -= len(m.Grantee) + copy(dAtA[i:], m.Grantee) + i = encodeVarintFeegrant(dAtA, i, uint64(len(m.Grantee))) + i-- + dAtA[i] = 0x12 + } + if len(m.Granter) > 0 { + i -= len(m.Granter) + copy(dAtA[i:], m.Granter) + i = encodeVarintFeegrant(dAtA, i, uint64(len(m.Granter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintFeegrant(dAtA []byte, offset int, v uint64) int { + offset -= sovFeegrant(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgGrantFeeAllowance) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Granter) + if l > 0 { + n += 1 + l + sovFeegrant(uint64(l)) + } + l = len(m.Grantee) + if l > 0 { + n += 1 + l + sovFeegrant(uint64(l)) + } + if m.Allowance != nil { + l = m.Allowance.Size() + n += 1 + l + sovFeegrant(uint64(l)) + } + return n +} + +func (m *MsgRevokeFeeAllowance) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Granter) + if l > 0 { + n += 1 + l + sovFeegrant(uint64(l)) + } + l = len(m.Grantee) + if l > 0 { + n += 1 + l + sovFeegrant(uint64(l)) + } + return n +} + +func (m *BasicFeeAllowance) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.SpendLimit) > 0 { + for _, e := range m.SpendLimit { + l = e.Size() + n += 1 + l + sovFeegrant(uint64(l)) + } + } + l = m.Expiration.Size() + n += 1 + l + sovFeegrant(uint64(l)) + return n +} + +func (m *PeriodicFeeAllowance) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Basic.Size() + n += 1 + l + sovFeegrant(uint64(l)) + l = m.Period.Size() + n += 1 + l + sovFeegrant(uint64(l)) + if len(m.PeriodSpendLimit) > 0 { + for _, e := range m.PeriodSpendLimit { + l = e.Size() + n += 1 + l + sovFeegrant(uint64(l)) + } + } + if len(m.PeriodCanSpend) > 0 { + for _, e := range m.PeriodCanSpend { + l = e.Size() + n += 1 + l + sovFeegrant(uint64(l)) + } + } + l = m.PeriodReset.Size() + n += 1 + l + sovFeegrant(uint64(l)) + return n +} + +func (m *Duration) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.Clock) + n += 1 + l + sovFeegrant(uint64(l)) + if m.Block != 0 { + n += 1 + sovFeegrant(uint64(m.Block)) + } + return n +} + +func (m *ExpiresAt) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Time) + n += 1 + l + sovFeegrant(uint64(l)) + if m.Height != 0 { + n += 1 + sovFeegrant(uint64(m.Height)) + } + return n +} + +func (m *FeeAllowanceGrant) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Granter) + if l > 0 { + n += 1 + l + sovFeegrant(uint64(l)) + } + l = len(m.Grantee) + if l > 0 { + n += 1 + l + sovFeegrant(uint64(l)) + } + if m.Allowance != nil { + l = m.Allowance.Size() + n += 1 + l + sovFeegrant(uint64(l)) + } + return n +} + +func sovFeegrant(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozFeegrant(x uint64) (n int) { + return sovFeegrant(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgGrantFeeAllowance) 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 ErrIntOverflowFeegrant + } + 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: MsgGrantFeeAllowance: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgGrantFeeAllowance: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Granter", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeegrant + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthFeegrant + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthFeegrant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Granter = append(m.Granter[:0], dAtA[iNdEx:postIndex]...) + if m.Granter == nil { + m.Granter = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeegrant + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthFeegrant + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthFeegrant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Grantee = append(m.Grantee[:0], dAtA[iNdEx:postIndex]...) + if m.Grantee == nil { + m.Grantee = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Allowance", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeegrant + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFeegrant + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFeegrant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Allowance == nil { + m.Allowance = &types.Any{} + } + if err := m.Allowance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFeegrant(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthFeegrant + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthFeegrant + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRevokeFeeAllowance) 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 ErrIntOverflowFeegrant + } + 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: MsgRevokeFeeAllowance: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRevokeFeeAllowance: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Granter", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeegrant + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthFeegrant + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthFeegrant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Granter = append(m.Granter[:0], dAtA[iNdEx:postIndex]...) + if m.Granter == nil { + m.Granter = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeegrant + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthFeegrant + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthFeegrant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Grantee = append(m.Grantee[:0], dAtA[iNdEx:postIndex]...) + if m.Grantee == nil { + m.Grantee = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFeegrant(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthFeegrant + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthFeegrant + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BasicFeeAllowance) 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 ErrIntOverflowFeegrant + } + 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: BasicFeeAllowance: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BasicFeeAllowance: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpendLimit", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeegrant + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFeegrant + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFeegrant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpendLimit = append(m.SpendLimit, types1.Coin{}) + if err := m.SpendLimit[len(m.SpendLimit)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Expiration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeegrant + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFeegrant + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFeegrant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Expiration.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFeegrant(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthFeegrant + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthFeegrant + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PeriodicFeeAllowance) 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 ErrIntOverflowFeegrant + } + 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: PeriodicFeeAllowance: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PeriodicFeeAllowance: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Basic", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeegrant + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFeegrant + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFeegrant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Basic.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Period", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeegrant + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFeegrant + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFeegrant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Period.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PeriodSpendLimit", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeegrant + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFeegrant + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFeegrant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PeriodSpendLimit = append(m.PeriodSpendLimit, types1.Coin{}) + if err := m.PeriodSpendLimit[len(m.PeriodSpendLimit)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PeriodCanSpend", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeegrant + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFeegrant + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFeegrant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PeriodCanSpend = append(m.PeriodCanSpend, types1.Coin{}) + if err := m.PeriodCanSpend[len(m.PeriodCanSpend)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PeriodReset", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeegrant + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFeegrant + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFeegrant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PeriodReset.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFeegrant(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthFeegrant + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthFeegrant + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Duration) 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 ErrIntOverflowFeegrant + } + 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: Duration: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Duration: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Clock", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeegrant + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFeegrant + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFeegrant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.Clock, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) + } + m.Block = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeegrant + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Block |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipFeegrant(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthFeegrant + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthFeegrant + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ExpiresAt) 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 ErrIntOverflowFeegrant + } + 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: ExpiresAt: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ExpiresAt: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeegrant + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFeegrant + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFeegrant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.Time, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeegrant + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipFeegrant(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthFeegrant + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthFeegrant + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FeeAllowanceGrant) 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 ErrIntOverflowFeegrant + } + 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: FeeAllowanceGrant: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FeeAllowanceGrant: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Granter", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeegrant + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthFeegrant + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthFeegrant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Granter = append(m.Granter[:0], dAtA[iNdEx:postIndex]...) + if m.Granter == nil { + m.Granter = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeegrant + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthFeegrant + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthFeegrant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Grantee = append(m.Grantee[:0], dAtA[iNdEx:postIndex]...) + if m.Grantee == nil { + m.Grantee = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Allowance", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeegrant + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFeegrant + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFeegrant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Allowance == nil { + m.Allowance = &types.Any{} + } + if err := m.Allowance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFeegrant(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthFeegrant + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthFeegrant + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipFeegrant(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, ErrIntOverflowFeegrant + } + 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, ErrIntOverflowFeegrant + } + 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, ErrIntOverflowFeegrant + } + 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, ErrInvalidLengthFeegrant + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupFeegrant + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthFeegrant + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthFeegrant = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowFeegrant = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupFeegrant = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/feegrant/types/types.proto b/x/feegrant/types/types.proto deleted file mode 100644 index 4b69bf19b0cb..000000000000 --- a/x/feegrant/types/types.proto +++ /dev/null @@ -1,115 +0,0 @@ -syntax = "proto3"; -package cosmos_sdk.x.feegrant.v1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; - -import "third_party/proto/cosmos-proto/cosmos.proto"; -import "third_party/proto/gogoproto/gogo.proto"; -import "types/types.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/any.proto"; - -// FeeAllowance defines the application-level fee allowance to be used in -// feegrant module -// message FeeAllowance { -// option (gogoproto.equal) = true; -// option (cosmos_proto.interface_type) = "*FeeAllowanceI"; - -// // sum defines a set of all acceptable concrete feeallowance implementations. -// oneof sum{ -// BasicFeeAllowance basic_fee_allowance= 1; -// PeriodicFeeAllowance periodic_fee_allowance= 2; -// } -// } - -// MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance -// of fees from the account of Granter. -message MsgGrantFeeAllowance{ - option (gogoproto.goproto_getters) = false; - - bytes granter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - bytes grantee = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - google.protobuf.Any allowance = 3 [ - (cosmos_proto.accepts_interface) = "FeeAllowanceI" - ]; -} - -// MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee. -message MsgRevokeFeeAllowance{ - bytes granter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - bytes grantee = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; -} - -// BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens -// that optionally expires. The delegatee can use up to SpendLimit to cover fees. -message BasicFeeAllowance{ - option (gogoproto.equal) = true; - option (gogoproto.goproto_getters) = false; - option (cosmos_proto.implements_interface) = "FeeAllowanceI"; - - repeated cosmos_sdk.v1.Coin spend_limit = 1 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"spend_limit\"" - ]; - ExpiresAt expiration = 2 [(gogoproto.nullable) = false]; -} - -// PeriodicFeeAllowance extends FeeAllowance to allow for both a maximum cap, -// as well as a limit per time period. -message PeriodicFeeAllowance{ - option (gogoproto.equal) = true; - option (gogoproto.goproto_getters) = false; - option (cosmos_proto.implements_interface) = "FeeAllowanceI"; - - BasicFeeAllowance basic = 1[(gogoproto.nullable) = false]; - Duration period = 2[(gogoproto.nullable) = false]; - repeated cosmos_sdk.v1.Coin period_spend_limit = 3 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"period_spend_limit\"" - ]; - repeated cosmos_sdk.v1.Coin period_can_spend = 4 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"period_can_spend\"" - ]; - - ExpiresAt period_reset = 5 [ - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"period_reset\"" - ]; -} - -// Duration is a repeating unit of either clock time or number of blocks. -// This is designed to be added to an ExpiresAt struct. -message Duration{ - option (gogoproto.equal) = true; - google.protobuf.Timestamp clock = 1 [ - (gogoproto.stdduration) = true, - (gogoproto.nullable) = false - ]; - int64 block = 2; -} - -// ExpiresAt is a point in time where something expires. -// It may be *either* block time or block height -message ExpiresAt{ - option (gogoproto.equal) = true; - google.protobuf.Timestamp time = 1 [ - (gogoproto.stdtime) = true, - (gogoproto.nullable) = false - ]; - int64 height = 2; -} - -// FeeAllowanceGrant is stored in the KVStore to record a grant with full context -message FeeAllowanceGrant{ - option (gogoproto.goproto_getters) = false; - - bytes granter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - bytes grantee = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - google.protobuf.Any allowance = 3 [ - (cosmos_proto.accepts_interface) = "FeeAllowanceI" - ]; -} From 2e51274cb5a39ea6e4f58b910ec3dcaf6ab8bcdd Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 26 Nov 2020 18:14:20 +0530 Subject: [PATCH 080/184] proto changes --- proto/cosmos/feegrant/v1beta1/feegrant.proto | 23 +- proto/cosmos/feegrant/v1beta1/tx.proto | 24 + types/query/query.pb.go | 2 +- x/feegrant/types/codec.go | 23 +- x/feegrant/types/feegrant.pb.go | 632 +---- x/feegrant/types/msgs.go | 2 +- x/feegrant/types/tx.pb.go | 655 +++++ x/feegrant/types/types.pb.go | 2531 ------------------ 8 files changed, 765 insertions(+), 3127 deletions(-) mode change 100644 => 100755 proto/cosmos/feegrant/v1beta1/feegrant.proto create mode 100644 proto/cosmos/feegrant/v1beta1/tx.proto create mode 100644 x/feegrant/types/tx.pb.go delete mode 100644 x/feegrant/types/types.pb.go diff --git a/proto/cosmos/feegrant/v1beta1/feegrant.proto b/proto/cosmos/feegrant/v1beta1/feegrant.proto old mode 100644 new mode 100755 index 39d22cc508c5..652ba1db200a --- a/proto/cosmos/feegrant/v1beta1/feegrant.proto +++ b/proto/cosmos/feegrant/v1beta1/feegrant.proto @@ -5,27 +5,10 @@ import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; import "cosmos_proto/cosmos.proto"; import "cosmos/base/v1beta1/coin.proto"; -import "tendermint/types/types.proto"; import "google/protobuf/timestamp.proto"; option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; -// MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance -// of fees from the account of Granter. -message MsgGrantFeeAllowance { - option (gogoproto.goproto_getters) = false; - - bytes granter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - bytes grantee = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - google.protobuf.Any allowance = 3 [(cosmos_proto.accepts_interface) = "FeeAllowanceI"]; -} - -// MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee. -message MsgRevokeFeeAllowance { - bytes granter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - bytes grantee = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; -} - // BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens // that optionally expires. The delegatee can use up to SpendLimit to cover fees. message BasicFeeAllowance { @@ -67,7 +50,8 @@ message PeriodicFeeAllowance { // Duration is a repeating unit of either clock time or number of blocks. // This is designed to be added to an ExpiresAt struct. message Duration { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; + google.protobuf.Timestamp clock = 1 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; int64 block = 2; } @@ -75,7 +59,8 @@ message Duration { // ExpiresAt is a point in time where something expires. // It may be *either* block time or block height message ExpiresAt { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; + google.protobuf.Timestamp time = 1 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; int64 height = 2; } diff --git a/proto/cosmos/feegrant/v1beta1/tx.proto b/proto/cosmos/feegrant/v1beta1/tx.proto new file mode 100644 index 000000000000..6092c7a2c6b7 --- /dev/null +++ b/proto/cosmos/feegrant/v1beta1/tx.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; +package cosmos.feegrant.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; + +// MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance +// of fees from the account of Granter. +message MsgGrantFeeAllowance { + option (gogoproto.goproto_getters) = false; + + bytes granter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + bytes grantee = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + google.protobuf.Any allowance = 3 [(cosmos_proto.accepts_interface) = "FeeAllowanceI"]; +} + +// MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee. +message MsgRevokeFeeAllowance { + bytes granter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + bytes grantee = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +} diff --git a/types/query/query.pb.go b/types/query/query.pb.go index c04a6bde32b6..266d337002e8 100644 --- a/types/query/query.pb.go +++ b/types/query/query.pb.go @@ -783,7 +783,7 @@ type Module struct { Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` // module version Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` - //checksum + // checksum Sum string `protobuf:"bytes,3,opt,name=sum,proto3" json:"sum,omitempty"` } diff --git a/x/feegrant/types/codec.go b/x/feegrant/types/codec.go index a051889d6b2d..77ba5a2e15cb 100644 --- a/x/feegrant/types/codec.go +++ b/x/feegrant/types/codec.go @@ -2,26 +2,33 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" ) -// RegisterCodec registers the account types and interface -func RegisterCodec(cdc *codec.Codec) { - cdc.RegisterInterface((*isFeeAllowance_Sum)(nil), nil) +// RegisterLegacyAminoCodec registers the account types and interface +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + // cdc.RegisterInterface((*isFeeAllowance_Sum)(nil), nil) + // cdc.RegisterConcrete(&FeeAllowance_BasicFeeAllowance{}, "cosmos-sdk/ProtoBasicFeeAllowance", nil) cdc.RegisterInterface((*FeeAllowanceI)(nil), nil) - cdc.RegisterConcrete(&FeeAllowance_BasicFeeAllowance{}, "cosmos-sdk/ProtoBasicFeeAllowance", nil) cdc.RegisterConcrete(&BasicFeeAllowance{}, "cosmos-sdk/BasicFeeAllowance", nil) cdc.RegisterConcrete(&PeriodicFeeAllowance{}, "cosmos-sdk/PeriodicFeeAllowance", nil) cdc.RegisterConcrete(FeeGrantTx{}, "cosmos-sdk/FeeGrantTx", nil) } var ( - amino = codec.New() + amino = codec.NewLegacyAmino() - ModuleCdc = codec.NewHybridCodec(amino) + // ModuleCdc references the global x/feegrant module codec. Note, the codec should + // ONLY be used in certain instances of tests and for JSON encoding as Amino is + // still used for that purpose. + // + // The actual codec used for serialization should be provided to x/feegrant and + // defined at the application level. + ModuleCdc = codec.NewAminoCodec(amino) ) func init() { - RegisterCodec(amino) - codec.RegisterCrypto(amino) + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) amino.Seal() } diff --git a/x/feegrant/types/feegrant.pb.go b/x/feegrant/types/feegrant.pb.go index 8abef53df106..8272f29d77ae 100644 --- a/x/feegrant/types/feegrant.pb.go +++ b/x/feegrant/types/feegrant.pb.go @@ -5,15 +5,14 @@ package types import ( fmt "fmt" - types "github.com/cosmos/cosmos-sdk/codec/types" + types1 "github.com/cosmos/cosmos-sdk/codec/types" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types1 "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" _ "github.com/golang/protobuf/ptypes/timestamp" _ "github.com/regen-network/cosmos-proto" - _ "github.com/tendermint/tendermint/proto/tendermint/types" io "io" math "math" math_bits "math/bits" @@ -32,100 +31,6 @@ var _ = time.Kitchen // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance -// of fees from the account of Granter. -type MsgGrantFeeAllowance struct { - Granter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=granter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"granter,omitempty"` - Grantee github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=grantee,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"grantee,omitempty"` - Allowance *types.Any `protobuf:"bytes,3,opt,name=allowance,proto3" json:"allowance,omitempty"` -} - -func (m *MsgGrantFeeAllowance) Reset() { *m = MsgGrantFeeAllowance{} } -func (m *MsgGrantFeeAllowance) String() string { return proto.CompactTextString(m) } -func (*MsgGrantFeeAllowance) ProtoMessage() {} -func (*MsgGrantFeeAllowance) Descriptor() ([]byte, []int) { - return fileDescriptor_7279582900c30aea, []int{0} -} -func (m *MsgGrantFeeAllowance) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgGrantFeeAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgGrantFeeAllowance.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 *MsgGrantFeeAllowance) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgGrantFeeAllowance.Merge(m, src) -} -func (m *MsgGrantFeeAllowance) XXX_Size() int { - return m.Size() -} -func (m *MsgGrantFeeAllowance) XXX_DiscardUnknown() { - xxx_messageInfo_MsgGrantFeeAllowance.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgGrantFeeAllowance proto.InternalMessageInfo - -// MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee. -type MsgRevokeFeeAllowance struct { - Granter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=granter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"granter,omitempty"` - Grantee github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=grantee,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"grantee,omitempty"` -} - -func (m *MsgRevokeFeeAllowance) Reset() { *m = MsgRevokeFeeAllowance{} } -func (m *MsgRevokeFeeAllowance) String() string { return proto.CompactTextString(m) } -func (*MsgRevokeFeeAllowance) ProtoMessage() {} -func (*MsgRevokeFeeAllowance) Descriptor() ([]byte, []int) { - return fileDescriptor_7279582900c30aea, []int{1} -} -func (m *MsgRevokeFeeAllowance) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRevokeFeeAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRevokeFeeAllowance.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 *MsgRevokeFeeAllowance) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRevokeFeeAllowance.Merge(m, src) -} -func (m *MsgRevokeFeeAllowance) XXX_Size() int { - return m.Size() -} -func (m *MsgRevokeFeeAllowance) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRevokeFeeAllowance.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRevokeFeeAllowance proto.InternalMessageInfo - -func (m *MsgRevokeFeeAllowance) GetGranter() github_com_cosmos_cosmos_sdk_types.AccAddress { - if m != nil { - return m.Granter - } - return nil -} - -func (m *MsgRevokeFeeAllowance) GetGrantee() github_com_cosmos_cosmos_sdk_types.AccAddress { - if m != nil { - return m.Grantee - } - return nil -} - // BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens // that optionally expires. The delegatee can use up to SpendLimit to cover fees. type BasicFeeAllowance struct { @@ -137,7 +42,7 @@ func (m *BasicFeeAllowance) Reset() { *m = BasicFeeAllowance{} } func (m *BasicFeeAllowance) String() string { return proto.CompactTextString(m) } func (*BasicFeeAllowance) ProtoMessage() {} func (*BasicFeeAllowance) Descriptor() ([]byte, []int) { - return fileDescriptor_7279582900c30aea, []int{2} + return fileDescriptor_7279582900c30aea, []int{0} } func (m *BasicFeeAllowance) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -180,7 +85,7 @@ func (m *PeriodicFeeAllowance) Reset() { *m = PeriodicFeeAllowance{} } func (m *PeriodicFeeAllowance) String() string { return proto.CompactTextString(m) } func (*PeriodicFeeAllowance) ProtoMessage() {} func (*PeriodicFeeAllowance) Descriptor() ([]byte, []int) { - return fileDescriptor_7279582900c30aea, []int{3} + return fileDescriptor_7279582900c30aea, []int{1} } func (m *PeriodicFeeAllowance) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -220,7 +125,7 @@ func (m *Duration) Reset() { *m = Duration{} } func (m *Duration) String() string { return proto.CompactTextString(m) } func (*Duration) ProtoMessage() {} func (*Duration) Descriptor() ([]byte, []int) { - return fileDescriptor_7279582900c30aea, []int{4} + return fileDescriptor_7279582900c30aea, []int{2} } func (m *Duration) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -274,7 +179,7 @@ func (m *ExpiresAt) Reset() { *m = ExpiresAt{} } func (m *ExpiresAt) String() string { return proto.CompactTextString(m) } func (*ExpiresAt) ProtoMessage() {} func (*ExpiresAt) Descriptor() ([]byte, []int) { - return fileDescriptor_7279582900c30aea, []int{5} + return fileDescriptor_7279582900c30aea, []int{3} } func (m *ExpiresAt) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -321,14 +226,14 @@ func (m *ExpiresAt) GetHeight() int64 { type FeeAllowanceGrant struct { Granter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=granter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"granter,omitempty"` Grantee github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=grantee,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"grantee,omitempty"` - Allowance *types.Any `protobuf:"bytes,3,opt,name=allowance,proto3" json:"allowance,omitempty"` + Allowance *types1.Any `protobuf:"bytes,3,opt,name=allowance,proto3" json:"allowance,omitempty"` } func (m *FeeAllowanceGrant) Reset() { *m = FeeAllowanceGrant{} } func (m *FeeAllowanceGrant) String() string { return proto.CompactTextString(m) } func (*FeeAllowanceGrant) ProtoMessage() {} func (*FeeAllowanceGrant) Descriptor() ([]byte, []int) { - return fileDescriptor_7279582900c30aea, []int{6} + return fileDescriptor_7279582900c30aea, []int{4} } func (m *FeeAllowanceGrant) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -358,8 +263,6 @@ func (m *FeeAllowanceGrant) XXX_DiscardUnknown() { var xxx_messageInfo_FeeAllowanceGrant proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgGrantFeeAllowance)(nil), "cosmos.feegrant.v1beta1.MsgGrantFeeAllowance") - proto.RegisterType((*MsgRevokeFeeAllowance)(nil), "cosmos.feegrant.v1beta1.MsgRevokeFeeAllowance") proto.RegisterType((*BasicFeeAllowance)(nil), "cosmos.feegrant.v1beta1.BasicFeeAllowance") proto.RegisterType((*PeriodicFeeAllowance)(nil), "cosmos.feegrant.v1beta1.PeriodicFeeAllowance") proto.RegisterType((*Duration)(nil), "cosmos.feegrant.v1beta1.Duration") @@ -372,52 +275,49 @@ func init() { } var fileDescriptor_7279582900c30aea = []byte{ - // 706 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x55, 0xbf, 0x4f, 0x13, 0x51, - 0x1c, 0xef, 0xb3, 0x2d, 0xc2, 0x2b, 0x1a, 0x39, 0xab, 0xb4, 0x68, 0xee, 0xf0, 0x06, 0xd3, 0x98, - 0x70, 0x0d, 0x75, 0x31, 0x5d, 0x4c, 0x0f, 0x01, 0x0d, 0x92, 0x98, 0xd3, 0xc9, 0xa5, 0xb9, 0xbb, - 0x7e, 0x39, 0x2e, 0xf4, 0xee, 0x35, 0xf7, 0x1e, 0x48, 0x57, 0x27, 0x47, 0x26, 0xe3, 0xc8, 0xec, - 0x66, 0xe2, 0x1f, 0x41, 0x98, 0x88, 0x93, 0x13, 0x18, 0x58, 0x9c, 0x1d, 0x49, 0x4c, 0xcc, 0xfb, - 0x71, 0x6d, 0x81, 0x00, 0x25, 0x4e, 0xc6, 0xa5, 0xbd, 0x77, 0xef, 0xfb, 0xf9, 0xf1, 0x7d, 0x9f, - 0x6f, 0x5f, 0xf1, 0x43, 0x9f, 0xd0, 0x88, 0xd0, 0xea, 0x0a, 0x40, 0x90, 0xb8, 0x31, 0xab, 0x6e, - 0xcc, 0x7a, 0xc0, 0xdc, 0xd9, 0xde, 0x0b, 0xab, 0x93, 0x10, 0x46, 0xb4, 0x49, 0x59, 0x67, 0xf5, - 0x5e, 0xab, 0xba, 0xa9, 0x62, 0x40, 0x02, 0x22, 0x6a, 0xaa, 0xfc, 0x49, 0x96, 0x4f, 0x95, 0x03, - 0x42, 0x82, 0x36, 0x54, 0xc5, 0xca, 0x5b, 0x5f, 0xa9, 0xba, 0x71, 0x37, 0xdd, 0x92, 0x4c, 0x4d, - 0x89, 0x51, 0xb4, 0x72, 0x4b, 0x57, 0x66, 0x3c, 0x97, 0x42, 0xcf, 0x88, 0x4f, 0xc2, 0x58, 0xed, - 0xdf, 0x67, 0x10, 0xb7, 0x20, 0x89, 0xc2, 0x98, 0x55, 0x59, 0xb7, 0x03, 0x54, 0x7e, 0xaa, 0x5d, - 0xe3, 0xb4, 0x26, 0x0b, 0x23, 0xa0, 0xcc, 0x8d, 0x3a, 0xb2, 0xc0, 0xfc, 0x8d, 0x70, 0x71, 0x99, - 0x06, 0x8b, 0xdc, 0xff, 0x02, 0x40, 0xa3, 0xdd, 0x26, 0xef, 0xdc, 0xd8, 0x07, 0x6d, 0x09, 0x5f, - 0x17, 0x4d, 0x41, 0x52, 0x42, 0xd3, 0xa8, 0x32, 0x6e, 0xcf, 0x1e, 0xef, 0x1b, 0x33, 0x41, 0xc8, - 0x56, 0xd7, 0x3d, 0xcb, 0x27, 0x91, 0x72, 0xa9, 0xbe, 0x66, 0x68, 0x6b, 0x4d, 0x09, 0x37, 0x7c, - 0xbf, 0xd1, 0x6a, 0x25, 0x40, 0xa9, 0x93, 0x32, 0xf4, 0xc9, 0xa0, 0x74, 0xed, 0x2f, 0xc9, 0x40, - 0x9b, 0xc7, 0x63, 0x6e, 0x6a, 0xb3, 0x94, 0x9d, 0x46, 0x95, 0x42, 0xad, 0x68, 0xc9, 0x3e, 0xad, - 0xb4, 0x4f, 0xab, 0x11, 0x77, 0xed, 0x89, 0xdd, 0xaf, 0x33, 0x37, 0x06, 0x9b, 0x7a, 0xe1, 0xf4, - 0x91, 0xf5, 0xdc, 0x87, 0x6d, 0x23, 0x63, 0x7e, 0x41, 0xf8, 0xce, 0x32, 0x0d, 0x1c, 0xd8, 0x20, - 0x6b, 0xf0, 0x6f, 0x1c, 0x00, 0xcf, 0x6c, 0xc2, 0x76, 0x69, 0xe8, 0x9f, 0xf0, 0xfb, 0x1e, 0xe1, - 0x02, 0xed, 0x40, 0xdc, 0x6a, 0xb6, 0xc3, 0x28, 0x64, 0x25, 0x34, 0x9d, 0xad, 0x14, 0x6a, 0x65, - 0x4b, 0x4d, 0x13, 0x9f, 0x9f, 0x74, 0x40, 0xad, 0x39, 0x12, 0xc6, 0xf6, 0xc2, 0xce, 0xbe, 0x91, - 0xf9, 0xb5, 0x6f, 0x68, 0x5d, 0x37, 0x6a, 0xd7, 0xcd, 0x01, 0xac, 0xf9, 0xf9, 0xc0, 0xa8, 0x0c, - 0x61, 0x8e, 0xd3, 0x50, 0x07, 0x0b, 0xe4, 0x4b, 0x0e, 0xd4, 0x9e, 0x63, 0x0c, 0x9b, 0x9d, 0x30, - 0x71, 0x59, 0x48, 0x62, 0xd1, 0x6a, 0xa1, 0x66, 0x5a, 0xe7, 0xfc, 0x4e, 0xac, 0x79, 0x5e, 0x0a, - 0xb4, 0xc1, 0xec, 0x1c, 0xf7, 0xe2, 0x0c, 0x60, 0xeb, 0x65, 0x1e, 0xcf, 0xcf, 0x6d, 0x03, 0x7d, - 0x3b, 0x1d, 0xa2, 0xb9, 0x9b, 0xc3, 0xc5, 0x57, 0x90, 0x84, 0xa4, 0x75, 0xea, 0x08, 0x16, 0x70, - 0xde, 0xe3, 0xe7, 0x22, 0x02, 0x2b, 0xd4, 0x1e, 0x9d, 0x2b, 0x7c, 0xe6, 0xf4, 0x94, 0x01, 0x09, - 0xd7, 0x9e, 0xe2, 0x91, 0x8e, 0xe0, 0x57, 0x1d, 0x3c, 0x38, 0x97, 0xe8, 0xd9, 0xba, 0xb4, 0xab, - 0xf0, 0x0a, 0xa6, 0x7d, 0x44, 0x58, 0x93, 0x8f, 0xcd, 0xc1, 0x48, 0xb2, 0x97, 0x45, 0xb2, 0xac, - 0x22, 0x29, 0xcb, 0x48, 0xce, 0x52, 0x5c, 0x2d, 0x99, 0x5b, 0x92, 0xe0, 0x75, 0x3f, 0x9f, 0x2d, - 0x84, 0xd5, 0xcb, 0xa6, 0xef, 0xc6, 0x92, 0xb9, 0x94, 0xbb, 0xcc, 0xd6, 0x92, 0xb2, 0x35, 0x79, - 0xc2, 0x56, 0x8f, 0xe0, 0x6a, 0xa6, 0x6e, 0x4a, 0xf8, 0x9c, 0x1b, 0x0b, 0x5f, 0x9a, 0x87, 0xc7, - 0x15, 0x61, 0x02, 0x14, 0x58, 0x29, 0x3f, 0xf4, 0xd0, 0xdc, 0x53, 0xb6, 0x6e, 0x9f, 0xb0, 0x25, - 0x58, 0x4c, 0xa7, 0x20, 0x97, 0x0e, 0x5f, 0x5d, 0x34, 0x4c, 0x1e, 0x1e, 0x4d, 0x43, 0xd4, 0xea, - 0x38, 0xef, 0xb7, 0x89, 0xbf, 0xa6, 0xe6, 0x67, 0xea, 0xcc, 0xad, 0xf2, 0x26, 0xbd, 0x3d, 0xed, - 0x51, 0xae, 0xfd, 0xe9, 0xc0, 0x40, 0x8e, 0x84, 0x68, 0x45, 0x9c, 0xf7, 0x04, 0x96, 0x8f, 0x4c, - 0xd6, 0x91, 0x8b, 0x7a, 0x8e, 0x8b, 0x9a, 0x3e, 0x1e, 0xeb, 0xb9, 0xd6, 0x9e, 0xe0, 0x1c, 0xbf, - 0x84, 0x87, 0xd5, 0xd8, 0xe2, 0x1a, 0x02, 0xa1, 0xdd, 0xc5, 0x23, 0xab, 0x10, 0x06, 0xab, 0x4c, - 0x69, 0xa8, 0x95, 0x12, 0x39, 0x46, 0x78, 0x62, 0xb0, 0x35, 0x71, 0xa5, 0xff, 0x27, 0xd7, 0xb8, - 0xbd, 0xb8, 0x73, 0xa8, 0xa3, 0xbd, 0x43, 0x1d, 0xfd, 0x38, 0xd4, 0xd1, 0xd6, 0x91, 0x9e, 0xd9, - 0x3b, 0xd2, 0x33, 0xdf, 0x8f, 0xf4, 0xcc, 0xdb, 0x8b, 0xed, 0x6d, 0xf6, 0xff, 0xe4, 0x85, 0x53, - 0x6f, 0x44, 0x48, 0x3f, 0xfe, 0x13, 0x00, 0x00, 0xff, 0xff, 0xc7, 0xdf, 0x09, 0xbc, 0x04, 0x08, - 0x00, 0x00, + // 659 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xbd, 0x4f, 0x14, 0x4d, + 0x18, 0xbf, 0x79, 0xef, 0x8e, 0x17, 0xe6, 0xd0, 0xc8, 0x78, 0x91, 0x3b, 0x4c, 0x76, 0x71, 0x0b, + 0x43, 0x4c, 0xd8, 0x0d, 0xd8, 0x98, 0x6b, 0xcc, 0x2d, 0x02, 0x1a, 0x34, 0x31, 0xab, 0x95, 0xcd, + 0x65, 0x76, 0x6f, 0x58, 0x36, 0xec, 0xee, 0x6c, 0x76, 0x06, 0xe5, 0x5a, 0x2b, 0x4b, 0x2a, 0x63, + 0x49, 0x6d, 0xed, 0x1f, 0x41, 0xa8, 0x88, 0x95, 0x15, 0x18, 0x68, 0xac, 0x2d, 0x49, 0x4c, 0xcc, + 0x7c, 0xec, 0xdd, 0x01, 0x01, 0x8e, 0x58, 0xdd, 0x3e, 0x33, 0xcf, 0xef, 0x63, 0x9e, 0xdf, 0x4c, + 0x0e, 0x3e, 0x0c, 0x28, 0x4b, 0x28, 0x73, 0xd6, 0x09, 0x09, 0x73, 0x9c, 0x72, 0xe7, 0xfd, 0x82, + 0x4f, 0x38, 0x5e, 0xe8, 0x2f, 0xd8, 0x59, 0x4e, 0x39, 0x45, 0xd3, 0xaa, 0xcf, 0xee, 0x2f, 0xeb, + 0xbe, 0x99, 0x7a, 0x48, 0x43, 0x2a, 0x7b, 0x1c, 0xf1, 0xa5, 0xda, 0x67, 0x9a, 0x21, 0xa5, 0x61, + 0x4c, 0x1c, 0x59, 0xf9, 0x5b, 0xeb, 0x0e, 0x4e, 0x7b, 0xc5, 0x96, 0x62, 0xea, 0x28, 0x8c, 0xa6, + 0x55, 0x5b, 0x86, 0x36, 0xe3, 0x63, 0x46, 0xfa, 0x46, 0x02, 0x1a, 0xa5, 0x7a, 0xdf, 0x3c, 0xcf, + 0xca, 0xa3, 0x84, 0x30, 0x8e, 0x93, 0x4c, 0x35, 0x58, 0x7f, 0x00, 0x9c, 0x72, 0x31, 0x8b, 0x82, + 0x15, 0x42, 0xda, 0x71, 0x4c, 0x3f, 0xe0, 0x34, 0x20, 0xe8, 0x23, 0x80, 0x35, 0x96, 0x91, 0xb4, + 0xdb, 0x89, 0xa3, 0x24, 0xe2, 0x0d, 0x30, 0x5b, 0x9e, 0xab, 0x2d, 0x36, 0x6d, 0xad, 0x2d, 0xd4, + 0x8a, 0xe3, 0xd8, 0x4b, 0x34, 0x4a, 0xdd, 0x95, 0xbd, 0x43, 0xb3, 0xf4, 0xfb, 0xd0, 0x44, 0x3d, + 0x9c, 0xc4, 0x2d, 0x6b, 0x08, 0x6b, 0x7d, 0x3d, 0x32, 0xe7, 0xc2, 0x88, 0x6f, 0x6c, 0xf9, 0x76, + 0x40, 0x13, 0x6d, 0x5f, 0xff, 0xcc, 0xb3, 0xee, 0xa6, 0xc3, 0x7b, 0x19, 0x61, 0x92, 0x86, 0x79, + 0x50, 0x22, 0x5f, 0x0a, 0x20, 0x7a, 0x0e, 0x21, 0xd9, 0xce, 0xa2, 0x1c, 0xf3, 0x88, 0xa6, 0x8d, + 0xff, 0x66, 0xc1, 0x5c, 0x6d, 0xd1, 0xb2, 0x2f, 0x99, 0xaa, 0xbd, 0x2c, 0x5a, 0x09, 0x6b, 0x73, + 0xb7, 0x22, 0xbc, 0x78, 0x43, 0xd8, 0x56, 0xf3, 0xd3, 0xae, 0x59, 0xfa, 0xb5, 0x6b, 0x82, 0xef, + 0xdf, 0xe6, 0x6f, 0x0d, 0x1f, 0xf4, 0x85, 0xb5, 0x5f, 0x81, 0xf5, 0xd7, 0x24, 0x8f, 0x68, 0xf7, + 0xdc, 0x08, 0x56, 0x60, 0xd5, 0x17, 0x73, 0x69, 0x00, 0x29, 0xfc, 0xe8, 0x52, 0xe1, 0x0b, 0xd3, + 0xd3, 0x06, 0x14, 0x1c, 0x3d, 0x85, 0x63, 0x99, 0xe4, 0xd7, 0x27, 0x78, 0x70, 0x29, 0xd1, 0xb3, + 0x2d, 0x65, 0x57, 0xe3, 0x35, 0x0c, 0x7d, 0x06, 0x10, 0xa9, 0xcf, 0xce, 0x70, 0x24, 0xe5, 0xeb, + 0x22, 0x79, 0xa5, 0x23, 0x69, 0xaa, 0x48, 0x2e, 0x52, 0xdc, 0x2c, 0x99, 0x3b, 0x8a, 0xe0, 0xcd, + 0x20, 0x9f, 0x1d, 0x00, 0xf5, 0x62, 0x27, 0xc0, 0xa9, 0x62, 0x6e, 0x54, 0xae, 0xb3, 0xb5, 0xa6, + 0x6d, 0x4d, 0x9f, 0xb1, 0xd5, 0x27, 0xb8, 0x99, 0xa9, 0xdb, 0x0a, 0xbe, 0x84, 0x53, 0xe9, 0x0b, + 0xf9, 0x70, 0x52, 0x13, 0xe6, 0x84, 0x11, 0xde, 0xa8, 0x8e, 0x7c, 0x69, 0xee, 0x6b, 0x5b, 0x77, + 0xcf, 0xd8, 0x92, 0x2c, 0x96, 0x57, 0x53, 0xa5, 0x27, 0xaa, 0xab, 0x2e, 0x93, 0x0f, 0xc7, 0x8b, + 0x10, 0x51, 0x0b, 0x56, 0x83, 0x98, 0x06, 0x9b, 0xfa, 0xfe, 0xcc, 0xd8, 0xea, 0x25, 0xda, 0xc5, + 0x4b, 0xb4, 0xdf, 0x16, 0x2f, 0xd1, 0x1d, 0x17, 0xda, 0x5f, 0x8e, 0x4c, 0xe0, 0x29, 0x08, 0xaa, + 0xc3, 0xaa, 0x2f, 0xb1, 0xe2, 0xca, 0x94, 0x3d, 0x55, 0xb4, 0x2a, 0x42, 0xd4, 0x0a, 0xe0, 0x44, + 0xdf, 0x35, 0x7a, 0x02, 0x2b, 0xe2, 0x41, 0x8f, 0xaa, 0xb1, 0x23, 0x34, 0x24, 0x02, 0xdd, 0x83, + 0x63, 0x1b, 0x24, 0x0a, 0x37, 0xb8, 0xd6, 0xd0, 0x95, 0x16, 0x39, 0x05, 0x70, 0x6a, 0xf8, 0x68, + 0xab, 0x62, 0x6a, 0x68, 0x0d, 0xfe, 0x2f, 0xc7, 0x47, 0x72, 0x29, 0x38, 0xe9, 0x2e, 0x9c, 0x1e, + 0x9a, 0xf3, 0x23, 0x84, 0xd5, 0x0e, 0x82, 0x76, 0xb7, 0x9b, 0x13, 0xc6, 0xbc, 0x82, 0x61, 0x40, + 0x46, 0xa4, 0x83, 0x7f, 0x21, 0x23, 0x68, 0x19, 0x4e, 0xe0, 0xc2, 0x6b, 0xa3, 0x2c, 0x87, 0x51, + 0xbf, 0x30, 0x8c, 0x76, 0xda, 0x73, 0xa7, 0xf6, 0xcf, 0x87, 0xe6, 0x0d, 0x90, 0xad, 0x8a, 0x88, + 0xd6, 0x5d, 0xdd, 0x3b, 0x36, 0xc0, 0xc1, 0xb1, 0x01, 0x7e, 0x1e, 0x1b, 0x60, 0xe7, 0xc4, 0x28, + 0x1d, 0x9c, 0x18, 0xa5, 0x1f, 0x27, 0x46, 0xe9, 0xdd, 0xd5, 0xf6, 0xb6, 0x07, 0x7f, 0x09, 0xd2, + 0xa9, 0x3f, 0x26, 0xa5, 0x1f, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x74, 0xa3, 0xa5, 0x9f, 0x32, + 0x06, 0x00, 0x00, } func (this *BasicFeeAllowance) Equal(that interface{}) bool { @@ -552,92 +452,6 @@ func (this *ExpiresAt) Equal(that interface{}) bool { } return true } -func (m *MsgGrantFeeAllowance) 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 *MsgGrantFeeAllowance) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgGrantFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Allowance != nil { - { - size, err := m.Allowance.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintFeegrant(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if len(m.Grantee) > 0 { - i -= len(m.Grantee) - copy(dAtA[i:], m.Grantee) - i = encodeVarintFeegrant(dAtA, i, uint64(len(m.Grantee))) - i-- - dAtA[i] = 0x12 - } - if len(m.Granter) > 0 { - i -= len(m.Granter) - copy(dAtA[i:], m.Granter) - i = encodeVarintFeegrant(dAtA, i, uint64(len(m.Granter))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgRevokeFeeAllowance) 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 *MsgRevokeFeeAllowance) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRevokeFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Grantee) > 0 { - i -= len(m.Grantee) - copy(dAtA[i:], m.Grantee) - i = encodeVarintFeegrant(dAtA, i, uint64(len(m.Grantee))) - i-- - dAtA[i] = 0x12 - } - if len(m.Granter) > 0 { - i -= len(m.Granter) - copy(dAtA[i:], m.Granter) - i = encodeVarintFeegrant(dAtA, i, uint64(len(m.Granter))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *BasicFeeAllowance) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -791,12 +605,12 @@ func (m *Duration) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x10 } - n6, err6 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.Clock, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.Clock):]) - if err6 != nil { - return 0, err6 + n5, err5 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.Clock, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.Clock):]) + if err5 != nil { + return 0, err5 } - i -= n6 - i = encodeVarintFeegrant(dAtA, i, uint64(n6)) + i -= n5 + i = encodeVarintFeegrant(dAtA, i, uint64(n5)) i-- dAtA[i] = 0xa return len(dAtA) - i, nil @@ -827,12 +641,12 @@ func (m *ExpiresAt) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x10 } - n7, err7 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Time):]) - if err7 != nil { - return 0, err7 + n6, err6 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Time):]) + if err6 != nil { + return 0, err6 } - i -= n7 - i = encodeVarintFeegrant(dAtA, i, uint64(n7)) + i -= n6 + i = encodeVarintFeegrant(dAtA, i, uint64(n6)) i-- dAtA[i] = 0xa return len(dAtA) - i, nil @@ -898,44 +712,6 @@ func encodeVarintFeegrant(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgGrantFeeAllowance) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Granter) - if l > 0 { - n += 1 + l + sovFeegrant(uint64(l)) - } - l = len(m.Grantee) - if l > 0 { - n += 1 + l + sovFeegrant(uint64(l)) - } - if m.Allowance != nil { - l = m.Allowance.Size() - n += 1 + l + sovFeegrant(uint64(l)) - } - return n -} - -func (m *MsgRevokeFeeAllowance) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Granter) - if l > 0 { - n += 1 + l + sovFeegrant(uint64(l)) - } - l = len(m.Grantee) - if l > 0 { - n += 1 + l + sovFeegrant(uint64(l)) - } - return n -} - func (m *BasicFeeAllowance) Size() (n int) { if m == nil { return 0 @@ -1035,284 +811,6 @@ func sovFeegrant(x uint64) (n int) { func sozFeegrant(x uint64) (n int) { return sovFeegrant(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgGrantFeeAllowance) 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 ErrIntOverflowFeegrant - } - 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: MsgGrantFeeAllowance: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgGrantFeeAllowance: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Granter", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowFeegrant - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthFeegrant - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthFeegrant - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Granter = append(m.Granter[:0], dAtA[iNdEx:postIndex]...) - if m.Granter == nil { - m.Granter = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowFeegrant - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthFeegrant - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthFeegrant - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Grantee = append(m.Grantee[:0], dAtA[iNdEx:postIndex]...) - if m.Grantee == nil { - m.Grantee = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Allowance", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowFeegrant - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthFeegrant - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthFeegrant - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Allowance == nil { - m.Allowance = &types.Any{} - } - if err := m.Allowance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipFeegrant(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthFeegrant - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthFeegrant - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgRevokeFeeAllowance) 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 ErrIntOverflowFeegrant - } - 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: MsgRevokeFeeAllowance: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRevokeFeeAllowance: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Granter", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowFeegrant - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthFeegrant - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthFeegrant - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Granter = append(m.Granter[:0], dAtA[iNdEx:postIndex]...) - if m.Granter == nil { - m.Granter = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowFeegrant - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthFeegrant - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthFeegrant - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Grantee = append(m.Grantee[:0], dAtA[iNdEx:postIndex]...) - if m.Grantee == nil { - m.Grantee = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipFeegrant(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthFeegrant - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthFeegrant - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *BasicFeeAllowance) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1371,7 +869,7 @@ func (m *BasicFeeAllowance) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SpendLimit = append(m.SpendLimit, types1.Coin{}) + m.SpendLimit = append(m.SpendLimit, types.Coin{}) if err := m.SpendLimit[len(m.SpendLimit)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -1557,7 +1055,7 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.PeriodSpendLimit = append(m.PeriodSpendLimit, types1.Coin{}) + m.PeriodSpendLimit = append(m.PeriodSpendLimit, types.Coin{}) if err := m.PeriodSpendLimit[len(m.PeriodSpendLimit)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -1591,7 +1089,7 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.PeriodCanSpend = append(m.PeriodCanSpend, types1.Coin{}) + m.PeriodCanSpend = append(m.PeriodCanSpend, types.Coin{}) if err := m.PeriodCanSpend[len(m.PeriodCanSpend)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -1990,7 +1488,7 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Allowance == nil { - m.Allowance = &types.Any{} + m.Allowance = &types1.Any{} } if err := m.Allowance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/feegrant/types/msgs.go b/x/feegrant/types/msgs.go index 3f7f1690cd36..d68ebef5638c 100644 --- a/x/feegrant/types/msgs.go +++ b/x/feegrant/types/msgs.go @@ -5,7 +5,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -func (msg MsgGrantFeeAllowance) NewMsgGrantFeeAllowance(feeAllowance *FeeAllowance, granter, grantee sdk.AccAddress) (MsgGrantFeeAllowance, error) { +func (msg MsgGrantFeeAllowance) NewMsgGrantFeeAllowance(feeAllowance *FeeAllowanceI, granter, grantee sdk.AccAddress) (MsgGrantFeeAllowance, error) { return MsgGrantFeeAllowance{ Granter: granter, Grantee: grantee, diff --git a/x/feegrant/types/tx.pb.go b/x/feegrant/types/tx.pb.go new file mode 100644 index 000000000000..bed0fc097cf1 --- /dev/null +++ b/x/feegrant/types/tx.pb.go @@ -0,0 +1,655 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/feegrant/v1beta1/tx.proto + +package types + +import ( + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/codec/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "github.com/regen-network/cosmos-proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance +// of fees from the account of Granter. +type MsgGrantFeeAllowance struct { + Granter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=granter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"granter,omitempty"` + Grantee github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=grantee,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"grantee,omitempty"` + Allowance *types.Any `protobuf:"bytes,3,opt,name=allowance,proto3" json:"allowance,omitempty"` +} + +func (m *MsgGrantFeeAllowance) Reset() { *m = MsgGrantFeeAllowance{} } +func (m *MsgGrantFeeAllowance) String() string { return proto.CompactTextString(m) } +func (*MsgGrantFeeAllowance) ProtoMessage() {} +func (*MsgGrantFeeAllowance) Descriptor() ([]byte, []int) { + return fileDescriptor_dd44ad7946dad783, []int{0} +} +func (m *MsgGrantFeeAllowance) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgGrantFeeAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgGrantFeeAllowance.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 *MsgGrantFeeAllowance) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgGrantFeeAllowance.Merge(m, src) +} +func (m *MsgGrantFeeAllowance) XXX_Size() int { + return m.Size() +} +func (m *MsgGrantFeeAllowance) XXX_DiscardUnknown() { + xxx_messageInfo_MsgGrantFeeAllowance.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgGrantFeeAllowance proto.InternalMessageInfo + +// MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee. +type MsgRevokeFeeAllowance struct { + Granter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=granter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"granter,omitempty"` + Grantee github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=grantee,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"grantee,omitempty"` +} + +func (m *MsgRevokeFeeAllowance) Reset() { *m = MsgRevokeFeeAllowance{} } +func (m *MsgRevokeFeeAllowance) String() string { return proto.CompactTextString(m) } +func (*MsgRevokeFeeAllowance) ProtoMessage() {} +func (*MsgRevokeFeeAllowance) Descriptor() ([]byte, []int) { + return fileDescriptor_dd44ad7946dad783, []int{1} +} +func (m *MsgRevokeFeeAllowance) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRevokeFeeAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRevokeFeeAllowance.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 *MsgRevokeFeeAllowance) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRevokeFeeAllowance.Merge(m, src) +} +func (m *MsgRevokeFeeAllowance) XXX_Size() int { + return m.Size() +} +func (m *MsgRevokeFeeAllowance) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRevokeFeeAllowance.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRevokeFeeAllowance proto.InternalMessageInfo + +func (m *MsgRevokeFeeAllowance) GetGranter() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Granter + } + return nil +} + +func (m *MsgRevokeFeeAllowance) GetGrantee() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Grantee + } + return nil +} + +func init() { + proto.RegisterType((*MsgGrantFeeAllowance)(nil), "cosmos.feegrant.v1beta1.MsgGrantFeeAllowance") + proto.RegisterType((*MsgRevokeFeeAllowance)(nil), "cosmos.feegrant.v1beta1.MsgRevokeFeeAllowance") +} + +func init() { proto.RegisterFile("cosmos/feegrant/v1beta1/tx.proto", fileDescriptor_dd44ad7946dad783) } + +var fileDescriptor_dd44ad7946dad783 = []byte{ + // 303 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0x4d, 0x2f, 0x4a, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, + 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x87, 0xa8, + 0xd0, 0x83, 0xa9, 0xd0, 0x83, 0xaa, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xab, 0xd1, 0x07, + 0xb1, 0x20, 0xca, 0xa5, 0x24, 0xd3, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0xc1, 0xbc, 0xa4, 0xd2, + 0x34, 0xfd, 0xc4, 0xbc, 0x4a, 0x98, 0x14, 0xc4, 0xa4, 0x78, 0x88, 0x1e, 0xa8, 0xb1, 0x60, 0x8e, + 0xd2, 0x5f, 0x46, 0x2e, 0x11, 0xdf, 0xe2, 0x74, 0x77, 0x90, 0x05, 0x6e, 0xa9, 0xa9, 0x8e, 0x39, + 0x39, 0xf9, 0xe5, 0x89, 0x79, 0xc9, 0xa9, 0x42, 0xde, 0x5c, 0xec, 0x60, 0x5b, 0x53, 0x8b, 0x24, + 0x18, 0x15, 0x18, 0x35, 0x78, 0x9c, 0x0c, 0x7f, 0xdd, 0x93, 0xd7, 0x4d, 0xcf, 0x2c, 0xc9, 0x28, + 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0x85, 0x1a, 0x03, 0xa5, 0x74, 0x8b, 0x53, 0xb2, 0xf5, 0x4b, 0x2a, + 0x0b, 0x52, 0x8b, 0xf5, 0x1c, 0x93, 0x93, 0x1d, 0x53, 0x52, 0x8a, 0x52, 0x8b, 0x8b, 0x83, 0x60, + 0x26, 0x20, 0x0c, 0x4b, 0x95, 0x60, 0xa2, 0xd0, 0xb0, 0x54, 0x21, 0x57, 0x2e, 0xce, 0x44, 0x98, + 0x33, 0x25, 0x98, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0x44, 0xf4, 0x20, 0x9e, 0xd7, 0x83, 0x79, 0x5e, + 0xcf, 0x31, 0xaf, 0xd2, 0x49, 0xf0, 0xd4, 0x16, 0x5d, 0x5e, 0x64, 0x4f, 0x79, 0x06, 0x21, 0x74, + 0x5a, 0xb1, 0x74, 0x2c, 0x90, 0x67, 0x50, 0xda, 0xc8, 0xc8, 0x25, 0xea, 0x5b, 0x9c, 0x1e, 0x94, + 0x5a, 0x96, 0x9f, 0x9d, 0x3a, 0x34, 0x02, 0xc0, 0xc9, 0xfd, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, + 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, + 0x8f, 0xe5, 0x18, 0xa2, 0xf0, 0x9b, 0x58, 0x81, 0x48, 0x6c, 0x60, 0xc3, 0x93, 0xd8, 0xc0, 0xc1, + 0x65, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xd4, 0x42, 0x3b, 0x0e, 0x8c, 0x02, 0x00, 0x00, +} + +func (m *MsgGrantFeeAllowance) 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 *MsgGrantFeeAllowance) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgGrantFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Allowance != nil { + { + size, err := m.Allowance.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.Grantee) > 0 { + i -= len(m.Grantee) + copy(dAtA[i:], m.Grantee) + i = encodeVarintTx(dAtA, i, uint64(len(m.Grantee))) + i-- + dAtA[i] = 0x12 + } + if len(m.Granter) > 0 { + i -= len(m.Granter) + copy(dAtA[i:], m.Granter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Granter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRevokeFeeAllowance) 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 *MsgRevokeFeeAllowance) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRevokeFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Grantee) > 0 { + i -= len(m.Grantee) + copy(dAtA[i:], m.Grantee) + i = encodeVarintTx(dAtA, i, uint64(len(m.Grantee))) + i-- + dAtA[i] = 0x12 + } + if len(m.Granter) > 0 { + i -= len(m.Granter) + copy(dAtA[i:], m.Granter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Granter))) + i-- + dAtA[i] = 0xa + } + 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 *MsgGrantFeeAllowance) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Granter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Grantee) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Allowance != nil { + l = m.Allowance.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRevokeFeeAllowance) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Granter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Grantee) + if l > 0 { + n += 1 + l + sovTx(uint64(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 *MsgGrantFeeAllowance) 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: MsgGrantFeeAllowance: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgGrantFeeAllowance: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Granter", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Granter = append(m.Granter[:0], dAtA[iNdEx:postIndex]...) + if m.Granter == nil { + m.Granter = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Grantee = append(m.Grantee[:0], dAtA[iNdEx:postIndex]...) + if m.Grantee == nil { + m.Grantee = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Allowance", 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.Allowance == nil { + m.Allowance = &types.Any{} + } + if err := m.Allowance.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 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRevokeFeeAllowance) 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: MsgRevokeFeeAllowance: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRevokeFeeAllowance: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Granter", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Granter = append(m.Granter[:0], dAtA[iNdEx:postIndex]...) + if m.Granter == nil { + m.Granter = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Grantee = append(m.Grantee[:0], dAtA[iNdEx:postIndex]...) + if m.Grantee == nil { + m.Grantee = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/feegrant/types/types.pb.go b/x/feegrant/types/types.pb.go deleted file mode 100644 index 79c6e9672521..000000000000 --- a/x/feegrant/types/types.pb.go +++ /dev/null @@ -1,2531 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: x/feegrant/types/types.proto - -package types - -import ( - fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" - _ "github.com/golang/protobuf/ptypes/timestamp" - _ "github.com/regen-network/cosmos-proto" - io "io" - math "math" - math_bits "math/bits" - time "time" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf -var _ = time.Kitchen - -// 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 - -// FeeAllowance defines the application-level fee allowance to be used in -// feegrant module -type FeeAllowance struct { - // sum defines a set of all acceptable concrete feeallowance implementations. - // - // Types that are valid to be assigned to Sum: - // *FeeAllowance_BasicFeeAllowance - // *FeeAllowance_PeriodicFeeAllowance - Sum isFeeAllowance_Sum `protobuf_oneof:"sum"` -} - -func (m *FeeAllowance) Reset() { *m = FeeAllowance{} } -func (m *FeeAllowance) String() string { return proto.CompactTextString(m) } -func (*FeeAllowance) ProtoMessage() {} -func (*FeeAllowance) Descriptor() ([]byte, []int) { - return fileDescriptor_86c534389d2c5768, []int{0} -} -func (m *FeeAllowance) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *FeeAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_FeeAllowance.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 *FeeAllowance) XXX_Merge(src proto.Message) { - xxx_messageInfo_FeeAllowance.Merge(m, src) -} -func (m *FeeAllowance) XXX_Size() int { - return m.Size() -} -func (m *FeeAllowance) XXX_DiscardUnknown() { - xxx_messageInfo_FeeAllowance.DiscardUnknown(m) -} - -var xxx_messageInfo_FeeAllowance proto.InternalMessageInfo - -type isFeeAllowance_Sum interface { - isFeeAllowance_Sum() - Equal(interface{}) bool - MarshalTo([]byte) (int, error) - Size() int -} - -type FeeAllowance_BasicFeeAllowance struct { - BasicFeeAllowance *BasicFeeAllowance `protobuf:"bytes,1,opt,name=basic_fee_allowance,json=basicFeeAllowance,proto3,oneof" json:"basic_fee_allowance,omitempty"` -} -type FeeAllowance_PeriodicFeeAllowance struct { - PeriodicFeeAllowance *PeriodicFeeAllowance `protobuf:"bytes,2,opt,name=periodic_fee_allowance,json=periodicFeeAllowance,proto3,oneof" json:"periodic_fee_allowance,omitempty"` -} - -func (*FeeAllowance_BasicFeeAllowance) isFeeAllowance_Sum() {} -func (*FeeAllowance_PeriodicFeeAllowance) isFeeAllowance_Sum() {} - -func (m *FeeAllowance) GetSum() isFeeAllowance_Sum { - if m != nil { - return m.Sum - } - return nil -} - -func (m *FeeAllowance) GetBasicFeeAllowance() *BasicFeeAllowance { - if x, ok := m.GetSum().(*FeeAllowance_BasicFeeAllowance); ok { - return x.BasicFeeAllowance - } - return nil -} - -func (m *FeeAllowance) GetPeriodicFeeAllowance() *PeriodicFeeAllowance { - if x, ok := m.GetSum().(*FeeAllowance_PeriodicFeeAllowance); ok { - return x.PeriodicFeeAllowance - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*FeeAllowance) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*FeeAllowance_BasicFeeAllowance)(nil), - (*FeeAllowance_PeriodicFeeAllowance)(nil), - } -} - -// MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance -// of fees from the account of Granter. -type MsgGrantFeeAllowance struct { - Granter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=granter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"granter,omitempty"` - Grantee github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=grantee,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"grantee,omitempty"` - Allowance *FeeAllowance `protobuf:"bytes,3,opt,name=allowance,proto3" json:"allowance,omitempty"` -} - -func (m *MsgGrantFeeAllowance) Reset() { *m = MsgGrantFeeAllowance{} } -func (m *MsgGrantFeeAllowance) String() string { return proto.CompactTextString(m) } -func (*MsgGrantFeeAllowance) ProtoMessage() {} -func (*MsgGrantFeeAllowance) Descriptor() ([]byte, []int) { - return fileDescriptor_86c534389d2c5768, []int{1} -} -func (m *MsgGrantFeeAllowance) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgGrantFeeAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgGrantFeeAllowance.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 *MsgGrantFeeAllowance) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgGrantFeeAllowance.Merge(m, src) -} -func (m *MsgGrantFeeAllowance) XXX_Size() int { - return m.Size() -} -func (m *MsgGrantFeeAllowance) XXX_DiscardUnknown() { - xxx_messageInfo_MsgGrantFeeAllowance.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgGrantFeeAllowance proto.InternalMessageInfo - -// MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee. -type MsgRevokeFeeAllowance struct { - Granter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=granter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"granter,omitempty"` - Grantee github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=grantee,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"grantee,omitempty"` -} - -func (m *MsgRevokeFeeAllowance) Reset() { *m = MsgRevokeFeeAllowance{} } -func (m *MsgRevokeFeeAllowance) String() string { return proto.CompactTextString(m) } -func (*MsgRevokeFeeAllowance) ProtoMessage() {} -func (*MsgRevokeFeeAllowance) Descriptor() ([]byte, []int) { - return fileDescriptor_86c534389d2c5768, []int{2} -} -func (m *MsgRevokeFeeAllowance) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRevokeFeeAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRevokeFeeAllowance.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 *MsgRevokeFeeAllowance) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRevokeFeeAllowance.Merge(m, src) -} -func (m *MsgRevokeFeeAllowance) XXX_Size() int { - return m.Size() -} -func (m *MsgRevokeFeeAllowance) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRevokeFeeAllowance.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRevokeFeeAllowance proto.InternalMessageInfo - -func (m *MsgRevokeFeeAllowance) GetGranter() github_com_cosmos_cosmos_sdk_types.AccAddress { - if m != nil { - return m.Granter - } - return nil -} - -func (m *MsgRevokeFeeAllowance) GetGrantee() github_com_cosmos_cosmos_sdk_types.AccAddress { - if m != nil { - return m.Grantee - } - return nil -} - -// BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens -// that optionally expires. The delegatee can use up to SpendLimit to cover fees. -type BasicFeeAllowance struct { - SpendLimit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=spend_limit,json=spendLimit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"spend_limit" yaml:"spend_limit"` - Expiration ExpiresAt `protobuf:"bytes,2,opt,name=expiration,proto3" json:"expiration"` -} - -func (m *BasicFeeAllowance) Reset() { *m = BasicFeeAllowance{} } -func (m *BasicFeeAllowance) String() string { return proto.CompactTextString(m) } -func (*BasicFeeAllowance) ProtoMessage() {} -func (*BasicFeeAllowance) Descriptor() ([]byte, []int) { - return fileDescriptor_86c534389d2c5768, []int{3} -} -func (m *BasicFeeAllowance) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BasicFeeAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BasicFeeAllowance.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 *BasicFeeAllowance) XXX_Merge(src proto.Message) { - xxx_messageInfo_BasicFeeAllowance.Merge(m, src) -} -func (m *BasicFeeAllowance) XXX_Size() int { - return m.Size() -} -func (m *BasicFeeAllowance) XXX_DiscardUnknown() { - xxx_messageInfo_BasicFeeAllowance.DiscardUnknown(m) -} - -var xxx_messageInfo_BasicFeeAllowance proto.InternalMessageInfo - -// PeriodicFeeAllowance extends FeeAllowance to allow for both a maximum cap, -// as well as a limit per time period. -type PeriodicFeeAllowance struct { - Basic BasicFeeAllowance `protobuf:"bytes,1,opt,name=basic,proto3" json:"basic"` - Period Duration `protobuf:"bytes,2,opt,name=period,proto3" json:"period"` - PeriodSpendLimit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=period_spend_limit,json=periodSpendLimit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"period_spend_limit" yaml:"period_spend_limit"` - PeriodCanSpend github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=period_can_spend,json=periodCanSpend,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"period_can_spend" yaml:"period_can_spend"` - PeriodReset ExpiresAt `protobuf:"bytes,5,opt,name=period_reset,json=periodReset,proto3" json:"period_reset" yaml:"period_reset"` -} - -func (m *PeriodicFeeAllowance) Reset() { *m = PeriodicFeeAllowance{} } -func (m *PeriodicFeeAllowance) String() string { return proto.CompactTextString(m) } -func (*PeriodicFeeAllowance) ProtoMessage() {} -func (*PeriodicFeeAllowance) Descriptor() ([]byte, []int) { - return fileDescriptor_86c534389d2c5768, []int{4} -} -func (m *PeriodicFeeAllowance) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PeriodicFeeAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PeriodicFeeAllowance.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 *PeriodicFeeAllowance) XXX_Merge(src proto.Message) { - xxx_messageInfo_PeriodicFeeAllowance.Merge(m, src) -} -func (m *PeriodicFeeAllowance) XXX_Size() int { - return m.Size() -} -func (m *PeriodicFeeAllowance) XXX_DiscardUnknown() { - xxx_messageInfo_PeriodicFeeAllowance.DiscardUnknown(m) -} - -var xxx_messageInfo_PeriodicFeeAllowance proto.InternalMessageInfo - -// Duration is a repeating unit of either clock time or number of blocks. -// This is designed to be added to an ExpiresAt struct. -type Duration struct { - Clock time.Duration `protobuf:"bytes,1,opt,name=clock,proto3,stdduration" json:"clock"` - Block int64 `protobuf:"varint,2,opt,name=block,proto3" json:"block,omitempty"` -} - -func (m *Duration) Reset() { *m = Duration{} } -func (m *Duration) String() string { return proto.CompactTextString(m) } -func (*Duration) ProtoMessage() {} -func (*Duration) Descriptor() ([]byte, []int) { - return fileDescriptor_86c534389d2c5768, []int{5} -} -func (m *Duration) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Duration) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Duration.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 *Duration) XXX_Merge(src proto.Message) { - xxx_messageInfo_Duration.Merge(m, src) -} -func (m *Duration) XXX_Size() int { - return m.Size() -} -func (m *Duration) XXX_DiscardUnknown() { - xxx_messageInfo_Duration.DiscardUnknown(m) -} - -var xxx_messageInfo_Duration proto.InternalMessageInfo - -func (m *Duration) GetClock() time.Duration { - if m != nil { - return m.Clock - } - return 0 -} - -func (m *Duration) GetBlock() int64 { - if m != nil { - return m.Block - } - return 0 -} - -// ExpiresAt is a point in time where something expires. -// It may be *either* block time or block height -type ExpiresAt struct { - Time time.Time `protobuf:"bytes,1,opt,name=time,proto3,stdtime" json:"time"` - Height int64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` -} - -func (m *ExpiresAt) Reset() { *m = ExpiresAt{} } -func (m *ExpiresAt) String() string { return proto.CompactTextString(m) } -func (*ExpiresAt) ProtoMessage() {} -func (*ExpiresAt) Descriptor() ([]byte, []int) { - return fileDescriptor_86c534389d2c5768, []int{6} -} -func (m *ExpiresAt) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ExpiresAt) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ExpiresAt.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 *ExpiresAt) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExpiresAt.Merge(m, src) -} -func (m *ExpiresAt) XXX_Size() int { - return m.Size() -} -func (m *ExpiresAt) XXX_DiscardUnknown() { - xxx_messageInfo_ExpiresAt.DiscardUnknown(m) -} - -var xxx_messageInfo_ExpiresAt proto.InternalMessageInfo - -func (m *ExpiresAt) GetTime() time.Time { - if m != nil { - return m.Time - } - return time.Time{} -} - -func (m *ExpiresAt) GetHeight() int64 { - if m != nil { - return m.Height - } - return 0 -} - -// FeeAllowanceGrant is stored in the KVStore to record a grant with full context -type FeeAllowanceGrant struct { - Granter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=granter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"granter,omitempty"` - Grantee github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=grantee,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"grantee,omitempty"` - Allowance *FeeAllowance `protobuf:"bytes,3,opt,name=allowance,proto3" json:"allowance,omitempty"` -} - -func (m *FeeAllowanceGrant) Reset() { *m = FeeAllowanceGrant{} } -func (m *FeeAllowanceGrant) String() string { return proto.CompactTextString(m) } -func (*FeeAllowanceGrant) ProtoMessage() {} -func (*FeeAllowanceGrant) Descriptor() ([]byte, []int) { - return fileDescriptor_86c534389d2c5768, []int{7} -} -func (m *FeeAllowanceGrant) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *FeeAllowanceGrant) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_FeeAllowanceGrant.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 *FeeAllowanceGrant) XXX_Merge(src proto.Message) { - xxx_messageInfo_FeeAllowanceGrant.Merge(m, src) -} -func (m *FeeAllowanceGrant) XXX_Size() int { - return m.Size() -} -func (m *FeeAllowanceGrant) XXX_DiscardUnknown() { - xxx_messageInfo_FeeAllowanceGrant.DiscardUnknown(m) -} - -var xxx_messageInfo_FeeAllowanceGrant proto.InternalMessageInfo - -func init() { - proto.RegisterType((*FeeAllowance)(nil), "cosmos_sdk.x.feegrant.v1.FeeAllowance") - proto.RegisterType((*MsgGrantFeeAllowance)(nil), "cosmos_sdk.x.feegrant.v1.MsgGrantFeeAllowance") - proto.RegisterType((*MsgRevokeFeeAllowance)(nil), "cosmos_sdk.x.feegrant.v1.MsgRevokeFeeAllowance") - proto.RegisterType((*BasicFeeAllowance)(nil), "cosmos_sdk.x.feegrant.v1.BasicFeeAllowance") - proto.RegisterType((*PeriodicFeeAllowance)(nil), "cosmos_sdk.x.feegrant.v1.PeriodicFeeAllowance") - proto.RegisterType((*Duration)(nil), "cosmos_sdk.x.feegrant.v1.Duration") - proto.RegisterType((*ExpiresAt)(nil), "cosmos_sdk.x.feegrant.v1.ExpiresAt") - proto.RegisterType((*FeeAllowanceGrant)(nil), "cosmos_sdk.x.feegrant.v1.FeeAllowanceGrant") -} - -func init() { proto.RegisterFile("x/feegrant/types/types.proto", fileDescriptor_86c534389d2c5768) } - -var fileDescriptor_86c534389d2c5768 = []byte{ - // 735 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x56, 0xcd, 0x4f, 0x13, 0x4d, - 0x18, 0xef, 0xbc, 0x6d, 0x79, 0x61, 0x4a, 0xc8, 0xdb, 0xa1, 0x2f, 0xd6, 0x6a, 0xba, 0x64, 0x4d, - 0x08, 0x91, 0xb0, 0x0d, 0x78, 0x31, 0x3d, 0xd9, 0x05, 0x41, 0x82, 0x24, 0x66, 0xf5, 0x64, 0x62, - 0x36, 0xfb, 0x31, 0xdd, 0x6e, 0xda, 0xdd, 0xd9, 0xec, 0x6c, 0x11, 0x12, 0xff, 0x00, 0xe3, 0x89, - 0xa3, 0x47, 0xce, 0x9e, 0x34, 0xf1, 0x8f, 0x20, 0x9e, 0x38, 0x7a, 0x02, 0x03, 0x89, 0xf1, 0x6c, - 0xbc, 0x68, 0x3c, 0x98, 0x9d, 0x99, 0xa5, 0x0b, 0x65, 0x0d, 0xe8, 0xc9, 0x78, 0x69, 0x76, 0x9e, - 0x3c, 0xbf, 0x8f, 0xe7, 0x63, 0x77, 0x0a, 0xaf, 0x6f, 0x35, 0xda, 0x18, 0x3b, 0xa1, 0xe1, 0x47, - 0x8d, 0x68, 0x3b, 0xc0, 0x94, 0xff, 0x2a, 0x41, 0x48, 0x22, 0x82, 0xaa, 0x16, 0xa1, 0x1e, 0xa1, - 0x3a, 0xb5, 0xbb, 0xca, 0x96, 0x92, 0x24, 0x2a, 0x9b, 0x0b, 0xb5, 0xb9, 0xa8, 0xe3, 0x86, 0xb6, - 0x1e, 0x18, 0x61, 0xb4, 0xdd, 0x60, 0xc9, 0x0d, 0x9e, 0x3b, 0x9f, 0x3e, 0x70, 0x9a, 0xda, 0xcc, - 0x70, 0xb2, 0x43, 0x1c, 0x32, 0x78, 0x12, 0x79, 0xe5, 0x21, 0x07, 0x35, 0xc9, 0x21, 0xc4, 0xe9, - 0x61, 0x8e, 0x32, 0xfb, 0xed, 0x46, 0xe4, 0x7a, 0x98, 0x46, 0x86, 0x17, 0xf0, 0x04, 0xf9, 0x0b, - 0x80, 0xe3, 0x2b, 0x18, 0xb7, 0x7a, 0x3d, 0xf2, 0xd4, 0xf0, 0x2d, 0x8c, 0x9e, 0xc0, 0x49, 0xd3, - 0xa0, 0xae, 0xa5, 0xb7, 0x31, 0xd6, 0x8d, 0x24, 0x5c, 0x05, 0xd3, 0x60, 0xb6, 0xb4, 0x38, 0xa7, - 0x64, 0x55, 0xa4, 0xa8, 0x31, 0x28, 0xcd, 0x74, 0x2f, 0xa7, 0x95, 0xcd, 0xb3, 0x41, 0xd4, 0x86, - 0x53, 0x01, 0x0e, 0x5d, 0x62, 0x0f, 0x29, 0xfc, 0xc3, 0x14, 0x94, 0x6c, 0x85, 0x07, 0x02, 0x77, - 0x46, 0xa4, 0x12, 0x9c, 0x13, 0x6f, 0x4e, 0x7d, 0xda, 0x95, 0xc0, 0xbb, 0xb7, 0xf3, 0x13, 0x37, - 0xd3, 0xe1, 0x35, 0xb5, 0x08, 0xf3, 0xb4, 0xef, 0xc9, 0xdf, 0x01, 0xac, 0x6c, 0x50, 0x67, 0x35, - 0xe6, 0x3e, 0xe5, 0x6f, 0x1d, 0xfe, 0xcb, 0x04, 0x71, 0xc8, 0x4a, 0x1e, 0x57, 0x17, 0xbe, 0x1d, - 0x48, 0xf3, 0x8e, 0x1b, 0x75, 0xfa, 0xa6, 0x62, 0x11, 0x4f, 0x4c, 0x26, 0x99, 0x16, 0xb5, 0xbb, - 0xa2, 0xdf, 0x2d, 0xcb, 0x6a, 0xd9, 0x76, 0x88, 0x29, 0xd5, 0x12, 0x86, 0x01, 0x19, 0xaf, 0xee, - 0x77, 0xc8, 0x30, 0x5a, 0x86, 0x63, 0x83, 0x66, 0xe5, 0x59, 0xb3, 0x66, 0xb2, 0x9b, 0x95, 0x2e, - 0x4a, 0x1b, 0x00, 0x9b, 0x85, 0xe7, 0xbb, 0x52, 0x4e, 0x7e, 0x03, 0xe0, 0xff, 0x1b, 0xd4, 0xd1, - 0xf0, 0x26, 0xe9, 0xe2, 0x3f, 0xa3, 0x7e, 0xf9, 0x23, 0x80, 0xe5, 0xa1, 0x25, 0x43, 0xcf, 0x60, - 0x89, 0x06, 0xd8, 0xb7, 0xf5, 0x9e, 0xeb, 0xb9, 0x51, 0x15, 0x4c, 0xe7, 0x67, 0x4b, 0x8b, 0x93, - 0xe9, 0xbe, 0x6c, 0x2e, 0x28, 0x4b, 0xc4, 0xf5, 0xd5, 0x95, 0xbd, 0x03, 0x29, 0xf7, 0xf9, 0x40, - 0x42, 0xdb, 0x86, 0xd7, 0x6b, 0xca, 0x29, 0x94, 0xfc, 0xea, 0x50, 0x9a, 0xbd, 0x80, 0xab, 0x98, - 0x86, 0x6a, 0x90, 0x21, 0xef, 0xc7, 0x40, 0xb4, 0x06, 0x21, 0xde, 0x0a, 0xdc, 0xd0, 0x88, 0x5c, - 0xe2, 0x8b, 0x0d, 0xbe, 0x91, 0x3d, 0x94, 0xbb, 0x71, 0x2e, 0xa6, 0xad, 0x48, 0x2d, 0xc4, 0x66, - 0xb4, 0x14, 0xb8, 0x39, 0x1a, 0x0f, 0x26, 0x5e, 0x5a, 0xf9, 0x75, 0x01, 0x56, 0xce, 0xdb, 0x75, - 0xb4, 0x0a, 0x8b, 0xec, 0x85, 0xfa, 0x85, 0x97, 0x51, 0x08, 0x72, 0x3c, 0xba, 0x03, 0x47, 0xf8, - 0x4b, 0x23, 0x2c, 0xcb, 0xd9, 0x4c, 0xcb, 0x7d, 0xee, 0x4f, 0x10, 0x08, 0x1c, 0xda, 0x01, 0x10, - 0xf1, 0x47, 0x3d, 0xdd, 0xfe, 0x7c, 0x76, 0xfb, 0x37, 0x44, 0xfb, 0xaf, 0xf2, 0xf6, 0x0f, 0x83, - 0x2f, 0x37, 0x85, 0xff, 0x38, 0xc1, 0xc3, 0xc1, 0x2c, 0x5e, 0x00, 0x28, 0x82, 0xba, 0x65, 0xf8, - 0x9c, 0xb9, 0x5a, 0xc8, 0x36, 0xb4, 0x2e, 0x0c, 0x5d, 0x39, 0x65, 0xe8, 0x04, 0x7a, 0x39, 0x3b, - 0x13, 0x1c, 0xbe, 0x64, 0xf8, 0xcc, 0x11, 0xb2, 0xe0, 0xb8, 0x20, 0x0c, 0x31, 0xc5, 0x51, 0xb5, - 0x78, 0xf1, 0xd5, 0xb8, 0x26, 0x7c, 0x4d, 0x9e, 0xf2, 0xc5, 0x68, 0x64, 0xad, 0xc4, 0x8f, 0x5a, - 0x7c, 0x4a, 0xad, 0x8c, 0x09, 0x47, 0x93, 0x41, 0xa1, 0x26, 0x2c, 0x5a, 0x3d, 0x62, 0x75, 0xc5, - 0x96, 0xd4, 0x14, 0x7e, 0x05, 0x28, 0xc9, 0x15, 0xa0, 0x3c, 0x4a, 0xae, 0x00, 0x75, 0x34, 0x96, - 0x7a, 0x79, 0x28, 0x01, 0x8d, 0x43, 0x50, 0x05, 0x16, 0x4d, 0x86, 0x8d, 0xf7, 0x22, 0xaf, 0xf1, - 0x43, 0xb3, 0xc0, 0x34, 0x2c, 0x38, 0x76, 0x62, 0x12, 0xdd, 0x86, 0x85, 0xf8, 0x26, 0xb9, 0xa8, - 0xc6, 0x4e, 0xac, 0xc1, 0x10, 0x68, 0x0a, 0x8e, 0x74, 0xb0, 0xeb, 0x74, 0x22, 0xa1, 0x21, 0x4e, - 0x42, 0xe4, 0x2b, 0x80, 0xe5, 0xf4, 0xde, 0xb2, 0x0f, 0xf4, 0xdf, 0xf1, 0x51, 0x56, 0x57, 0xf7, - 0x8e, 0xea, 0x60, 0xff, 0xa8, 0x0e, 0x3e, 0x1c, 0xd5, 0xc1, 0xce, 0x71, 0x3d, 0xb7, 0x7f, 0x5c, - 0xcf, 0xbd, 0x3f, 0xae, 0xe7, 0x1e, 0xff, 0xdc, 0xdd, 0xd9, 0xbf, 0x20, 0xe6, 0x08, 0x1b, 0xc3, - 0xad, 0x1f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x60, 0xf1, 0xd1, 0x21, 0x9d, 0x08, 0x00, 0x00, -} - -func (this *FeeAllowance) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*FeeAllowance) - if !ok { - that2, ok := that.(FeeAllowance) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if that1.Sum == nil { - if this.Sum != nil { - return false - } - } else if this.Sum == nil { - return false - } else if !this.Sum.Equal(that1.Sum) { - return false - } - return true -} -func (this *FeeAllowance_BasicFeeAllowance) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*FeeAllowance_BasicFeeAllowance) - if !ok { - that2, ok := that.(FeeAllowance_BasicFeeAllowance) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !this.BasicFeeAllowance.Equal(that1.BasicFeeAllowance) { - return false - } - return true -} -func (this *FeeAllowance_PeriodicFeeAllowance) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*FeeAllowance_PeriodicFeeAllowance) - if !ok { - that2, ok := that.(FeeAllowance_PeriodicFeeAllowance) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !this.PeriodicFeeAllowance.Equal(that1.PeriodicFeeAllowance) { - return false - } - return true -} -func (this *BasicFeeAllowance) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*BasicFeeAllowance) - if !ok { - that2, ok := that.(BasicFeeAllowance) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if len(this.SpendLimit) != len(that1.SpendLimit) { - return false - } - for i := range this.SpendLimit { - if !this.SpendLimit[i].Equal(&that1.SpendLimit[i]) { - return false - } - } - if !this.Expiration.Equal(&that1.Expiration) { - return false - } - return true -} -func (this *PeriodicFeeAllowance) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*PeriodicFeeAllowance) - if !ok { - that2, ok := that.(PeriodicFeeAllowance) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !this.Basic.Equal(&that1.Basic) { - return false - } - if !this.Period.Equal(&that1.Period) { - return false - } - if len(this.PeriodSpendLimit) != len(that1.PeriodSpendLimit) { - return false - } - for i := range this.PeriodSpendLimit { - if !this.PeriodSpendLimit[i].Equal(&that1.PeriodSpendLimit[i]) { - return false - } - } - if len(this.PeriodCanSpend) != len(that1.PeriodCanSpend) { - return false - } - for i := range this.PeriodCanSpend { - if !this.PeriodCanSpend[i].Equal(&that1.PeriodCanSpend[i]) { - return false - } - } - if !this.PeriodReset.Equal(&that1.PeriodReset) { - return false - } - return true -} -func (this *Duration) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*Duration) - if !ok { - that2, ok := that.(Duration) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if this.Clock != that1.Clock { - return false - } - if this.Block != that1.Block { - return false - } - return true -} -func (this *ExpiresAt) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*ExpiresAt) - if !ok { - that2, ok := that.(ExpiresAt) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !this.Time.Equal(that1.Time) { - return false - } - if this.Height != that1.Height { - return false - } - return true -} -func (this *FeeAllowance) GetFeeAllowanceI() FeeAllowanceI { - if x := this.GetBasicFeeAllowance(); x != nil { - return x - } - if x := this.GetPeriodicFeeAllowance(); x != nil { - return x - } - return nil -} - -func (this *FeeAllowance) SetFeeAllowanceI(value FeeAllowanceI) error { - if value == nil { - this.Sum = nil - return nil - } - switch vt := value.(type) { - case *BasicFeeAllowance: - this.Sum = &FeeAllowance_BasicFeeAllowance{vt} - return nil - case *PeriodicFeeAllowance: - this.Sum = &FeeAllowance_PeriodicFeeAllowance{vt} - return nil - } - return fmt.Errorf("can't encode value of type %T as message FeeAllowance", value) -} - -func (m *FeeAllowance) 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 *FeeAllowance) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *FeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Sum != nil { - { - size := m.Sum.Size() - i -= size - if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *FeeAllowance_BasicFeeAllowance) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *FeeAllowance_BasicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.BasicFeeAllowance != nil { - { - size, err := m.BasicFeeAllowance.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} -func (m *FeeAllowance_PeriodicFeeAllowance) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *FeeAllowance_PeriodicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.PeriodicFeeAllowance != nil { - { - size, err := m.PeriodicFeeAllowance.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} -func (m *MsgGrantFeeAllowance) 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 *MsgGrantFeeAllowance) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgGrantFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Allowance != nil { - { - size, err := m.Allowance.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if len(m.Grantee) > 0 { - i -= len(m.Grantee) - copy(dAtA[i:], m.Grantee) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Grantee))) - i-- - dAtA[i] = 0x12 - } - if len(m.Granter) > 0 { - i -= len(m.Granter) - copy(dAtA[i:], m.Granter) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Granter))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgRevokeFeeAllowance) 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 *MsgRevokeFeeAllowance) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRevokeFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Grantee) > 0 { - i -= len(m.Grantee) - copy(dAtA[i:], m.Grantee) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Grantee))) - i-- - dAtA[i] = 0x12 - } - if len(m.Granter) > 0 { - i -= len(m.Granter) - copy(dAtA[i:], m.Granter) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Granter))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *BasicFeeAllowance) 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 *BasicFeeAllowance) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BasicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Expiration.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.SpendLimit) > 0 { - for iNdEx := len(m.SpendLimit) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.SpendLimit[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *PeriodicFeeAllowance) 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 *PeriodicFeeAllowance) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PeriodicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.PeriodReset.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - if len(m.PeriodCanSpend) > 0 { - for iNdEx := len(m.PeriodCanSpend) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.PeriodCanSpend[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - if len(m.PeriodSpendLimit) > 0 { - for iNdEx := len(m.PeriodSpendLimit) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.PeriodSpendLimit[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - { - size, err := m.Period.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size, err := m.Basic.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *Duration) 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 *Duration) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Duration) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Block != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Block)) - i-- - dAtA[i] = 0x10 - } - n8, err8 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.Clock, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.Clock):]) - if err8 != nil { - return 0, err8 - } - i -= n8 - i = encodeVarintTypes(dAtA, i, uint64(n8)) - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *ExpiresAt) 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 *ExpiresAt) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExpiresAt) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Height != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x10 - } - n9, err9 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Time):]) - if err9 != nil { - return 0, err9 - } - i -= n9 - i = encodeVarintTypes(dAtA, i, uint64(n9)) - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *FeeAllowanceGrant) 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 *FeeAllowanceGrant) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *FeeAllowanceGrant) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Allowance != nil { - { - size, err := m.Allowance.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if len(m.Grantee) > 0 { - i -= len(m.Grantee) - copy(dAtA[i:], m.Grantee) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Grantee))) - i-- - dAtA[i] = 0x12 - } - if len(m.Granter) > 0 { - i -= len(m.Granter) - copy(dAtA[i:], m.Granter) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Granter))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { - offset -= sovTypes(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *FeeAllowance) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Sum != nil { - n += m.Sum.Size() - } - return n -} - -func (m *FeeAllowance_BasicFeeAllowance) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.BasicFeeAllowance != nil { - l = m.BasicFeeAllowance.Size() - n += 1 + l + sovTypes(uint64(l)) - } - return n -} -func (m *FeeAllowance_PeriodicFeeAllowance) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PeriodicFeeAllowance != nil { - l = m.PeriodicFeeAllowance.Size() - n += 1 + l + sovTypes(uint64(l)) - } - return n -} -func (m *MsgGrantFeeAllowance) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Granter) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.Grantee) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - if m.Allowance != nil { - l = m.Allowance.Size() - n += 1 + l + sovTypes(uint64(l)) - } - return n -} - -func (m *MsgRevokeFeeAllowance) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Granter) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.Grantee) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - return n -} - -func (m *BasicFeeAllowance) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.SpendLimit) > 0 { - for _, e := range m.SpendLimit { - l = e.Size() - n += 1 + l + sovTypes(uint64(l)) - } - } - l = m.Expiration.Size() - n += 1 + l + sovTypes(uint64(l)) - return n -} - -func (m *PeriodicFeeAllowance) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Basic.Size() - n += 1 + l + sovTypes(uint64(l)) - l = m.Period.Size() - n += 1 + l + sovTypes(uint64(l)) - if len(m.PeriodSpendLimit) > 0 { - for _, e := range m.PeriodSpendLimit { - l = e.Size() - n += 1 + l + sovTypes(uint64(l)) - } - } - if len(m.PeriodCanSpend) > 0 { - for _, e := range m.PeriodCanSpend { - l = e.Size() - n += 1 + l + sovTypes(uint64(l)) - } - } - l = m.PeriodReset.Size() - n += 1 + l + sovTypes(uint64(l)) - return n -} - -func (m *Duration) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.Clock) - n += 1 + l + sovTypes(uint64(l)) - if m.Block != 0 { - n += 1 + sovTypes(uint64(m.Block)) - } - return n -} - -func (m *ExpiresAt) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Time) - n += 1 + l + sovTypes(uint64(l)) - if m.Height != 0 { - n += 1 + sovTypes(uint64(m.Height)) - } - return n -} - -func (m *FeeAllowanceGrant) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Granter) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.Grantee) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - if m.Allowance != nil { - l = m.Allowance.Size() - n += 1 + l + sovTypes(uint64(l)) - } - return n -} - -func sovTypes(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTypes(x uint64) (n int) { - return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *FeeAllowance) 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 ErrIntOverflowTypes - } - 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: FeeAllowance: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: FeeAllowance: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BasicFeeAllowance", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &BasicFeeAllowance{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Sum = &FeeAllowance_BasicFeeAllowance{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PeriodicFeeAllowance", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &PeriodicFeeAllowance{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Sum = &FeeAllowance_PeriodicFeeAllowance{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgGrantFeeAllowance) 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 ErrIntOverflowTypes - } - 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: MsgGrantFeeAllowance: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgGrantFeeAllowance: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Granter", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Granter = append(m.Granter[:0], dAtA[iNdEx:postIndex]...) - if m.Granter == nil { - m.Granter = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Grantee = append(m.Grantee[:0], dAtA[iNdEx:postIndex]...) - if m.Grantee == nil { - m.Grantee = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Allowance", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Allowance == nil { - m.Allowance = &FeeAllowance{} - } - if err := m.Allowance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgRevokeFeeAllowance) 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 ErrIntOverflowTypes - } - 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: MsgRevokeFeeAllowance: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRevokeFeeAllowance: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Granter", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Granter = append(m.Granter[:0], dAtA[iNdEx:postIndex]...) - if m.Granter == nil { - m.Granter = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Grantee = append(m.Grantee[:0], dAtA[iNdEx:postIndex]...) - if m.Grantee == nil { - m.Grantee = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *BasicFeeAllowance) 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 ErrIntOverflowTypes - } - 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: BasicFeeAllowance: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BasicFeeAllowance: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SpendLimit", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SpendLimit = append(m.SpendLimit, types.Coin{}) - if err := m.SpendLimit[len(m.SpendLimit)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Expiration", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Expiration.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PeriodicFeeAllowance) 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 ErrIntOverflowTypes - } - 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: PeriodicFeeAllowance: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PeriodicFeeAllowance: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Basic", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Basic.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Period", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Period.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PeriodSpendLimit", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PeriodSpendLimit = append(m.PeriodSpendLimit, types.Coin{}) - if err := m.PeriodSpendLimit[len(m.PeriodSpendLimit)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PeriodCanSpend", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PeriodCanSpend = append(m.PeriodCanSpend, types.Coin{}) - if err := m.PeriodCanSpend[len(m.PeriodCanSpend)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PeriodReset", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.PeriodReset.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Duration) 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 ErrIntOverflowTypes - } - 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: Duration: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Duration: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Clock", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.Clock, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) - } - m.Block = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Block |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ExpiresAt) 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 ErrIntOverflowTypes - } - 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: ExpiresAt: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ExpiresAt: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.Time, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Height |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *FeeAllowanceGrant) 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 ErrIntOverflowTypes - } - 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: FeeAllowanceGrant: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: FeeAllowanceGrant: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Granter", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Granter = append(m.Granter[:0], dAtA[iNdEx:postIndex]...) - if m.Granter == nil { - m.Granter = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Grantee = append(m.Grantee[:0], dAtA[iNdEx:postIndex]...) - if m.Grantee == nil { - m.Grantee = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Allowance", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Allowance == nil { - m.Allowance = &FeeAllowance{} - } - if err := m.Allowance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipTypes(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, ErrIntOverflowTypes - } - 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, ErrIntOverflowTypes - } - 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, ErrIntOverflowTypes - } - 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, ErrInvalidLengthTypes - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTypes - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTypes - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") -) From 1617e5a48f36e44873a6d3bc33b1086ce603df53 Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 26 Nov 2020 21:15:50 +0530 Subject: [PATCH 081/184] fix errors --- simapp/ante.go | 11 ++++-- x/feegrant/alias.go | 4 +- x/feegrant/ante/fee.go | 9 +++-- x/feegrant/handler.go | 13 ++++--- x/feegrant/keeper/keeper.go | 4 +- x/feegrant/keeper/querier.go | 8 ++-- x/feegrant/module.go | 12 +++--- x/feegrant/types/grant.go | 20 +++++++++- x/feegrant/types/msgs.go | 67 ++++++++++++++++++++++++++++----- x/feegrant/types/test_common.go | 10 ++--- x/feegrant/types/tx.go | 2 +- 11 files changed, 115 insertions(+), 45 deletions(-) diff --git a/simapp/ante.go b/simapp/ante.go index e53f8638d577..7543ab4336bc 100644 --- a/simapp/ante.go +++ b/simapp/ante.go @@ -1,9 +1,11 @@ package simapp import ( + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" "github.com/cosmos/cosmos-sdk/x/feegrant" feegrantante "github.com/cosmos/cosmos-sdk/x/feegrant/ante" ) @@ -12,10 +14,11 @@ import ( // numbers, checks signatures & account numbers, and deducts fees from the first // signer. func NewAnteHandler( - ak auth.AccountKeeper, supplyKeeper feegrant.SupplyKeeper, feeGrantKeeper feegrant.Keeper, - sigGasConsumer auth.SignatureVerificationGasConsumer, + ak authkeeper.AccountKeeper, supplyKeeper feegrant.SupplyKeeper, feeGrantKeeper feegrant.Keeper, + sigGasConsumer authante.SignatureVerificationGasConsumer, ) sdk.AnteHandler { + txConfig := legacytx.StdTxConfig{Cdc: codec.NewLegacyAmino()} return sdk.ChainAnteDecorators( authante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first authante.NewMempoolFeeDecorator(), @@ -29,7 +32,7 @@ func NewAnteHandler( authante.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators authante.NewValidateSigCountDecorator(ak), authante.NewSigGasConsumeDecorator(ak, sigGasConsumer), - authante.NewSigVerificationDecorator(ak), + authante.NewSigVerificationDecorator(ak, txConfig.SignModeHandler()), authante.NewIncrementSequenceDecorator(ak), // innermost AnteDecorator ) } diff --git a/x/feegrant/alias.go b/x/feegrant/alias.go index 74ea930daf17..d2021396e369 100644 --- a/x/feegrant/alias.go +++ b/x/feegrant/alias.go @@ -24,7 +24,7 @@ const ( var ( NewDeductGrantedFeeDecorator = ante.NewDeductGrantedFeeDecorator - RegisterCodec = types.RegisterCodec + RegisterCodec = types.RegisterLegacyAminoCodec ExpiresAtTime = types.ExpiresAtTime ExpiresAtHeight = types.ExpiresAtHeight ClockDuration = types.ClockDuration @@ -53,7 +53,7 @@ type ( BasicFeeAllowance = types.BasicFeeAllowance ExpiresAt = types.ExpiresAt Duration = types.Duration - FeeAllowance = types.FeeAllowance + FeeAllowance = types.FeeAllowanceI FeeAllowanceGrant = types.FeeAllowanceGrant MsgGrantFeeAllowance = types.MsgGrantFeeAllowance MsgRevokeFeeAllowance = types.MsgRevokeFeeAllowance diff --git a/x/feegrant/ante/fee.go b/x/feegrant/ante/fee.go index af3cf51852a8..72b1247f55f9 100644 --- a/x/feegrant/ante/fee.go +++ b/x/feegrant/ante/fee.go @@ -5,7 +5,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/auth" + authante "github.com/cosmos/cosmos-sdk/x/auth/ante" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) @@ -54,8 +55,8 @@ func (d DeductGrantedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula } // sanity check from DeductFeeDecorator - if addr := d.sk.GetModuleAddress(auth.FeeCollectorName); addr == nil { - panic(fmt.Sprintf("%s module account has not been set", auth.FeeCollectorName)) + if addr := d.sk.GetModuleAddress(authtypes.FeeCollectorName); addr == nil { + panic(fmt.Sprintf("%s module account has not been set", authtypes.FeeCollectorName)) } fee := feeTx.GetFee() @@ -89,7 +90,7 @@ func (d DeductGrantedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula } // deduct fee if non-zero - err = auth.DeductFees(d.sk, ctx, feePayerAcc, fee) + err = authante.DeductFees(d.sk, ctx, feePayerAcc, fee) if err != nil { return ctx, err } diff --git a/x/feegrant/handler.go b/x/feegrant/handler.go index 40d483a41790..a8dbd6db92d3 100644 --- a/x/feegrant/handler.go +++ b/x/feegrant/handler.go @@ -3,6 +3,7 @@ package feegrant import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) func NewHandler(k Keeper) sdk.Handler { @@ -10,10 +11,10 @@ func NewHandler(k Keeper) sdk.Handler { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { - case MsgGrantFeeAllowance: + case *MsgGrantFeeAllowance: return handleGrantFee(ctx, k, msg) - case MsgRevokeFeeAllowance: + case *MsgRevokeFeeAllowance: return handleRevokeFee(ctx, k, msg) default: @@ -22,14 +23,14 @@ func NewHandler(k Keeper) sdk.Handler { } } -func handleGrantFee(ctx sdk.Context, k Keeper, msg MsgGrantFeeAllowance) (*sdk.Result, error) { +func handleGrantFee(ctx sdk.Context, k Keeper, msg types.MsgGrantFeeAllowance) (*sdk.Result, error) { feegrant := FeeAllowanceGrant(msg) k.GrantFeeAllowance(ctx, feegrant) - return &sdk.Result{Events: ctx.EventManager().Events()}, nil + return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil } -func handleRevokeFee(ctx sdk.Context, k Keeper, msg MsgRevokeFeeAllowance) (*sdk.Result, error) { +func handleRevokeFee(ctx sdk.Context, k Keeper, msg types.MsgRevokeFeeAllowance) (*sdk.Result, error) { k.RevokeFeeAllowance(ctx, msg.Granter, msg.Grantee) - return &sdk.Result{Events: ctx.EventManager().Events()}, nil + return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil } diff --git a/x/feegrant/keeper/keeper.go b/x/feegrant/keeper/keeper.go index d3fb815f06a5..e618161d90ae 100644 --- a/x/feegrant/keeper/keeper.go +++ b/x/feegrant/keeper/keeper.go @@ -63,13 +63,13 @@ func (k Keeper) RevokeFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddr // GetFeeAllowance returns the allowance between the granter and grantee. // If there is none, it returns nil, nil. // Returns an error on parsing issues -func (k Keeper) GetFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddress) *types.FeeAllowance { +func (k Keeper) GetFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddress) types.FeeAllowanceI { grant, found := k.GetFeeGrant(ctx, granter, grantee) if !found { return nil } - return grant.Allowance + return grant.GetFeeGrant() } // GetFeeGrant returns entire grant between both accounts diff --git a/x/feegrant/keeper/querier.go b/x/feegrant/keeper/querier.go index 41b0ab7970c4..8b0e06b9643e 100644 --- a/x/feegrant/keeper/querier.go +++ b/x/feegrant/keeper/querier.go @@ -14,7 +14,7 @@ const ( ) // NewQuerier creates a new querier -func NewQuerier(keeper Keeper) sdk.Querier { +func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { var ( res []byte @@ -23,7 +23,7 @@ func NewQuerier(keeper Keeper) sdk.Querier { switch path[0] { case QueryGetFeeAllowances: - res, err = queryGetFeeAllowances(ctx, path[1:], keeper) + res, err = queryGetFeeAllowances(ctx, path[1:], keeper, legacyQuerierCdc) default: err = sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown %s query endpoint: %s", types.ModuleName, path[0]) @@ -33,7 +33,7 @@ func NewQuerier(keeper Keeper) sdk.Querier { } } -func queryGetFeeAllowances(ctx sdk.Context, args []string, keeper Keeper) ([]byte, error) { +func queryGetFeeAllowances(ctx sdk.Context, args []string, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { grantee := args[0] granteeAddr, err := sdk.AccAddressFromBech32(grantee) if err != nil { @@ -53,7 +53,7 @@ func queryGetFeeAllowances(ctx sdk.Context, args []string, keeper Keeper) ([]byt return []byte("[]"), nil } - bz, err := codec.MarshalJSONIndent(keeper.cdc, grants) + bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, grants) if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) } diff --git a/x/feegrant/module.go b/x/feegrant/module.go index 588abc2bd10e..7c4ca5be08ce 100644 --- a/x/feegrant/module.go +++ b/x/feegrant/module.go @@ -55,8 +55,8 @@ func (AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { } // LegacyQuerierHandler returns the feegrant module sdk.Querier. -func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { - return keeper.NewQuerier(am.keeper) +func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return keeper.NewQuerier(am.keeper, legacyQuerierCdc) } // DefaultGenesis returns default genesis state as raw bytes for the feegrant @@ -148,10 +148,10 @@ func (AppModule) QuerierRoute() string { return QuerierRoute } -// NewQuerierHandler returns the feegrant module sdk.Querier. -func (am AppModule) NewQuerierHandler() sdk.Querier { - return NewQuerier(am.keeper) -} +// // NewQuerierHandler returns the feegrant module sdk.Querier. +// func (am AppModule) NewQuerierHandler() sdk.Querier { +// return NewQuerier(am.keeper) +// } // InitGenesis performs genesis initialization for the feegrant module. It returns // no validator updates. diff --git a/x/feegrant/types/grant.go b/x/feegrant/types/grant.go index a3c6b142ef49..f28671e90694 100644 --- a/x/feegrant/types/grant.go +++ b/x/feegrant/types/grant.go @@ -3,9 +3,15 @@ package types import ( "time" + "github.com/cosmos/cosmos-sdk/codec/types" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) +var ( + _ types.UnpackInterfacesMessage = &FeeAllowanceGrant{} +) + // ValidateBasic performs basic validation on // FeeAllowanceGrant func (a FeeAllowanceGrant) ValidateBasic() error { @@ -23,7 +29,19 @@ func (a FeeAllowanceGrant) ValidateBasic() error { } func (a FeeAllowanceGrant) GetFeeGrant() FeeAllowanceI { - return a.Allowance.GetFeeAllowanceI() + allowance, ok := a.Allowance.GetCachedValue().(FeeAllowanceI) + if !ok { + return nil + } + + return allowance + // return a.Allowance.GetFeeAllowanceI() +} + +// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces +func (a FeeAllowanceGrant) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { + var allowance FeeAllowanceI + return unpacker.UnpackAny(a.Allowance, &allowance) } // PrepareForExport will m ake all needed changes to the allowance to prepare to be diff --git a/x/feegrant/types/msgs.go b/x/feegrant/types/msgs.go index d68ebef5638c..38f76f773efe 100644 --- a/x/feegrant/types/msgs.go +++ b/x/feegrant/types/msgs.go @@ -1,30 +1,60 @@ package types import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/codec/types" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/gogo/protobuf/proto" +) + +var ( + _, _ sdk.Msg = &MsgGrantFeeAllowance{}, &MsgRevokeFeeAllowance{} + _ types.UnpackInterfacesMessage = &MsgGrantFeeAllowance{} +) + +// feegrant message types +const ( + TypeMsgGrantFeeAllowance = "grant_fee_allowance" + TypeMsgRevokeFeeAllowance = "revoke_fee_allowance" ) -func (msg MsgGrantFeeAllowance) NewMsgGrantFeeAllowance(feeAllowance *FeeAllowanceI, granter, grantee sdk.AccAddress) (MsgGrantFeeAllowance, error) { - return MsgGrantFeeAllowance{ +// NewMsgGrantFeeAllowance creates a new MsgGrantFeeAllowance. +//nolint:interfacer +func (msg MsgGrantFeeAllowance) NewMsgGrantFeeAllowance(feeAllowance FeeAllowanceI, granter, grantee sdk.AccAddress) (*MsgGrantFeeAllowance, error) { + msg1, ok := feeAllowance.(proto.Message) + if !ok { + return nil, fmt.Errorf("cannot proto marshal %T", msg1) + } + any, err := types.NewAnyWithValue(msg1) + if err != nil { + return nil, err + } + + return &MsgGrantFeeAllowance{ Granter: granter, Grantee: grantee, - Allowance: feeAllowance, + Allowance: any, }, nil } -func (msg MsgGrantFeeAllowance) GetFeeGrant() FeeAllowanceI { - return msg.Allowance.GetFeeAllowanceI() -} +// func (msg MsgGrantFeeAllowance) GetFeeGrant() FeeAllowanceI { +// return msg.GetFeeAllowanceI() +// } +// Route implements the sdk.Msg interface. func (msg MsgGrantFeeAllowance) Route() string { return RouterKey } +// Type implements the sdk.Msg interface. func (msg MsgGrantFeeAllowance) Type() string { - return "grant-fee-allowance" + return TypeMsgGrantFeeAllowance } +// ValidateBasic implements the sdk.Msg interface. func (msg MsgGrantFeeAllowance) ValidateBasic() error { if msg.Granter.Empty() { return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "missing granter address") @@ -36,14 +66,31 @@ func (msg MsgGrantFeeAllowance) ValidateBasic() error { return nil } +// GetSignBytes returns the message bytes to sign over. func (msg MsgGrantFeeAllowance) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) } func (msg MsgGrantFeeAllowance) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Granter} } +// GetFeeAllowanceI returns unpacked FeeAllowance +func (msg MsgGrantFeeAllowance) GetFeeAllowanceI() FeeAllowanceI { + allowance, ok := msg.Allowance.GetCachedValue().(FeeAllowanceI) + if !ok { + return nil + } + + return allowance +} + +// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces +func (msg MsgGrantFeeAllowance) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { + var allowance FeeAllowanceI + return unpacker.UnpackAny(msg.Allowance, &allowance) +} + func NewMsgRevokeFeeAllowance(granter sdk.AccAddress, grantee sdk.AccAddress) MsgRevokeFeeAllowance { return MsgRevokeFeeAllowance{Granter: granter, Grantee: grantee} } @@ -53,7 +100,7 @@ func (msg MsgRevokeFeeAllowance) Route() string { } func (msg MsgRevokeFeeAllowance) Type() string { - return "revoke-fee-allowance" + return TypeMsgRevokeFeeAllowance } func (msg MsgRevokeFeeAllowance) ValidateBasic() error { @@ -68,7 +115,7 @@ func (msg MsgRevokeFeeAllowance) ValidateBasic() error { } func (msg MsgRevokeFeeAllowance) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) } func (msg MsgRevokeFeeAllowance) GetSigners() []sdk.AccAddress { diff --git a/x/feegrant/types/test_common.go b/x/feegrant/types/test_common.go index bb3686650c48..50e064e81156 100644 --- a/x/feegrant/types/test_common.go +++ b/x/feegrant/types/test_common.go @@ -3,14 +3,14 @@ package types import ( - "github.com/tendermint/tendermint/crypto" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" ) -func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums []uint64, seqs []uint64, fee GrantedFee) sdk.Tx { - sigs := make([]authtypes.StdSignature, len(privs)) +func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []cryptotypes.PrivKey, accNums []uint64, seqs []uint64, fee GrantedFee) sdk.Tx { + sigs := make([]legacytx.StdSignature, len(privs)) for i, priv := range privs { signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], fee, msgs, "") @@ -19,7 +19,7 @@ func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums panic(err) } - sigs[i] = authtypes.StdSignature{PubKey: priv.PubKey(), Signature: sig} + sigs[i] = legacytx.StdSignature{PubKey: priv.PubKey(), Signature: sig} } tx := NewFeeGrantTx(msgs, fee, sigs, "") diff --git a/x/feegrant/types/tx.go b/x/feegrant/types/tx.go index 6d757ee8a492..67ba75589dcd 100644 --- a/x/feegrant/types/tx.go +++ b/x/feegrant/types/tx.go @@ -81,7 +81,7 @@ func CountSubKeys(pub cryptotypes.PubKey) int { } numKeys := 0 - for _, subkey := range v.PubKeys { + for _, subkey := range v.GetPubKeys() { numKeys += CountSubKeys(subkey) } From 13f503e7fd7cba3e38bc972804298b5ee4e2e7fc Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 26 Nov 2020 21:46:33 +0530 Subject: [PATCH 082/184] fix errors --- x/feegrant/handler.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/x/feegrant/handler.go b/x/feegrant/handler.go index a8dbd6db92d3..594105a86391 100644 --- a/x/feegrant/handler.go +++ b/x/feegrant/handler.go @@ -23,14 +23,28 @@ func NewHandler(k Keeper) sdk.Handler { } } -func handleGrantFee(ctx sdk.Context, k Keeper, msg types.MsgGrantFeeAllowance) (*sdk.Result, error) { - feegrant := FeeAllowanceGrant(msg) +func handleGrantFee(ctx sdk.Context, k Keeper, msg *types.MsgGrantFeeAllowance) (*sdk.Result, error) { + grantee, err := sdk.AccAddressFromBech32(msg.Grantee.String()) + if err != nil { + return nil, err + } + + granter, err := sdk.AccAddressFromBech32(msg.Granter.String()) + if err != nil { + return nil, err + } + + feegrant := types.FeeAllowanceGrant(types.FeeAllowanceGrant{ + Grantee: grantee, + Granter: granter, + Allowance: msg.Allowance, + }) k.GrantFeeAllowance(ctx, feegrant) return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil } -func handleRevokeFee(ctx sdk.Context, k Keeper, msg types.MsgRevokeFeeAllowance) (*sdk.Result, error) { +func handleRevokeFee(ctx sdk.Context, k Keeper, msg *types.MsgRevokeFeeAllowance) (*sdk.Result, error) { k.RevokeFeeAllowance(ctx, msg.Granter, msg.Grantee) return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil } From cb10556e97deb513934a498ae823809c74a10023 Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 1 Dec 2020 14:24:29 +0530 Subject: [PATCH 083/184] genesis state changed to proto --- proto/cosmos/feegrant/v1beta1/genesis.proto | 12 + proto/cosmos/feegrant/v1beta1/tx.proto | 18 + x/feegrant/genesis.go | 11 +- x/feegrant/handler.go | 35 +- x/feegrant/keeper/msg_server.go | 65 ++++ x/feegrant/keeper/querier.go | 1 + x/feegrant/module.go | 47 +-- x/feegrant/types/events.go | 2 + x/feegrant/types/genesis.go | 40 ++ x/feegrant/types/genesis.pb.go | 336 +++++++++++++++++ x/feegrant/types/grant.go | 21 ++ x/feegrant/types/msgs.go | 8 +- x/feegrant/types/tx.pb.go | 394 +++++++++++++++++++- 13 files changed, 923 insertions(+), 67 deletions(-) create mode 100644 proto/cosmos/feegrant/v1beta1/genesis.proto create mode 100644 x/feegrant/keeper/msg_server.go create mode 100644 x/feegrant/types/genesis.go create mode 100644 x/feegrant/types/genesis.pb.go diff --git a/proto/cosmos/feegrant/v1beta1/genesis.proto b/proto/cosmos/feegrant/v1beta1/genesis.proto new file mode 100644 index 000000000000..9460a27d42cc --- /dev/null +++ b/proto/cosmos/feegrant/v1beta1/genesis.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package cosmos.feegrant.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/feegrant/v1beta1/feegrant.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; + +// GenesisState contains a set of fee allowances, persisted from the store +message GenesisState { + repeated FeeAllowanceGrant fee_allowances = 1 [(gogoproto.nullable) = false]; +} \ No newline at end of file diff --git a/proto/cosmos/feegrant/v1beta1/tx.proto b/proto/cosmos/feegrant/v1beta1/tx.proto index 6092c7a2c6b7..ad065ed0c04d 100644 --- a/proto/cosmos/feegrant/v1beta1/tx.proto +++ b/proto/cosmos/feegrant/v1beta1/tx.proto @@ -7,6 +7,18 @@ import "cosmos_proto/cosmos.proto"; option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; +// Msg defines the feegrant msg service. +service Msg { + + // GrantFeeAllowance grants fee allowance to the grantee on the granter's + // account with the provided expiration time. + rpc GrantFeeAllowance(MsgGrantFeeAllowance) returns (MsgGrantFeeAllowanceResponse); + + // RevokeFeeAllowance revokes any fee allowance of granter's account that + // has been granted to the grantee. + rpc RevokeFeeAllowance(MsgRevokeFeeAllowance) returns (MsgRevokeFeeAllowanceResponse); +} + // MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance // of fees from the account of Granter. message MsgGrantFeeAllowance { @@ -17,8 +29,14 @@ message MsgGrantFeeAllowance { google.protobuf.Any allowance = 3 [(cosmos_proto.accepts_interface) = "FeeAllowanceI"]; } +// MsgGrantFeeAllowanceResponse defines the Msg/GrantFeeAllowanceResponse response type. +message MsgGrantFeeAllowanceResponse {} + // MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee. message MsgRevokeFeeAllowance { bytes granter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; bytes grantee = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; } + +// MsgRevokeFeeAllowanceResponse defines the Msg/RevokeFeeAllowanceResponse response type. +message MsgRevokeFeeAllowanceResponse {} diff --git a/x/feegrant/genesis.go b/x/feegrant/genesis.go index d32598a6e167..47244cea0baa 100644 --- a/x/feegrant/genesis.go +++ b/x/feegrant/genesis.go @@ -2,6 +2,7 @@ package feegrant import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) // GenesisState contains a set of fee allowances, persisted from the store @@ -19,8 +20,8 @@ func (g GenesisState) ValidateBasic() error { } // InitGenesis will initialize the keeper from a *previously validated* GenesisState -func InitGenesis(ctx sdk.Context, k Keeper, gen GenesisState) { - for _, f := range gen { +func InitGenesis(ctx sdk.Context, k Keeper, data *types.GenesisState) { + for _, f := range data.FeeAllowances { k.GrantFeeAllowance(ctx, f) } } @@ -32,7 +33,7 @@ func InitGenesis(ctx sdk.Context, k Keeper, gen GenesisState) { // for export, like if they have expiry at 5000 and current is 4000, they export with // expiry of 1000. Every FeeAllowance has a method `PrepareForExport` that allows // them to perform any changes needed prior to export. -func ExportGenesis(ctx sdk.Context, k Keeper) (GenesisState, error) { +func ExportGenesis(ctx sdk.Context, k Keeper) (*types.GenesisState, error) { time, height := ctx.BlockTime(), ctx.BlockHeight() var grants []FeeAllowanceGrant @@ -41,5 +42,7 @@ func ExportGenesis(ctx sdk.Context, k Keeper) (GenesisState, error) { return false }) - return grants, err + return &types.GenesisState{ + FeeAllowances: grants, + }, err } diff --git a/x/feegrant/handler.go b/x/feegrant/handler.go index 594105a86391..9064f2e27476 100644 --- a/x/feegrant/handler.go +++ b/x/feegrant/handler.go @@ -3,48 +3,25 @@ package feegrant import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" ) func NewHandler(k Keeper) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) + msgServer := keeper.NewMsgServerImpl(k) switch msg := msg.(type) { case *MsgGrantFeeAllowance: - return handleGrantFee(ctx, k, msg) + res, err := msgServer.GrantFeeAllowance(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) case *MsgRevokeFeeAllowance: - return handleRevokeFee(ctx, k, msg) + res, err := msgServer.RevokeFeeAllowance(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) default: return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", ModuleName, msg) } } } - -func handleGrantFee(ctx sdk.Context, k Keeper, msg *types.MsgGrantFeeAllowance) (*sdk.Result, error) { - grantee, err := sdk.AccAddressFromBech32(msg.Grantee.String()) - if err != nil { - return nil, err - } - - granter, err := sdk.AccAddressFromBech32(msg.Granter.String()) - if err != nil { - return nil, err - } - - feegrant := types.FeeAllowanceGrant(types.FeeAllowanceGrant{ - Grantee: grantee, - Granter: granter, - Allowance: msg.Allowance, - }) - - k.GrantFeeAllowance(ctx, feegrant) - return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil -} - -func handleRevokeFee(ctx sdk.Context, k Keeper, msg *types.MsgRevokeFeeAllowance) (*sdk.Result, error) { - k.RevokeFeeAllowance(ctx, msg.Granter, msg.Grantee) - return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil -} diff --git a/x/feegrant/keeper/msg_server.go b/x/feegrant/keeper/msg_server.go new file mode 100644 index 000000000000..2552cd64f06a --- /dev/null +++ b/x/feegrant/keeper/msg_server.go @@ -0,0 +1,65 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/cosmos-sdk/x/feegrant/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the feegrant MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(k Keeper) types.MsgServer { + return &msgServer{ + Keeper: k, + } +} + +var _ types.MsgServer = msgServer{} + +func (k msgServer) GrantFeeAllowance(goCtx context.Context, msg *types.MsgGrantFeeAllowance) (*types.MsgGrantFeeAllowanceResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + grantee, err := sdk.AccAddressFromBech32(msg.Grantee.String()) + if err != nil { + return nil, err + } + + granter, err := sdk.AccAddressFromBech32(msg.Granter.String()) + if err != nil { + return nil, err + } + + feegrant := types.FeeAllowanceGrant{ + Grantee: grantee, + Granter: granter, + Allowance: msg.Allowance, + } + + k.Keeper.GrantFeeAllowance(ctx, feegrant) + + return &types.MsgGrantFeeAllowanceResponse{}, nil +} + +func (k msgServer) RevokeFeeAllowance(goCtx context.Context, msg *types.MsgRevokeFeeAllowance) (*types.MsgRevokeFeeAllowanceResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + grantee, err := sdk.AccAddressFromBech32(msg.Grantee.String()) + if err != nil { + return nil, err + } + + granter, err := sdk.AccAddressFromBech32(msg.Granter.String()) + if err != nil { + return nil, err + } + + k.Keeper.RevokeFeeAllowance(ctx, granter, grantee) + + return &types.MsgRevokeFeeAllowanceResponse{}, nil +} diff --git a/x/feegrant/keeper/querier.go b/x/feegrant/keeper/querier.go index 8b0e06b9643e..1073f1be9e2a 100644 --- a/x/feegrant/keeper/querier.go +++ b/x/feegrant/keeper/querier.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) +// querier types const ( QueryGetFeeAllowances = "fees" ) diff --git a/x/feegrant/module.go b/x/feegrant/module.go index 7c4ca5be08ce..e1b30a3535f0 100644 --- a/x/feegrant/module.go +++ b/x/feegrant/module.go @@ -2,6 +2,7 @@ package feegrant import ( "encoding/json" + "fmt" "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" @@ -67,21 +68,25 @@ func (AppModuleBasic) DefaultGenesis(_ codec.JSONMarshaler) json.RawMessage { // ValidateGenesis performs genesis state validation for the feegrant module. func (a AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, config sdkclient.TxEncodingConfig, bz json.RawMessage) error { - _, err := a.getValidatedGenesis(cdc, bz) - return err + var data types.GenesisState + if err := cdc.UnmarshalJSON(bz, &data); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + + return types.ValidateGenesis(data) } -func (a AppModuleBasic) getValidatedGenesis(cdc codec.JSONMarshaler, bz json.RawMessage) (GenesisState, error) { - var data GenesisState +// func (a AppModuleBasic) getValidatedGenesis(cdc codec.JSONMarshaler, bz json.RawMessage) (GenesisState, error) { +// var data GenesisState - // TODO migrate genesis types to proto - // err := cdc.UnmarshalJSON(bz, &data) - // if err != nil { - // return nil, err - // } +// // TODO migrate genesis types to proto +// // err := cdc.UnmarshalJSON(bz, &data) +// // if err != nil { +// // return nil, err +// // } - return data, data.ValidateBasic() -} +// return data, data.ValidateBasic() +// } // RegisterRESTRoutes registers the REST routes for the feegrant module. func (AppModuleBasic) RegisterRESTRoutes(ctx sdkclient.Context, rtr *mux.Router) { @@ -156,26 +161,22 @@ func (AppModule) QuerierRoute() string { // InitGenesis performs genesis initialization for the feegrant module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, bz json.RawMessage) []abci.ValidatorUpdate { - genesisState, err := am.getValidatedGenesis(cdc, bz) - if err != nil { - panic(err) - } + var gs types.GenesisState + cdc.MustUnmarshalJSON(bz, &gs) - InitGenesis(ctx, am.keeper, genesisState) + InitGenesis(ctx, am.keeper, &gs) return []abci.ValidatorUpdate{} } // ExportGenesis returns the exported genesis state as raw bytes for the feegrant // module. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONMarshaler) json.RawMessage { - // TODO - // gs, err := ExportGenesis(ctx, am.keeper) - // if err != nil { - // panic(err) - // } + gs, err := ExportGenesis(ctx, am.keeper) + if err != nil { + panic(err) + } - // return cdc.MustMarshalJSON(gs) - return nil + return cdc.MustMarshalJSON(gs) } // BeginBlock returns the begin blocker for the feegrant module. diff --git a/x/feegrant/types/events.go b/x/feegrant/types/events.go index 28caa2e6c9f8..b82ccb7b1cd8 100644 --- a/x/feegrant/types/events.go +++ b/x/feegrant/types/events.go @@ -8,4 +8,6 @@ const ( AttributeKeyGranter = "granter" AttributeKeyGrantee = "grantee" + + AttributeValueCategory = ModuleName ) diff --git a/x/feegrant/types/genesis.go b/x/feegrant/types/genesis.go new file mode 100644 index 000000000000..57ade9b43de2 --- /dev/null +++ b/x/feegrant/types/genesis.go @@ -0,0 +1,40 @@ +package types + +import "github.com/cosmos/cosmos-sdk/codec/types" + +var _ types.UnpackInterfacesMessage = GenesisState{} + +// NewGenesisState creates new GenesisState object +func NewGenesisState(entries []FeeAllowanceGrant) *GenesisState { + return &GenesisState{ + FeeAllowances: entries, + } +} + +// ValidateGenesis ensures all grants in the genesis state are valid +func ValidateGenesis(data GenesisState) error { + for _, f := range data.FeeAllowances { + err := f.GetFeeGrant().ValidateBasic() + if err != nil { + return err + } + } + return nil +} + +// DefaultGenesisState returns default state for feegrant module. +func DefaultGenesisState() *GenesisState { + return &GenesisState{} +} + +// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces +func (data GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { + for _, f := range data.FeeAllowances { + err := f.UnpackInterfaces(unpacker) + if err != nil { + return err + } + } + + return nil +} diff --git a/x/feegrant/types/genesis.pb.go b/x/feegrant/types/genesis.pb.go new file mode 100644 index 000000000000..4fee817ccb56 --- /dev/null +++ b/x/feegrant/types/genesis.pb.go @@ -0,0 +1,336 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/feegrant/v1beta1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the feegrant module's genesis state. +type GenesisState struct { + FeeAllowances []FeeAllowanceGrant `protobuf:"bytes,1,rep,name=fee_allowances,json=feeAllowances,proto3" json:"fee_allowances"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_ac719d2d0954d1bf, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetFeeAllowances() []FeeAllowanceGrant { + if m != nil { + return m.FeeAllowances + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "cosmos.feegrant.v1beta1.GenesisState") +} + +func init() { + proto.RegisterFile("cosmos/feegrant/v1beta1/genesis.proto", fileDescriptor_ac719d2d0954d1bf) +} + +var fileDescriptor_ac719d2d0954d1bf = []byte{ + // 221 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4d, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0x4d, 0x2f, 0x4a, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, + 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, + 0xc9, 0x17, 0x12, 0x87, 0x28, 0xd3, 0x83, 0x29, 0xd3, 0x83, 0x2a, 0x93, 0x12, 0x49, 0xcf, 0x4f, + 0xcf, 0x07, 0xab, 0xd1, 0x07, 0xb1, 0x20, 0xca, 0xa5, 0xd4, 0x70, 0x99, 0x0a, 0xd7, 0x0f, 0x56, + 0xa7, 0x94, 0xce, 0xc5, 0xe3, 0x0e, 0xb1, 0x27, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0x28, 0x9c, 0x8b, + 0x2f, 0x2d, 0x35, 0x35, 0x3e, 0x31, 0x27, 0x27, 0xbf, 0x3c, 0x31, 0x2f, 0x39, 0xb5, 0x58, 0x82, + 0x51, 0x81, 0x59, 0x83, 0xdb, 0x48, 0x4b, 0x0f, 0x87, 0xfd, 0x7a, 0x6e, 0xa9, 0xa9, 0x8e, 0x30, + 0xd5, 0xee, 0x20, 0x19, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0x78, 0xd3, 0x90, 0x24, 0x8a, + 0x9d, 0xdc, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, + 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x37, 0x3d, 0xb3, + 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xea, 0x6a, 0x08, 0xa5, 0x5b, 0x9c, 0x92, + 0xad, 0x5f, 0x81, 0xf0, 0x42, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0xe1, 0xc6, 0x80, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xaf, 0x53, 0x6e, 0xc5, 0x38, 0x01, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.FeeAllowances) > 0 { + for iNdEx := len(m.FeeAllowances) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.FeeAllowances[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.FeeAllowances) > 0 { + for _, e := range m.FeeAllowances { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeAllowances", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FeeAllowances = append(m.FeeAllowances, FeeAllowanceGrant{}) + if err := m.FeeAllowances[len(m.FeeAllowances)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/feegrant/types/grant.go b/x/feegrant/types/grant.go index f28671e90694..a943c6ab24f1 100644 --- a/x/feegrant/types/grant.go +++ b/x/feegrant/types/grant.go @@ -1,17 +1,38 @@ package types import ( + fmt "fmt" "time" "github.com/cosmos/cosmos-sdk/codec/types" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + proto "github.com/gogo/protobuf/proto" ) var ( _ types.UnpackInterfacesMessage = &FeeAllowanceGrant{} ) +// NewFeeAllowanceGrant creates a new FeeAllowanceGrant. +func NewFeeAllowanceGrant(granter, grantee sdk.AccAddress, feeAllowance FeeAllowanceI) (*FeeAllowanceGrant, error) { + msg, ok := feeAllowance.(proto.Message) + if !ok { + return nil, fmt.Errorf("cannot proto marshal %T", msg) + } + any, err := types.NewAnyWithValue(msg) + if err != nil { + return nil, err + } + + return &FeeAllowanceGrant{ + Granter: granter, + Grantee: grantee, + Allowance: any, + }, nil +} + // ValidateBasic performs basic validation on // FeeAllowanceGrant func (a FeeAllowanceGrant) ValidateBasic() error { diff --git a/x/feegrant/types/msgs.go b/x/feegrant/types/msgs.go index 38f76f773efe..6e544dd26205 100644 --- a/x/feegrant/types/msgs.go +++ b/x/feegrant/types/msgs.go @@ -23,12 +23,12 @@ const ( // NewMsgGrantFeeAllowance creates a new MsgGrantFeeAllowance. //nolint:interfacer -func (msg MsgGrantFeeAllowance) NewMsgGrantFeeAllowance(feeAllowance FeeAllowanceI, granter, grantee sdk.AccAddress) (*MsgGrantFeeAllowance, error) { - msg1, ok := feeAllowance.(proto.Message) +func NewMsgGrantFeeAllowance(feeAllowance FeeAllowanceI, granter, grantee sdk.AccAddress) (*MsgGrantFeeAllowance, error) { + msg, ok := feeAllowance.(proto.Message) if !ok { - return nil, fmt.Errorf("cannot proto marshal %T", msg1) + return nil, fmt.Errorf("cannot proto marshal %T", msg) } - any, err := types.NewAnyWithValue(msg1) + any, err := types.NewAnyWithValue(msg) if err != nil { return nil, err } diff --git a/x/feegrant/types/tx.pb.go b/x/feegrant/types/tx.pb.go index bed0fc097cf1..5c9e2cfee7b0 100644 --- a/x/feegrant/types/tx.pb.go +++ b/x/feegrant/types/tx.pb.go @@ -4,12 +4,17 @@ package types import ( + context "context" fmt "fmt" types "github.com/cosmos/cosmos-sdk/codec/types" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" _ "github.com/regen-network/cosmos-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" @@ -67,6 +72,43 @@ func (m *MsgGrantFeeAllowance) XXX_DiscardUnknown() { var xxx_messageInfo_MsgGrantFeeAllowance proto.InternalMessageInfo +// MsgGrantFeeAllowanceResponse defines the Msg/GrantFeeAllowanceResponse response type. +type MsgGrantFeeAllowanceResponse struct { +} + +func (m *MsgGrantFeeAllowanceResponse) Reset() { *m = MsgGrantFeeAllowanceResponse{} } +func (m *MsgGrantFeeAllowanceResponse) String() string { return proto.CompactTextString(m) } +func (*MsgGrantFeeAllowanceResponse) ProtoMessage() {} +func (*MsgGrantFeeAllowanceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_dd44ad7946dad783, []int{1} +} +func (m *MsgGrantFeeAllowanceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgGrantFeeAllowanceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgGrantFeeAllowanceResponse.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 *MsgGrantFeeAllowanceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgGrantFeeAllowanceResponse.Merge(m, src) +} +func (m *MsgGrantFeeAllowanceResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgGrantFeeAllowanceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgGrantFeeAllowanceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgGrantFeeAllowanceResponse proto.InternalMessageInfo + // MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee. type MsgRevokeFeeAllowance struct { Granter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=granter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"granter,omitempty"` @@ -77,7 +119,7 @@ func (m *MsgRevokeFeeAllowance) Reset() { *m = MsgRevokeFeeAllowance{} } func (m *MsgRevokeFeeAllowance) String() string { return proto.CompactTextString(m) } func (*MsgRevokeFeeAllowance) ProtoMessage() {} func (*MsgRevokeFeeAllowance) Descriptor() ([]byte, []int) { - return fileDescriptor_dd44ad7946dad783, []int{1} + return fileDescriptor_dd44ad7946dad783, []int{2} } func (m *MsgRevokeFeeAllowance) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -120,15 +162,54 @@ func (m *MsgRevokeFeeAllowance) GetGrantee() github_com_cosmos_cosmos_sdk_types. return nil } +// MsgRevokeFeeAllowanceResponse defines the Msg/RevokeFeeAllowanceResponse response type. +type MsgRevokeFeeAllowanceResponse struct { +} + +func (m *MsgRevokeFeeAllowanceResponse) Reset() { *m = MsgRevokeFeeAllowanceResponse{} } +func (m *MsgRevokeFeeAllowanceResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRevokeFeeAllowanceResponse) ProtoMessage() {} +func (*MsgRevokeFeeAllowanceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_dd44ad7946dad783, []int{3} +} +func (m *MsgRevokeFeeAllowanceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRevokeFeeAllowanceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRevokeFeeAllowanceResponse.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 *MsgRevokeFeeAllowanceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRevokeFeeAllowanceResponse.Merge(m, src) +} +func (m *MsgRevokeFeeAllowanceResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRevokeFeeAllowanceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRevokeFeeAllowanceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRevokeFeeAllowanceResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgGrantFeeAllowance)(nil), "cosmos.feegrant.v1beta1.MsgGrantFeeAllowance") + proto.RegisterType((*MsgGrantFeeAllowanceResponse)(nil), "cosmos.feegrant.v1beta1.MsgGrantFeeAllowanceResponse") proto.RegisterType((*MsgRevokeFeeAllowance)(nil), "cosmos.feegrant.v1beta1.MsgRevokeFeeAllowance") + proto.RegisterType((*MsgRevokeFeeAllowanceResponse)(nil), "cosmos.feegrant.v1beta1.MsgRevokeFeeAllowanceResponse") } func init() { proto.RegisterFile("cosmos/feegrant/v1beta1/tx.proto", fileDescriptor_dd44ad7946dad783) } var fileDescriptor_dd44ad7946dad783 = []byte{ - // 303 bytes of a gzipped FileDescriptorProto + // 375 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0x4d, 0x2f, 0x4a, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x87, 0xa8, @@ -143,11 +224,140 @@ var fileDescriptor_dd44ad7946dad783 = []byte{ 0x26, 0x20, 0x0c, 0x4b, 0x95, 0x60, 0xa2, 0xd0, 0xb0, 0x54, 0x21, 0x57, 0x2e, 0xce, 0x44, 0x98, 0x33, 0x25, 0x98, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0x44, 0xf4, 0x20, 0x9e, 0xd7, 0x83, 0x79, 0x5e, 0xcf, 0x31, 0xaf, 0xd2, 0x49, 0xf0, 0xd4, 0x16, 0x5d, 0x5e, 0x64, 0x4f, 0x79, 0x06, 0x21, 0x74, - 0x5a, 0xb1, 0x74, 0x2c, 0x90, 0x67, 0x50, 0xda, 0xc8, 0xc8, 0x25, 0xea, 0x5b, 0x9c, 0x1e, 0x94, - 0x5a, 0x96, 0x9f, 0x9d, 0x3a, 0x34, 0x02, 0xc0, 0xc9, 0xfd, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, - 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, - 0x8f, 0xe5, 0x18, 0xa2, 0xf0, 0x9b, 0x58, 0x81, 0x48, 0x6c, 0x60, 0xc3, 0x93, 0xd8, 0xc0, 0xc1, - 0x65, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xd4, 0x42, 0x3b, 0x0e, 0x8c, 0x02, 0x00, 0x00, + 0x5a, 0xb1, 0x74, 0x2c, 0x90, 0x67, 0x50, 0x92, 0xe3, 0x92, 0xc1, 0xe6, 0xfd, 0xa0, 0xd4, 0xe2, + 0x82, 0xfc, 0xbc, 0xe2, 0x54, 0xa5, 0x8d, 0x8c, 0x5c, 0xa2, 0xbe, 0xc5, 0xe9, 0x41, 0xa9, 0x65, + 0xf9, 0xd9, 0xa9, 0x43, 0x23, 0x80, 0x94, 0xe4, 0xb9, 0x64, 0xb1, 0x3a, 0x19, 0xe6, 0x29, 0xa3, + 0x7f, 0x8c, 0x5c, 0xcc, 0xbe, 0xc5, 0xe9, 0x42, 0x95, 0x5c, 0x82, 0x98, 0x11, 0xaf, 0xab, 0x87, + 0x23, 0xdd, 0xe9, 0x61, 0x0b, 0x28, 0x29, 0x53, 0x92, 0x94, 0xc3, 0x9c, 0x20, 0x54, 0xc3, 0x25, + 0x84, 0x25, 0x4c, 0xf5, 0xf0, 0x19, 0x86, 0xa9, 0x5e, 0xca, 0x8c, 0x34, 0xf5, 0x30, 0xdb, 0x9d, + 0xdc, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, + 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x0a, 0x7f, 0x98, 0x57, 0x20, + 0xb2, 0x2b, 0x38, 0xf8, 0x93, 0xd8, 0xc0, 0x09, 0xce, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x04, + 0x77, 0xff, 0x0b, 0xce, 0x03, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // GrantFeeAllowance grants fee allowance to the grantee on the granter's + // account with the provided expiration time. + GrantFeeAllowance(ctx context.Context, in *MsgGrantFeeAllowance, opts ...grpc.CallOption) (*MsgGrantFeeAllowanceResponse, error) + // RevokeFeeAllowance revokes any fee allowance of granter's account that + // has been granted to the grantee. + RevokeFeeAllowance(ctx context.Context, in *MsgRevokeFeeAllowance, opts ...grpc.CallOption) (*MsgRevokeFeeAllowanceResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) GrantFeeAllowance(ctx context.Context, in *MsgGrantFeeAllowance, opts ...grpc.CallOption) (*MsgGrantFeeAllowanceResponse, error) { + out := new(MsgGrantFeeAllowanceResponse) + err := c.cc.Invoke(ctx, "/cosmos.feegrant.v1beta1.Msg/GrantFeeAllowance", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) RevokeFeeAllowance(ctx context.Context, in *MsgRevokeFeeAllowance, opts ...grpc.CallOption) (*MsgRevokeFeeAllowanceResponse, error) { + out := new(MsgRevokeFeeAllowanceResponse) + err := c.cc.Invoke(ctx, "/cosmos.feegrant.v1beta1.Msg/RevokeFeeAllowance", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // GrantFeeAllowance grants fee allowance to the grantee on the granter's + // account with the provided expiration time. + GrantFeeAllowance(context.Context, *MsgGrantFeeAllowance) (*MsgGrantFeeAllowanceResponse, error) + // RevokeFeeAllowance revokes any fee allowance of granter's account that + // has been granted to the grantee. + RevokeFeeAllowance(context.Context, *MsgRevokeFeeAllowance) (*MsgRevokeFeeAllowanceResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) GrantFeeAllowance(ctx context.Context, req *MsgGrantFeeAllowance) (*MsgGrantFeeAllowanceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GrantFeeAllowance not implemented") +} +func (*UnimplementedMsgServer) RevokeFeeAllowance(ctx context.Context, req *MsgRevokeFeeAllowance) (*MsgRevokeFeeAllowanceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RevokeFeeAllowance not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_GrantFeeAllowance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgGrantFeeAllowance) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).GrantFeeAllowance(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.feegrant.v1beta1.Msg/GrantFeeAllowance", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).GrantFeeAllowance(ctx, req.(*MsgGrantFeeAllowance)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_RevokeFeeAllowance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRevokeFeeAllowance) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RevokeFeeAllowance(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.feegrant.v1beta1.Msg/RevokeFeeAllowance", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RevokeFeeAllowance(ctx, req.(*MsgRevokeFeeAllowance)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "cosmos.feegrant.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GrantFeeAllowance", + Handler: _Msg_GrantFeeAllowance_Handler, + }, + { + MethodName: "RevokeFeeAllowance", + Handler: _Msg_RevokeFeeAllowance_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cosmos/feegrant/v1beta1/tx.proto", } func (m *MsgGrantFeeAllowance) Marshal() (dAtA []byte, err error) { @@ -199,6 +409,29 @@ func (m *MsgGrantFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgGrantFeeAllowanceResponse) 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 *MsgGrantFeeAllowanceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgGrantFeeAllowanceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgRevokeFeeAllowance) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -236,6 +469,29 @@ func (m *MsgRevokeFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgRevokeFeeAllowanceResponse) 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 *MsgRevokeFeeAllowanceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRevokeFeeAllowanceResponse) 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 @@ -268,6 +524,15 @@ func (m *MsgGrantFeeAllowance) Size() (n int) { return n } +func (m *MsgGrantFeeAllowanceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgRevokeFeeAllowance) Size() (n int) { if m == nil { return 0 @@ -285,6 +550,15 @@ func (m *MsgRevokeFeeAllowance) Size() (n int) { return n } +func (m *MsgRevokeFeeAllowanceResponse) 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 } @@ -448,6 +722,59 @@ func (m *MsgGrantFeeAllowance) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgGrantFeeAllowanceResponse) 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: MsgGrantFeeAllowanceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgGrantFeeAllowanceResponse: 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 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgRevokeFeeAllowance) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -569,6 +896,59 @@ func (m *MsgRevokeFeeAllowance) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgRevokeFeeAllowanceResponse) 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: MsgRevokeFeeAllowanceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRevokeFeeAllowanceResponse: 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 { + return ErrInvalidLengthTx + } + if (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 From 7ed4d953b440698406b069524d6359cfb8ab6922 Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 1 Dec 2020 22:22:04 +0530 Subject: [PATCH 084/184] fix keeper tests --- proto/cosmos/feegrant/v1beta1/query.proto | 28 + x/feegrant/genesis.go | 2 +- x/feegrant/keeper/grpc_query.go | 63 +++ x/feegrant/keeper/keeper.go | 7 +- x/feegrant/keeper/keeper_test.go | 191 ++----- x/feegrant/keeper/msg_server.go | 8 +- x/feegrant/keeper/querier_test.go | 142 ++--- x/feegrant/module.go | 13 +- x/feegrant/types/codec.go | 29 +- x/feegrant/types/genesis.pb.go | 2 +- x/feegrant/types/grant.go | 10 +- x/feegrant/types/query.pb.go | 637 ++++++++++++++++++++++ 12 files changed, 901 insertions(+), 231 deletions(-) create mode 100644 proto/cosmos/feegrant/v1beta1/query.proto create mode 100644 x/feegrant/keeper/grpc_query.go create mode 100644 x/feegrant/types/query.pb.go diff --git a/proto/cosmos/feegrant/v1beta1/query.proto b/proto/cosmos/feegrant/v1beta1/query.proto new file mode 100644 index 000000000000..f67980e5a9a7 --- /dev/null +++ b/proto/cosmos/feegrant/v1beta1/query.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; +package cosmos.feegrant.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/feegrant/v1beta1/feegrant.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; + +// Query defines the gRPC querier service. +service Query { + // FeeAllowance returns fee granted to the grantee by the granter. + rpc FeeAllowance(QueryFeeAllowanceRequest) returns (QueryFeeAllowanceResponse) {} +} + +// QueryFeeAllowanceRequest is the request type for the Query/FeeAllowance RPC method. +message QueryFeeAllowanceRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string granter = 1; + string grantee = 2; +} + +// QueryFeeAllowanceResponse is the response type for the Query/FeeAllowance RPC method. +message QueryFeeAllowanceResponse { + // fee_allowance is a fee_allowance granted for grantee by granter. + cosmos.feegrant.v1beta1.FeeAllowanceGrant fee_allowance = 1; +} diff --git a/x/feegrant/genesis.go b/x/feegrant/genesis.go index 47244cea0baa..df74fedc1c19 100644 --- a/x/feegrant/genesis.go +++ b/x/feegrant/genesis.go @@ -22,7 +22,7 @@ func (g GenesisState) ValidateBasic() error { // InitGenesis will initialize the keeper from a *previously validated* GenesisState func InitGenesis(ctx sdk.Context, k Keeper, data *types.GenesisState) { for _, f := range data.FeeAllowances { - k.GrantFeeAllowance(ctx, f) + k.GrantFeeAllowance(ctx, f.Granter, f.Grantee, f.GetFeeGrant()) } } diff --git a/x/feegrant/keeper/grpc_query.go b/x/feegrant/keeper/grpc_query.go new file mode 100644 index 000000000000..d89c5b4d927a --- /dev/null +++ b/x/feegrant/keeper/grpc_query.go @@ -0,0 +1,63 @@ +package keeper + +import ( + "context" + + "github.com/gogo/protobuf/proto" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" +) + +var _ types.QueryServer = Keeper{} + +// FeeAllowance returns fee granted to the grantee by the granter. +func (q Keeper) FeeAllowance(c context.Context, req *types.QueryFeeAllowanceRequest) (*types.QueryFeeAllowanceResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + if req.Granter == "" { + return nil, status.Errorf(codes.InvalidArgument, "invalid granter addr") + } + + if req.Grantee == "" { + return nil, status.Errorf(codes.InvalidArgument, "invalid grantee addr") + } + + granterAddr, err := sdk.AccAddressFromBech32(req.Granter) + if err != nil { + return nil, err + } + + granteeAddr, err := sdk.AccAddressFromBech32(req.Grantee) + if err != nil { + return nil, err + } + + ctx := sdk.UnwrapSDKContext(c) + + feeAllowance := q.GetFeeAllowance(ctx, granterAddr, granteeAddr) + if feeAllowance == nil { + return nil, status.Errorf(codes.NotFound, "no fee allowance found") + } + + msg, ok := feeAllowance.(proto.Message) + if !ok { + return nil, status.Errorf(codes.Internal, "can't proto marshal %T", msg) + } + + feeAllowanceAny, err := codectypes.NewAnyWithValue(msg) + if err != nil { + return nil, status.Errorf(codes.Internal, err.Error()) + } + + return &types.QueryFeeAllowanceResponse{ + FeeAllowance: &types.FeeAllowanceGrant{ + Allowance: feeAllowanceAny, + }, + }, nil +} diff --git a/x/feegrant/keeper/keeper.go b/x/feegrant/keeper/keeper.go index e618161d90ae..4cf0b024ae4e 100644 --- a/x/feegrant/keeper/keeper.go +++ b/x/feegrant/keeper/keeper.go @@ -29,9 +29,10 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { } // GrantFeeAllowance creates a new grant -func (k Keeper) GrantFeeAllowance(ctx sdk.Context, grant types.FeeAllowanceGrant) { +func (k Keeper) GrantFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddress, feeAllowance types.FeeAllowanceI) { store := ctx.KVStore(k.storeKey) - key := types.FeeAllowanceKey(grant.Granter, grant.Grantee) + key := types.FeeAllowanceKey(granter, grantee) + grant := types.NewFeeAllowanceGrant(granter, grantee, feeAllowance) bz := k.cdc.MustMarshalBinaryBare(&grant) store.Set(key, bz) @@ -157,6 +158,6 @@ func (k Keeper) UseGrantedFees(ctx sdk.Context, granter, grantee sdk.AccAddress, } // if we accepted, store the updated state of the allowance - k.GrantFeeAllowance(ctx, grant) + k.GrantFeeAllowance(ctx, granter, grantee, grant.GetFeeGrant()) return nil } diff --git a/x/feegrant/keeper/keeper_test.go b/x/feegrant/keeper/keeper_test.go index e579922999b6..0f7fdfeedd91 100644 --- a/x/feegrant/keeper/keeper_test.go +++ b/x/feegrant/keeper/keeper_test.go @@ -2,32 +2,21 @@ package keeper_test import ( "testing" - "time" "github.com/stretchr/testify/suite" - abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/libs/log" - dbm "github.com/tendermint/tm-db" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - codec "github.com/cosmos/cosmos-sdk/codec" - codecstd "github.com/cosmos/cosmos-sdk/codec/std" - "github.com/cosmos/cosmos-sdk/store" + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) type KeeperTestSuite struct { suite.Suite - cdc *codec.Codec - ctx sdk.Context - dk keeper.Keeper - - addr sdk.AccAddress - addr2 sdk.AccAddress - addr3 sdk.AccAddress - addr4 sdk.AccAddress + app *simapp.SimApp + ctx sdk.Context + addrs []sdk.AccAddress } func TestKeeperTestSuite(t *testing.T) { @@ -35,97 +24,44 @@ func TestKeeperTestSuite(t *testing.T) { } func (suite *KeeperTestSuite) SetupTest() { - db := dbm.NewMemDB() - - cdc := codec.New() - types.RegisterCodec(cdc) - sdk.RegisterCodec(cdc) - suite.cdc = cdc - appCodec := codecstd.NewAppCodec(cdc) - delCapKey := sdk.NewKVStoreKey("delKey") - - ms := store.NewCommitMultiStore(db) - ms.MountStoreWithDB(delCapKey, sdk.StoreTypeIAVL, db) - ms.LoadLatestVersion() - - suite.dk = keeper.NewKeeper(appCodec, delCapKey) - suite.ctx = sdk.NewContext(ms, abci.Header{ChainID: "test-chain-id", Time: time.Now().UTC(), Height: 1234}, false, log.NewNopLogger()) - - suite.addr = mustAddr("cosmos157ez5zlaq0scm9aycwphhqhmg3kws4qusmekll") - suite.addr2 = mustAddr("cosmos1rjxwm0rwyuldsg00qf5lt26wxzzppjzxs2efdw") - suite.addr3 = mustAddr("cosmos1qk93t4j0yyzgqgt6k5qf8deh8fq6smpn3ntu3x") - suite.addr4 = mustAddr("cosmos1p9qh4ldfd6n0qehujsal4k7g0e37kel90rc4ts") - -} + app := simapp.Setup(false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) -func mustAddr(acc string) sdk.AccAddress { - addr, err := sdk.AccAddressFromBech32(acc) - if err != nil { - panic(err) - } - return addr + suite.app = app + suite.ctx = ctx + suite.addrs = simapp.AddTestAddrsIncremental(app, ctx, 4, sdk.NewInt(30000000)) } func (suite *KeeperTestSuite) TestKeeperCrud() { ctx := suite.ctx - k := suite.dk + k := suite.app.FeeGrantKeeper // some helpers atom := sdk.NewCoins(sdk.NewInt64Coin("atom", 555)) eth := sdk.NewCoins(sdk.NewInt64Coin("eth", 123)) - basic := &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ + basic := &types.BasicFeeAllowance{ SpendLimit: atom, Expiration: types.ExpiresAtHeight(334455), - }, - }, } - basic2 := &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ + + basic2 := &types.BasicFeeAllowance{ SpendLimit: eth, Expiration: types.ExpiresAtHeight(172436), - }, - }, } // let's set up some initial state here - k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: suite.addr, - Grantee: suite.addr2, - Allowance: basic, - }) - k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: suite.addr, - Grantee: suite.addr3, - Allowance: basic2, - }) - k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: suite.addr2, - Grantee: suite.addr3, - Allowance: basic, - }) - k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: suite.addr2, - Grantee: suite.addr4, - Allowance: basic, - }) - k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: suite.addr4, - Grantee: suite.addr, - Allowance: basic2, - }) + k.GrantFeeAllowance(ctx, suite.addrs[0], suite.addrs[1], basic) + k.GrantFeeAllowance(ctx, suite.addrs[0], suite.addrs[2], basic2) + k.GrantFeeAllowance(ctx, suite.addrs[1], suite.addrs[2], basic) + k.GrantFeeAllowance(ctx, suite.addrs[1], suite.addrs[3], basic) + k.GrantFeeAllowance(ctx, suite.addrs[3], suite.addrs[0], basic2) // remove some, overwrite other - k.RevokeFeeAllowance(ctx, suite.addr, suite.addr2) - k.RevokeFeeAllowance(ctx, suite.addr, suite.addr3) - k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: suite.addr, - Grantee: suite.addr3, - Allowance: basic, - }) - k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: suite.addr2, - Grantee: suite.addr3, - Allowance: basic2, - }) + k.RevokeFeeAllowance(ctx, suite.addrs[0], suite.addrs[1]) + k.RevokeFeeAllowance(ctx, suite.addrs[0], suite.addrs[2]) + + k.GrantFeeAllowance(ctx, suite.addrs[0], suite.addrs[2], basic) + k.GrantFeeAllowance(ctx, suite.addrs[1], suite.addrs[2], basic2) // end state: // addr -> addr3 (basic) @@ -136,24 +72,24 @@ func (suite *KeeperTestSuite) TestKeeperCrud() { cases := map[string]struct { grantee sdk.AccAddress granter sdk.AccAddress - allowance *types.FeeAllowance + allowance types.FeeAllowanceI }{ "addr revoked": { - granter: suite.addr, - grantee: suite.addr2, + granter: suite.addrs[0], + grantee: suite.addrs[1], }, "addr revoked and added": { - granter: suite.addr, - grantee: suite.addr3, + granter: suite.addrs[0], + grantee: suite.addrs[2], allowance: basic, }, "addr never there": { - granter: suite.addr, - grantee: suite.addr4, + granter: suite.addrs[0], + grantee: suite.addrs[3], }, "addr modified": { - granter: suite.addr2, - grantee: suite.addr3, + granter: suite.addrs[1], + grantee: suite.addrs[2], allowance: basic2, }, } @@ -176,17 +112,20 @@ func (suite *KeeperTestSuite) TestKeeperCrud() { grants []types.FeeAllowanceGrant }{ "addr2 has none": { - grantee: suite.addr2, + grantee: suite.addrs[1], }, "addr has one": { - grantee: suite.addr, - grants: []types.FeeAllowanceGrant{{Granter: suite.addr4, Grantee: suite.addr, Allowance: basic2}}, + grantee: suite.addrs[0], + // grants: []types.FeeAllowanceGrant{{Granter: suite.addrs[3], Grantee: suite.addrs[0], Allowance: basic2}}, + grants: []types.FeeAllowanceGrant{ + types.NewFeeAllowanceGrant(suite.addrs[3], suite.addrs[0], basic2), + }, }, "addr3 has two": { - grantee: suite.addr3, + grantee: suite.addrs[2], grants: []types.FeeAllowanceGrant{ - {Granter: suite.addr, Grantee: suite.addr3, Allowance: basic}, - {Granter: suite.addr2, Grantee: suite.addr3, Allowance: basic2}, + types.NewFeeAllowanceGrant(suite.addrs[1], suite.addrs[2], basic2), + types.NewFeeAllowanceGrant(suite.addrs[0], suite.addrs[2], basic), }, }, } @@ -207,33 +146,29 @@ func (suite *KeeperTestSuite) TestKeeperCrud() { func (suite *KeeperTestSuite) TestUseGrantedFee() { ctx := suite.ctx - k := suite.dk + k := suite.app.FeeGrantKeeper // some helpers atom := sdk.NewCoins(sdk.NewInt64Coin("atom", 555)) eth := sdk.NewCoins(sdk.NewInt64Coin("eth", 123)) - future := &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ + future := &types.BasicFeeAllowance{ SpendLimit: atom, Expiration: types.ExpiresAtHeight(5678), - }, - }, } - expired := &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ + expired := &types.BasicFeeAllowance{ SpendLimit: eth, Expiration: types.ExpiresAtHeight(55), - }, - }, } // for testing limits of the contract hugeAtom := sdk.NewCoins(sdk.NewInt64Coin("atom", 9999)) + _ = hugeAtom smallAtom := sdk.NewCoins(sdk.NewInt64Coin("atom", 1)) - futureAfterSmall := &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ + _ = smallAtom + futureAfterSmall := &types.BasicFeeAllowance{ SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 554)), Expiration: types.ExpiresAtHeight(5678), - }, - }, } // then lots of queries @@ -242,32 +177,32 @@ func (suite *KeeperTestSuite) TestUseGrantedFee() { granter sdk.AccAddress fee sdk.Coins allowed bool - final *types.FeeAllowance + final types.FeeAllowanceI }{ "use entire pot": { - granter: suite.addr, - grantee: suite.addr2, + granter: suite.addrs[0], + grantee: suite.addrs[1], fee: atom, allowed: true, final: nil, }, "expired and removed": { - granter: suite.addr, - grantee: suite.addr3, + granter: suite.addrs[0], + grantee: suite.addrs[2], fee: eth, allowed: false, final: nil, }, "too high": { - granter: suite.addr, - grantee: suite.addr2, + granter: suite.addrs[0], + grantee: suite.addrs[1], fee: hugeAtom, allowed: false, final: future, }, "use a little": { - granter: suite.addr, - grantee: suite.addr2, + granter: suite.addrs[0], + grantee: suite.addrs[1], fee: smallAtom, allowed: true, final: futureAfterSmall, @@ -281,16 +216,8 @@ func (suite *KeeperTestSuite) TestUseGrantedFee() { // addr -> addr2 (future) // addr -> addr3 (expired) - k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: suite.addr, - Grantee: suite.addr2, - Allowance: future, - }) - k.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: suite.addr, - Grantee: suite.addr3, - Allowance: expired, - }) + k.GrantFeeAllowance(ctx, suite.addrs[0], suite.addrs[1], future) + k.GrantFeeAllowance(ctx, suite.addrs[0], suite.addrs[3], expired) err := k.UseGrantedFees(ctx, tc.granter, tc.grantee, tc.fee) if tc.allowed { diff --git a/x/feegrant/keeper/msg_server.go b/x/feegrant/keeper/msg_server.go index 2552cd64f06a..cd4d3d92c2b0 100644 --- a/x/feegrant/keeper/msg_server.go +++ b/x/feegrant/keeper/msg_server.go @@ -35,13 +35,7 @@ func (k msgServer) GrantFeeAllowance(goCtx context.Context, msg *types.MsgGrantF return nil, err } - feegrant := types.FeeAllowanceGrant{ - Grantee: grantee, - Granter: granter, - Allowance: msg.Allowance, - } - - k.Keeper.GrantFeeAllowance(ctx, feegrant) + k.Keeper.GrantFeeAllowance(ctx, granter, grantee, msg.GetFeeAllowanceI()) return &types.MsgGrantFeeAllowanceResponse{}, nil } diff --git a/x/feegrant/keeper/querier_test.go b/x/feegrant/keeper/querier_test.go index 3efd772b33f7..0ad795f69190 100644 --- a/x/feegrant/keeper/querier_test.go +++ b/x/feegrant/keeper/querier_test.go @@ -1,82 +1,82 @@ package keeper_test -import ( - abci "github.com/tendermint/tendermint/abci/types" +// import ( +// abci "github.com/tendermint/tendermint/abci/types" - codec "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" -) +// codec "github.com/cosmos/cosmos-sdk/codec" +// sdk "github.com/cosmos/cosmos-sdk/types" +// "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" +// "github.com/cosmos/cosmos-sdk/x/feegrant/types" +// ) -func (suite *KeeperTestSuite) TestQuery() { - ctx := suite.ctx - k := suite.dk +// func (suite *KeeperTestSuite) TestQuery() { +// ctx := suite.ctx +// k := suite.dk - cdc := codec.New() - types.RegisterCodec(cdc) +// cdc := codec.New() +// types.RegisterCodec(cdc) - // some helpers - grant1 := types.FeeAllowanceGrant{ - Granter: suite.addr, - Grantee: suite.addr3, - Allowance: &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ - SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 555)), - Expiration: types.ExpiresAtHeight(334455), - }, - }, - }, - } - grant2 := types.FeeAllowanceGrant{ - Granter: suite.addr2, - Grantee: suite.addr3, - Allowance: &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ - SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("eth", 123)), - Expiration: types.ExpiresAtHeight(334455)}}}, - } - // let's set up some initial state here - k.GrantFeeAllowance(ctx, grant1) - k.GrantFeeAllowance(ctx, grant2) +// // some helpers +// grant1 := types.FeeAllowanceGrant{ +// Granter: suite.addr, +// Grantee: suite.addr3, +// Allowance: &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ +// SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 555)), +// Expiration: types.ExpiresAtHeight(334455), +// }, +// }, +// }, +// } +// grant2 := types.FeeAllowanceGrant{ +// Granter: suite.addr2, +// Grantee: suite.addr3, +// Allowance: &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ +// SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("eth", 123)), +// Expiration: types.ExpiresAtHeight(334455)}}}, +// } +// // let's set up some initial state here +// k.GrantFeeAllowance(ctx, grant1) +// k.GrantFeeAllowance(ctx, grant2) - // now try some queries - cases := map[string]struct { - path []string - valid bool - res []types.FeeAllowanceGrant - }{ - "bad path": { - path: []string{"foo", "bar"}, - }, - "no data": { - // addr in bech32 - path: []string{"fees", "cosmos157ez5zlaq0scm9aycwphhqhmg3kws4qusmekll"}, - valid: true, - }, - "two grants": { - // addr3 in bech32 - path: []string{"fees", "cosmos1qk93t4j0yyzgqgt6k5qf8deh8fq6smpn3ntu3x"}, - valid: true, - res: []types.FeeAllowanceGrant{grant1, grant2}, - }, - } +// // now try some queries +// cases := map[string]struct { +// path []string +// valid bool +// res []types.FeeAllowanceGrant +// }{ +// "bad path": { +// path: []string{"foo", "bar"}, +// }, +// "no data": { +// // addr in bech32 +// path: []string{"fees", "cosmos157ez5zlaq0scm9aycwphhqhmg3kws4qusmekll"}, +// valid: true, +// }, +// "two grants": { +// // addr3 in bech32 +// path: []string{"fees", "cosmos1qk93t4j0yyzgqgt6k5qf8deh8fq6smpn3ntu3x"}, +// valid: true, +// res: []types.FeeAllowanceGrant{grant1, grant2}, +// }, +// } - querier := keeper.NewQuerier(k) - for name, tc := range cases { - tc := tc - suite.Run(name, func() { - bz, err := querier(ctx, tc.path, abci.RequestQuery{}) - if !tc.valid { - suite.Error(err) - return - } - suite.NoError(err) +// querier := keeper.NewQuerier(k) +// for name, tc := range cases { +// tc := tc +// suite.Run(name, func() { +// bz, err := querier(ctx, tc.path, abci.RequestQuery{}) +// if !tc.valid { +// suite.Error(err) +// return +// } +// suite.NoError(err) - var grants []types.FeeAllowanceGrant - serr := cdc.UnmarshalJSON(bz, &grants) - suite.NoError(serr) +// var grants []types.FeeAllowanceGrant +// serr := cdc.UnmarshalJSON(bz, &grants) +// suite.NoError(serr) - suite.Equal(tc.res, grants) - }) - } +// suite.Equal(tc.res, grants) +// }) +// } -} +// } diff --git a/x/feegrant/module.go b/x/feegrant/module.go index e1b30a3535f0..7a811b9cf5f2 100644 --- a/x/feegrant/module.go +++ b/x/feegrant/module.go @@ -45,14 +45,12 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { // RegisterLegacyAminoCodec registers the feegrant module's types for the given codec. func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - // TODO - // types.RegisterLegacyAminoCodec(cdc) + types.RegisterLegacyAminoCodec(cdc) } // RegisterInterfaces registers the feegrant module's interface types func (AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { - // TODO - // types.RegisterInterfaces(registry) + types.RegisterInterfaces(registry) } // LegacyQuerierHandler returns the feegrant module sdk.Querier. @@ -161,10 +159,11 @@ func (AppModule) QuerierRoute() string { // InitGenesis performs genesis initialization for the feegrant module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, bz json.RawMessage) []abci.ValidatorUpdate { - var gs types.GenesisState - cdc.MustUnmarshalJSON(bz, &gs) + // TODO + // var gs types.GenesisState + // cdc.MustUnmarshalJSON(bz, &gs) - InitGenesis(ctx, am.keeper, &gs) + // InitGenesis(ctx, am.keeper, &gs) return []abci.ValidatorUpdate{} } diff --git a/x/feegrant/types/codec.go b/x/feegrant/types/codec.go index 77ba5a2e15cb..d1df61df0f6b 100644 --- a/x/feegrant/types/codec.go +++ b/x/feegrant/types/codec.go @@ -2,17 +2,38 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" ) -// RegisterLegacyAminoCodec registers the account types and interface +// RegisterLegacyAminoCodec registers concrete types and interfaces on the given codec. func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - // cdc.RegisterInterface((*isFeeAllowance_Sum)(nil), nil) - // cdc.RegisterConcrete(&FeeAllowance_BasicFeeAllowance{}, "cosmos-sdk/ProtoBasicFeeAllowance", nil) cdc.RegisterInterface((*FeeAllowanceI)(nil), nil) + cdc.RegisterInterface((*sdk.MsgRequest)(nil), nil) + cdc.RegisterConcrete(&MsgGrantFeeAllowance{}, "cosmos-sdk/MsgGrantFeeAllowance", nil) + cdc.RegisterConcrete(&MsgRevokeFeeAllowance{}, "cosmos-sdk/MsgRevokeFeeAllowance", nil) cdc.RegisterConcrete(&BasicFeeAllowance{}, "cosmos-sdk/BasicFeeAllowance", nil) cdc.RegisterConcrete(&PeriodicFeeAllowance{}, "cosmos-sdk/PeriodicFeeAllowance", nil) - cdc.RegisterConcrete(FeeGrantTx{}, "cosmos-sdk/FeeGrantTx", nil) + // cdc.RegisterConcrete(FeeGrantTx{}, "cosmos-sdk/FeeGrantTx", nil) +} + +// RegisterInterfaces registers the interfaces types with the interface registry +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgGrantFeeAllowance{}, + &MsgRevokeFeeAllowance{}, + ) + + registry.RegisterInterface( + "cosmos.authz.v1beta1.FeeAllowance", + (*FeeAllowanceI)(nil), + &BasicFeeAllowance{}, + &PeriodicFeeAllowance{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } var ( diff --git a/x/feegrant/types/genesis.pb.go b/x/feegrant/types/genesis.pb.go index 4fee817ccb56..6af384084557 100644 --- a/x/feegrant/types/genesis.pb.go +++ b/x/feegrant/types/genesis.pb.go @@ -23,7 +23,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// GenesisState defines the feegrant module's genesis state. +// GenesisState contains a set of fee allowances, persisted from the store type GenesisState struct { FeeAllowances []FeeAllowanceGrant `protobuf:"bytes,1,rep,name=fee_allowances,json=feeAllowances,proto3" json:"fee_allowances"` } diff --git a/x/feegrant/types/grant.go b/x/feegrant/types/grant.go index a943c6ab24f1..2c472b2fb898 100644 --- a/x/feegrant/types/grant.go +++ b/x/feegrant/types/grant.go @@ -16,21 +16,21 @@ var ( ) // NewFeeAllowanceGrant creates a new FeeAllowanceGrant. -func NewFeeAllowanceGrant(granter, grantee sdk.AccAddress, feeAllowance FeeAllowanceI) (*FeeAllowanceGrant, error) { +func NewFeeAllowanceGrant(granter, grantee sdk.AccAddress, feeAllowance FeeAllowanceI) FeeAllowanceGrant { msg, ok := feeAllowance.(proto.Message) if !ok { - return nil, fmt.Errorf("cannot proto marshal %T", msg) + panic(fmt.Errorf("cannot proto marshal %T", msg)) } any, err := types.NewAnyWithValue(msg) if err != nil { - return nil, err + panic(err) } - return &FeeAllowanceGrant{ + return FeeAllowanceGrant{ Granter: granter, Grantee: grantee, Allowance: any, - }, nil + } } // ValidateBasic performs basic validation on diff --git a/x/feegrant/types/query.pb.go b/x/feegrant/types/query.pb.go new file mode 100644 index 000000000000..80ce8852681f --- /dev/null +++ b/x/feegrant/types/query.pb.go @@ -0,0 +1,637 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/feegrant/v1beta1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + 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 + +// QueryFeeAllowanceRequest is the request type for the Query/FeeAllowance RPC method. +type QueryFeeAllowanceRequest struct { + Granter string `protobuf:"bytes,1,opt,name=granter,proto3" json:"granter,omitempty"` + Grantee string `protobuf:"bytes,2,opt,name=grantee,proto3" json:"grantee,omitempty"` +} + +func (m *QueryFeeAllowanceRequest) Reset() { *m = QueryFeeAllowanceRequest{} } +func (m *QueryFeeAllowanceRequest) String() string { return proto.CompactTextString(m) } +func (*QueryFeeAllowanceRequest) ProtoMessage() {} +func (*QueryFeeAllowanceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_59efc303945de53f, []int{0} +} +func (m *QueryFeeAllowanceRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryFeeAllowanceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryFeeAllowanceRequest.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 *QueryFeeAllowanceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFeeAllowanceRequest.Merge(m, src) +} +func (m *QueryFeeAllowanceRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryFeeAllowanceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFeeAllowanceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryFeeAllowanceRequest proto.InternalMessageInfo + +// QueryFeeAllowanceResponse is the response type for the Query/FeeAllowance RPC method. +type QueryFeeAllowanceResponse struct { + // fee_allowance is a fee_allowance granted for grantee by granter. + FeeAllowance *FeeAllowanceGrant `protobuf:"bytes,1,opt,name=fee_allowance,json=feeAllowance,proto3" json:"fee_allowance,omitempty"` +} + +func (m *QueryFeeAllowanceResponse) Reset() { *m = QueryFeeAllowanceResponse{} } +func (m *QueryFeeAllowanceResponse) String() string { return proto.CompactTextString(m) } +func (*QueryFeeAllowanceResponse) ProtoMessage() {} +func (*QueryFeeAllowanceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_59efc303945de53f, []int{1} +} +func (m *QueryFeeAllowanceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryFeeAllowanceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryFeeAllowanceResponse.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 *QueryFeeAllowanceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFeeAllowanceResponse.Merge(m, src) +} +func (m *QueryFeeAllowanceResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryFeeAllowanceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFeeAllowanceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryFeeAllowanceResponse proto.InternalMessageInfo + +func (m *QueryFeeAllowanceResponse) GetFeeAllowance() *FeeAllowanceGrant { + if m != nil { + return m.FeeAllowance + } + return nil +} + +func init() { + proto.RegisterType((*QueryFeeAllowanceRequest)(nil), "cosmos.feegrant.v1beta1.QueryFeeAllowanceRequest") + proto.RegisterType((*QueryFeeAllowanceResponse)(nil), "cosmos.feegrant.v1beta1.QueryFeeAllowanceResponse") +} + +func init() { + proto.RegisterFile("cosmos/feegrant/v1beta1/query.proto", fileDescriptor_59efc303945de53f) +} + +var fileDescriptor_59efc303945de53f = []byte{ + // 288 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4e, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0x4d, 0x2f, 0x4a, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, + 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, + 0x12, 0x87, 0x28, 0xd2, 0x83, 0x29, 0xd2, 0x83, 0x2a, 0x92, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, + 0xab, 0xd1, 0x07, 0xb1, 0x20, 0xca, 0xa5, 0xd4, 0x70, 0x99, 0x09, 0xd7, 0x0f, 0x56, 0xa7, 0x14, + 0xc1, 0x25, 0x11, 0x08, 0xb2, 0xc5, 0x2d, 0x35, 0xd5, 0x31, 0x27, 0x27, 0xbf, 0x3c, 0x31, 0x2f, + 0x39, 0x35, 0x28, 0xb5, 0xb0, 0x34, 0xb5, 0xb8, 0x44, 0x48, 0x82, 0x8b, 0x1d, 0xac, 0x34, 0xb5, + 0x48, 0x82, 0x51, 0x81, 0x51, 0x83, 0x33, 0x08, 0xc6, 0x45, 0xc8, 0xa4, 0x4a, 0x30, 0x21, 0xcb, + 0xa4, 0x5a, 0x71, 0x74, 0x2c, 0x90, 0x67, 0x78, 0xb1, 0x40, 0x9e, 0x41, 0x29, 0x87, 0x4b, 0x12, + 0x8b, 0xc9, 0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, 0x42, 0xfe, 0x5c, 0xbc, 0x69, 0xa9, 0xa9, 0xf1, + 0x89, 0x30, 0x09, 0xb0, 0x05, 0xdc, 0x46, 0x5a, 0x7a, 0x38, 0x7c, 0xa9, 0x87, 0x6c, 0x8a, 0x3b, + 0x48, 0x26, 0x88, 0x27, 0x0d, 0x49, 0xc8, 0xa8, 0x81, 0x91, 0x8b, 0x15, 0x6c, 0x9d, 0x50, 0x39, + 0x17, 0x0f, 0xb2, 0x62, 0x21, 0x43, 0x9c, 0x66, 0xe2, 0xf2, 0xb8, 0x94, 0x11, 0x29, 0x5a, 0x20, + 0x3e, 0x52, 0x62, 0x70, 0x72, 0x3f, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, + 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, + 0xdd, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x68, 0xbc, 0x40, 0x28, + 0xdd, 0xe2, 0x94, 0x6c, 0xfd, 0x0a, 0x44, 0x24, 0x95, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, + 0xa3, 0xc6, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xe8, 0xbb, 0x8d, 0x3b, 0x18, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Returns any `FeeAllowance` (or `nil`), granted to the grantee by the granter. + FeeAllowance(ctx context.Context, in *QueryFeeAllowanceRequest, opts ...grpc.CallOption) (*QueryFeeAllowanceResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) FeeAllowance(ctx context.Context, in *QueryFeeAllowanceRequest, opts ...grpc.CallOption) (*QueryFeeAllowanceResponse, error) { + out := new(QueryFeeAllowanceResponse) + err := c.cc.Invoke(ctx, "/cosmos.feegrant.v1beta1.Query/FeeAllowance", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Returns any `FeeAllowance` (or `nil`), granted to the grantee by the granter. + FeeAllowance(context.Context, *QueryFeeAllowanceRequest) (*QueryFeeAllowanceResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) FeeAllowance(ctx context.Context, req *QueryFeeAllowanceRequest) (*QueryFeeAllowanceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FeeAllowance not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_FeeAllowance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryFeeAllowanceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).FeeAllowance(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.feegrant.v1beta1.Query/FeeAllowance", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).FeeAllowance(ctx, req.(*QueryFeeAllowanceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "cosmos.feegrant.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "FeeAllowance", + Handler: _Query_FeeAllowance_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cosmos/feegrant/v1beta1/query.proto", +} + +func (m *QueryFeeAllowanceRequest) 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 *QueryFeeAllowanceRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFeeAllowanceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Grantee) > 0 { + i -= len(m.Grantee) + copy(dAtA[i:], m.Grantee) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Grantee))) + i-- + dAtA[i] = 0x12 + } + if len(m.Granter) > 0 { + i -= len(m.Granter) + copy(dAtA[i:], m.Granter) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Granter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryFeeAllowanceResponse) 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 *QueryFeeAllowanceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFeeAllowanceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.FeeAllowance != nil { + { + size, err := m.FeeAllowance.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryFeeAllowanceRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Granter) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Grantee) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryFeeAllowanceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.FeeAllowance != nil { + l = m.FeeAllowance.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryFeeAllowanceRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryFeeAllowanceRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFeeAllowanceRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Granter", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Granter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Grantee = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryFeeAllowanceResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryFeeAllowanceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFeeAllowanceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeAllowance", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.FeeAllowance == nil { + m.FeeAllowance = &FeeAllowanceGrant{} + } + if err := m.FeeAllowance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) From c89db6d10ac3ec5a1c71c565aef64a44eef0afa9 Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 1 Dec 2020 23:22:29 +0530 Subject: [PATCH 085/184] fix test --- x/feegrant/types/grant_test.go | 71 +++++++++++----------------------- 1 file changed, 22 insertions(+), 49 deletions(-) diff --git a/x/feegrant/types/grant_test.go b/x/feegrant/types/grant_test.go index a82b15ecd9f1..3a6f210a5224 100644 --- a/x/feegrant/types/grant_test.go +++ b/x/feegrant/types/grant_test.go @@ -16,70 +16,43 @@ func TestGrant(t *testing.T) { require.NoError(t, err) atom := sdk.NewCoins(sdk.NewInt64Coin("atom", 555)) - cdc := codec.New() - RegisterCodec(cdc) + cdc := codec.NewLegacyAmino() + RegisterLegacyAminoCodec(cdc) cases := map[string]struct { grant FeeAllowanceGrant valid bool }{ "good": { - grant: FeeAllowanceGrant{ - Grantee: addr, - Granter: addr2, - Allowance: &FeeAllowance{Sum: &FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &BasicFeeAllowance{ - SpendLimit: atom, - Expiration: ExpiresAtHeight(100), - }, - }, - }, - }, + grant: NewFeeAllowanceGrant(addr2, addr, &BasicFeeAllowance{ + SpendLimit: atom, + Expiration: ExpiresAtHeight(100), + }), valid: true, }, "no grantee": { - grant: FeeAllowanceGrant{ - Granter: addr2, - Allowance: &FeeAllowance{Sum: &FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &BasicFeeAllowance{ - SpendLimit: atom, - Expiration: ExpiresAtHeight(100), - }, - }, - }, - }, + grant: NewFeeAllowanceGrant(addr2, nil, &BasicFeeAllowance{ + SpendLimit: atom, + Expiration: ExpiresAtHeight(100), + }), }, "no granter": { - grant: FeeAllowanceGrant{ - Grantee: addr2, - Allowance: &FeeAllowance{Sum: &FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &BasicFeeAllowance{ - SpendLimit: atom, - Expiration: ExpiresAtHeight(100), - }, - }, - }, - }, + grant: NewFeeAllowanceGrant(nil, addr, &BasicFeeAllowance{ + SpendLimit: atom, + Expiration: ExpiresAtHeight(100), + }), }, "self-grant": { - grant: FeeAllowanceGrant{ - Grantee: addr2, - Granter: addr2, - Allowance: &FeeAllowance{Sum: &FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &BasicFeeAllowance{ - SpendLimit: atom, - Expiration: ExpiresAtHeight(100), - }, - }, - }, - }, + grant: NewFeeAllowanceGrant(addr2, addr2, &BasicFeeAllowance{ + SpendLimit: atom, + Expiration: ExpiresAtHeight(100), + }), }, "bad allowance": { - grant: FeeAllowanceGrant{ - Grantee: addr, - Granter: addr2, - Allowance: &FeeAllowance{Sum: &FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &BasicFeeAllowance{ - Expiration: ExpiresAtHeight(0), - }, - }, - }, - }, + grant: NewFeeAllowanceGrant(addr2, addr, &BasicFeeAllowance{ + SpendLimit: atom, + Expiration: ExpiresAtHeight(-1), + }), }, } From 37aa0c124917bd371dfcfdf3ded4601cd58ac730 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 2 Dec 2020 14:35:36 +0530 Subject: [PATCH 086/184] fixed tests --- x/feegrant/keeper/keeper.go | 2 +- x/feegrant/types/grant_test.go | 42 +++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/x/feegrant/keeper/keeper.go b/x/feegrant/keeper/keeper.go index 4cf0b024ae4e..79d9802b3677 100644 --- a/x/feegrant/keeper/keeper.go +++ b/x/feegrant/keeper/keeper.go @@ -14,7 +14,7 @@ import ( // Keeper manages state of all fee grants, as well as calculating approval. // It must have a codec with all available allowances registered. type Keeper struct { - cdc codec.Marshaler + cdc codec.BinaryMarshaler storeKey sdk.StoreKey } diff --git a/x/feegrant/types/grant_test.go b/x/feegrant/types/grant_test.go index 3a6f210a5224..c826889c7bf5 100644 --- a/x/feegrant/types/grant_test.go +++ b/x/feegrant/types/grant_test.go @@ -1,57 +1,60 @@ -package types +package types_test import ( + "fmt" "testing" - "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestGrant(t *testing.T) { + app := simapp.Setup(false) addr, err := sdk.AccAddressFromBech32("cosmos1qk93t4j0yyzgqgt6k5qf8deh8fq6smpn3ntu3x") require.NoError(t, err) addr2, err := sdk.AccAddressFromBech32("cosmos1p9qh4ldfd6n0qehujsal4k7g0e37kel90rc4ts") require.NoError(t, err) atom := sdk.NewCoins(sdk.NewInt64Coin("atom", 555)) - cdc := codec.NewLegacyAmino() - RegisterLegacyAminoCodec(cdc) + cdc := app.AppCodec() + // RegisterLegacyAminoCodec(cdc) cases := map[string]struct { - grant FeeAllowanceGrant + grant types.FeeAllowanceGrant valid bool }{ "good": { - grant: NewFeeAllowanceGrant(addr2, addr, &BasicFeeAllowance{ + grant: types.NewFeeAllowanceGrant(addr2, addr, &types.BasicFeeAllowance{ SpendLimit: atom, - Expiration: ExpiresAtHeight(100), + Expiration: types.ExpiresAtHeight(100), }), valid: true, }, "no grantee": { - grant: NewFeeAllowanceGrant(addr2, nil, &BasicFeeAllowance{ + grant: types.NewFeeAllowanceGrant(addr2, nil, &types.BasicFeeAllowance{ SpendLimit: atom, - Expiration: ExpiresAtHeight(100), + Expiration: types.ExpiresAtHeight(100), }), }, "no granter": { - grant: NewFeeAllowanceGrant(nil, addr, &BasicFeeAllowance{ + grant: types.NewFeeAllowanceGrant(nil, addr, &types.BasicFeeAllowance{ SpendLimit: atom, - Expiration: ExpiresAtHeight(100), + Expiration: types.ExpiresAtHeight(100), }), }, "self-grant": { - grant: NewFeeAllowanceGrant(addr2, addr2, &BasicFeeAllowance{ + grant: types.NewFeeAllowanceGrant(addr2, addr2, &types.BasicFeeAllowance{ SpendLimit: atom, - Expiration: ExpiresAtHeight(100), + Expiration: types.ExpiresAtHeight(100), }), }, "bad allowance": { - grant: NewFeeAllowanceGrant(addr2, addr, &BasicFeeAllowance{ + grant: types.NewFeeAllowanceGrant(addr2, addr, &types.BasicFeeAllowance{ SpendLimit: atom, - Expiration: ExpiresAtHeight(-1), + Expiration: types.ExpiresAtHeight(-1), }), }, } @@ -67,14 +70,17 @@ func TestGrant(t *testing.T) { require.NoError(t, err) // if it is valid, let's try to serialize, deserialize, and make sure it matches - bz, err := cdc.MarshalBinaryBare(tc.grant) + bz, err := cdc.MarshalBinaryBare(&tc.grant) require.NoError(t, err) - var loaded FeeAllowanceGrant + var loaded types.FeeAllowanceGrant err = cdc.UnmarshalBinaryBare(bz, &loaded) require.NoError(t, err) - err = tc.grant.ValidateBasic() + err = loaded.ValidateBasic() require.NoError(t, err) + fmt.Println("tc", tc.grant) + fmt.Println("tc", loaded) + assert.Equal(t, tc.grant, loaded) }) } From aad466a92acf7d4369bb979b93777dccb234a839 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 2 Dec 2020 14:46:53 +0530 Subject: [PATCH 087/184] fix tests --- x/feegrant/types/basic_fee_test.go | 21 ++++--- x/feegrant/types/expiration_test.go | 81 ++++++++++++------------ x/feegrant/types/periodic_fee_test.go | 91 ++++++++++++++------------- 3 files changed, 98 insertions(+), 95 deletions(-) diff --git a/x/feegrant/types/basic_fee_test.go b/x/feegrant/types/basic_fee_test.go index 887fa5fbf3c5..440aaeaf49da 100644 --- a/x/feegrant/types/basic_fee_test.go +++ b/x/feegrant/types/basic_fee_test.go @@ -1,10 +1,11 @@ -package types +package types_test import ( "testing" "time" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -16,7 +17,7 @@ func TestBasicFeeValidAllow(t *testing.T) { leftAtom := sdk.NewCoins(sdk.NewInt64Coin("atom", 512)) cases := map[string]struct { - allow *BasicFeeAllowance + allow *types.BasicFeeAllowance // all other checks are ignored if valid=false fee sdk.Coins blockTime time.Time @@ -27,11 +28,11 @@ func TestBasicFeeValidAllow(t *testing.T) { remains sdk.Coins }{ "empty": { - allow: &BasicFeeAllowance{}, + allow: &types.BasicFeeAllowance{}, valid: false, }, "small fee": { - allow: &BasicFeeAllowance{ + allow: &types.BasicFeeAllowance{ SpendLimit: atom, }, valid: true, @@ -41,7 +42,7 @@ func TestBasicFeeValidAllow(t *testing.T) { remains: leftAtom, }, "all fee": { - allow: &BasicFeeAllowance{ + allow: &types.BasicFeeAllowance{ SpendLimit: smallAtom, }, valid: true, @@ -50,7 +51,7 @@ func TestBasicFeeValidAllow(t *testing.T) { remove: true, }, "wrong fee": { - allow: &BasicFeeAllowance{ + allow: &types.BasicFeeAllowance{ SpendLimit: smallAtom, }, valid: true, @@ -58,9 +59,9 @@ func TestBasicFeeValidAllow(t *testing.T) { accept: false, }, "non-expired": { - allow: &BasicFeeAllowance{ + allow: &types.BasicFeeAllowance{ SpendLimit: atom, - Expiration: ExpiresAtHeight(100), + Expiration: types.ExpiresAtHeight(100), }, valid: true, fee: smallAtom, @@ -70,9 +71,9 @@ func TestBasicFeeValidAllow(t *testing.T) { remains: leftAtom, }, "expired": { - allow: &BasicFeeAllowance{ + allow: &types.BasicFeeAllowance{ SpendLimit: atom, - Expiration: ExpiresAtHeight(100), + Expiration: types.ExpiresAtHeight(100), }, valid: true, fee: smallAtom, diff --git a/x/feegrant/types/expiration_test.go b/x/feegrant/types/expiration_test.go index 6cab366eabdc..9cc7684b5065 100644 --- a/x/feegrant/types/expiration_test.go +++ b/x/feegrant/types/expiration_test.go @@ -1,9 +1,10 @@ -package types +package types_test import ( "testing" "time" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -12,39 +13,39 @@ func TestExpiresAt(t *testing.T) { now := time.Now() cases := map[string]struct { - example ExpiresAt + example types.ExpiresAt valid bool zero bool - before ExpiresAt - after ExpiresAt + before types.ExpiresAt + after types.ExpiresAt }{ "basic": { - example: ExpiresAtHeight(100), + example: types.ExpiresAtHeight(100), valid: true, - before: ExpiresAt{Height: 50, Time: now}, - after: ExpiresAt{Height: 122, Time: now}, + before: types.ExpiresAt{Height: 50, Time: now}, + after: types.ExpiresAt{Height: 122, Time: now}, }, "zero": { - example: ExpiresAt{}, + example: types.ExpiresAt{}, zero: true, valid: true, - before: ExpiresAt{Height: 1}, + before: types.ExpiresAt{Height: 1}, }, "double": { - example: ExpiresAt{Height: 100, Time: now}, + example: types.ExpiresAt{Height: 100, Time: now}, valid: false, }, "match height": { - example: ExpiresAtHeight(1000), + example: types.ExpiresAtHeight(1000), valid: true, - before: ExpiresAt{Height: 999, Time: now}, - after: ExpiresAt{Height: 1000, Time: now}, + before: types.ExpiresAt{Height: 999, Time: now}, + after: types.ExpiresAt{Height: 1000, Time: now}, }, "match time": { - example: ExpiresAtTime(now), + example: types.ExpiresAtTime(now), valid: true, - before: ExpiresAt{Height: 43, Time: now.Add(-1 * time.Second)}, - after: ExpiresAt{Height: 76, Time: now}, + before: types.ExpiresAt{Height: 43, Time: now.Add(-1 * time.Second)}, + after: types.ExpiresAt{Height: 76, Time: now}, }, } @@ -73,37 +74,37 @@ func TestDurationValid(t *testing.T) { now := time.Now() cases := map[string]struct { - period Duration + period types.Duration valid bool - compatible ExpiresAt - incompatible ExpiresAt + compatible types.ExpiresAt + incompatible types.ExpiresAt }{ "basic height": { - period: BlockDuration(100), + period: types.BlockDuration(100), valid: true, - compatible: ExpiresAtHeight(50), - incompatible: ExpiresAtTime(now), + compatible: types.ExpiresAtHeight(50), + incompatible: types.ExpiresAtTime(now), }, "basic time": { - period: ClockDuration(time.Hour), + period: types.ClockDuration(time.Hour), valid: true, - compatible: ExpiresAtTime(now), - incompatible: ExpiresAtHeight(50), + compatible: types.ExpiresAtTime(now), + incompatible: types.ExpiresAtHeight(50), }, "zero": { - period: Duration{}, + period: types.Duration{}, valid: false, }, "double": { - period: Duration{Block: 100, Clock: time.Hour}, + period: types.Duration{Block: 100, Clock: time.Hour}, valid: false, }, "negative clock": { - period: ClockDuration(-1 * time.Hour), + period: types.ClockDuration(-1 * time.Hour), valid: false, }, "negative block": { - period: BlockDuration(-5), + period: types.BlockDuration(-5), valid: false, }, } @@ -128,26 +129,26 @@ func TestDurationStep(t *testing.T) { now := time.Now() cases := map[string]struct { - expires ExpiresAt - period Duration + expires types.ExpiresAt + period types.Duration valid bool - result ExpiresAt + result types.ExpiresAt }{ "add height": { - expires: ExpiresAtHeight(789), - period: BlockDuration(100), + expires: types.ExpiresAtHeight(789), + period: types.BlockDuration(100), valid: true, - result: ExpiresAtHeight(889), + result: types.ExpiresAtHeight(889), }, "add time": { - expires: ExpiresAtTime(now), - period: ClockDuration(time.Hour), + expires: types.ExpiresAtTime(now), + period: types.ClockDuration(time.Hour), valid: true, - result: ExpiresAtTime(now.Add(time.Hour)), + result: types.ExpiresAtTime(now.Add(time.Hour)), }, "mismatch": { - expires: ExpiresAtHeight(789), - period: ClockDuration(time.Hour), + expires: types.ExpiresAtHeight(789), + period: types.ClockDuration(time.Hour), valid: false, }, } diff --git a/x/feegrant/types/periodic_fee_test.go b/x/feegrant/types/periodic_fee_test.go index 40a8ca864184..0f853da28a60 100644 --- a/x/feegrant/types/periodic_fee_test.go +++ b/x/feegrant/types/periodic_fee_test.go @@ -1,10 +1,11 @@ -package types +package types_test import ( "testing" "time" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -17,7 +18,7 @@ func TestPeriodicFeeValidAllow(t *testing.T) { eth := sdk.NewCoins(sdk.NewInt64Coin("eth", 1)) cases := map[string]struct { - allow PeriodicFeeAllowance + allow types.PeriodicFeeAllowance // all other checks are ignored if valid=false fee sdk.Coins blockTime time.Time @@ -27,46 +28,46 @@ func TestPeriodicFeeValidAllow(t *testing.T) { remove bool remains sdk.Coins remainsPeriod sdk.Coins - periodReset ExpiresAt + periodReset types.ExpiresAt }{ "empty": { - allow: PeriodicFeeAllowance{}, + allow: types.PeriodicFeeAllowance{}, valid: false, }, "only basic": { - allow: PeriodicFeeAllowance{ - Basic: BasicFeeAllowance{ + allow: types.PeriodicFeeAllowance{ + Basic: types.BasicFeeAllowance{ SpendLimit: atom, - Expiration: ExpiresAtHeight(100), + Expiration: types.ExpiresAtHeight(100), }, }, valid: false, }, "empty basic": { - allow: PeriodicFeeAllowance{ - Period: BlockDuration(50), + allow: types.PeriodicFeeAllowance{ + Period: types.BlockDuration(50), PeriodSpendLimit: smallAtom, }, valid: false, }, "mismatched currencies": { - allow: PeriodicFeeAllowance{ - Basic: BasicFeeAllowance{ + allow: types.PeriodicFeeAllowance{ + Basic: types.BasicFeeAllowance{ SpendLimit: atom, - Expiration: ExpiresAtHeight(100), + Expiration: types.ExpiresAtHeight(100), }, - Period: BlockDuration(10), + Period: types.BlockDuration(10), PeriodSpendLimit: eth, }, valid: false, }, "first time": { - allow: PeriodicFeeAllowance{ - Basic: BasicFeeAllowance{ + allow: types.PeriodicFeeAllowance{ + Basic: types.BasicFeeAllowance{ SpendLimit: atom, - Expiration: ExpiresAtHeight(100), + Expiration: types.ExpiresAtHeight(100), }, - Period: BlockDuration(10), + Period: types.BlockDuration(10), PeriodSpendLimit: smallAtom, }, valid: true, @@ -76,16 +77,16 @@ func TestPeriodicFeeValidAllow(t *testing.T) { remove: false, remainsPeriod: nil, remains: leftAtom, - periodReset: ExpiresAtHeight(85), + periodReset: types.ExpiresAtHeight(85), }, "same period": { - allow: PeriodicFeeAllowance{ - Basic: BasicFeeAllowance{ + allow: types.PeriodicFeeAllowance{ + Basic: types.BasicFeeAllowance{ SpendLimit: atom, - Expiration: ExpiresAtHeight(100), + Expiration: types.ExpiresAtHeight(100), }, - Period: BlockDuration(10), - PeriodReset: ExpiresAtHeight(80), + Period: types.BlockDuration(10), + PeriodReset: types.ExpiresAtHeight(80), PeriodSpendLimit: leftAtom, PeriodCanSpend: smallAtom, }, @@ -96,16 +97,16 @@ func TestPeriodicFeeValidAllow(t *testing.T) { remove: false, remainsPeriod: nil, remains: leftAtom, - periodReset: ExpiresAtHeight(80), + periodReset: types.ExpiresAtHeight(80), }, "step one period": { - allow: PeriodicFeeAllowance{ - Basic: BasicFeeAllowance{ + allow: types.PeriodicFeeAllowance{ + Basic: types.BasicFeeAllowance{ SpendLimit: atom, - Expiration: ExpiresAtHeight(100), + Expiration: types.ExpiresAtHeight(100), }, - Period: BlockDuration(10), - PeriodReset: ExpiresAtHeight(70), + Period: types.BlockDuration(10), + PeriodReset: types.ExpiresAtHeight(70), PeriodSpendLimit: leftAtom, }, valid: true, @@ -115,16 +116,16 @@ func TestPeriodicFeeValidAllow(t *testing.T) { remove: false, remainsPeriod: nil, remains: smallAtom, - periodReset: ExpiresAtHeight(80), // one step from last reset, not now + periodReset: types.ExpiresAtHeight(80), // one step from last reset, not now }, "step limited by global allowance": { - allow: PeriodicFeeAllowance{ - Basic: BasicFeeAllowance{ + allow: types.PeriodicFeeAllowance{ + Basic: types.BasicFeeAllowance{ SpendLimit: smallAtom, - Expiration: ExpiresAtHeight(100), + Expiration: types.ExpiresAtHeight(100), }, - Period: BlockDuration(10), - PeriodReset: ExpiresAtHeight(70), + Period: types.BlockDuration(10), + PeriodReset: types.ExpiresAtHeight(70), PeriodSpendLimit: atom, }, valid: true, @@ -134,15 +135,15 @@ func TestPeriodicFeeValidAllow(t *testing.T) { remove: false, remainsPeriod: smallAtom.Sub(oneAtom), remains: smallAtom.Sub(oneAtom), - periodReset: ExpiresAtHeight(80), // one step from last reset, not now + periodReset: types.ExpiresAtHeight(80), // one step from last reset, not now }, "expired": { - allow: PeriodicFeeAllowance{ - Basic: BasicFeeAllowance{ + allow: types.PeriodicFeeAllowance{ + Basic: types.BasicFeeAllowance{ SpendLimit: atom, - Expiration: ExpiresAtHeight(100), + Expiration: types.ExpiresAtHeight(100), }, - Period: BlockDuration(10), + Period: types.BlockDuration(10), PeriodSpendLimit: smallAtom, }, valid: true, @@ -152,13 +153,13 @@ func TestPeriodicFeeValidAllow(t *testing.T) { remove: true, }, "over period limit": { - allow: PeriodicFeeAllowance{ - Basic: BasicFeeAllowance{ + allow: types.PeriodicFeeAllowance{ + Basic: types.BasicFeeAllowance{ SpendLimit: atom, - Expiration: ExpiresAtHeight(100), + Expiration: types.ExpiresAtHeight(100), }, - Period: BlockDuration(10), - PeriodReset: ExpiresAtHeight(80), + Period: types.BlockDuration(10), + PeriodReset: types.ExpiresAtHeight(80), PeriodSpendLimit: leftAtom, PeriodCanSpend: smallAtom, }, From d8962c20038efc13e0715c5750525857160b6759 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 2 Dec 2020 21:44:07 +0530 Subject: [PATCH 088/184] updated expected keepers --- x/feegrant/alias.go | 2 +- x/feegrant/ante/fee.go | 10 +++++----- x/feegrant/types/expected_keepers.go | 15 ++++++++------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/x/feegrant/alias.go b/x/feegrant/alias.go index d2021396e369..258f52490b81 100644 --- a/x/feegrant/alias.go +++ b/x/feegrant/alias.go @@ -61,6 +61,6 @@ type ( FeeGrantTx = types.FeeGrantTx GrantedFee = types.GrantedFee DelegatedSignDoc = types.DelegatedSignDoc - SupplyKeeper = types.SupplyKeeper + SupplyKeeper = types.BankKeeper Keeper = keeper.Keeper ) diff --git a/x/feegrant/ante/fee.go b/x/feegrant/ante/fee.go index 72b1247f55f9..51800958ff30 100644 --- a/x/feegrant/ante/fee.go +++ b/x/feegrant/ante/fee.go @@ -32,14 +32,14 @@ type GrantedFeeTx interface { type DeductGrantedFeeDecorator struct { ak types.AccountKeeper k keeper.Keeper - sk types.SupplyKeeper + bk types.BankKeeper } -func NewDeductGrantedFeeDecorator(ak types.AccountKeeper, sk types.SupplyKeeper, k keeper.Keeper) DeductGrantedFeeDecorator { +func NewDeductGrantedFeeDecorator(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) DeductGrantedFeeDecorator { return DeductGrantedFeeDecorator{ ak: ak, k: k, - sk: sk, + bk: bk, } } @@ -55,7 +55,7 @@ func (d DeductGrantedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula } // sanity check from DeductFeeDecorator - if addr := d.sk.GetModuleAddress(authtypes.FeeCollectorName); addr == nil { + if addr := d.ak.GetModuleAddress(authtypes.FeeCollectorName); addr == nil { panic(fmt.Sprintf("%s module account has not been set", authtypes.FeeCollectorName)) } @@ -90,7 +90,7 @@ func (d DeductGrantedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula } // deduct fee if non-zero - err = authante.DeductFees(d.sk, ctx, feePayerAcc, fee) + err = authante.DeductFees(d.bk, ctx, feePayerAcc, fee) if err != nil { return ctx, err } diff --git a/x/feegrant/types/expected_keepers.go b/x/feegrant/types/expected_keepers.go index b7c6c6fe6596..ca35fa72d603 100644 --- a/x/feegrant/types/expected_keepers.go +++ b/x/feegrant/types/expected_keepers.go @@ -6,16 +6,17 @@ import ( // supply "github.com/cosmos/cosmos-sdk/x/supply/exported" ) -// SupplyKeeper defines the expected supply Keeper (noalias) -type SupplyKeeper interface { - SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error - GetModuleAccount(ctx sdk.Context, moduleName string) auth.ModuleAccountI +// AccountKeeper defines the expected auth Account Keeper (noalias) +type AccountKeeper interface { GetModuleAddress(moduleName string) sdk.AccAddress -} + GetModuleAccount(ctx sdk.Context, moduleName string) auth.ModuleAccountI -// SupplyKeeper defines the expected auth Account Keeper (noalias) -type AccountKeeper interface { NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) auth.AccountI GetAccount(ctx sdk.Context, addr sdk.AccAddress) auth.AccountI SetAccount(ctx sdk.Context, acc auth.AccountI) } + +// BankKeeper defines the expected supply Keeper (noalias) +type BankKeeper interface { + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error +} From a96d5a59893624368b40d728f423646db3331439 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 2 Dec 2020 21:44:25 +0530 Subject: [PATCH 089/184] updated ante tests --- x/feegrant/ante/fee_test.go | 124 +++++++++++++++++++++++------------- 1 file changed, 80 insertions(+), 44 deletions(-) diff --git a/x/feegrant/ante/fee_test.go b/x/feegrant/ante/fee_test.go index de1773f0c4c3..a1345ad916c6 100644 --- a/x/feegrant/ante/fee_test.go +++ b/x/feegrant/ante/fee_test.go @@ -3,14 +3,18 @@ package ante_test import ( "testing" - "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" + "github.com/cosmos/cosmos-sdk/client" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/stretchr/testify/suite" "github.com/tendermint/tendermint/crypto" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + "github.com/cosmos/cosmos-sdk/x/auth/signing" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/feegrant/ante" "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" @@ -21,7 +25,11 @@ import ( // in order to allow payment of fees via a grant. // // This is used for our full-stack tests -func newAnteHandler(ak authkeeper.AccountKeeper, supplyKeeper authtypes.SupplyKeeper, dk keeper.Keeper, sigGasConsumer authante.SignatureVerificationGasConsumer) sdk.AnteHandler { +func newAnteHandler( + ak authkeeper.AccountKeeper, bankKeeper authtypes.BankKeeper, + dk keeper.Keeper, sigGasConsumer authante.SignatureVerificationGasConsumer, + signModeHandler signing.SignModeHandler, +) sdk.AnteHandler { return sdk.ChainAnteDecorators( authante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first authante.NewMempoolFeeDecorator(), @@ -30,31 +38,69 @@ func newAnteHandler(ak authkeeper.AccountKeeper, supplyKeeper authtypes.SupplyKe authante.NewConsumeGasForTxSizeDecorator(ak), // DeductGrantedFeeDecorator will create an empty account if we sign with no tokens but valid validation // This must be before SetPubKey, ValidateSigCount, SigVerification, which error if account doesn't exist yet - ante.NewDeductGrantedFeeDecorator(ak, supplyKeeper, dk), + ante.NewDeductGrantedFeeDecorator(ak, bankKeeper, dk), authante.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators authante.NewValidateSigCountDecorator(ak), authante.NewSigGasConsumeDecorator(ak, sigGasConsumer), - authante.NewSigVerificationDecorator(ak), + authante.NewSigVerificationDecorator(ak, signModeHandler), authante.NewIncrementSequenceDecorator(ak), // innermost AnteDecorator ) } -func TestDeductFeesNoDelegation(t *testing.T) { +// AnteTestSuite is a test suite to be used with ante handler tests. +type AnteTestSuite struct { + suite.Suite + + app *simapp.SimApp + anteHandler sdk.AnteHandler + ctx sdk.Context + clientCtx client.Context + txBuilder client.TxBuilder +} + +// returns context and app with params set on account keeper +// func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { +// app := simapp.Setup(isCheckTx) +// ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) +// app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) + +// return app, ctx +// } + +// SetupTest setups a new test, with new app, context, and anteHandler. +func (suite *AnteTestSuite) SetupTest(isCheckTx bool) { + suite.app, suite.ctx = createTestApp(isCheckTx) + suite.ctx = suite.ctx.WithBlockHeight(1) + + // Set up TxConfig. + encodingConfig := simapp.MakeTestEncodingConfig() + // We're using TestMsg encoding in some tests, so register it here. + encodingConfig.Amino.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg", nil) + testdata.RegisterInterfaces(encodingConfig.InterfaceRegistry) + + suite.clientCtx = client.Context{}. + WithTxConfig(encodingConfig.TxConfig) + + suite.anteHandler = newAnteHandler(suite.app.AccountKeeper, suite.app.BankKeeper, suite.app.FeeGrantKeeper, authante.DefaultSigVerificationGasConsumer, encodingConfig.TxConfig.SignModeHandler()) +} + +func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { + suite.SetupTest(true) // setup - app, ctx := createTestApp(true) + app, ctx := suite.app, suite.ctx // this just tests our handler - dfd := ante.NewDeductGrantedFeeDecorator(app.AccountKeeper, app.SupplyKeeper, app.FeeGrantKeeper) + dfd := ante.NewDeductGrantedFeeDecorator(app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper) ourAnteHandler := sdk.ChainAnteDecorators(dfd) // this tests the whole stack - anteHandlerStack := newAnteHandler(app.AccountKeeper, app.SupplyKeeper, app.FeeGrantKeeper, SigGasNoConsumer) + anteHandlerStack := suite.anteHandler // keys and addresses - priv1, _, addr1 := authtypes.KeyTestPubAddr() - priv2, _, addr2 := authtypes.KeyTestPubAddr() - priv3, _, addr3 := authtypes.KeyTestPubAddr() - priv4, _, addr4 := authtypes.KeyTestPubAddr() + priv1, _, addr1 := testdata.KeyTestPubAddr() + priv2, _, addr2 := testdata.KeyTestPubAddr() + priv3, _, addr3 := testdata.KeyTestPubAddr() + priv4, _, addr4 := testdata.KeyTestPubAddr() // Set addr1 with insufficient funds acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1) @@ -67,40 +113,26 @@ func TestDeductFeesNoDelegation(t *testing.T) { app.BankKeeper.SetBalances(ctx, addr2, []sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(99999))}) // Set grant from addr2 to addr3 (plenty to pay) - app.FeeGrantKeeper.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: addr2, - Grantee: addr3, - Allowance: &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ - SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 500)), - }, - }, - }, + app.FeeGrantKeeper.GrantFeeAllowance(ctx, addr2, addr3, &types.BasicFeeAllowance{ + SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 500)), }) // Set low grant from addr2 to addr4 (keeper will reject) - app.FeeGrantKeeper.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: addr2, - Grantee: addr4, - Allowance: &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ - SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 20)), - }, - }, - }, + app.FeeGrantKeeper.GrantFeeAllowance(ctx, addr2, addr4, &types.BasicFeeAllowance{ + SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 20)), }) // Set grant from addr1 to addr4 (cannot cover this ) - app.FeeGrantKeeper.GrantFeeAllowance(ctx, types.FeeAllowanceGrant{ - Granter: addr2, - Grantee: addr3, - Allowance: &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ - SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 500)), - }, - }, - }, + app.FeeGrantKeeper.GrantFeeAllowance(ctx, addr2, addr3, &types.BasicFeeAllowance{ + SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 500)), }) + // app.FeeGrantKeeper.GrantFeeAllowance(ctx, addr1, addr4, &types.BasicFeeAllowance{ + // SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 500)), + // }) + cases := map[string]struct { - signerKey crypto.PrivKey + signerKey cryptotypes.PrivKey signer sdk.AccAddress feeAccount sdk.AccAddress handler sdk.AnteHandler @@ -246,19 +278,19 @@ func TestDeductFeesNoDelegation(t *testing.T) { for name, stc := range cases { tc := stc // to make scopelint happy - t.Run(name, func(t *testing.T) { + suite.T().Run(name, func(t *testing.T) { // msg and signatures fee := types.NewGrantedFee(100000, sdk.NewCoins(sdk.NewInt64Coin("atom", tc.fee)), tc.feeAccount) - msgs := []sdk.Msg{sdk.NewTestMsg(tc.signer)} - privs, accNums, seqs := []crypto.PrivKey{tc.signerKey}, []uint64{0}, []uint64{0} + msgs := []sdk.Msg{testdata.NewTestMsg(tc.signer)} + privs, accNums, seqs := []cryptotypes.PrivKey{tc.signerKey}, []uint64{0}, []uint64{0} tx := types.NewTestTx(ctx, msgs, privs, accNums, seqs, fee) _, err := tc.handler(ctx, tx, false) if tc.valid { - require.NoError(t, err) + suite.Require().NoError(err) } else { - require.Error(t, err) + suite.Require().Error(err) } }) } @@ -267,7 +299,7 @@ func TestDeductFeesNoDelegation(t *testing.T) { // returns context and app with params set on account keeper func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { app := simapp.Setup(isCheckTx) - ctx := app.BaseApp.NewContext(isCheckTx, abci.Header{}) + ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) return app, ctx @@ -277,3 +309,7 @@ func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { func SigGasNoConsumer(meter sdk.GasMeter, sig []byte, pubkey crypto.PubKey, params authtypes.Params) error { return nil } + +func TestAnteTestSuite(t *testing.T) { + suite.Run(t, new(AnteTestSuite)) +} From 2c1902bde2e12e4d8449f1cb7da30856decdb174 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 2 Dec 2020 21:49:54 +0530 Subject: [PATCH 090/184] lint --- x/feegrant/keeper/keeper.go | 2 +- x/feegrant/types/grant.go | 3 +-- x/feegrant/types/msgs.go | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/x/feegrant/keeper/keeper.go b/x/feegrant/keeper/keeper.go index 79d9802b3677..a3d9d10554cf 100644 --- a/x/feegrant/keeper/keeper.go +++ b/x/feegrant/keeper/keeper.go @@ -19,7 +19,7 @@ type Keeper struct { } // NewKeeper creates a fee grant Keeper -func NewKeeper(cdc codec.Marshaler, storeKey sdk.StoreKey) Keeper { +func NewKeeper(cdc codec.BinaryMarshaler, storeKey sdk.StoreKey) Keeper { return Keeper{cdc: cdc, storeKey: storeKey} } diff --git a/x/feegrant/types/grant.go b/x/feegrant/types/grant.go index 2c472b2fb898..3bdf40dedde5 100644 --- a/x/feegrant/types/grant.go +++ b/x/feegrant/types/grant.go @@ -5,7 +5,6 @@ import ( "time" "github.com/cosmos/cosmos-sdk/codec/types" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" proto "github.com/gogo/protobuf/proto" @@ -60,7 +59,7 @@ func (a FeeAllowanceGrant) GetFeeGrant() FeeAllowanceI { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (a FeeAllowanceGrant) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (a FeeAllowanceGrant) UnpackInterfaces(unpacker types.AnyUnpacker) error { var allowance FeeAllowanceI return unpacker.UnpackAny(a.Allowance, &allowance) } diff --git a/x/feegrant/types/msgs.go b/x/feegrant/types/msgs.go index 6e544dd26205..e0a674cd0810 100644 --- a/x/feegrant/types/msgs.go +++ b/x/feegrant/types/msgs.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/cosmos/cosmos-sdk/codec/types" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/gogo/protobuf/proto" @@ -86,7 +85,7 @@ func (msg MsgGrantFeeAllowance) GetFeeAllowanceI() FeeAllowanceI { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgGrantFeeAllowance) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (msg MsgGrantFeeAllowance) UnpackInterfaces(unpacker types.AnyUnpacker) error { var allowance FeeAllowanceI return unpacker.UnpackAny(msg.Allowance, &allowance) } From 6c16146dc52467f26f53020f6ca04ab39f2f8370 Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 3 Dec 2020 12:52:07 +0530 Subject: [PATCH 091/184] deleted alias.go --- simapp/ante.go | 7 +++-- simapp/app.go | 10 ++++--- x/feegrant/alias.go | 66 ------------------------------------------- x/feegrant/genesis.go | 11 ++++---- x/feegrant/handler.go | 9 +++--- x/feegrant/module.go | 10 +++---- 6 files changed, 26 insertions(+), 87 deletions(-) delete mode 100644 x/feegrant/alias.go diff --git a/simapp/ante.go b/simapp/ante.go index 7543ab4336bc..94c51bba2133 100644 --- a/simapp/ante.go +++ b/simapp/ante.go @@ -6,15 +6,16 @@ import ( authante "github.com/cosmos/cosmos-sdk/x/auth/ante" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" - "github.com/cosmos/cosmos-sdk/x/feegrant" feegrantante "github.com/cosmos/cosmos-sdk/x/feegrant/ante" + feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" + feegranttypes "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) // NewAnteHandler returns an AnteHandler that checks and increments sequence // numbers, checks signatures & account numbers, and deducts fees from the first // signer. func NewAnteHandler( - ak authkeeper.AccountKeeper, supplyKeeper feegrant.SupplyKeeper, feeGrantKeeper feegrant.Keeper, + ak authkeeper.AccountKeeper, bankKeeper feegranttypes.BankKeeper, feeGrantKeeper feegrantkeeper.Keeper, sigGasConsumer authante.SignatureVerificationGasConsumer, ) sdk.AnteHandler { @@ -28,7 +29,7 @@ func NewAnteHandler( // DeductGrantedFeeDecorator will create an empty account if we sign with no // tokens but valid validation. This must be before SetPubKey, ValidateSigCount, // SigVerification, which error if account doesn't exist yet. - feegrantante.NewDeductGrantedFeeDecorator(ak, supplyKeeper, feeGrantKeeper), + feegrantante.NewDeductGrantedFeeDecorator(ak, bankKeeper, feeGrantKeeper), authante.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators authante.NewValidateSigCountDecorator(ak), authante.NewSigGasConsumeDecorator(ak, sigGasConsumer), diff --git a/simapp/app.go b/simapp/app.go index 0f700b3c4ca9..0e63ab3ee4bf 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -55,6 +55,8 @@ import ( evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" "github.com/cosmos/cosmos-sdk/x/feegrant" + feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" + feegranttypes "github.com/cosmos/cosmos-sdk/x/feegrant/types" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/cosmos/cosmos-sdk/x/gov" @@ -176,7 +178,7 @@ type SimApp struct { IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly EvidenceKeeper evidencekeeper.Keeper TransferKeeper ibctransferkeeper.Keeper - FeeGrantKeeper feegrant.Keeper + FeeGrantKeeper feegrantkeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper @@ -219,7 +221,7 @@ func NewSimApp( keys := sdk.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, - govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, + govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegranttypes.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) @@ -274,7 +276,7 @@ func NewSimApp( app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, ) - app.FeeGrantKeeper = feegrant.NewKeeper(appCodec, keys[feegrant.StoreKey]) + app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegranttypes.StoreKey]) app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath) // register the staking hooks @@ -374,7 +376,7 @@ func NewSimApp( app.mm.SetOrderInitGenesis( capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName, - ibchost.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, ibctransfertypes.ModuleName, feegrant.ModuleName, + ibchost.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, ibctransfertypes.ModuleName, feegranttypes.ModuleName, ) app.mm.RegisterInvariants(&app.CrisisKeeper) diff --git a/x/feegrant/alias.go b/x/feegrant/alias.go deleted file mode 100644 index 258f52490b81..000000000000 --- a/x/feegrant/alias.go +++ /dev/null @@ -1,66 +0,0 @@ -package feegrant - -import ( - "github.com/cosmos/cosmos-sdk/x/feegrant/ante" - "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" -) - -// nolint - -const ( - DefaultCodespace = types.DefaultCodespace - EventTypeUseFeeGrant = types.EventTypeUseFeeGrant - EventTypeRevokeFeeGrant = types.EventTypeRevokeFeeGrant - EventTypeSetFeeGrant = types.EventTypeSetFeeGrant - AttributeKeyGranter = types.AttributeKeyGranter - AttributeKeyGrantee = types.AttributeKeyGrantee - ModuleName = types.ModuleName - StoreKey = types.StoreKey - RouterKey = types.RouterKey - QuerierRoute = types.QuerierRoute - QueryGetFeeAllowances = keeper.QueryGetFeeAllowances -) - -var ( - NewDeductGrantedFeeDecorator = ante.NewDeductGrantedFeeDecorator - RegisterCodec = types.RegisterLegacyAminoCodec - ExpiresAtTime = types.ExpiresAtTime - ExpiresAtHeight = types.ExpiresAtHeight - ClockDuration = types.ClockDuration - BlockDuration = types.BlockDuration - FeeAllowanceKey = types.FeeAllowanceKey - FeeAllowancePrefixByGrantee = types.FeeAllowancePrefixByGrantee - NewMsgRevokeFeeAllowance = types.NewMsgRevokeFeeAllowance - NewFeeGrantTx = types.NewFeeGrantTx - CountSubKeys = types.CountSubKeys - NewGrantedFee = types.NewGrantedFee - StdSignBytes = types.StdSignBytes - NewKeeper = keeper.NewKeeper - NewQuerier = keeper.NewQuerier - - ModuleCdc = types.ModuleCdc - ErrFeeLimitExceeded = types.ErrFeeLimitExceeded - ErrFeeLimitExpired = types.ErrFeeLimitExpired - ErrInvalidDuration = types.ErrInvalidDuration - ErrNoAllowance = types.ErrNoAllowance - FeeAllowanceKeyPrefix = types.FeeAllowanceKeyPrefix -) - -type ( - GrantedFeeTx = ante.GrantedFeeTx - DeductGrantedFeeDecorator = ante.DeductGrantedFeeDecorator - BasicFeeAllowance = types.BasicFeeAllowance - ExpiresAt = types.ExpiresAt - Duration = types.Duration - FeeAllowance = types.FeeAllowanceI - FeeAllowanceGrant = types.FeeAllowanceGrant - MsgGrantFeeAllowance = types.MsgGrantFeeAllowance - MsgRevokeFeeAllowance = types.MsgRevokeFeeAllowance - PeriodicFeeAllowance = types.PeriodicFeeAllowance - FeeGrantTx = types.FeeGrantTx - GrantedFee = types.GrantedFee - DelegatedSignDoc = types.DelegatedSignDoc - SupplyKeeper = types.BankKeeper - Keeper = keeper.Keeper -) diff --git a/x/feegrant/genesis.go b/x/feegrant/genesis.go index df74fedc1c19..abe3109f5585 100644 --- a/x/feegrant/genesis.go +++ b/x/feegrant/genesis.go @@ -2,11 +2,12 @@ package feegrant import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) // GenesisState contains a set of fee allowances, persisted from the store -type GenesisState []FeeAllowanceGrant +type GenesisState []types.FeeAllowanceGrant // ValidateBasic ensures all grants in the genesis state are valid func (g GenesisState) ValidateBasic() error { @@ -20,7 +21,7 @@ func (g GenesisState) ValidateBasic() error { } // InitGenesis will initialize the keeper from a *previously validated* GenesisState -func InitGenesis(ctx sdk.Context, k Keeper, data *types.GenesisState) { +func InitGenesis(ctx sdk.Context, k keeper.Keeper, data *types.GenesisState) { for _, f := range data.FeeAllowances { k.GrantFeeAllowance(ctx, f.Granter, f.Grantee, f.GetFeeGrant()) } @@ -33,11 +34,11 @@ func InitGenesis(ctx sdk.Context, k Keeper, data *types.GenesisState) { // for export, like if they have expiry at 5000 and current is 4000, they export with // expiry of 1000. Every FeeAllowance has a method `PrepareForExport` that allows // them to perform any changes needed prior to export. -func ExportGenesis(ctx sdk.Context, k Keeper) (*types.GenesisState, error) { +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) (*types.GenesisState, error) { time, height := ctx.BlockTime(), ctx.BlockHeight() - var grants []FeeAllowanceGrant + var grants []types.FeeAllowanceGrant - err := k.IterateAllFeeAllowances(ctx, func(grant FeeAllowanceGrant) bool { + err := k.IterateAllFeeAllowances(ctx, func(grant types.FeeAllowanceGrant) bool { grants = append(grants, grant.PrepareForExport(time, height)) return false }) diff --git a/x/feegrant/handler.go b/x/feegrant/handler.go index 9064f2e27476..8bf04d40df8e 100644 --- a/x/feegrant/handler.go +++ b/x/feegrant/handler.go @@ -4,24 +4,25 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) -func NewHandler(k Keeper) sdk.Handler { +func NewHandler(k keeper.Keeper) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) msgServer := keeper.NewMsgServerImpl(k) switch msg := msg.(type) { - case *MsgGrantFeeAllowance: + case *types.MsgGrantFeeAllowance: res, err := msgServer.GrantFeeAllowance(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) - case *MsgRevokeFeeAllowance: + case *types.MsgRevokeFeeAllowance: res, err := msgServer.RevokeFeeAllowance(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", ModuleName, msg) + return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) } } } diff --git a/x/feegrant/module.go b/x/feegrant/module.go index 7a811b9cf5f2..d7021a34d97b 100644 --- a/x/feegrant/module.go +++ b/x/feegrant/module.go @@ -33,7 +33,7 @@ type AppModuleBasic struct{} // Name returns the feegrant module's name. func (AppModuleBasic) Name() string { - return ModuleName + return types.ModuleName } // RegisterServices registers a gRPC query service to respond to the @@ -117,11 +117,11 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { // AppModule implements an application module for the feegrant module. type AppModule struct { AppModuleBasic - keeper Keeper + keeper keeper.Keeper } // NewAppModule creates a new AppModule object -func NewAppModule(keeper Keeper) AppModule { +func NewAppModule(keeper keeper.Keeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{}, keeper: keeper, @@ -130,7 +130,7 @@ func NewAppModule(keeper Keeper) AppModule { // Name returns the feegrant module's name. func (AppModule) Name() string { - return ModuleName + return types.ModuleName } // RegisterInvariants registers the feegrant module invariants. @@ -148,7 +148,7 @@ func (am AppModule) NewHandler() sdk.Handler { // QuerierRoute returns the feegrant module's querier route name. func (AppModule) QuerierRoute() string { - return QuerierRoute + return types.QuerierRoute } // // NewQuerierHandler returns the feegrant module sdk.Querier. From 1892a3d8c2a36a271001f62c0a4d63e69b795da5 Mon Sep 17 00:00:00 2001 From: atheesh Date: Sat, 5 Dec 2020 13:16:34 +0530 Subject: [PATCH 092/184] tx updated to proto tx --- client/tx_config.go | 2 ++ simapp/ante.go | 5 ++++- simapp/app.go | 4 ++-- x/auth/legacy/legacytx/stdtx_builder.go | 4 ++++ x/feegrant/ante/fee.go | 4 ++-- x/feegrant/ante/fee_test.go | 24 +++++++++++++++++++----- 6 files changed, 33 insertions(+), 10 deletions(-) diff --git a/client/tx_config.go b/client/tx_config.go index 6992a7a2402d..02030c323572 100644 --- a/client/tx_config.go +++ b/client/tx_config.go @@ -42,5 +42,7 @@ type ( SetFeeAmount(amount sdk.Coins) SetGasLimit(limit uint64) SetTimeoutHeight(height uint64) + SetFeePayer(feePayer sdk.AccAddress) + SetFeeGranter(feeGranter sdk.AccAddress) } ) diff --git a/simapp/ante.go b/simapp/ante.go index 94c51bba2133..8a0d331c141f 100644 --- a/simapp/ante.go +++ b/simapp/ante.go @@ -6,6 +6,7 @@ import ( authante "github.com/cosmos/cosmos-sdk/x/auth/ante" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" + "github.com/cosmos/cosmos-sdk/x/auth/signing" feegrantante "github.com/cosmos/cosmos-sdk/x/feegrant/ante" feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" feegranttypes "github.com/cosmos/cosmos-sdk/x/feegrant/types" @@ -16,14 +17,16 @@ import ( // signer. func NewAnteHandler( ak authkeeper.AccountKeeper, bankKeeper feegranttypes.BankKeeper, feeGrantKeeper feegrantkeeper.Keeper, - sigGasConsumer authante.SignatureVerificationGasConsumer, + sigGasConsumer authante.SignatureVerificationGasConsumer, signModeHandler signing.SignModeHandler, ) sdk.AnteHandler { txConfig := legacytx.StdTxConfig{Cdc: codec.NewLegacyAmino()} return sdk.ChainAnteDecorators( authante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first + authante.NewRejectExtensionOptionsDecorator(), authante.NewMempoolFeeDecorator(), authante.NewValidateBasicDecorator(), + authante.TxTimeoutHeightDecorator{}, authante.NewValidateMemoDecorator(ak), authante.NewConsumeGasForTxSizeDecorator(ak), // DeductGrantedFeeDecorator will create an empty account if we sign with no diff --git a/simapp/app.go b/simapp/app.go index 0e63ab3ee4bf..e64c7dcccc97 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -416,8 +416,8 @@ func NewSimApp( app.SetInitChainer(app.InitChainer) app.SetBeginBlocker(app.BeginBlocker) app.SetAnteHandler( - ante.NewAnteHandler( - app.AccountKeeper, app.BankKeeper, ante.DefaultSigVerificationGasConsumer, + NewAnteHandler( + app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, ante.DefaultSigVerificationGasConsumer, encodingConfig.TxConfig.SignModeHandler(), ), ) diff --git a/x/auth/legacy/legacytx/stdtx_builder.go b/x/auth/legacy/legacytx/stdtx_builder.go index 153c4b2bbbc1..02fbcf1aaea5 100644 --- a/x/auth/legacy/legacytx/stdtx_builder.go +++ b/x/auth/legacy/legacytx/stdtx_builder.go @@ -84,6 +84,10 @@ func (s *StdTxBuilder) SetTimeoutHeight(height uint64) { s.TimeoutHeight = height } +func (s *StdTxBuilder) SetFeePayer(_ sdk.AccAddress) {} + +func (s *StdTxBuilder) SetFeeGranter(_ sdk.AccAddress) {} + // StdTxConfig is a context.TxConfig for StdTx type StdTxConfig struct { Cdc *codec.LegacyAmino diff --git a/x/feegrant/ante/fee.go b/x/feegrant/ante/fee.go index 51800958ff30..a0d5379c9638 100644 --- a/x/feegrant/ante/fee.go +++ b/x/feegrant/ante/fee.go @@ -49,7 +49,7 @@ func NewDeductGrantedFeeDecorator(ak types.AccountKeeper, bk types.BankKeeper, k // signer, the handler will check if a fee grant has been authorized. If the // transaction's signer does not exist, it will be created. func (d DeductGrantedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { - feeTx, ok := tx.(GrantedFeeTx) + feeTx, ok := tx.(sdk.FeeTx) if !ok { return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a GrantedFeeTx") } @@ -61,7 +61,7 @@ func (d DeductGrantedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula fee := feeTx.GetFee() feePayer := feeTx.FeePayer() - txSigner := feeTx.MainSigner() + txSigner := feeTx.FeeGranter() // ensure the grant is allowed, if we request a different fee payer if !txSigner.Equals(feePayer) { diff --git a/x/feegrant/ante/fee_test.go b/x/feegrant/ante/fee_test.go index a1345ad916c6..5610697bc5f4 100644 --- a/x/feegrant/ante/fee_test.go +++ b/x/feegrant/ante/fee_test.go @@ -4,17 +4,20 @@ import ( "testing" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/stretchr/testify/suite" "github.com/tendermint/tendermint/crypto" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/simapp/helpers" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/signing" + "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/feegrant/ante" "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" @@ -81,7 +84,7 @@ func (suite *AnteTestSuite) SetupTest(isCheckTx bool) { suite.clientCtx = client.Context{}. WithTxConfig(encodingConfig.TxConfig) - suite.anteHandler = newAnteHandler(suite.app.AccountKeeper, suite.app.BankKeeper, suite.app.FeeGrantKeeper, authante.DefaultSigVerificationGasConsumer, encodingConfig.TxConfig.SignModeHandler()) + suite.anteHandler = simapp.NewAnteHandler(suite.app.AccountKeeper, suite.app.BankKeeper, suite.app.FeeGrantKeeper, authante.DefaultSigVerificationGasConsumer, encodingConfig.TxConfig.SignModeHandler()) } func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { @@ -89,6 +92,8 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { // setup app, ctx := suite.app, suite.ctx + protoTxCfg := tx.NewTxConfig(codec.NewProtoCodec(app.InterfaceRegistry()), tx.DefaultSignModes) + // this just tests our handler dfd := ante.NewDeductGrantedFeeDecorator(app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper) ourAnteHandler := sdk.ChainAnteDecorators(dfd) @@ -280,13 +285,22 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { tc := stc // to make scopelint happy suite.T().Run(name, func(t *testing.T) { // msg and signatures - fee := types.NewGrantedFee(100000, sdk.NewCoins(sdk.NewInt64Coin("atom", tc.fee)), tc.feeAccount) + // fee := types.NewGrantedFee(100000, sdk.NewCoins(sdk.NewInt64Coin("atom", tc.fee)), tc.feeAccount) + fee := sdk.NewCoins(sdk.NewInt64Coin("atom", tc.fee)) msgs := []sdk.Msg{testdata.NewTestMsg(tc.signer)} - privs, accNums, seqs := []cryptotypes.PrivKey{tc.signerKey}, []uint64{0}, []uint64{0} + _, accNums, seqs := []cryptotypes.PrivKey{tc.signerKey}, []uint64{0}, []uint64{0} + + // tx := types.NewTestTx(ctx, msgs, privs, accNums, seqs, fee) + + tx, err := helpers.GenTx(protoTxCfg, msgs, fee, helpers.DefaultGenTxGas, ctx.ChainID(), accNums, seqs, stc.signerKey) + protoTx, err := protoTxCfg.WrapTxBuilder(tx) + + suite.Require().NoError(err) - tx := types.NewTestTx(ctx, msgs, privs, accNums, seqs, fee) + protoTx.SetFeePayer(tc.feeAccount) + protoTx.SetFeeGranter(tc.signer) - _, err := tc.handler(ctx, tx, false) + _, err = tc.handler(ctx, protoTx.GetTx(), false) if tc.valid { suite.Require().NoError(err) } else { From 13eea6e889a20197356be5d25f3f7ba81bcdbfab Mon Sep 17 00:00:00 2001 From: atheesh Date: Sat, 5 Dec 2020 13:40:59 +0530 Subject: [PATCH 093/184] remove explicit signmode --- simapp/ante.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/simapp/ante.go b/simapp/ante.go index 8a0d331c141f..0af65940ced4 100644 --- a/simapp/ante.go +++ b/simapp/ante.go @@ -1,11 +1,9 @@ package simapp import ( - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" "github.com/cosmos/cosmos-sdk/x/auth/signing" feegrantante "github.com/cosmos/cosmos-sdk/x/feegrant/ante" feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" @@ -20,7 +18,6 @@ func NewAnteHandler( sigGasConsumer authante.SignatureVerificationGasConsumer, signModeHandler signing.SignModeHandler, ) sdk.AnteHandler { - txConfig := legacytx.StdTxConfig{Cdc: codec.NewLegacyAmino()} return sdk.ChainAnteDecorators( authante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first authante.NewRejectExtensionOptionsDecorator(), @@ -36,7 +33,7 @@ func NewAnteHandler( authante.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators authante.NewValidateSigCountDecorator(ak), authante.NewSigGasConsumeDecorator(ak, sigGasConsumer), - authante.NewSigVerificationDecorator(ak, txConfig.SignModeHandler()), + authante.NewSigVerificationDecorator(ak, signModeHandler), authante.NewIncrementSequenceDecorator(ak), // innermost AnteDecorator ) } From 07847ab3e8a3fc93e703d1d9ed5033436ee0f359 Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 7 Dec 2020 14:32:14 +0530 Subject: [PATCH 094/184] tests --- x/feegrant/ante/fee_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/x/feegrant/ante/fee_test.go b/x/feegrant/ante/fee_test.go index 5610697bc5f4..24194658bac6 100644 --- a/x/feegrant/ante/fee_test.go +++ b/x/feegrant/ante/fee_test.go @@ -247,14 +247,14 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { handler: anteHandlerStack, valid: false, }, - "valid fee grant without account (whole stack)": { - signerKey: priv3, - signer: addr3, - feeAccount: addr2, - fee: 50, - handler: anteHandlerStack, - valid: true, - }, + // "valid fee grant without account (whole stack)": { + // signerKey: priv3, + // signer: addr3, + // feeAccount: addr2, + // fee: 50, + // handler: anteHandlerStack, + // valid: true, + // }, "no fee grant (whole stack)": { signerKey: priv3, signer: addr3, From 85cd87e1c0bd6bebe68d50aed74528d94818ae9f Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 7 Dec 2020 16:16:21 +0530 Subject: [PATCH 095/184] Added `cli/query.go` --- proto/cosmos/feegrant/v1beta1/query.proto | 24 + x/feegrant/client/cli/query.go | 135 ++++++ x/feegrant/keeper/grpc_query.go | 41 ++ x/feegrant/types/query.pb.go | 549 +++++++++++++++++++++- 4 files changed, 732 insertions(+), 17 deletions(-) create mode 100644 x/feegrant/client/cli/query.go diff --git a/proto/cosmos/feegrant/v1beta1/query.proto b/proto/cosmos/feegrant/v1beta1/query.proto index f67980e5a9a7..2d8bfb8f86d1 100644 --- a/proto/cosmos/feegrant/v1beta1/query.proto +++ b/proto/cosmos/feegrant/v1beta1/query.proto @@ -3,6 +3,7 @@ package cosmos.feegrant.v1beta1; import "gogoproto/gogo.proto"; import "cosmos/feegrant/v1beta1/feegrant.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; @@ -10,6 +11,9 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; service Query { // FeeAllowance returns fee granted to the grantee by the granter. rpc FeeAllowance(QueryFeeAllowanceRequest) returns (QueryFeeAllowanceResponse) {} + + // FeeAllowances returns all the grants for address. + rpc FeeAllowances(QueryFeeAllowancesRequest) returns (QueryFeeAllowancesResponse) {} } // QueryFeeAllowanceRequest is the request type for the Query/FeeAllowance RPC method. @@ -26,3 +30,23 @@ message QueryFeeAllowanceResponse { // fee_allowance is a fee_allowance granted for grantee by granter. cosmos.feegrant.v1beta1.FeeAllowanceGrant fee_allowance = 1; } + +// QueryFeeAllowancesRequest is the request type for the Query/FeeAllowances RPC method. +message QueryFeeAllowancesRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string grantee = 1; + + // pagination defines an pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryFeeAllowancesResponse is the response type for the Query/FeeAllowances RPC method. +message QueryFeeAllowancesResponse { + // fee_allowance is a fee_allowance granted for grantee by granter. + repeated cosmos.feegrant.v1beta1.FeeAllowanceGrant fee_allowances = 1; + + // pagination defines an pagination for the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} diff --git a/x/feegrant/client/cli/query.go b/x/feegrant/client/cli/query.go new file mode 100644 index 000000000000..fdf4aedf1963 --- /dev/null +++ b/x/feegrant/client/cli/query.go @@ -0,0 +1,135 @@ +package cli + +import ( + "context" + "fmt" + "strings" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/version" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/spf13/cobra" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd() *cobra.Command { + feegrantQueryCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Querying commands for the feegrant module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + feegrantQueryCmd.AddCommand() + + return feegrantQueryCmd +} + +// GetCmdQueryFeeGrant returns cmd to query for a grant between granter and grantee. +func GetCmdQueryFeeGrant() *cobra.Command { + cmd := &cobra.Command{ + Use: "grant [granter] [grantee]", + Args: cobra.ExactArgs(2), + Short: "Query details of a single grant", + Long: strings.TrimSpace( + fmt.Sprintf(`Query details for a grant. +You can find the fee-grant of a granter and grantee. + +Example: +$ %s query feegrant grant [granter] [grantee] +`, version.AppName), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.ReadQueryCommandFlags(clientCtx, cmd.Flags()) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + granterAddr, err := sdk.AccAddressFromBech32(args[0]) + if err != nil { + return err + } + + granteeAddr, err := sdk.AccAddressFromBech32(args[1]) + if err != nil { + return err + } + + res, err := queryClient.FeeAllowance( + context.Background(), + &types.QueryFeeAllowanceRequest{ + Granter: granterAddr.String(), + Grantee: granteeAddr.String(), + }, + ) + + if err != nil { + return err + } + + return clientCtx.PrintOutput(res.FeeAllowance) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetCmdQueryGranteeFeeGrant returns cmd to query for all grants for a grantee. +func GetCmdQueryGranteeFeeGrant() *cobra.Command { + cmd := &cobra.Command{ + Use: "grants [grantee]", + Args: cobra.ExactArgs(1), + Short: "Query all grants of a grantee", + Long: strings.TrimSpace( + fmt.Sprintf(`Queries all the grants for a grantee address. + +Example: +$ %s query feegrant grants [grantee] +`, version.AppName), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.ReadQueryCommandFlags(clientCtx, cmd.Flags()) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + granteeAddr, err := sdk.AccAddressFromBech32(args[1]) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + res, err := queryClient.FeeAllowances( + context.Background(), + &types.QueryFeeAllowancesRequest{ + Grantee: granteeAddr.String(), + Pagination: pageReq, + }, + ) + + if err != nil { + return err + } + + return clientCtx.PrintOutput(res.FeeAllowances) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "grants") + + return cmd +} diff --git a/x/feegrant/keeper/grpc_query.go b/x/feegrant/keeper/grpc_query.go index d89c5b4d927a..1c65a785a28a 100644 --- a/x/feegrant/keeper/grpc_query.go +++ b/x/feegrant/keeper/grpc_query.go @@ -8,7 +8,9 @@ import ( "google.golang.org/grpc/status" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) @@ -61,3 +63,42 @@ func (q Keeper) FeeAllowance(c context.Context, req *types.QueryFeeAllowanceRequ }, }, nil } + +func (q Keeper) FeeAllowances(c context.Context, req *types.QueryFeeAllowancesRequest) (*types.QueryFeeAllowancesResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + if req.Grantee == "" { + return nil, status.Errorf(codes.InvalidArgument, "invalid grantee addr") + } + + granteeAddr, err := sdk.AccAddressFromBech32(req.Grantee) + if err != nil { + return nil, err + } + + ctx := sdk.UnwrapSDKContext(c) + + var grants []*types.FeeAllowanceGrant + + store := ctx.KVStore(q.storeKey) + grantsStore := prefix.NewStore(store, types.FeeAllowancePrefixByGrantee(granteeAddr)) + + pageRes, err := query.Paginate(grantsStore, req.Pagination, func(key []byte, value []byte) error { + var grant *types.FeeAllowanceGrant + + if err := q.cdc.UnmarshalBinaryBare(value, grant); err != nil { + return err + } + + grants = append(grants, grant) + return nil + }) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryFeeAllowancesResponse{FeeAllowances: grants, Pagination: pageRes}, nil +} diff --git a/x/feegrant/types/query.pb.go b/x/feegrant/types/query.pb.go index 80ce8852681f..603f1d4bd084 100644 --- a/x/feegrant/types/query.pb.go +++ b/x/feegrant/types/query.pb.go @@ -6,6 +6,7 @@ package types import ( context "context" fmt "fmt" + query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -113,9 +114,106 @@ func (m *QueryFeeAllowanceResponse) GetFeeAllowance() *FeeAllowanceGrant { return nil } +// QueryFeeAllowancesRequest is the request type for the Query/FeeAllowances RPC method. +type QueryFeeAllowancesRequest struct { + Grantee string `protobuf:"bytes,1,opt,name=grantee,proto3" json:"grantee,omitempty"` + // pagination defines an pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryFeeAllowancesRequest) Reset() { *m = QueryFeeAllowancesRequest{} } +func (m *QueryFeeAllowancesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryFeeAllowancesRequest) ProtoMessage() {} +func (*QueryFeeAllowancesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_59efc303945de53f, []int{2} +} +func (m *QueryFeeAllowancesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryFeeAllowancesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryFeeAllowancesRequest.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 *QueryFeeAllowancesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFeeAllowancesRequest.Merge(m, src) +} +func (m *QueryFeeAllowancesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryFeeAllowancesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFeeAllowancesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryFeeAllowancesRequest proto.InternalMessageInfo + +// QueryFeeAllowancesResponse is the response type for the Query/FeeAllowances RPC method. +type QueryFeeAllowancesResponse struct { + // fee_allowance is a fee_allowance granted for grantee by granter. + FeeAllowances []*FeeAllowanceGrant `protobuf:"bytes,1,rep,name=fee_allowances,json=feeAllowances,proto3" json:"fee_allowances,omitempty"` + // pagination defines an pagination for the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryFeeAllowancesResponse) Reset() { *m = QueryFeeAllowancesResponse{} } +func (m *QueryFeeAllowancesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryFeeAllowancesResponse) ProtoMessage() {} +func (*QueryFeeAllowancesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_59efc303945de53f, []int{3} +} +func (m *QueryFeeAllowancesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryFeeAllowancesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryFeeAllowancesResponse.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 *QueryFeeAllowancesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFeeAllowancesResponse.Merge(m, src) +} +func (m *QueryFeeAllowancesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryFeeAllowancesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFeeAllowancesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryFeeAllowancesResponse proto.InternalMessageInfo + +func (m *QueryFeeAllowancesResponse) GetFeeAllowances() []*FeeAllowanceGrant { + if m != nil { + return m.FeeAllowances + } + return nil +} + +func (m *QueryFeeAllowancesResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + func init() { proto.RegisterType((*QueryFeeAllowanceRequest)(nil), "cosmos.feegrant.v1beta1.QueryFeeAllowanceRequest") proto.RegisterType((*QueryFeeAllowanceResponse)(nil), "cosmos.feegrant.v1beta1.QueryFeeAllowanceResponse") + proto.RegisterType((*QueryFeeAllowancesRequest)(nil), "cosmos.feegrant.v1beta1.QueryFeeAllowancesRequest") + proto.RegisterType((*QueryFeeAllowancesResponse)(nil), "cosmos.feegrant.v1beta1.QueryFeeAllowancesResponse") } func init() { @@ -123,25 +221,33 @@ func init() { } var fileDescriptor_59efc303945de53f = []byte{ - // 288 bytes of a gzipped FileDescriptorProto + // 416 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4e, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0x4d, 0x2f, 0x4a, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x87, 0x28, 0xd2, 0x83, 0x29, 0xd2, 0x83, 0x2a, 0x92, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, - 0xab, 0xd1, 0x07, 0xb1, 0x20, 0xca, 0xa5, 0xd4, 0x70, 0x99, 0x09, 0xd7, 0x0f, 0x56, 0xa7, 0x14, - 0xc1, 0x25, 0x11, 0x08, 0xb2, 0xc5, 0x2d, 0x35, 0xd5, 0x31, 0x27, 0x27, 0xbf, 0x3c, 0x31, 0x2f, - 0x39, 0x35, 0x28, 0xb5, 0xb0, 0x34, 0xb5, 0xb8, 0x44, 0x48, 0x82, 0x8b, 0x1d, 0xac, 0x34, 0xb5, - 0x48, 0x82, 0x51, 0x81, 0x51, 0x83, 0x33, 0x08, 0xc6, 0x45, 0xc8, 0xa4, 0x4a, 0x30, 0x21, 0xcb, - 0xa4, 0x5a, 0x71, 0x74, 0x2c, 0x90, 0x67, 0x78, 0xb1, 0x40, 0x9e, 0x41, 0x29, 0x87, 0x4b, 0x12, - 0x8b, 0xc9, 0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, 0x42, 0xfe, 0x5c, 0xbc, 0x69, 0xa9, 0xa9, 0xf1, - 0x89, 0x30, 0x09, 0xb0, 0x05, 0xdc, 0x46, 0x5a, 0x7a, 0x38, 0x7c, 0xa9, 0x87, 0x6c, 0x8a, 0x3b, - 0x48, 0x26, 0x88, 0x27, 0x0d, 0x49, 0xc8, 0xa8, 0x81, 0x91, 0x8b, 0x15, 0x6c, 0x9d, 0x50, 0x39, - 0x17, 0x0f, 0xb2, 0x62, 0x21, 0x43, 0x9c, 0x66, 0xe2, 0xf2, 0xb8, 0x94, 0x11, 0x29, 0x5a, 0x20, - 0x3e, 0x52, 0x62, 0x70, 0x72, 0x3f, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, - 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, - 0xdd, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x68, 0xbc, 0x40, 0x28, - 0xdd, 0xe2, 0x94, 0x6c, 0xfd, 0x0a, 0x44, 0x24, 0x95, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, - 0xa3, 0xc6, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xe8, 0xbb, 0x8d, 0x3b, 0x18, 0x02, 0x00, 0x00, + 0xab, 0xd1, 0x07, 0xb1, 0x20, 0xca, 0xa5, 0xd4, 0x70, 0x99, 0x09, 0xd7, 0x0f, 0x51, 0xa7, 0x05, + 0x55, 0x97, 0x94, 0x58, 0x9c, 0x0a, 0xb1, 0x0f, 0xae, 0xb2, 0x20, 0x31, 0x3d, 0x33, 0x2f, 0xb1, + 0x24, 0x33, 0x3f, 0x0f, 0xa2, 0x56, 0x29, 0x82, 0x4b, 0x22, 0x10, 0xa4, 0xc2, 0x2d, 0x35, 0xd5, + 0x31, 0x27, 0x27, 0xbf, 0x3c, 0x31, 0x2f, 0x39, 0x35, 0x28, 0xb5, 0xb0, 0x34, 0xb5, 0xb8, 0x44, + 0x48, 0x82, 0x8b, 0x1d, 0x6c, 0x6c, 0x6a, 0x91, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x8c, + 0x8b, 0x90, 0x49, 0x95, 0x60, 0x42, 0x96, 0x49, 0xb5, 0xe2, 0xe8, 0x58, 0x20, 0xcf, 0xf0, 0x62, + 0x81, 0x3c, 0x83, 0x52, 0x0e, 0x97, 0x24, 0x16, 0x93, 0x8b, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x85, + 0xfc, 0xb9, 0x78, 0xd3, 0x52, 0x53, 0xe3, 0x13, 0x61, 0x12, 0x60, 0x0b, 0xb8, 0x8d, 0xb4, 0xf4, + 0x70, 0x84, 0x88, 0x1e, 0xb2, 0x29, 0xee, 0x20, 0x99, 0x20, 0x9e, 0x34, 0x24, 0x21, 0xa5, 0x76, + 0x46, 0x2c, 0xd6, 0x15, 0x63, 0xf8, 0x24, 0x15, 0xd5, 0x27, 0xa9, 0x42, 0x6e, 0x5c, 0x5c, 0x88, + 0x30, 0x01, 0x7b, 0x86, 0xdb, 0x48, 0x0d, 0xe6, 0x0a, 0x50, 0x00, 0xea, 0x41, 0x22, 0x0c, 0xe6, + 0x8e, 0x80, 0xc4, 0x74, 0x58, 0xf8, 0x04, 0x21, 0xe9, 0x44, 0xf2, 0xf7, 0x0e, 0x46, 0x2e, 0x29, + 0x6c, 0x2e, 0x81, 0xfa, 0x3c, 0x90, 0x8b, 0x0f, 0xc5, 0xe7, 0xc5, 0x12, 0x8c, 0x0a, 0xcc, 0x24, + 0x7a, 0x9d, 0x17, 0xd9, 0xeb, 0xc5, 0x42, 0xee, 0x58, 0xfc, 0xa0, 0x4e, 0xd0, 0x0f, 0x10, 0xf7, + 0x20, 0x7b, 0xc2, 0xe8, 0x0f, 0x23, 0x17, 0x2b, 0xd8, 0xe9, 0x42, 0xe5, 0x5c, 0x3c, 0xc8, 0xd6, + 0x0a, 0x19, 0xe2, 0x74, 0x1d, 0xae, 0xd4, 0x23, 0x65, 0x44, 0x8a, 0x16, 0x88, 0x63, 0x94, 0x18, + 0x84, 0xaa, 0xb8, 0x78, 0x51, 0xc2, 0x4d, 0x88, 0x04, 0x63, 0x60, 0xd1, 0x2d, 0x65, 0x4c, 0x92, + 0x1e, 0x98, 0xdd, 0x4e, 0xee, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, + 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, + 0x9b, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0xcd, 0x5c, 0x10, 0x4a, + 0xb7, 0x38, 0x25, 0x5b, 0xbf, 0x02, 0x91, 0x23, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, + 0x79, 0xcb, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x59, 0x97, 0xd4, 0x89, 0x05, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -156,8 +262,10 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { - // Returns any `FeeAllowance` (or `nil`), granted to the grantee by the granter. + // FeeAllowance returns fee granted to the grantee by the granter. FeeAllowance(ctx context.Context, in *QueryFeeAllowanceRequest, opts ...grpc.CallOption) (*QueryFeeAllowanceResponse, error) + // FeeAllowances returns all the grants for address. + FeeAllowances(ctx context.Context, in *QueryFeeAllowancesRequest, opts ...grpc.CallOption) (*QueryFeeAllowancesResponse, error) } type queryClient struct { @@ -177,10 +285,21 @@ func (c *queryClient) FeeAllowance(ctx context.Context, in *QueryFeeAllowanceReq return out, nil } +func (c *queryClient) FeeAllowances(ctx context.Context, in *QueryFeeAllowancesRequest, opts ...grpc.CallOption) (*QueryFeeAllowancesResponse, error) { + out := new(QueryFeeAllowancesResponse) + err := c.cc.Invoke(ctx, "/cosmos.feegrant.v1beta1.Query/FeeAllowances", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { - // Returns any `FeeAllowance` (or `nil`), granted to the grantee by the granter. + // FeeAllowance returns fee granted to the grantee by the granter. FeeAllowance(context.Context, *QueryFeeAllowanceRequest) (*QueryFeeAllowanceResponse, error) + // FeeAllowances returns all the grants for address. + FeeAllowances(context.Context, *QueryFeeAllowancesRequest) (*QueryFeeAllowancesResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -190,6 +309,9 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) FeeAllowance(ctx context.Context, req *QueryFeeAllowanceRequest) (*QueryFeeAllowanceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method FeeAllowance not implemented") } +func (*UnimplementedQueryServer) FeeAllowances(ctx context.Context, req *QueryFeeAllowancesRequest) (*QueryFeeAllowancesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FeeAllowances not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -213,6 +335,24 @@ func _Query_FeeAllowance_Handler(srv interface{}, ctx context.Context, dec func( return interceptor(ctx, in, info, handler) } +func _Query_FeeAllowances_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryFeeAllowancesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).FeeAllowances(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.feegrant.v1beta1.Query/FeeAllowances", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).FeeAllowances(ctx, req.(*QueryFeeAllowancesRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "cosmos.feegrant.v1beta1.Query", HandlerType: (*QueryServer)(nil), @@ -221,6 +361,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "FeeAllowance", Handler: _Query_FeeAllowance_Handler, }, + { + MethodName: "FeeAllowances", + Handler: _Query_FeeAllowances_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmos/feegrant/v1beta1/query.proto", @@ -298,6 +442,97 @@ func (m *QueryFeeAllowanceResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } +func (m *QueryFeeAllowancesRequest) 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 *QueryFeeAllowancesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFeeAllowancesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Grantee) > 0 { + i -= len(m.Grantee) + copy(dAtA[i:], m.Grantee) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Grantee))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryFeeAllowancesResponse) 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 *QueryFeeAllowancesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFeeAllowancesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.FeeAllowances) > 0 { + for iNdEx := len(m.FeeAllowances) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.FeeAllowances[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -339,6 +574,42 @@ func (m *QueryFeeAllowanceResponse) Size() (n int) { return n } +func (m *QueryFeeAllowancesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Grantee) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryFeeAllowancesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.FeeAllowances) > 0 { + for _, e := range m.FeeAllowances { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -551,6 +822,250 @@ func (m *QueryFeeAllowanceResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryFeeAllowancesRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryFeeAllowancesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFeeAllowancesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Grantee = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryFeeAllowancesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryFeeAllowancesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFeeAllowancesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeAllowances", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FeeAllowances = append(m.FeeAllowances, &FeeAllowanceGrant{}) + if err := m.FeeAllowances[len(m.FeeAllowances)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 From d8383331cf226ed78b556dffcbd5bda8f2dfafae Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 7 Dec 2020 16:53:42 +0530 Subject: [PATCH 096/184] Added tx.go in cli --- x/feegrant/client/cli/query.go | 5 +- x/feegrant/client/cli/tx.go | 125 +++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 x/feegrant/client/cli/tx.go diff --git a/x/feegrant/client/cli/query.go b/x/feegrant/client/cli/query.go index fdf4aedf1963..93b1fc379392 100644 --- a/x/feegrant/client/cli/query.go +++ b/x/feegrant/client/cli/query.go @@ -23,7 +23,10 @@ func GetQueryCmd() *cobra.Command { RunE: client.ValidateCmd, } - feegrantQueryCmd.AddCommand() + feegrantQueryCmd.AddCommand( + GetCmdQueryFeeGrant(), + GetCmdQueryGranteeFeeGrant(), + ) return feegrantQueryCmd } diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go new file mode 100644 index 000000000000..9cc1b5d511b3 --- /dev/null +++ b/x/feegrant/client/cli/tx.go @@ -0,0 +1,125 @@ +package cli + +import ( + "fmt" + "strings" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/simapp/simd/cmd" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/spf13/cobra" +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + feegrantTxCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Feegrant transactions subcommands", + Long: "Grant and revoke fee allowance for a grantee by a granter", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + feegrantTxCmd.AddCommand( + NewCmdFeeGrant(), + NewCmdRevokeFeegrant(), + ) + + return feegrantTxCmd +} + + +func NewCmdFeeGrant() *cobra.Command { + cmd:= &cobra.Command{ + Use: "grant [grantee] [limit] --from [granter]", + Short: "Grant Fee allowance to an address", + Long: strings.TrimSpace( + fmt.Sprintf( + `Grant authorization to use fee from your address. + +Examples: +%s tx %s grant cosmos1skjw... 1000stake --from=cosmos1skjw... + `, version.AppName, types.ModuleName, + ) + ), + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, Args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.ReadTxCommandFlags(clientCtx, cmd.Flags()) + if err != nil { + return err + } + + grantee, err := sdk.AccAddressFromBech32(args[0]) + if err != nil { + return err + } + + limit, err := sdk.ParseCoinsNormalized(args[2]) + if err != nil { + return err + } + + period := time.Duration(viper.GetInt64(FlagExpiration)) * time.Second + + basic := types.BasicFeeAllowance{ + SpendLimit: limit, + Expiration: period, + } + + msg, err := types.NewMsgGrantFeeAllowance(&basic, clientCtx.GetFromAddress(), grantee) + if err != nil { + return err + } + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + cmd.Flags().Int64(FlagExpiration, int64(365*24*60*60), "The second unit of time duration which the grant is active for the user; Default is a year") + return cmd +} + +func NewCmdRevokeFeegrant() *cobra.Command { + cmd := &cobra.Command{ + Use: "revoke [grantee_address] --from=[granter_address]", + Short: "revoke fee-grant", + Long: strings.TrimSpace( + fmt.Sprintf(`revoke fee grant from a granter to a grantee: + +Example: + $ %s tx %s revoke cosmos1skj.. --from=cosmos1skj.. + `, version.AppName, types.ModuleName), + ), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.ReadTxCommandFlags(clientCtx, cmd.Flags()) + if err != nil { + return err + } + + grantee, err := sdk.AccAddressFromBech32(args[0]) + if err != nil { + return err + } + + granter := clientCtx.GetFromAddress() + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} \ No newline at end of file From 695b143ed63bf38ecbaea27c295b6d1b7073069b Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 7 Dec 2020 21:09:59 +0530 Subject: [PATCH 097/184] updated `module.go` --- proto/cosmos/feegrant/v1beta1/query.proto | 9 +- x/feegrant/module.go | 20 +- x/feegrant/types/query.pb.go | 59 ++-- x/feegrant/types/query.pb.gw.go | 322 ++++++++++++++++++++++ 4 files changed, 369 insertions(+), 41 deletions(-) create mode 100644 x/feegrant/types/query.pb.gw.go diff --git a/proto/cosmos/feegrant/v1beta1/query.proto b/proto/cosmos/feegrant/v1beta1/query.proto index 2d8bfb8f86d1..df5021e5a0cc 100644 --- a/proto/cosmos/feegrant/v1beta1/query.proto +++ b/proto/cosmos/feegrant/v1beta1/query.proto @@ -4,16 +4,21 @@ package cosmos.feegrant.v1beta1; import "gogoproto/gogo.proto"; import "cosmos/feegrant/v1beta1/feegrant.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; +import "google/api/annotations.proto"; option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; // Query defines the gRPC querier service. service Query { // FeeAllowance returns fee granted to the grantee by the granter. - rpc FeeAllowance(QueryFeeAllowanceRequest) returns (QueryFeeAllowanceResponse) {} + rpc FeeAllowance(QueryFeeAllowanceRequest) returns (QueryFeeAllowanceResponse) { + option (google.api.http).get = "/cosmos/feegrant/v1beta1/granters/{granter}/grantees/{grantee}/grant"; + } // FeeAllowances returns all the grants for address. - rpc FeeAllowances(QueryFeeAllowancesRequest) returns (QueryFeeAllowancesResponse) {} + rpc FeeAllowances(QueryFeeAllowancesRequest) returns (QueryFeeAllowancesResponse) { + option (google.api.http).get = "/cosmos/feegrant/v1beta1/grants/{grantee}"; + } } // QueryFeeAllowanceRequest is the request type for the Query/FeeAllowance RPC method. diff --git a/x/feegrant/module.go b/x/feegrant/module.go index d7021a34d97b..ac3d6d376b2c 100644 --- a/x/feegrant/module.go +++ b/x/feegrant/module.go @@ -1,6 +1,7 @@ package feegrant import ( + "context" "encoding/json" "fmt" @@ -15,6 +16,7 @@ import ( cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/x/feegrant/client/cli" "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) @@ -39,8 +41,8 @@ func (AppModuleBasic) Name() string { // RegisterServices registers a gRPC query service to respond to the // module-specific gRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { - // TODO - // types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) } // RegisterLegacyAminoCodec registers the feegrant module's types for the given codec. @@ -87,27 +89,21 @@ func (a AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, config sdkclien // } // RegisterRESTRoutes registers the REST routes for the feegrant module. -func (AppModuleBasic) RegisterRESTRoutes(ctx sdkclient.Context, rtr *mux.Router) { - // TODO - // rest.RegisterRoutes(ctx, rtr) -} +func (AppModuleBasic) RegisterRESTRoutes(ctx sdkclient.Context, rtr *mux.Router) {} // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the feegrant module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) { - // TODO add grpc gateway in proto files - // types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) } // GetTxCmd returns the root tx command for the feegrant module. func (AppModuleBasic) GetTxCmd() *cobra.Command { - // TODO - return nil + return cli.GetTxCmd() } // GetQueryCmd returns no root query command for the feegrant module. func (AppModuleBasic) GetQueryCmd() *cobra.Command { - // TODO - return nil + return cli.GetQueryCmd() } // ---------------------------------------------------------------------------- diff --git a/x/feegrant/types/query.pb.go b/x/feegrant/types/query.pb.go index 603f1d4bd084..0dcfcbbcc567 100644 --- a/x/feegrant/types/query.pb.go +++ b/x/feegrant/types/query.pb.go @@ -10,6 +10,7 @@ import ( _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -221,33 +222,37 @@ func init() { } var fileDescriptor_59efc303945de53f = []byte{ - // 416 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4e, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0x4d, 0x2f, 0x4a, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, - 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, - 0x12, 0x87, 0x28, 0xd2, 0x83, 0x29, 0xd2, 0x83, 0x2a, 0x92, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, - 0xab, 0xd1, 0x07, 0xb1, 0x20, 0xca, 0xa5, 0xd4, 0x70, 0x99, 0x09, 0xd7, 0x0f, 0x51, 0xa7, 0x05, - 0x55, 0x97, 0x94, 0x58, 0x9c, 0x0a, 0xb1, 0x0f, 0xae, 0xb2, 0x20, 0x31, 0x3d, 0x33, 0x2f, 0xb1, - 0x24, 0x33, 0x3f, 0x0f, 0xa2, 0x56, 0x29, 0x82, 0x4b, 0x22, 0x10, 0xa4, 0xc2, 0x2d, 0x35, 0xd5, - 0x31, 0x27, 0x27, 0xbf, 0x3c, 0x31, 0x2f, 0x39, 0x35, 0x28, 0xb5, 0xb0, 0x34, 0xb5, 0xb8, 0x44, - 0x48, 0x82, 0x8b, 0x1d, 0x6c, 0x6c, 0x6a, 0x91, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x8c, - 0x8b, 0x90, 0x49, 0x95, 0x60, 0x42, 0x96, 0x49, 0xb5, 0xe2, 0xe8, 0x58, 0x20, 0xcf, 0xf0, 0x62, - 0x81, 0x3c, 0x83, 0x52, 0x0e, 0x97, 0x24, 0x16, 0x93, 0x8b, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x85, - 0xfc, 0xb9, 0x78, 0xd3, 0x52, 0x53, 0xe3, 0x13, 0x61, 0x12, 0x60, 0x0b, 0xb8, 0x8d, 0xb4, 0xf4, - 0x70, 0x84, 0x88, 0x1e, 0xb2, 0x29, 0xee, 0x20, 0x99, 0x20, 0x9e, 0x34, 0x24, 0x21, 0xa5, 0x76, - 0x46, 0x2c, 0xd6, 0x15, 0x63, 0xf8, 0x24, 0x15, 0xd5, 0x27, 0xa9, 0x42, 0x6e, 0x5c, 0x5c, 0x88, - 0x30, 0x01, 0x7b, 0x86, 0xdb, 0x48, 0x0d, 0xe6, 0x0a, 0x50, 0x00, 0xea, 0x41, 0x22, 0x0c, 0xe6, - 0x8e, 0x80, 0xc4, 0x74, 0x58, 0xf8, 0x04, 0x21, 0xe9, 0x44, 0xf2, 0xf7, 0x0e, 0x46, 0x2e, 0x29, - 0x6c, 0x2e, 0x81, 0xfa, 0x3c, 0x90, 0x8b, 0x0f, 0xc5, 0xe7, 0xc5, 0x12, 0x8c, 0x0a, 0xcc, 0x24, - 0x7a, 0x9d, 0x17, 0xd9, 0xeb, 0xc5, 0x42, 0xee, 0x58, 0xfc, 0xa0, 0x4e, 0xd0, 0x0f, 0x10, 0xf7, - 0x20, 0x7b, 0xc2, 0xe8, 0x0f, 0x23, 0x17, 0x2b, 0xd8, 0xe9, 0x42, 0xe5, 0x5c, 0x3c, 0xc8, 0xd6, - 0x0a, 0x19, 0xe2, 0x74, 0x1d, 0xae, 0xd4, 0x23, 0x65, 0x44, 0x8a, 0x16, 0x88, 0x63, 0x94, 0x18, - 0x84, 0xaa, 0xb8, 0x78, 0x51, 0xc2, 0x4d, 0x88, 0x04, 0x63, 0x60, 0xd1, 0x2d, 0x65, 0x4c, 0x92, - 0x1e, 0x98, 0xdd, 0x4e, 0xee, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, - 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, - 0x9b, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0xcd, 0x5c, 0x10, 0x4a, - 0xb7, 0x38, 0x25, 0x5b, 0xbf, 0x02, 0x91, 0x23, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, - 0x79, 0xcb, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x59, 0x97, 0xd4, 0x89, 0x05, 0x04, 0x00, 0x00, + // 476 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xbd, 0x6e, 0x13, 0x41, + 0x10, 0xc7, 0x6f, 0x8d, 0xf8, 0xda, 0xc4, 0x14, 0x2b, 0x24, 0x8e, 0x13, 0xba, 0x44, 0x46, 0x0a, + 0x10, 0x94, 0x5b, 0xd9, 0xe9, 0xe8, 0x40, 0xc8, 0x6e, 0x90, 0x20, 0xae, 0x10, 0x0d, 0x5a, 0x9b, + 0xf1, 0x62, 0xe1, 0xdc, 0x5e, 0x6e, 0xd7, 0x40, 0x84, 0x68, 0x68, 0xa0, 0x44, 0xe2, 0x05, 0xd2, + 0xf3, 0x02, 0xf4, 0x34, 0x94, 0x96, 0x68, 0x28, 0x91, 0x4d, 0xc1, 0x3b, 0xd0, 0xa0, 0xdb, 0x0f, + 0x7b, 0x2d, 0xee, 0x88, 0xae, 0xf2, 0x79, 0xe6, 0x3f, 0x33, 0xff, 0xdf, 0xec, 0x2e, 0xbe, 0x3e, + 0x14, 0xf2, 0x50, 0x48, 0x3a, 0x02, 0xe0, 0x39, 0x4b, 0x15, 0x7d, 0xd9, 0x1e, 0x80, 0x62, 0x6d, + 0x7a, 0x34, 0x85, 0xfc, 0x38, 0xc9, 0x72, 0xa1, 0x04, 0xb9, 0x62, 0x44, 0x89, 0x13, 0x25, 0x56, + 0x14, 0x5d, 0xe6, 0x82, 0x0b, 0xad, 0xa1, 0xc5, 0x97, 0x91, 0x47, 0x3b, 0x55, 0x3d, 0x97, 0xf5, + 0x46, 0xb7, 0x6b, 0x75, 0x03, 0x26, 0xc1, 0xcc, 0x5b, 0x2a, 0x33, 0xc6, 0xc7, 0x29, 0x53, 0x63, + 0x91, 0x5a, 0xed, 0x35, 0x2e, 0x04, 0x9f, 0x00, 0x65, 0xd9, 0x98, 0xb2, 0x34, 0x15, 0x4a, 0x27, + 0xa5, 0xc9, 0xb6, 0x1e, 0xe3, 0xf0, 0xa0, 0xa8, 0xef, 0x02, 0xdc, 0x9d, 0x4c, 0xc4, 0x2b, 0x96, + 0x0e, 0xa1, 0x0f, 0x47, 0x53, 0x90, 0x8a, 0x84, 0xf8, 0xbc, 0x1e, 0x0a, 0x79, 0x88, 0xb6, 0xd1, + 0xcd, 0x8b, 0x7d, 0xf7, 0x77, 0x95, 0x81, 0xb0, 0xe1, 0x67, 0xe0, 0xce, 0x85, 0x0f, 0x27, 0x5b, + 0xc1, 0xef, 0x93, 0xad, 0xa0, 0x35, 0xc1, 0x57, 0x4b, 0x3a, 0xcb, 0x4c, 0xa4, 0x12, 0xc8, 0x43, + 0xdc, 0x1c, 0x01, 0x3c, 0x65, 0x2e, 0xa1, 0x07, 0x6c, 0x74, 0x76, 0x93, 0x8a, 0x7d, 0x25, 0x7e, + 0x97, 0x5e, 0x91, 0xe9, 0x6f, 0x8e, 0xbc, 0x50, 0xeb, 0x3d, 0x2a, 0x19, 0x27, 0xff, 0x21, 0x81, + 0x75, 0x12, 0x20, 0x5d, 0x8c, 0x57, 0x1b, 0xd3, 0x30, 0x1b, 0x9d, 0x1d, 0xe7, 0xa2, 0x58, 0x6f, + 0x62, 0x8e, 0xd3, 0xf9, 0x78, 0xc4, 0xb8, 0xdb, 0x4f, 0xdf, 0xab, 0xf4, 0xb8, 0xbf, 0x20, 0x1c, + 0x95, 0x39, 0xb1, 0xe4, 0x07, 0xf8, 0xd2, 0x1a, 0xb9, 0x0c, 0xd1, 0xf6, 0x99, 0x9a, 0xe8, 0x4d, + 0x1f, 0x5d, 0x92, 0x5e, 0x09, 0xc3, 0x8d, 0x53, 0x19, 0x8c, 0x1f, 0x1f, 0xa2, 0xf3, 0xa7, 0x81, + 0xcf, 0x6a, 0xeb, 0xe4, 0x2b, 0xc2, 0x9b, 0xfe, 0x5c, 0xd2, 0xae, 0xb4, 0x57, 0x75, 0x7d, 0xa2, + 0x4e, 0x9d, 0x12, 0xe3, 0xa6, 0xf5, 0xe0, 0xdd, 0xf7, 0x5f, 0x9f, 0x1a, 0x5d, 0x72, 0x9f, 0x56, + 0xbd, 0x04, 0x7b, 0x05, 0x25, 0x7d, 0x63, 0xbf, 0xde, 0xda, 0x10, 0x2c, 0x43, 0x60, 0x43, 0xe4, + 0x33, 0xc2, 0xcd, 0xb5, 0x53, 0x20, 0x35, 0x3c, 0xb9, 0xcb, 0x13, 0xed, 0xd7, 0xaa, 0xb1, 0x20, + 0x6d, 0x0d, 0x72, 0x9b, 0xdc, 0xfa, 0x3f, 0x88, 0xe7, 0xf9, 0x5e, 0xef, 0xdb, 0x3c, 0x46, 0xb3, + 0x79, 0x8c, 0x7e, 0xce, 0x63, 0xf4, 0x71, 0x11, 0x07, 0xb3, 0x45, 0x1c, 0xfc, 0x58, 0xc4, 0xc1, + 0x93, 0x3d, 0x3e, 0x56, 0xcf, 0xa7, 0x83, 0x64, 0x28, 0x0e, 0x5d, 0x3b, 0xf3, 0xb3, 0x27, 0x9f, + 0xbd, 0xa0, 0xaf, 0x57, 0xbd, 0xd5, 0x71, 0x06, 0x72, 0x70, 0x4e, 0x3f, 0xed, 0xfd, 0xbf, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x90, 0xce, 0xea, 0x72, 0xa2, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/feegrant/types/query.pb.gw.go b/x/feegrant/types/query.pb.gw.go new file mode 100644 index 000000000000..448e7beb63f6 --- /dev/null +++ b/x/feegrant/types/query.pb.gw.go @@ -0,0 +1,322 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: cosmos/feegrant/v1beta1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage + +func request_Query_FeeAllowance_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFeeAllowanceRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["granter"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "granter") + } + + protoReq.Granter, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "granter", err) + } + + val, ok = pathParams["grantee"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "grantee") + } + + protoReq.Grantee, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "grantee", err) + } + + msg, err := client.FeeAllowance(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_FeeAllowance_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFeeAllowanceRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["granter"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "granter") + } + + protoReq.Granter, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "granter", err) + } + + val, ok = pathParams["grantee"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "grantee") + } + + protoReq.Grantee, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "grantee", err) + } + + msg, err := server.FeeAllowance(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_FeeAllowances_0 = &utilities.DoubleArray{Encoding: map[string]int{"grantee": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_FeeAllowances_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFeeAllowancesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["grantee"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "grantee") + } + + protoReq.Grantee, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "grantee", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_FeeAllowances_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.FeeAllowances(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_FeeAllowances_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFeeAllowancesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["grantee"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "grantee") + } + + protoReq.Grantee, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "grantee", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_FeeAllowances_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.FeeAllowances(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_FeeAllowance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_FeeAllowance_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_FeeAllowance_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_FeeAllowances_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_FeeAllowances_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_FeeAllowances_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_FeeAllowance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_FeeAllowance_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_FeeAllowance_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_FeeAllowances_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_FeeAllowances_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_FeeAllowances_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_FeeAllowance_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7}, []string{"cosmos", "feegrant", "v1beta1", "granters", "granter", "grantees", "grantee", "grant"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_FeeAllowances_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "feegrant", "v1beta1", "grants", "grantee"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_FeeAllowance_0 = runtime.ForwardResponseMessage + + forward_Query_FeeAllowances_0 = runtime.ForwardResponseMessage +) From 9ea89d92594023668177e025d8ebab0e93283e23 Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 7 Dec 2020 23:19:46 +0530 Subject: [PATCH 098/184] resolve errors in tx.go --- x/feegrant/client/cli/query.go | 5 ++++- x/feegrant/client/cli/tx.go | 41 ++++++++++++++++++++++++---------- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/x/feegrant/client/cli/query.go b/x/feegrant/client/cli/query.go index 93b1fc379392..e8735015a9d9 100644 --- a/x/feegrant/client/cli/query.go +++ b/x/feegrant/client/cli/query.go @@ -127,7 +127,10 @@ $ %s query feegrant grants [grantee] return err } - return clientCtx.PrintOutput(res.FeeAllowances) + // TODO + fmt.Println(res.FeeAllowances) + // return clientCtx.PrintOutput(res.FeeAllowances) + return nil }, } diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index 9cc1b5d511b3..d46ad27e828f 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -3,11 +3,22 @@ package cli import ( "fmt" "strings" + "time" + + "github.com/spf13/cobra" + "github.com/spf13/viper" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/simapp/simd/cmd" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/feegrant/types" - "github.com/spf13/cobra" +) + +// flag for feegrant module +const ( + FlagExpiration = "expiration" ) // GetTxCmd returns the transaction commands for this module @@ -29,10 +40,9 @@ func GetTxCmd() *cobra.Command { return feegrantTxCmd } - func NewCmdFeeGrant() *cobra.Command { - cmd:= &cobra.Command{ - Use: "grant [grantee] [limit] --from [granter]", + cmd := &cobra.Command{ + Use: "grant [grantee] [limit] --from [granter]", Short: "Grant Fee allowance to an address", Long: strings.TrimSpace( fmt.Sprintf( @@ -41,10 +51,10 @@ func NewCmdFeeGrant() *cobra.Command { Examples: %s tx %s grant cosmos1skjw... 1000stake --from=cosmos1skjw... `, version.AppName, types.ModuleName, - ) + ), ), Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, Args []string) error { + RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) clientCtx, err := client.ReadTxCommandFlags(clientCtx, cmd.Flags()) if err != nil { @@ -62,10 +72,12 @@ Examples: } period := time.Duration(viper.GetInt64(FlagExpiration)) * time.Second + _ = period // TODO basic := types.BasicFeeAllowance{ SpendLimit: limit, - Expiration: period, + // TODO + // Expiration: period, } msg, err := types.NewMsgGrantFeeAllowance(&basic, clientCtx.GetFromAddress(), grantee) @@ -78,7 +90,7 @@ Examples: } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, + }, } flags.AddTxFlagsToCmd(cmd) @@ -88,7 +100,7 @@ Examples: func NewCmdRevokeFeegrant() *cobra.Command { cmd := &cobra.Command{ - Use: "revoke [grantee_address] --from=[granter_address]", + Use: "revoke [grantee_address] --from=[granter_address]", Short: "revoke fee-grant", Long: strings.TrimSpace( fmt.Sprintf(`revoke fee grant from a granter to a grantee: @@ -112,14 +124,19 @@ Example: granter := clientCtx.GetFromAddress() + msg := types.MsgRevokeFeeAllowance{ + Granter: granter, + Grantee: grantee, + } + if err := msg.ValidateBasic(); err != nil { return err } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) }, - } + } flags.AddTxFlagsToCmd(cmd) return cmd -} \ No newline at end of file +} From debec042b70beedff8a41d2ec3dc34951f2a3203 Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 8 Dec 2020 20:17:50 +0530 Subject: [PATCH 099/184] Add fee payer gentx func --- simapp/helpers/test_helpers.go | 64 ++++++++++++++++++++++++++++++++++ x/feegrant/ante/fee_test.go | 8 ++--- x/feegrant/client/cli/tx.go | 4 ++- 3 files changed, 69 insertions(+), 7 deletions(-) diff --git a/simapp/helpers/test_helpers.go b/simapp/helpers/test_helpers.go index 9ccecbd976c4..75331e206547 100644 --- a/simapp/helpers/test_helpers.go +++ b/simapp/helpers/test_helpers.go @@ -78,3 +78,67 @@ func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, ch return tx.GetTx(), nil } + +// GenTxFee generates a signed mock transaction with fee payer and fee granter. +func GenTxWithFeePayer(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, + accSeqs []uint64, feePayer sdk.AccAddress, feeGranter sdk.AccAddress, priv ...cryptotypes.PrivKey) (sdk.Tx, error) { + sigs := make([]signing.SignatureV2, len(priv)) + + // create a random length memo + r := rand.New(rand.NewSource(time.Now().UnixNano())) + + memo := simulation.RandStringOfLength(r, simulation.RandIntBetween(r, 0, 100)) + + signMode := gen.SignModeHandler().DefaultMode() + + // 1st round: set SignatureV2 with empty signatures, to set correct + // signer infos. + for i, p := range priv { + sigs[i] = signing.SignatureV2{ + PubKey: p.PubKey(), + Data: &signing.SingleSignatureData{ + SignMode: signMode, + }, + Sequence: accSeqs[i], + } + } + + tx := gen.NewTxBuilder() + err := tx.SetMsgs(msgs...) + if err != nil { + return nil, err + } + err = tx.SetSignatures(sigs...) + if err != nil { + return nil, err + } + tx.SetMemo(memo) + tx.SetFeeAmount(feeAmt) + tx.SetGasLimit(gas) + tx.SetFeePayer(feePayer) + tx.SetFeeGranter(feeGranter) + + // 2nd round: once all signer infos are set, every signer can sign. + for i, p := range priv { + signerData := authsign.SignerData{ + ChainID: chainID, + AccountNumber: accNums[i], + Sequence: accSeqs[i], + } + signBytes, err := gen.SignModeHandler().GetSignBytes(signMode, signerData, tx.GetTx()) + if err != nil { + panic(err) + } + sig, err := p.Sign(signBytes) + if err != nil { + panic(err) + } + sigs[i].Data.(*signing.SingleSignatureData).Signature = sig + err = tx.SetSignatures(sigs...) + if err != nil { + panic(err) + } + } + + return tx.GetTx(), nil +} diff --git a/x/feegrant/ante/fee_test.go b/x/feegrant/ante/fee_test.go index 24194658bac6..d0496d82e206 100644 --- a/x/feegrant/ante/fee_test.go +++ b/x/feegrant/ante/fee_test.go @@ -292,15 +292,11 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { // tx := types.NewTestTx(ctx, msgs, privs, accNums, seqs, fee) - tx, err := helpers.GenTx(protoTxCfg, msgs, fee, helpers.DefaultGenTxGas, ctx.ChainID(), accNums, seqs, stc.signerKey) - protoTx, err := protoTxCfg.WrapTxBuilder(tx) + tx, err := helpers.GenTxWithFeePayer(protoTxCfg, msgs, fee, helpers.DefaultGenTxGas, ctx.ChainID(), accNums, seqs, tc.feeAccount, tc.signer, stc.signerKey) suite.Require().NoError(err) - protoTx.SetFeePayer(tc.feeAccount) - protoTx.SetFeeGranter(tc.signer) - - _, err = tc.handler(ctx, protoTx.GetTx(), false) + _, err = tc.handler(ctx, tx, false) if tc.valid { suite.Require().NoError(err) } else { diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index d46ad27e828f..8fe34d002143 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -66,6 +66,8 @@ Examples: return err } + granter := clientCtx.GetFromAddress() + limit, err := sdk.ParseCoinsNormalized(args[2]) if err != nil { return err @@ -80,7 +82,7 @@ Examples: // Expiration: period, } - msg, err := types.NewMsgGrantFeeAllowance(&basic, clientCtx.GetFromAddress(), grantee) + msg, err := types.NewMsgGrantFeeAllowance(&basic, granter, grantee) if err != nil { return err } From 865f70ea718f5aa0b2186c80fff4aaccddf0f430 Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 8 Dec 2020 20:35:05 +0530 Subject: [PATCH 100/184] updated tx --- x/feegrant/client/cli/tx.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index 8fe34d002143..5bddb7c2597e 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -74,12 +74,10 @@ Examples: } period := time.Duration(viper.GetInt64(FlagExpiration)) * time.Second - _ = period // TODO basic := types.BasicFeeAllowance{ SpendLimit: limit, - // TODO - // Expiration: period, + Expiration: types.ExpiresAtTime(time.Now().Add(period)), } msg, err := types.NewMsgGrantFeeAllowance(&basic, granter, grantee) From 3b43fef1f42a3291d7448b5b2f56667f8c6fe918 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 9 Dec 2020 12:10:03 +0530 Subject: [PATCH 101/184] fixed error --- x/feegrant/ante/fee.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/feegrant/ante/fee.go b/x/feegrant/ante/fee.go index a0d5379c9638..3aa4daca6ccc 100644 --- a/x/feegrant/ante/fee.go +++ b/x/feegrant/ante/fee.go @@ -64,7 +64,7 @@ func (d DeductGrantedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula txSigner := feeTx.FeeGranter() // ensure the grant is allowed, if we request a different fee payer - if !txSigner.Equals(feePayer) { + if txSigner != nil && !txSigner.Equals(feePayer) { err := d.k.UseGrantedFees(ctx, feePayer, txSigner, fee) if err != nil { return ctx, sdkerrors.Wrapf(err, "%s not allowed to pay fees from %s", txSigner, feePayer) From 3c69591d652db62c70ddfbbea62583531e28c4f9 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 9 Dec 2020 12:10:48 +0530 Subject: [PATCH 102/184] WIP: cli tests --- x/feegrant/client/cli/cli_test.go | 277 ++++++++++++++++++++++++++++++ x/feegrant/client/cli/tx.go | 10 +- x/feegrant/keeper/grpc_query.go | 2 + x/feegrant/keeper/keeper.go | 7 +- x/feegrant/keeper/msg_server.go | 5 +- 5 files changed, 296 insertions(+), 5 deletions(-) create mode 100644 x/feegrant/client/cli/cli_test.go diff --git a/x/feegrant/client/cli/cli_test.go b/x/feegrant/client/cli/cli_test.go new file mode 100644 index 000000000000..f0b681164df5 --- /dev/null +++ b/x/feegrant/client/cli/cli_test.go @@ -0,0 +1,277 @@ +package cli_test + +import ( + "fmt" + "testing" + + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/cosmos/cosmos-sdk/testutil/network" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/client/cli" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/gogo/protobuf/proto" + "github.com/stretchr/testify/suite" +) + +type IntegrationTestSuite struct { + suite.Suite + + cfg network.Config + network *network.Network + addedGranter sdk.AccAddress + addedGrantee sdk.AccAddress + addedGrant types.FeeAllowanceI +} + +func (s *IntegrationTestSuite) SetupSuite() { + s.T().Log("setting up integration test suite") + + if testing.Short() { + s.T().Skip("skipping test in unit-tests mode.") + } + + cfg := network.DefaultConfig() + cfg.NumValidators = 2 + + s.cfg = cfg + s.network = network.New(s.T(), cfg) + + _, err := s.network.WaitForHeight(1) + s.Require().NoError(err) + + val := s.network.Validators[0] + granter := val.Address + grantee := s.network.Validators[1].Address + + clientCtx := val.ClientCtx + commonFlags := []string{ + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + args := append( + []string{ + grantee.String(), + "100steak", + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + }, + commonFlags..., + ) + + cmd := cli.NewCmdFeeGrant() + + _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, args) + s.Require().NoError(err) + + s.addedGranter = granter + s.addedGrantee = grantee +} + +func (s *IntegrationTestSuite) TearDownSuite() { + s.T().Log("tearing down integration test suite") + s.network.Cleanup() +} + +func (s *IntegrationTestSuite) TestCmdGetFeeGrant() { + val := s.network.Validators[0] + granter := val.Address + grantee := s.network.Validators[1].Address + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + respType proto.Message + }{ + { + "valid req", + []string{ + granter.String(), + grantee.String(), + }, + false, + &types.FeeAllowanceGrant{ + Granter: granter, + Grantee: grantee, + // Allowance: , + }, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetCmdQueryFeeGrant() + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + fmt.Println("out, err", out, err) + s.Require().NotNil(nil) + + // if tc.expectErr { + // s.Require().Error(err) + // } else { + // s.Require().NoError(err) + // s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + // txResp := tc.respType.(*sdk.TxResponse) + // s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + // } + }) + } +} + +func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { + val := s.network.Validators[0] + granter := val.Address + grantee := s.network.Validators[1].Address + clientCtx := val.ClientCtx + + commonFlags := []string{ + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + testCases := []struct { + name string + args []string + expectErr bool + respType proto.Message + expectedCode uint32 + }{ + { + "wromg grantee address", + append( + []string{ + "wrong_grantee", + "100steak", + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + }, + commonFlags..., + ), + true, + nil, + 0, + }, + { + "Valid fee grant", + append( + []string{ + grantee.String(), + "100steak", + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + }, + commonFlags..., + ), + false, + &sdk.TxResponse{}, + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.NewCmdFeeGrant() + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() { + val := s.network.Validators[0] + granter := s.addedGranter + grantee := s.addedGrantee + clientCtx := val.ClientCtx + + commonFlags := []string{ + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + testCases := []struct { + name string + args []string + expectErr bool + respType proto.Message + expectedCode uint32 + }{ + { + "invalid grantee", + append( + []string{ + "wrong_grantee", + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + }, + commonFlags..., + ), + true, + nil, + 0, + }, + { + "Non existed grant", + append( + []string{ + "cosmos1aeuqja06474dfrj7uqsvukm6rael982kk89mqr", + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + }, + commonFlags..., + ), + false, + &sdk.TxResponse{}, + 4, + }, + { + "Valid revoke", + append( + []string{ + grantee.String(), + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + }, + commonFlags..., + ), + false, + &sdk.TxResponse{}, + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.NewCmdRevokeFeegrant() + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} + +func TestIntegrationTestSuite(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) +} diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index 5bddb7c2597e..582681942e4c 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -6,7 +6,6 @@ import ( "time" "github.com/spf13/cobra" - "github.com/spf13/viper" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -68,12 +67,17 @@ Examples: granter := clientCtx.GetFromAddress() - limit, err := sdk.ParseCoinsNormalized(args[2]) + limit, err := sdk.ParseCoinsNormalized(args[1]) if err != nil { return err } - period := time.Duration(viper.GetInt64(FlagExpiration)) * time.Second + exp, err := cmd.Flags().GetInt64(FlagExpiration) + if err != nil { + return err + } + + period := time.Duration(exp) * time.Second basic := types.BasicFeeAllowance{ SpendLimit: limit, diff --git a/x/feegrant/keeper/grpc_query.go b/x/feegrant/keeper/grpc_query.go index 1c65a785a28a..5eb89c7a66f4 100644 --- a/x/feegrant/keeper/grpc_query.go +++ b/x/feegrant/keeper/grpc_query.go @@ -59,6 +59,8 @@ func (q Keeper) FeeAllowance(c context.Context, req *types.QueryFeeAllowanceRequ return &types.QueryFeeAllowanceResponse{ FeeAllowance: &types.FeeAllowanceGrant{ + Granter: granterAddr, + Grantee: granteeAddr, Allowance: feeAllowanceAny, }, }, nil diff --git a/x/feegrant/keeper/keeper.go b/x/feegrant/keeper/keeper.go index a3d9d10554cf..1b62372bffae 100644 --- a/x/feegrant/keeper/keeper.go +++ b/x/feegrant/keeper/keeper.go @@ -46,9 +46,13 @@ func (k Keeper) GrantFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddre } // RevokeFeeAllowance removes an existing grant -func (k Keeper) RevokeFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddress) { +func (k Keeper) RevokeFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddress) error { store := ctx.KVStore(k.storeKey) key := types.FeeAllowanceKey(granter, grantee) + _, found := k.GetFeeGrant(ctx, granter, grantee) + if !found { + return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "fee-grant not found") + } store.Delete(key) @@ -59,6 +63,7 @@ func (k Keeper) RevokeFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddr sdk.NewAttribute(types.AttributeKeyGrantee, grantee.String()), ), ) + return nil } // GetFeeAllowance returns the allowance between the granter and grantee. diff --git a/x/feegrant/keeper/msg_server.go b/x/feegrant/keeper/msg_server.go index cd4d3d92c2b0..417140e2de6c 100644 --- a/x/feegrant/keeper/msg_server.go +++ b/x/feegrant/keeper/msg_server.go @@ -53,7 +53,10 @@ func (k msgServer) RevokeFeeAllowance(goCtx context.Context, msg *types.MsgRevok return nil, err } - k.Keeper.RevokeFeeAllowance(ctx, granter, grantee) + err = k.Keeper.RevokeFeeAllowance(ctx, granter, grantee) + if err != nil { + return nil, err + } return &types.MsgRevokeFeeAllowanceResponse{}, nil } From ec9dad3a1525a305ce41e9a3b04f4f5ad8823c74 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 9 Dec 2020 12:18:09 +0530 Subject: [PATCH 103/184] fix query error --- x/feegrant/client/cli/query.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/feegrant/client/cli/query.go b/x/feegrant/client/cli/query.go index e8735015a9d9..c069b9667ee0 100644 --- a/x/feegrant/client/cli/query.go +++ b/x/feegrant/client/cli/query.go @@ -75,7 +75,7 @@ $ %s query feegrant grant [granter] [grantee] return err } - return clientCtx.PrintOutput(res.FeeAllowance) + return clientCtx.PrintProto(res.FeeAllowance) }, } From f69d5dd0ccdfbb771dce2d69a7ac5b596323881c Mon Sep 17 00:00:00 2001 From: atheesh Date: Fri, 11 Dec 2020 13:37:40 +0530 Subject: [PATCH 104/184] fix tests --- x/feegrant/ante/fee_test.go | 58 +++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/x/feegrant/ante/fee_test.go b/x/feegrant/ante/fee_test.go index d0496d82e206..f18a6655ef49 100644 --- a/x/feegrant/ante/fee_test.go +++ b/x/feegrant/ante/fee_test.go @@ -107,6 +107,12 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { priv3, _, addr3 := testdata.KeyTestPubAddr() priv4, _, addr4 := testdata.KeyTestPubAddr() + nonExistedAccNums := make(map[string]uint64) + nonExistedAccNums[addr1.String()] = 0 + nonExistedAccNums[addr2.String()] = 1 + nonExistedAccNums[addr3.String()] = 2 + nonExistedAccNums[addr4.String()] = 3 + // Set addr1 with insufficient funds acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1) app.AccountKeeper.SetAccount(ctx, acc1) @@ -137,12 +143,13 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { // }) cases := map[string]struct { - signerKey cryptotypes.PrivKey - signer sdk.AccAddress - feeAccount sdk.AccAddress - handler sdk.AnteHandler - fee int64 - valid bool + signerKey cryptotypes.PrivKey + signer sdk.AccAddress + feeAccount sdk.AccAddress + feeAccountKey cryptotypes.PrivKey + handler sdk.AnteHandler + fee int64 + valid bool }{ "paying with low funds (only ours)": { signerKey: priv1, @@ -211,7 +218,6 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { handler: ourAnteHandler, valid: false, }, - "paying with low funds (whole stack)": { signerKey: priv1, signer: addr1, @@ -247,14 +253,15 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { handler: anteHandlerStack, valid: false, }, - // "valid fee grant without account (whole stack)": { - // signerKey: priv3, - // signer: addr3, - // feeAccount: addr2, - // fee: 50, - // handler: anteHandlerStack, - // valid: true, - // }, + "valid fee grant without account (whole stack)": { + signerKey: priv3, + signer: addr3, + feeAccountKey: priv2, + feeAccount: addr2, + fee: 50, + handler: anteHandlerStack, + valid: true, + }, "no fee grant (whole stack)": { signerKey: priv3, signer: addr3, @@ -284,19 +291,28 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { for name, stc := range cases { tc := stc // to make scopelint happy suite.T().Run(name, func(t *testing.T) { - // msg and signatures - // fee := types.NewGrantedFee(100000, sdk.NewCoins(sdk.NewInt64Coin("atom", tc.fee)), tc.feeAccount) fee := sdk.NewCoins(sdk.NewInt64Coin("atom", tc.fee)) msgs := []sdk.Msg{testdata.NewTestMsg(tc.signer)} - _, accNums, seqs := []cryptotypes.PrivKey{tc.signerKey}, []uint64{0}, []uint64{0} - // tx := types.NewTestTx(ctx, msgs, privs, accNums, seqs, fee) + acc := app.AccountKeeper.GetAccount(ctx, tc.signer) + privs, accNums, seqs := []cryptotypes.PrivKey{tc.signerKey}, []uint64{nonExistedAccNums[tc.signer.String()]}, []uint64{0} + if acc != nil { + privs, accNums, seqs = []cryptotypes.PrivKey{tc.signerKey}, []uint64{acc.GetAccountNumber()}, []uint64{acc.GetSequence()} + } - tx, err := helpers.GenTxWithFeePayer(protoTxCfg, msgs, fee, helpers.DefaultGenTxGas, ctx.ChainID(), accNums, seqs, tc.feeAccount, tc.signer, stc.signerKey) + if tc.feeAccountKey != nil { + feeAcc := app.AccountKeeper.GetAccount(ctx, tc.feeAccount) + if feeAcc != nil { + privs, accNums, seqs = append(privs, tc.feeAccountKey), append(accNums, feeAcc.GetAccountNumber()), append(seqs, feeAcc.GetSequence()) + } else { + privs, accNums, seqs = append(privs, tc.feeAccountKey), append(accNums, nonExistedAccNums[tc.feeAccount.String()]), append(seqs, 0) + } + } + tx, err := helpers.GenTxWithFeePayer(protoTxCfg, msgs, fee, helpers.DefaultGenTxGas, ctx.ChainID(), accNums, seqs, tc.feeAccount, tc.signer, privs...) suite.Require().NoError(err) - _, err = tc.handler(ctx, tx, false) + if tc.valid { suite.Require().NoError(err) } else { From e424be4b324833bc24cfea26c6a5831da2badc03 Mon Sep 17 00:00:00 2001 From: atheesh Date: Fri, 11 Dec 2020 13:38:20 +0530 Subject: [PATCH 105/184] Unused types and funcs --- x/feegrant/ante/fee.go | 26 +- x/feegrant/types/test_common.go | 36 +-- x/feegrant/types/tx.go | 496 ++++++++++++++++---------------- 3 files changed, 279 insertions(+), 279 deletions(-) diff --git a/x/feegrant/ante/fee.go b/x/feegrant/ante/fee.go index 3aa4daca6ccc..32c1bbd2095d 100644 --- a/x/feegrant/ante/fee.go +++ b/x/feegrant/ante/fee.go @@ -11,19 +11,19 @@ import ( "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) -var ( - _ GrantedFeeTx = (*types.FeeGrantTx)(nil) // assert FeeGrantTx implements GrantedFeeTx -) - -// GrantedFeeTx defines the interface to be implemented by Tx to use the GrantedFeeDecorator -type GrantedFeeTx interface { - sdk.Tx - - GetGas() uint64 - GetFee() sdk.Coins - FeePayer() sdk.AccAddress - MainSigner() sdk.AccAddress -} +// var ( +// _ GrantedFeeTx = (*types.FeeGrantTx)(nil) // assert FeeGrantTx implements GrantedFeeTx +// ) + +// // GrantedFeeTx defines the interface to be implemented by Tx to use the GrantedFeeDecorator +// type GrantedFeeTx interface { +// sdk.Tx + +// GetGas() uint64 +// GetFee() sdk.Coins +// FeePayer() sdk.AccAddress +// MainSigner() sdk.AccAddress +// } // DeductGrantedFeeDecorator deducts fees from the first signer of the tx // If the first signer does not have the funds to pay for the fees, return with InsufficientFunds error diff --git a/x/feegrant/types/test_common.go b/x/feegrant/types/test_common.go index 50e064e81156..671cbffcdb0f 100644 --- a/x/feegrant/types/test_common.go +++ b/x/feegrant/types/test_common.go @@ -2,26 +2,26 @@ package types -import ( - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" +// import ( +// cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" -) +// sdk "github.com/cosmos/cosmos-sdk/types" +// "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" +// ) -func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []cryptotypes.PrivKey, accNums []uint64, seqs []uint64, fee GrantedFee) sdk.Tx { - sigs := make([]legacytx.StdSignature, len(privs)) - for i, priv := range privs { - signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], fee, msgs, "") +// func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []cryptotypes.PrivKey, accNums []uint64, seqs []uint64, fee GrantedFee) sdk.Tx { +// sigs := make([]legacytx.StdSignature, len(privs)) +// for i, priv := range privs { +// signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], fee, msgs, "") - sig, err := priv.Sign(signBytes) - if err != nil { - panic(err) - } +// sig, err := priv.Sign(signBytes) +// if err != nil { +// panic(err) +// } - sigs[i] = legacytx.StdSignature{PubKey: priv.PubKey(), Signature: sig} - } +// sigs[i] = legacytx.StdSignature{PubKey: priv.PubKey(), Signature: sig} +// } - tx := NewFeeGrantTx(msgs, fee, sigs, "") - return tx -} +// tx := NewFeeGrantTx(msgs, fee, sigs, "") +// return tx +// } diff --git a/x/feegrant/types/tx.go b/x/feegrant/types/tx.go index 67ba75589dcd..4c19286e1339 100644 --- a/x/feegrant/types/tx.go +++ b/x/feegrant/types/tx.go @@ -1,250 +1,250 @@ package types -import ( - "encoding/json" - - kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - - legacycodec "github.com/cosmos/cosmos-sdk/codec/legacy" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" -) - -var ( - _ sdk.Tx = FeeGrantTx{} - - maxGasWanted = uint64((1 << 63) - 1) -) - -// FeeGrantTx wraps a Msg with Fee and Signatures, -// adding the ability to delegate the fee payment -// NOTE: the first signature responsible for paying fees, either directly, -// or must be authorized to spend from the provided Fee.FeeAccount -type FeeGrantTx struct { - Msgs []sdk.Msg `json:"msg" yaml:"msg"` - Fee GrantedFee `json:"fee" yaml:"fee"` - Signatures []legacytx.StdSignature `json:"signatures" yaml:"signatures"` - Memo string `json:"memo" yaml:"memo"` - FeeAccount sdk.AccAddress `json:"fee_account" yaml:"fee_account"` -} - -func NewFeeGrantTx(msgs []sdk.Msg, fee GrantedFee, sigs []legacytx.StdSignature, memo string) FeeGrantTx { - return FeeGrantTx{ - Msgs: msgs, - Fee: fee, - Signatures: sigs, - Memo: memo, - } -} - -// GetMsgs returns the all the transaction's messages. -func (tx FeeGrantTx) GetMsgs() []sdk.Msg { return tx.Msgs } - -// ValidateBasic does a simple and lightweight validation check that doesn't -// require access to any other information. -func (tx FeeGrantTx) ValidateBasic() error { - stdSigs := tx.GetSignatures() - - if tx.Fee.Gas > maxGasWanted { - return sdkerrors.Wrapf( - sdkerrors.ErrInvalidRequest, - "invalid gas supplied; %d > %d", tx.Fee.Gas, maxGasWanted, - ) - } - if tx.Fee.Amount.IsAnyNegative() { - return sdkerrors.Wrapf( - sdkerrors.ErrInsufficientFee, - "invalid fee provided: %s", tx.Fee.Amount, - ) - } - if len(stdSigs) == 0 { - return sdkerrors.ErrNoSignatures - } - if len(stdSigs) != len(tx.GetSigners()) { - return sdkerrors.Wrapf( - sdkerrors.ErrUnauthorized, - "wrong number of signers; expected %d, got %d", tx.GetSigners(), len(stdSigs), - ) - } - - return nil -} - -// CountSubKeys counts the total number of keys for a multi-sig public key. -func CountSubKeys(pub cryptotypes.PubKey) int { - v, ok := pub.(*kmultisig.LegacyAminoPubKey) - if !ok { - return 1 - } - - numKeys := 0 - for _, subkey := range v.GetPubKeys() { - numKeys += CountSubKeys(subkey) - } - - return numKeys -} - -// GetSigners returns the addresses that must sign the transaction. -// Addresses are returned in a deterministic order. -// They are accumulated from the GetSigners method for each Msg -// in the order they appear in tx.GetMsgs(). -// Duplicate addresses will be omitted. -func (tx FeeGrantTx) GetSigners() []sdk.AccAddress { - seen := map[string]bool{} - var signers []sdk.AccAddress - for _, msg := range tx.GetMsgs() { - for _, addr := range msg.GetSigners() { - if !seen[addr.String()] { - signers = append(signers, addr) - seen[addr.String()] = true - } - } - } - return signers -} - -// GetMemo returns the memo -func (tx FeeGrantTx) GetMemo() string { return tx.Memo } - -// GetSignatures returns the signature of signers who signed the Msg. -// CONTRACT: Length returned is same as length of -// pubkeys returned from MsgKeySigners, and the order -// matches. -// CONTRACT: If the signature is missing (ie the Msg is -// invalid), then the corresponding signature is -// .Empty(). -func (tx FeeGrantTx) GetSignatures() [][]byte { - sigs := make([][]byte, len(tx.Signatures)) - for i, stdSig := range tx.Signatures { - sigs[i] = stdSig.Signature - } - return sigs -} - -// GetPubkeys returns the pubkeys of signers if the pubkey is included in the signature -// If pubkey is not included in the signature, then nil is in the slice instead -func (tx FeeGrantTx) GetPubKeys() []cryptotypes.PubKey { - pks := make([]cryptotypes.PubKey, len(tx.Signatures)) - - for i, stdSig := range tx.Signatures { - pks[i] = stdSig.GetPubKey() - } - return pks -} - -// GetSignBytes returns the signBytes of the tx for a given signer -func (tx FeeGrantTx) GetSignBytes(ctx sdk.Context, acc authtypes.AccountI) []byte { - genesis := ctx.BlockHeight() == 0 - chainID := ctx.ChainID() - var accNum uint64 - if !genesis { - accNum = acc.GetAccountNumber() - } - return StdSignBytes(chainID, accNum, acc.GetSequence(), tx.Fee, tx.Msgs, tx.Memo) -} - -// GetGas returns the Gas in GrantedFee -func (tx FeeGrantTx) GetGas() uint64 { return tx.Fee.Gas } - -// GetFee returns the FeeAmount in GrantedFee -func (tx FeeGrantTx) GetFee() sdk.Coins { return tx.Fee.Amount } - -// FeePayer returns the address that is responsible for paying fee -// This can be explicily set in GrantedFee, or defaults to MainSigner -func (tx FeeGrantTx) FeePayer() sdk.AccAddress { - if len(tx.Fee.FeeAccount) != 0 { - return tx.Fee.FeeAccount - } - return tx.MainSigner() -} - -// MainSigner returns the first signer of the tx, by default this -// account is responsible for fees, if not explicitly set. -func (tx FeeGrantTx) MainSigner() sdk.AccAddress { - if len(tx.GetSigners()) != 0 { - return tx.GetSigners()[0] - } - return sdk.AccAddress{} -} - -// GrantedFee includes the amount of coins paid in fees and the maximum -// gas to be used by the transaction. The ratio yields an effective "gasprice", -// which must be above some miminum to be accepted into the mempool. -type GrantedFee struct { - Amount sdk.Coins `json:"amount" yaml:"amount"` - Gas uint64 `json:"gas" yaml:"gas"` - FeeAccount sdk.AccAddress `json:"fee_account,omitempty" yaml:"fee_account"` -} - -// NewGrantedFee returns a new instance of GrantedFee -func NewGrantedFee(gas uint64, amount sdk.Coins, feeAccount sdk.AccAddress) GrantedFee { - return GrantedFee{ - Amount: amount, - Gas: gas, - FeeAccount: feeAccount, - } -} - -// Bytes for signing later -func (fee GrantedFee) Bytes() []byte { - // normalize. XXX - // this is a sign of something ugly - // (in the lcd_test, client side its null, - // server side its []) - if len(fee.Amount) == 0 { - fee.Amount = sdk.NewCoins() - } - - bz, err := legacycodec.Cdc.MarshalJSON(fee) - if err != nil { - panic(err) - } - return bz -} - -// GasPrices returns the gas prices for a GrantedFee. -// -// NOTE: The gas prices returned are not the true gas prices that were -// originally part of the submitted transaction because the fee is computed -// as fee = ceil(gasWanted * gasPrices). -func (fee GrantedFee) GasPrices() sdk.DecCoins { - return sdk.NewDecCoinsFromCoins(fee.Amount...).QuoDec(sdk.NewDec(int64(fee.Gas))) -} - -// DelegatedSignDoc is replay-prevention structure. -// It includes the result of msg.GetSignBytes(), -// as well as the ChainID (prevent cross chain replay) -// and the Sequence numbers for each signature (prevent -// inchain replay and enforce tx ordering per account). -type DelegatedSignDoc struct { - AccountNumber uint64 `json:"account_number" yaml:"account_number"` - ChainID string `json:"chain_id" yaml:"chain_id"` - Fee json.RawMessage `json:"fee" yaml:"fee"` - Memo string `json:"memo" yaml:"memo"` - Msgs []json.RawMessage `json:"msgs" yaml:"msgs"` - Sequence uint64 `json:"sequence" yaml:"sequence"` -} - -// StdSignBytes returns the bytes to sign for a transaction. -func StdSignBytes(chainID string, accnum uint64, sequence uint64, fee GrantedFee, msgs []sdk.Msg, memo string) []byte { - msgsBytes := make([]json.RawMessage, 0, len(msgs)) - for _, msg := range msgs { - msgsBytes = append(msgsBytes, json.RawMessage(msg.GetSignBytes())) - } - bz, err := legacycodec.Cdc.MarshalJSON(DelegatedSignDoc{ - AccountNumber: accnum, - ChainID: chainID, - Fee: json.RawMessage(fee.Bytes()), - Memo: memo, - Msgs: msgsBytes, - Sequence: sequence, - }) - if err != nil { - panic(err) - } - return sdk.MustSortJSON(bz) -} +// import ( +// "encoding/json" + +// kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" +// cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + +// legacycodec "github.com/cosmos/cosmos-sdk/codec/legacy" +// sdk "github.com/cosmos/cosmos-sdk/types" +// sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +// "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" +// authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" +// ) + +// var ( +// _ sdk.Tx = FeeGrantTx{} + +// maxGasWanted = uint64((1 << 63) - 1) +// ) + +// // FeeGrantTx wraps a Msg with Fee and Signatures, +// // adding the ability to delegate the fee payment +// // NOTE: the first signature responsible for paying fees, either directly, +// // or must be authorized to spend from the provided Fee.FeeAccount +// type FeeGrantTx struct { +// Msgs []sdk.Msg `json:"msg" yaml:"msg"` +// Fee GrantedFee `json:"fee" yaml:"fee"` +// Signatures []legacytx.StdSignature `json:"signatures" yaml:"signatures"` +// Memo string `json:"memo" yaml:"memo"` +// FeeAccount sdk.AccAddress `json:"fee_account" yaml:"fee_account"` +// } + +// func NewFeeGrantTx(msgs []sdk.Msg, fee GrantedFee, sigs []legacytx.StdSignature, memo string) FeeGrantTx { +// return FeeGrantTx{ +// Msgs: msgs, +// Fee: fee, +// Signatures: sigs, +// Memo: memo, +// } +// } + +// // GetMsgs returns the all the transaction's messages. +// func (tx FeeGrantTx) GetMsgs() []sdk.Msg { return tx.Msgs } + +// // ValidateBasic does a simple and lightweight validation check that doesn't +// // require access to any other information. +// func (tx FeeGrantTx) ValidateBasic() error { +// stdSigs := tx.GetSignatures() + +// if tx.Fee.Gas > maxGasWanted { +// return sdkerrors.Wrapf( +// sdkerrors.ErrInvalidRequest, +// "invalid gas supplied; %d > %d", tx.Fee.Gas, maxGasWanted, +// ) +// } +// if tx.Fee.Amount.IsAnyNegative() { +// return sdkerrors.Wrapf( +// sdkerrors.ErrInsufficientFee, +// "invalid fee provided: %s", tx.Fee.Amount, +// ) +// } +// if len(stdSigs) == 0 { +// return sdkerrors.ErrNoSignatures +// } +// if len(stdSigs) != len(tx.GetSigners()) { +// return sdkerrors.Wrapf( +// sdkerrors.ErrUnauthorized, +// "wrong number of signers1; expected %d, got %d", tx.GetSigners(), len(stdSigs), +// ) +// } + +// return nil +// } + +// // CountSubKeys counts the total number of keys for a multi-sig public key. +// func CountSubKeys(pub cryptotypes.PubKey) int { +// v, ok := pub.(*kmultisig.LegacyAminoPubKey) +// if !ok { +// return 1 +// } + +// numKeys := 0 +// for _, subkey := range v.GetPubKeys() { +// numKeys += CountSubKeys(subkey) +// } + +// return numKeys +// } + +// // GetSigners returns the addresses that must sign the transaction. +// // Addresses are returned in a deterministic order. +// // They are accumulated from the GetSigners method for each Msg +// // in the order they appear in tx.GetMsgs(). +// // Duplicate addresses will be omitted. +// func (tx FeeGrantTx) GetSigners() []sdk.AccAddress { +// seen := map[string]bool{} +// var signers []sdk.AccAddress +// for _, msg := range tx.GetMsgs() { +// for _, addr := range msg.GetSigners() { +// if !seen[addr.String()] { +// signers = append(signers, addr) +// seen[addr.String()] = true +// } +// } +// } +// return signers +// } + +// // GetMemo returns the memo +// func (tx FeeGrantTx) GetMemo() string { return tx.Memo } + +// // GetSignatures returns the signature of signers who signed the Msg. +// // CONTRACT: Length returned is same as length of +// // pubkeys returned from MsgKeySigners, and the order +// // matches. +// // CONTRACT: If the signature is missing (ie the Msg is +// // invalid), then the corresponding signature is +// // .Empty(). +// func (tx FeeGrantTx) GetSignatures() [][]byte { +// sigs := make([][]byte, len(tx.Signatures)) +// for i, stdSig := range tx.Signatures { +// sigs[i] = stdSig.Signature +// } +// return sigs +// } + +// // GetPubkeys returns the pubkeys of signers if the pubkey is included in the signature +// // If pubkey is not included in the signature, then nil is in the slice instead +// func (tx FeeGrantTx) GetPubKeys() []cryptotypes.PubKey { +// pks := make([]cryptotypes.PubKey, len(tx.Signatures)) + +// for i, stdSig := range tx.Signatures { +// pks[i] = stdSig.GetPubKey() +// } +// return pks +// } + +// // GetSignBytes returns the signBytes of the tx for a given signer +// func (tx FeeGrantTx) GetSignBytes(ctx sdk.Context, acc authtypes.AccountI) []byte { +// genesis := ctx.BlockHeight() == 0 +// chainID := ctx.ChainID() +// var accNum uint64 +// if !genesis { +// accNum = acc.GetAccountNumber() +// } +// return StdSignBytes(chainID, accNum, acc.GetSequence(), tx.Fee, tx.Msgs, tx.Memo) +// } + +// // GetGas returns the Gas in GrantedFee +// func (tx FeeGrantTx) GetGas() uint64 { return tx.Fee.Gas } + +// // GetFee returns the FeeAmount in GrantedFee +// func (tx FeeGrantTx) GetFee() sdk.Coins { return tx.Fee.Amount } + +// // FeePayer returns the address that is responsible for paying fee +// // This can be explicily set in GrantedFee, or defaults to MainSigner +// func (tx FeeGrantTx) FeePayer() sdk.AccAddress { +// if len(tx.Fee.FeeAccount) != 0 { +// return tx.Fee.FeeAccount +// } +// return tx.MainSigner() +// } + +// // MainSigner returns the first signer of the tx, by default this +// // account is responsible for fees, if not explicitly set. +// func (tx FeeGrantTx) MainSigner() sdk.AccAddress { +// if len(tx.GetSigners()) != 0 { +// return tx.GetSigners()[0] +// } +// return sdk.AccAddress{} +// } + +// // GrantedFee includes the amount of coins paid in fees and the maximum +// // gas to be used by the transaction. The ratio yields an effective "gasprice", +// // which must be above some miminum to be accepted into the mempool. +// type GrantedFee struct { +// Amount sdk.Coins `json:"amount" yaml:"amount"` +// Gas uint64 `json:"gas" yaml:"gas"` +// FeeAccount sdk.AccAddress `json:"fee_account,omitempty" yaml:"fee_account"` +// } + +// // NewGrantedFee returns a new instance of GrantedFee +// func NewGrantedFee(gas uint64, amount sdk.Coins, feeAccount sdk.AccAddress) GrantedFee { +// return GrantedFee{ +// Amount: amount, +// Gas: gas, +// FeeAccount: feeAccount, +// } +// } + +// // Bytes for signing later +// func (fee GrantedFee) Bytes() []byte { +// // normalize. XXX +// // this is a sign of something ugly +// // (in the lcd_test, client side its null, +// // server side its []) +// if len(fee.Amount) == 0 { +// fee.Amount = sdk.NewCoins() +// } + +// bz, err := legacycodec.Cdc.MarshalJSON(fee) +// if err != nil { +// panic(err) +// } +// return bz +// } + +// // GasPrices returns the gas prices for a GrantedFee. +// // +// // NOTE: The gas prices returned are not the true gas prices that were +// // originally part of the submitted transaction because the fee is computed +// // as fee = ceil(gasWanted * gasPrices). +// func (fee GrantedFee) GasPrices() sdk.DecCoins { +// return sdk.NewDecCoinsFromCoins(fee.Amount...).QuoDec(sdk.NewDec(int64(fee.Gas))) +// } + +// // DelegatedSignDoc is replay-prevention structure. +// // It includes the result of msg.GetSignBytes(), +// // as well as the ChainID (prevent cross chain replay) +// // and the Sequence numbers for each signature (prevent +// // inchain replay and enforce tx ordering per account). +// type DelegatedSignDoc struct { +// AccountNumber uint64 `json:"account_number" yaml:"account_number"` +// ChainID string `json:"chain_id" yaml:"chain_id"` +// Fee json.RawMessage `json:"fee" yaml:"fee"` +// Memo string `json:"memo" yaml:"memo"` +// Msgs []json.RawMessage `json:"msgs" yaml:"msgs"` +// Sequence uint64 `json:"sequence" yaml:"sequence"` +// } + +// // StdSignBytes returns the bytes to sign for a transaction. +// func StdSignBytes(chainID string, accnum uint64, sequence uint64, fee GrantedFee, msgs []sdk.Msg, memo string) []byte { +// msgsBytes := make([]json.RawMessage, 0, len(msgs)) +// for _, msg := range msgs { +// msgsBytes = append(msgsBytes, json.RawMessage(msg.GetSignBytes())) +// } +// bz, err := legacycodec.Cdc.MarshalJSON(DelegatedSignDoc{ +// AccountNumber: accnum, +// ChainID: chainID, +// Fee: json.RawMessage(fee.Bytes()), +// Memo: memo, +// Msgs: msgsBytes, +// Sequence: sequence, +// }) +// if err != nil { +// panic(err) +// } +// return sdk.MustSortJSON(bz) +// } From a5483f93c9fb14408d69b79b4b3805b627f80c6d Mon Sep 17 00:00:00 2001 From: atheesh Date: Sun, 13 Dec 2020 22:17:30 +0530 Subject: [PATCH 106/184] fix tests --- client/tx_config.go | 1 - simapp/helpers/test_helpers.go | 9 +++++++-- x/feegrant/ante/fee.go | 28 ++++++++++++++++------------ x/feegrant/ante/fee_test.go | 11 +---------- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/client/tx_config.go b/client/tx_config.go index 02030c323572..cfa6c3343107 100644 --- a/client/tx_config.go +++ b/client/tx_config.go @@ -43,6 +43,5 @@ type ( SetGasLimit(limit uint64) SetTimeoutHeight(height uint64) SetFeePayer(feePayer sdk.AccAddress) - SetFeeGranter(feeGranter sdk.AccAddress) } ) diff --git a/simapp/helpers/test_helpers.go b/simapp/helpers/test_helpers.go index 75331e206547..255d3a7496fe 100644 --- a/simapp/helpers/test_helpers.go +++ b/simapp/helpers/test_helpers.go @@ -18,6 +18,12 @@ const ( SimAppChainID = "simulation-app" ) +type txBuilder interface { + client.TxBuilder + + SetFeeGranter(feeGranter sdk.AccAddress) +} + // GenTx generates a signed mock transaction. func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey) (sdk.Tx, error) { sigs := make([]signing.SignatureV2, len(priv)) @@ -103,7 +109,7 @@ func GenTxWithFeePayer(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, ga } } - tx := gen.NewTxBuilder() + tx := gen.NewTxBuilder().(txBuilder) err := tx.SetMsgs(msgs...) if err != nil { return nil, err @@ -115,7 +121,6 @@ func GenTxWithFeePayer(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, ga tx.SetMemo(memo) tx.SetFeeAmount(feeAmt) tx.SetGasLimit(gas) - tx.SetFeePayer(feePayer) tx.SetFeeGranter(feeGranter) // 2nd round: once all signer infos are set, every signer can sign. diff --git a/x/feegrant/ante/fee.go b/x/feegrant/ante/fee.go index 32c1bbd2095d..3f13bf16e08a 100644 --- a/x/feegrant/ante/fee.go +++ b/x/feegrant/ante/fee.go @@ -61,27 +61,31 @@ func (d DeductGrantedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula fee := feeTx.GetFee() feePayer := feeTx.FeePayer() - txSigner := feeTx.FeeGranter() + feeGranter := feeTx.FeeGranter() + + deductFeesFrom := feePayer // ensure the grant is allowed, if we request a different fee payer - if txSigner != nil && !txSigner.Equals(feePayer) { - err := d.k.UseGrantedFees(ctx, feePayer, txSigner, fee) + if feeGranter != nil && !feeGranter.Equals(feePayer) { + err := d.k.UseGrantedFees(ctx, feeGranter, feePayer, fee) if err != nil { - return ctx, sdkerrors.Wrapf(err, "%s not allowed to pay fees from %s", txSigner, feePayer) + return ctx, sdkerrors.Wrapf(err, "%s not allowed to pay fees from %s", feeGranter, feePayer) } - // if there was a valid grant, ensure that the txSigner account exists (we create it if needed) - signerAcc := d.ak.GetAccount(ctx, txSigner) + // if there was a valid grant, ensure that the feeGranter account exists (we create it if needed) + signerAcc := d.ak.GetAccount(ctx, feePayer) if signerAcc == nil { - signerAcc = d.ak.NewAccountWithAddress(ctx, txSigner) + signerAcc = d.ak.NewAccountWithAddress(ctx, feePayer) d.ak.SetAccount(ctx, signerAcc) } + + deductFeesFrom = feeGranter } - // now, either way, we know that we are authorized to deduct the fees from the feePayer account - feePayerAcc := d.ak.GetAccount(ctx, feePayer) - if feePayerAcc == nil { - return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "fee payer address: %s does not exist", feePayer) + // now, either way, we know that we are authorized to deduct the fees from the deductFeesFrom account + deductFeesFromAcc := d.ak.GetAccount(ctx, deductFeesFrom) + if deductFeesFromAcc == nil { + return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "fee payer address: %s does not exist", deductFeesFrom) } // move on if there is no fee to deduct @@ -90,7 +94,7 @@ func (d DeductGrantedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula } // deduct fee if non-zero - err = authante.DeductFees(d.bk, ctx, feePayerAcc, fee) + err = authante.DeductFees(d.bk, ctx, deductFeesFromAcc, fee) if err != nil { return ctx, err } diff --git a/x/feegrant/ante/fee_test.go b/x/feegrant/ante/fee_test.go index f18a6655ef49..a89b1ac952ca 100644 --- a/x/feegrant/ante/fee_test.go +++ b/x/feegrant/ante/fee_test.go @@ -300,16 +300,7 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { privs, accNums, seqs = []cryptotypes.PrivKey{tc.signerKey}, []uint64{acc.GetAccountNumber()}, []uint64{acc.GetSequence()} } - if tc.feeAccountKey != nil { - feeAcc := app.AccountKeeper.GetAccount(ctx, tc.feeAccount) - if feeAcc != nil { - privs, accNums, seqs = append(privs, tc.feeAccountKey), append(accNums, feeAcc.GetAccountNumber()), append(seqs, feeAcc.GetSequence()) - } else { - privs, accNums, seqs = append(privs, tc.feeAccountKey), append(accNums, nonExistedAccNums[tc.feeAccount.String()]), append(seqs, 0) - } - } - - tx, err := helpers.GenTxWithFeePayer(protoTxCfg, msgs, fee, helpers.DefaultGenTxGas, ctx.ChainID(), accNums, seqs, tc.feeAccount, tc.signer, privs...) + tx, err := helpers.GenTxWithFeePayer(protoTxCfg, msgs, fee, helpers.DefaultGenTxGas, ctx.ChainID(), accNums, seqs, nil, tc.feeAccount, privs...) suite.Require().NoError(err) _, err = tc.handler(ctx, tx, false) From 1907c0c97094de3a909a3335e0e113e1b722aa49 Mon Sep 17 00:00:00 2001 From: atheesh Date: Sun, 13 Dec 2020 22:21:08 +0530 Subject: [PATCH 107/184] rename helper func to create tx --- simapp/helpers/test_helpers.go | 6 +++--- x/feegrant/ante/fee_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/simapp/helpers/test_helpers.go b/simapp/helpers/test_helpers.go index 255d3a7496fe..b82bc2b4a8f1 100644 --- a/simapp/helpers/test_helpers.go +++ b/simapp/helpers/test_helpers.go @@ -85,9 +85,9 @@ func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, ch return tx.GetTx(), nil } -// GenTxFee generates a signed mock transaction with fee payer and fee granter. -func GenTxWithFeePayer(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, - accSeqs []uint64, feePayer sdk.AccAddress, feeGranter sdk.AccAddress, priv ...cryptotypes.PrivKey) (sdk.Tx, error) { +// GenTxWithFeeGranter generates a signed mock transaction with fee granter field set with a given address. +func GenTxWithFeeGranter(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, + accSeqs []uint64, feeGranter sdk.AccAddress, priv ...cryptotypes.PrivKey) (sdk.Tx, error) { sigs := make([]signing.SignatureV2, len(priv)) // create a random length memo diff --git a/x/feegrant/ante/fee_test.go b/x/feegrant/ante/fee_test.go index a89b1ac952ca..e0ac991e31de 100644 --- a/x/feegrant/ante/fee_test.go +++ b/x/feegrant/ante/fee_test.go @@ -300,7 +300,7 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { privs, accNums, seqs = []cryptotypes.PrivKey{tc.signerKey}, []uint64{acc.GetAccountNumber()}, []uint64{acc.GetSequence()} } - tx, err := helpers.GenTxWithFeePayer(protoTxCfg, msgs, fee, helpers.DefaultGenTxGas, ctx.ChainID(), accNums, seqs, nil, tc.feeAccount, privs...) + tx, err := helpers.GenTxWithFeeGranter(protoTxCfg, msgs, fee, helpers.DefaultGenTxGas, ctx.ChainID(), accNums, seqs, tc.feeAccount, privs...) suite.Require().NoError(err) _, err = tc.handler(ctx, tx, false) From eedc5a5bdc707fd490f7897ba4fbe0e71ab48476 Mon Sep 17 00:00:00 2001 From: atheesh Date: Sun, 13 Dec 2020 22:28:22 +0530 Subject: [PATCH 108/184] remove unused --- x/feegrant/ante/fee_test.go | 40 +---- x/feegrant/types/test_common.go | 27 ---- x/feegrant/types/tx.go | 250 -------------------------------- 3 files changed, 1 insertion(+), 316 deletions(-) delete mode 100644 x/feegrant/types/test_common.go delete mode 100644 x/feegrant/types/tx.go diff --git a/x/feegrant/ante/fee_test.go b/x/feegrant/ante/fee_test.go index e0ac991e31de..f1cd718491e9 100644 --- a/x/feegrant/ante/fee_test.go +++ b/x/feegrant/ante/fee_test.go @@ -15,41 +15,12 @@ import ( "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" - authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - "github.com/cosmos/cosmos-sdk/x/auth/signing" "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/feegrant/ante" - "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) -// newAnteHandler is just like auth.NewAnteHandler, except we use the DeductGrantedFeeDecorator -// in order to allow payment of fees via a grant. -// -// This is used for our full-stack tests -func newAnteHandler( - ak authkeeper.AccountKeeper, bankKeeper authtypes.BankKeeper, - dk keeper.Keeper, sigGasConsumer authante.SignatureVerificationGasConsumer, - signModeHandler signing.SignModeHandler, -) sdk.AnteHandler { - return sdk.ChainAnteDecorators( - authante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first - authante.NewMempoolFeeDecorator(), - authante.NewValidateBasicDecorator(), - authante.NewValidateMemoDecorator(ak), - authante.NewConsumeGasForTxSizeDecorator(ak), - // DeductGrantedFeeDecorator will create an empty account if we sign with no tokens but valid validation - // This must be before SetPubKey, ValidateSigCount, SigVerification, which error if account doesn't exist yet - ante.NewDeductGrantedFeeDecorator(ak, bankKeeper, dk), - authante.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators - authante.NewValidateSigCountDecorator(ak), - authante.NewSigGasConsumeDecorator(ak, sigGasConsumer), - authante.NewSigVerificationDecorator(ak, signModeHandler), - authante.NewIncrementSequenceDecorator(ak), // innermost AnteDecorator - ) -} - // AnteTestSuite is a test suite to be used with ante handler tests. type AnteTestSuite struct { suite.Suite @@ -61,15 +32,6 @@ type AnteTestSuite struct { txBuilder client.TxBuilder } -// returns context and app with params set on account keeper -// func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { -// app := simapp.Setup(isCheckTx) -// ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) -// app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) - -// return app, ctx -// } - // SetupTest setups a new test, with new app, context, and anteHandler. func (suite *AnteTestSuite) SetupTest(isCheckTx bool) { suite.app, suite.ctx = createTestApp(isCheckTx) @@ -297,7 +259,7 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { acc := app.AccountKeeper.GetAccount(ctx, tc.signer) privs, accNums, seqs := []cryptotypes.PrivKey{tc.signerKey}, []uint64{nonExistedAccNums[tc.signer.String()]}, []uint64{0} if acc != nil { - privs, accNums, seqs = []cryptotypes.PrivKey{tc.signerKey}, []uint64{acc.GetAccountNumber()}, []uint64{acc.GetSequence()} + accNums, seqs = []uint64{acc.GetAccountNumber()}, []uint64{acc.GetSequence()} } tx, err := helpers.GenTxWithFeeGranter(protoTxCfg, msgs, fee, helpers.DefaultGenTxGas, ctx.ChainID(), accNums, seqs, tc.feeAccount, privs...) diff --git a/x/feegrant/types/test_common.go b/x/feegrant/types/test_common.go deleted file mode 100644 index 671cbffcdb0f..000000000000 --- a/x/feegrant/types/test_common.go +++ /dev/null @@ -1,27 +0,0 @@ -// noalias - -package types - -// import ( -// cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - -// sdk "github.com/cosmos/cosmos-sdk/types" -// "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" -// ) - -// func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []cryptotypes.PrivKey, accNums []uint64, seqs []uint64, fee GrantedFee) sdk.Tx { -// sigs := make([]legacytx.StdSignature, len(privs)) -// for i, priv := range privs { -// signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], fee, msgs, "") - -// sig, err := priv.Sign(signBytes) -// if err != nil { -// panic(err) -// } - -// sigs[i] = legacytx.StdSignature{PubKey: priv.PubKey(), Signature: sig} -// } - -// tx := NewFeeGrantTx(msgs, fee, sigs, "") -// return tx -// } diff --git a/x/feegrant/types/tx.go b/x/feegrant/types/tx.go deleted file mode 100644 index 4c19286e1339..000000000000 --- a/x/feegrant/types/tx.go +++ /dev/null @@ -1,250 +0,0 @@ -package types - -// import ( -// "encoding/json" - -// kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" -// cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - -// legacycodec "github.com/cosmos/cosmos-sdk/codec/legacy" -// sdk "github.com/cosmos/cosmos-sdk/types" -// sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -// "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" -// authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" -// ) - -// var ( -// _ sdk.Tx = FeeGrantTx{} - -// maxGasWanted = uint64((1 << 63) - 1) -// ) - -// // FeeGrantTx wraps a Msg with Fee and Signatures, -// // adding the ability to delegate the fee payment -// // NOTE: the first signature responsible for paying fees, either directly, -// // or must be authorized to spend from the provided Fee.FeeAccount -// type FeeGrantTx struct { -// Msgs []sdk.Msg `json:"msg" yaml:"msg"` -// Fee GrantedFee `json:"fee" yaml:"fee"` -// Signatures []legacytx.StdSignature `json:"signatures" yaml:"signatures"` -// Memo string `json:"memo" yaml:"memo"` -// FeeAccount sdk.AccAddress `json:"fee_account" yaml:"fee_account"` -// } - -// func NewFeeGrantTx(msgs []sdk.Msg, fee GrantedFee, sigs []legacytx.StdSignature, memo string) FeeGrantTx { -// return FeeGrantTx{ -// Msgs: msgs, -// Fee: fee, -// Signatures: sigs, -// Memo: memo, -// } -// } - -// // GetMsgs returns the all the transaction's messages. -// func (tx FeeGrantTx) GetMsgs() []sdk.Msg { return tx.Msgs } - -// // ValidateBasic does a simple and lightweight validation check that doesn't -// // require access to any other information. -// func (tx FeeGrantTx) ValidateBasic() error { -// stdSigs := tx.GetSignatures() - -// if tx.Fee.Gas > maxGasWanted { -// return sdkerrors.Wrapf( -// sdkerrors.ErrInvalidRequest, -// "invalid gas supplied; %d > %d", tx.Fee.Gas, maxGasWanted, -// ) -// } -// if tx.Fee.Amount.IsAnyNegative() { -// return sdkerrors.Wrapf( -// sdkerrors.ErrInsufficientFee, -// "invalid fee provided: %s", tx.Fee.Amount, -// ) -// } -// if len(stdSigs) == 0 { -// return sdkerrors.ErrNoSignatures -// } -// if len(stdSigs) != len(tx.GetSigners()) { -// return sdkerrors.Wrapf( -// sdkerrors.ErrUnauthorized, -// "wrong number of signers1; expected %d, got %d", tx.GetSigners(), len(stdSigs), -// ) -// } - -// return nil -// } - -// // CountSubKeys counts the total number of keys for a multi-sig public key. -// func CountSubKeys(pub cryptotypes.PubKey) int { -// v, ok := pub.(*kmultisig.LegacyAminoPubKey) -// if !ok { -// return 1 -// } - -// numKeys := 0 -// for _, subkey := range v.GetPubKeys() { -// numKeys += CountSubKeys(subkey) -// } - -// return numKeys -// } - -// // GetSigners returns the addresses that must sign the transaction. -// // Addresses are returned in a deterministic order. -// // They are accumulated from the GetSigners method for each Msg -// // in the order they appear in tx.GetMsgs(). -// // Duplicate addresses will be omitted. -// func (tx FeeGrantTx) GetSigners() []sdk.AccAddress { -// seen := map[string]bool{} -// var signers []sdk.AccAddress -// for _, msg := range tx.GetMsgs() { -// for _, addr := range msg.GetSigners() { -// if !seen[addr.String()] { -// signers = append(signers, addr) -// seen[addr.String()] = true -// } -// } -// } -// return signers -// } - -// // GetMemo returns the memo -// func (tx FeeGrantTx) GetMemo() string { return tx.Memo } - -// // GetSignatures returns the signature of signers who signed the Msg. -// // CONTRACT: Length returned is same as length of -// // pubkeys returned from MsgKeySigners, and the order -// // matches. -// // CONTRACT: If the signature is missing (ie the Msg is -// // invalid), then the corresponding signature is -// // .Empty(). -// func (tx FeeGrantTx) GetSignatures() [][]byte { -// sigs := make([][]byte, len(tx.Signatures)) -// for i, stdSig := range tx.Signatures { -// sigs[i] = stdSig.Signature -// } -// return sigs -// } - -// // GetPubkeys returns the pubkeys of signers if the pubkey is included in the signature -// // If pubkey is not included in the signature, then nil is in the slice instead -// func (tx FeeGrantTx) GetPubKeys() []cryptotypes.PubKey { -// pks := make([]cryptotypes.PubKey, len(tx.Signatures)) - -// for i, stdSig := range tx.Signatures { -// pks[i] = stdSig.GetPubKey() -// } -// return pks -// } - -// // GetSignBytes returns the signBytes of the tx for a given signer -// func (tx FeeGrantTx) GetSignBytes(ctx sdk.Context, acc authtypes.AccountI) []byte { -// genesis := ctx.BlockHeight() == 0 -// chainID := ctx.ChainID() -// var accNum uint64 -// if !genesis { -// accNum = acc.GetAccountNumber() -// } -// return StdSignBytes(chainID, accNum, acc.GetSequence(), tx.Fee, tx.Msgs, tx.Memo) -// } - -// // GetGas returns the Gas in GrantedFee -// func (tx FeeGrantTx) GetGas() uint64 { return tx.Fee.Gas } - -// // GetFee returns the FeeAmount in GrantedFee -// func (tx FeeGrantTx) GetFee() sdk.Coins { return tx.Fee.Amount } - -// // FeePayer returns the address that is responsible for paying fee -// // This can be explicily set in GrantedFee, or defaults to MainSigner -// func (tx FeeGrantTx) FeePayer() sdk.AccAddress { -// if len(tx.Fee.FeeAccount) != 0 { -// return tx.Fee.FeeAccount -// } -// return tx.MainSigner() -// } - -// // MainSigner returns the first signer of the tx, by default this -// // account is responsible for fees, if not explicitly set. -// func (tx FeeGrantTx) MainSigner() sdk.AccAddress { -// if len(tx.GetSigners()) != 0 { -// return tx.GetSigners()[0] -// } -// return sdk.AccAddress{} -// } - -// // GrantedFee includes the amount of coins paid in fees and the maximum -// // gas to be used by the transaction. The ratio yields an effective "gasprice", -// // which must be above some miminum to be accepted into the mempool. -// type GrantedFee struct { -// Amount sdk.Coins `json:"amount" yaml:"amount"` -// Gas uint64 `json:"gas" yaml:"gas"` -// FeeAccount sdk.AccAddress `json:"fee_account,omitempty" yaml:"fee_account"` -// } - -// // NewGrantedFee returns a new instance of GrantedFee -// func NewGrantedFee(gas uint64, amount sdk.Coins, feeAccount sdk.AccAddress) GrantedFee { -// return GrantedFee{ -// Amount: amount, -// Gas: gas, -// FeeAccount: feeAccount, -// } -// } - -// // Bytes for signing later -// func (fee GrantedFee) Bytes() []byte { -// // normalize. XXX -// // this is a sign of something ugly -// // (in the lcd_test, client side its null, -// // server side its []) -// if len(fee.Amount) == 0 { -// fee.Amount = sdk.NewCoins() -// } - -// bz, err := legacycodec.Cdc.MarshalJSON(fee) -// if err != nil { -// panic(err) -// } -// return bz -// } - -// // GasPrices returns the gas prices for a GrantedFee. -// // -// // NOTE: The gas prices returned are not the true gas prices that were -// // originally part of the submitted transaction because the fee is computed -// // as fee = ceil(gasWanted * gasPrices). -// func (fee GrantedFee) GasPrices() sdk.DecCoins { -// return sdk.NewDecCoinsFromCoins(fee.Amount...).QuoDec(sdk.NewDec(int64(fee.Gas))) -// } - -// // DelegatedSignDoc is replay-prevention structure. -// // It includes the result of msg.GetSignBytes(), -// // as well as the ChainID (prevent cross chain replay) -// // and the Sequence numbers for each signature (prevent -// // inchain replay and enforce tx ordering per account). -// type DelegatedSignDoc struct { -// AccountNumber uint64 `json:"account_number" yaml:"account_number"` -// ChainID string `json:"chain_id" yaml:"chain_id"` -// Fee json.RawMessage `json:"fee" yaml:"fee"` -// Memo string `json:"memo" yaml:"memo"` -// Msgs []json.RawMessage `json:"msgs" yaml:"msgs"` -// Sequence uint64 `json:"sequence" yaml:"sequence"` -// } - -// // StdSignBytes returns the bytes to sign for a transaction. -// func StdSignBytes(chainID string, accnum uint64, sequence uint64, fee GrantedFee, msgs []sdk.Msg, memo string) []byte { -// msgsBytes := make([]json.RawMessage, 0, len(msgs)) -// for _, msg := range msgs { -// msgsBytes = append(msgsBytes, json.RawMessage(msg.GetSignBytes())) -// } -// bz, err := legacycodec.Cdc.MarshalJSON(DelegatedSignDoc{ -// AccountNumber: accnum, -// ChainID: chainID, -// Fee: json.RawMessage(fee.Bytes()), -// Memo: memo, -// Msgs: msgsBytes, -// Sequence: sequence, -// }) -// if err != nil { -// panic(err) -// } -// return sdk.MustSortJSON(bz) -// } From 182507fdd043fae04be63d69ad5e706cf71b052b Mon Sep 17 00:00:00 2001 From: atheesh Date: Sun, 13 Dec 2020 22:32:45 +0530 Subject: [PATCH 109/184] update tx cfg --- client/tx_config.go | 1 - x/auth/legacy/legacytx/stdtx_builder.go | 2 -- 2 files changed, 3 deletions(-) diff --git a/client/tx_config.go b/client/tx_config.go index cfa6c3343107..6992a7a2402d 100644 --- a/client/tx_config.go +++ b/client/tx_config.go @@ -42,6 +42,5 @@ type ( SetFeeAmount(amount sdk.Coins) SetGasLimit(limit uint64) SetTimeoutHeight(height uint64) - SetFeePayer(feePayer sdk.AccAddress) } ) diff --git a/x/auth/legacy/legacytx/stdtx_builder.go b/x/auth/legacy/legacytx/stdtx_builder.go index 02fbcf1aaea5..83bb2f9ae48f 100644 --- a/x/auth/legacy/legacytx/stdtx_builder.go +++ b/x/auth/legacy/legacytx/stdtx_builder.go @@ -84,8 +84,6 @@ func (s *StdTxBuilder) SetTimeoutHeight(height uint64) { s.TimeoutHeight = height } -func (s *StdTxBuilder) SetFeePayer(_ sdk.AccAddress) {} - func (s *StdTxBuilder) SetFeeGranter(_ sdk.AccAddress) {} // StdTxConfig is a context.TxConfig for StdTx From 3e008312eb3d2d287befba93dcf5084274cbb2c5 Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 14 Dec 2020 16:30:16 +0530 Subject: [PATCH 110/184] fix cli tests --- x/feegrant/client/cli/cli_test.go | 149 +++++++++++++++++++++++++----- x/feegrant/client/cli/query.go | 13 +-- x/feegrant/keeper/grpc_query.go | 6 +- 3 files changed, 134 insertions(+), 34 deletions(-) diff --git a/x/feegrant/client/cli/cli_test.go b/x/feegrant/client/cli/cli_test.go index f0b681164df5..031efc61dafc 100644 --- a/x/feegrant/client/cli/cli_test.go +++ b/x/feegrant/client/cli/cli_test.go @@ -12,6 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/feegrant/types" "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/suite" + tmcli "github.com/tendermint/tendermint/libs/cli" ) type IntegrationTestSuite struct { @@ -21,7 +22,7 @@ type IntegrationTestSuite struct { network *network.Network addedGranter sdk.AccAddress addedGrantee sdk.AccAddress - addedGrant types.FeeAllowanceI + addedGrant types.FeeAllowanceGrant } func (s *IntegrationTestSuite) SetupSuite() { @@ -51,11 +52,15 @@ func (s *IntegrationTestSuite) SetupSuite() { fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } + fee := sdk.NewCoin("steak", sdk.NewInt(100)) + duration := 365 * 24 * 60 * 60 + args := append( []string{ grantee.String(), - "100steak", + fee.String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + fmt.Sprintf("--%s=%v", cli.FlagExpiration, duration), }, commonFlags..., ) @@ -67,6 +72,9 @@ func (s *IntegrationTestSuite) SetupSuite() { s.addedGranter = granter s.addedGrantee = grantee + s.addedGrant = types.NewFeeAllowanceGrant(granter, grantee, &types.BasicFeeAllowance{ + SpendLimit: sdk.NewCoins(fee), + }) } func (s *IntegrationTestSuite) TearDownSuite() { @@ -81,23 +89,54 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrant() { clientCtx := val.ClientCtx testCases := []struct { - name string - args []string - expectErr bool - respType proto.Message + name string + args []string + expectErrMsg string + expectErr bool + respType *types.FeeAllowanceGrant + resp *types.FeeAllowanceGrant }{ + { + "wrong granter", + []string{ + "wrong_granter", + grantee.String(), + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + "decoding bech32 failed", + true, nil, nil, + }, + { + "wrong grantee", + []string{ + granter.String(), + "wrong_grantee", + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + "decoding bech32 failed", + true, nil, nil, + }, + { + "non existed grant", + []string{ + "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", + grantee.String(), + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + "no fee allowance found", + true, nil, nil, + }, { "valid req", []string{ granter.String(), grantee.String(), + fmt.Sprintf("--%s=json", tmcli.OutputFlag), }, + "", false, - &types.FeeAllowanceGrant{ - Granter: granter, - Grantee: grantee, - // Allowance: , - }, + &types.FeeAllowanceGrant{}, + &s.addedGrant, }, } @@ -107,18 +146,82 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrant() { s.Run(tc.name, func() { cmd := cli.GetCmdQueryFeeGrant() out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) - fmt.Println("out, err", out, err) - s.Require().NotNil(nil) - - // if tc.expectErr { - // s.Require().Error(err) - // } else { - // s.Require().NoError(err) - // s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) - - // txResp := tc.respType.(*sdk.TxResponse) - // s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) - // } + + if tc.expectErr { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.expectErrMsg) + } else { + s.Require().NoError(err) + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().Equal(tc.respType.Grantee, tc.respType.Grantee) + s.Require().Equal(tc.respType.Granter, tc.respType.Granter) + s.Require().Equal( + tc.respType.GetFeeGrant().(*types.BasicFeeAllowance).SpendLimit, + tc.resp.GetFeeGrant().(*types.BasicFeeAllowance).SpendLimit, + ) + } + }) + } +} + +func (s *IntegrationTestSuite) TestCmdGetFeeGrants() { + val := s.network.Validators[0] + granter := val.Address + _ = granter + grantee := s.network.Validators[1].Address + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + resp *types.QueryFeeAllowancesResponse + expectLength int + }{ + { + "wrong grantee", + []string{ + "wrong_grantee", + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + true, nil, 0, + }, + { + "non existed grantee", + []string{ + "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + false, + &types.QueryFeeAllowancesResponse{}, + 0, + }, + { + "valid req", + []string{ + grantee.String(), + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + false, + &types.QueryFeeAllowancesResponse{}, + 1, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetCmdQueryFeeGrants() + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.resp), out.String()) + s.Require().Len(tc.resp.FeeAllowances, tc.expectLength) + } }) } } diff --git a/x/feegrant/client/cli/query.go b/x/feegrant/client/cli/query.go index c069b9667ee0..551436fdbdfe 100644 --- a/x/feegrant/client/cli/query.go +++ b/x/feegrant/client/cli/query.go @@ -25,7 +25,7 @@ func GetQueryCmd() *cobra.Command { feegrantQueryCmd.AddCommand( GetCmdQueryFeeGrant(), - GetCmdQueryGranteeFeeGrant(), + GetCmdQueryFeeGrants(), ) return feegrantQueryCmd @@ -84,8 +84,8 @@ $ %s query feegrant grant [granter] [grantee] return cmd } -// GetCmdQueryGranteeFeeGrant returns cmd to query for all grants for a grantee. -func GetCmdQueryGranteeFeeGrant() *cobra.Command { +// GetCmdQueryFeeGrants returns cmd to query for all grants for a grantee. +func GetCmdQueryFeeGrants() *cobra.Command { cmd := &cobra.Command{ Use: "grants [grantee]", Args: cobra.ExactArgs(1), @@ -105,7 +105,7 @@ $ %s query feegrant grants [grantee] } queryClient := types.NewQueryClient(clientCtx) - granteeAddr, err := sdk.AccAddressFromBech32(args[1]) + granteeAddr, err := sdk.AccAddressFromBech32(args[0]) if err != nil { return err } @@ -127,10 +127,7 @@ $ %s query feegrant grants [grantee] return err } - // TODO - fmt.Println(res.FeeAllowances) - // return clientCtx.PrintOutput(res.FeeAllowances) - return nil + return clientCtx.PrintProto(res) }, } diff --git a/x/feegrant/keeper/grpc_query.go b/x/feegrant/keeper/grpc_query.go index 5eb89c7a66f4..decab288d887 100644 --- a/x/feegrant/keeper/grpc_query.go +++ b/x/feegrant/keeper/grpc_query.go @@ -88,13 +88,13 @@ func (q Keeper) FeeAllowances(c context.Context, req *types.QueryFeeAllowancesRe grantsStore := prefix.NewStore(store, types.FeeAllowancePrefixByGrantee(granteeAddr)) pageRes, err := query.Paginate(grantsStore, req.Pagination, func(key []byte, value []byte) error { - var grant *types.FeeAllowanceGrant + var grant types.FeeAllowanceGrant - if err := q.cdc.UnmarshalBinaryBare(value, grant); err != nil { + if err := q.cdc.UnmarshalBinaryBare(value, &grant); err != nil { return err } - grants = append(grants, grant) + grants = append(grants, &grant) return nil }) From dc6eeb60e865bef69b2d54a90433e270428fc0fa Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 15 Dec 2020 21:06:14 +0530 Subject: [PATCH 111/184] added simulations --- simapp/params/weights.go | 4 + x/feegrant/simulation/operations.go | 156 +++++++++++++++++++++ x/feegrant/simulation/operations_test.go | 170 +++++++++++++++++++++++ x/feegrant/types/expected_keepers.go | 1 + 4 files changed, 331 insertions(+) create mode 100644 x/feegrant/simulation/operations.go create mode 100644 x/feegrant/simulation/operations_test.go diff --git a/simapp/params/weights.go b/simapp/params/weights.go index 0ba377b009b1..a7ea85ef7c1d 100644 --- a/simapp/params/weights.go +++ b/simapp/params/weights.go @@ -20,4 +20,8 @@ const ( DefaultWeightCommunitySpendProposal int = 5 DefaultWeightTextProposal int = 5 DefaultWeightParamChangeProposal int = 5 + + // feegrant + DefaultWeightGrantFeeAllowance int = 100 + DefaultWeightRevokeFeeAllowance int = 100 ) diff --git a/x/feegrant/simulation/operations.go b/x/feegrant/simulation/operations.go new file mode 100644 index 000000000000..4dd18a210c4c --- /dev/null +++ b/x/feegrant/simulation/operations.go @@ -0,0 +1,156 @@ +package simulation + +import ( + "math/rand" + "time" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/simapp/helpers" + simappparams "github.com/cosmos/cosmos-sdk/simapp/params" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/simulation" +) + +// Simulation operation weights constants +const ( + OpWeightMsgGrantFeeAllowance = "op_weight_msg_grant_fee_allowance" + OpWeightMsgRevokeFeeAllowance = "op_weight_msg_grant_revoke_allowance" +) + +func WeightedOperations( + appParams simtypes.AppParams, cdc codec.JSONMarshaler, + ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, +) simulation.WeightedOperations { + + var ( + weightMsgGrantFeeAllowance int + weightMsgRevokeFeeAllowance int + ) + + appParams.GetOrGenerate(cdc, OpWeightMsgGrantFeeAllowance, &weightMsgGrantFeeAllowance, nil, + func(_ *rand.Rand) { + weightMsgGrantFeeAllowance = simappparams.DefaultWeightGrantFeeAllowance + }, + ) + + appParams.GetOrGenerate(cdc, OpWeightMsgRevokeFeeAllowance, &weightMsgRevokeFeeAllowance, nil, + func(_ *rand.Rand) { + weightMsgRevokeFeeAllowance = simappparams.DefaultWeightRevokeFeeAllowance + }, + ) + + return simulation.WeightedOperations{ + simulation.NewWeightedOperation( + weightMsgGrantFeeAllowance, + SimulateMsgGrantFeeAllowance(ak, bk, k), + ), + simulation.NewWeightedOperation( + weightMsgRevokeFeeAllowance, + SimulateMsgRevokeFeeAllowance(ak, bk, k), + ), + } +} + +func SimulateMsgGrantFeeAllowance(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { + return func( + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + granter, _ := simtypes.RandomAcc(r, accs) + grantee, _ := simtypes.RandomAcc(r, accs) + + account := ak.GetAccount(ctx, granter.Address) + + spendableCoins := bk.SpendableCoins(ctx, account.GetAddress()) + fees, err := simtypes.RandomFees(r, ctx, spendableCoins) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgGrantFeeAllowance, err.Error()), nil, err + } + + spendableCoins = spendableCoins.Sub(fees) + + msg, err := types.NewMsgGrantFeeAllowance(&types.BasicFeeAllowance{ + SpendLimit: spendableCoins, + Expiration: types.ExpiresAtTime(ctx.BlockTime().Add(30 * time.Hour)), + }, granter.Address, grantee.Address) + + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgGrantFeeAllowance, err.Error()), nil, err + } + txGen := simappparams.MakeTestEncodingConfig().TxConfig + tx, err := helpers.GenTx( + txGen, + []sdk.Msg{msg}, + fees, + helpers.DefaultGenTxGas, + chainID, + []uint64{account.GetAccountNumber()}, + []uint64{account.GetSequence()}, + granter.PrivKey, + ) + + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgGrantFeeAllowance, "unable to generate mock tx"), nil, err + } + + _, _, err = app.Deliver(txGen.TxEncoder(), tx) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err + } + return simtypes.NewOperationMsg(msg, true, ""), nil, err + } +} + +func SimulateMsgRevokeFeeAllowance(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { + return func( + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + + hasGrant := false + var granterAddr sdk.AccAddress + var granteeAddr sdk.AccAddress + k.IterateAllFeeAllowances(ctx, func(grant types.FeeAllowanceGrant) bool { + granterAddr = grant.Granter + granteeAddr = grant.Grantee + hasGrant = true + return true + }) + + if !hasGrant { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRevokeFeeAllowance, "no grants"), nil, nil + } + granter, ok := simtypes.FindAccount(accs, granterAddr) + + if !ok { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRevokeFeeAllowance, "Account not found"), nil, nil + } + + account := ak.GetAccount(ctx, granter.Address) + spendableCoins := bk.SpendableCoins(ctx, account.GetAddress()) + fees, err := simtypes.RandomFees(r, ctx, spendableCoins) + + msg := types.NewMsgRevokeFeeAllowance(granterAddr, granteeAddr) + + txGen := simappparams.MakeTestEncodingConfig().TxConfig + tx, err := helpers.GenTx( + txGen, + []sdk.Msg{&msg}, + fees, + helpers.DefaultGenTxGas, + chainID, + []uint64{account.GetAccountNumber()}, + []uint64{account.GetSequence()}, + granter.PrivKey, + ) + + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRevokeFeeAllowance, err.Error()), nil, err + } + + _, _, err = app.Deliver(txGen.TxEncoder(), tx) + return simtypes.NewOperationMsg(&msg, true, ""), nil, err + } +} diff --git a/x/feegrant/simulation/operations_test.go b/x/feegrant/simulation/operations_test.go new file mode 100644 index 000000000000..63f28000282d --- /dev/null +++ b/x/feegrant/simulation/operations_test.go @@ -0,0 +1,170 @@ +package simulation_test + +import ( + "math/rand" + "testing" + "time" + + abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + "github.com/cosmos/cosmos-sdk/simapp" + simappparams "github.com/cosmos/cosmos-sdk/simapp/params" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/feegrant/simulation" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/stretchr/testify/suite" +) + +type SimTestSuite struct { + suite.Suite + + ctx sdk.Context + app *simapp.SimApp +} + +func (suite *SimTestSuite) SetupTest() { + checkTx := false + app := simapp.Setup(checkTx) + suite.app = app + suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{}) +} + +func (suite *SimTestSuite) getTestingAccounts(r *rand.Rand, n int) []simtypes.Account { + app, ctx := suite.app, suite.ctx + accounts := simtypes.RandomAccounts(r, n) + require := suite.Require() + + initAmt := sdk.TokensFromConsensusPower(200) + initCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initAmt)) + + // add coins to the accounts + for _, account := range accounts { + acc := app.AccountKeeper.NewAccountWithAddress(ctx, account.Address) + app.AccountKeeper.SetAccount(ctx, acc) + err := app.BankKeeper.SetBalances(ctx, account.Address, initCoins) + require.NoError(err) + } + + return accounts +} + +func (suite *SimTestSuite) TestWeightedOperations() { + app, ctx := suite.app, suite.ctx + require := suite.Require() + + ctx.WithChainID("test-chain") + + cdc := app.AppCodec() + appParams := make(simtypes.AppParams) + + weightesOps := simulation.WeightedOperations( + appParams, cdc, app.AccountKeeper, + app.BankKeeper, app.FeeGrantKeeper, + ) + + s := rand.NewSource(1) + r := rand.New(s) + accs := suite.getTestingAccounts(r, 3) + + expected := []struct { + weight int + opMsgRoute string + opMsgName string + }{ + { + simappparams.DefaultWeightGrantFeeAllowance, + types.ModuleName, + types.TypeMsgGrantFeeAllowance, + }, + { + simappparams.DefaultWeightRevokeFeeAllowance, + types.ModuleName, + types.TypeMsgRevokeFeeAllowance, + }, + } + + for i, w := range weightesOps { + operationMsg, _, _ := w.Op()(r, app.BaseApp, ctx, accs, ctx.ChainID()) + // the following checks are very much dependent from the ordering of the output given + // by WeightedOperations. if the ordering in WeightedOperations changes some tests + // will fail + require.Equal(expected[i].weight, w.Weight(), "weight should be the same") + require.Equal(expected[i].opMsgRoute, operationMsg.Route, "route should be the same") + require.Equal(expected[i].opMsgName, operationMsg.Name, "operation Msg name should be the same") + } +} + +func (suite *SimTestSuite) TestSimulateMsgGrantFeeAllowance() { + app, ctx := suite.app, suite.ctx + require := suite.Require() + + s := rand.NewSource(1) + r := rand.New(s) + accounts := suite.getTestingAccounts(r, 3) + + // begin a new block + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash}}) + + // execute operation + op := simulation.SimulateMsgGrantFeeAllowance(app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper) + operationMsg, futureOperations, err := op(r, app.BaseApp, ctx, accounts, "") + require.NoError(err) + + var msg types.MsgGrantFeeAllowance + types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) + + require.True(operationMsg.OK) + require.Equal("cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r", msg.Granter.String()) + require.Equal("cosmos1p8wcgrjr4pjju90xg6u9cgq55dxwq8j7u4x9a0", msg.Grantee.String()) + require.Equal(types.TypeMsgGrantFeeAllowance, msg.Type()) + require.Equal(types.ModuleName, msg.Route()) + require.Len(futureOperations, 0) +} + +func (suite *SimTestSuite) TestSimulateMsgRevokeFeeAllowance() { + app, ctx := suite.app, suite.ctx + require := suite.Require() + + s := rand.NewSource(1) + r := rand.New(s) + accounts := suite.getTestingAccounts(r, 3) + + // begin a new block + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}}) + + feeAmt := sdk.TokensFromConsensusPower(200000) + feeCoins := sdk.NewCoins(sdk.NewCoin("foo", feeAmt)) + + granter, grantee := accounts[0], accounts[1] + + app.FeeGrantKeeper.GrantFeeAllowance( + ctx, + granter.Address, + grantee.Address, + &types.BasicFeeAllowance{ + SpendLimit: feeCoins, + Expiration: types.ExpiresAtTime(ctx.BlockTime().Add(30 * time.Hour)), + }, + ) + + // execute operation + op := simulation.SimulateMsgRevokeFeeAllowance(app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper) + operationMsg, futureOperations, err := op(r, app.BaseApp, ctx, accounts, "") + require.NoError(err) + + var msg types.MsgRevokeFeeAllowance + types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) + + require.True(operationMsg.OK) + require.Equal(granter.Address, msg.Granter) + require.Equal(grantee.Address, msg.Grantee) + require.Equal(types.TypeMsgRevokeFeeAllowance, msg.Type()) + require.Equal(types.ModuleName, msg.Route()) + require.Len(futureOperations, 0) +} + +func TestSimTestSuite(t *testing.T) { + suite.Run(t, new(SimTestSuite)) +} diff --git a/x/feegrant/types/expected_keepers.go b/x/feegrant/types/expected_keepers.go index ca35fa72d603..40966b06d47f 100644 --- a/x/feegrant/types/expected_keepers.go +++ b/x/feegrant/types/expected_keepers.go @@ -18,5 +18,6 @@ type AccountKeeper interface { // BankKeeper defines the expected supply Keeper (noalias) type BankKeeper interface { + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error } From 738bdd0342d280a17d7e8c6971a719a835629042 Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 15 Dec 2020 22:24:09 +0530 Subject: [PATCH 112/184] Add `decoder.go` --- simapp/app.go | 2 +- x/feegrant/module.go | 55 +++++++++++++++++++++--- x/feegrant/simulation/decoder.go | 26 ++++++++++++ x/feegrant/simulation/decoder_test.go | 60 +++++++++++++++++++++++++++ 4 files changed, 136 insertions(+), 7 deletions(-) create mode 100644 x/feegrant/simulation/decoder.go create mode 100644 x/feegrant/simulation/decoder_test.go diff --git a/simapp/app.go b/simapp/app.go index c4e18b546db7..c00acc356781 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -345,7 +345,7 @@ func NewSimApp( bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), capability.NewAppModule(appCodec, *app.CapabilityKeeper), crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants), - feegrant.NewAppModule(app.FeeGrantKeeper), + feegrant.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper), gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), diff --git a/x/feegrant/module.go b/x/feegrant/module.go index ac3d6d376b2c..772ed13db0c8 100644 --- a/x/feegrant/module.go +++ b/x/feegrant/module.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "math/rand" "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" @@ -16,14 +17,17 @@ import ( cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/feegrant/client/cli" "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" + "github.com/cosmos/cosmos-sdk/x/feegrant/simulation" "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleSimulation = AppModule{} ) // ---------------------------------------------------------------------------- @@ -31,7 +35,9 @@ var ( // ---------------------------------------------------------------------------- // AppModuleBasic defines the basic application module used by the feegrant module. -type AppModuleBasic struct{} +type AppModuleBasic struct { + cdc codec.Marshaler +} // Name returns the feegrant module's name. func (AppModuleBasic) Name() string { @@ -113,14 +119,18 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { // AppModule implements an application module for the feegrant module. type AppModule struct { AppModuleBasic - keeper keeper.Keeper + keeper keeper.Keeper + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper } // NewAppModule creates a new AppModule object -func NewAppModule(keeper keeper.Keeper) AppModule { +func NewAppModule(cdc codec.Marshaler, ak types.AccountKeeper, bk types.BankKeeper, keeper keeper.Keeper) AppModule { return AppModule{ - AppModuleBasic: AppModuleBasic{}, + AppModuleBasic: AppModuleBasic{cdc: cdc}, keeper: keeper, + accountKeeper: ak, + bankKeeper: bk, } } @@ -182,3 +192,36 @@ func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { return []abci.ValidatorUpdate{} } + +//____________________________________________________________________________ + +// AppModuleSimulation functions + +// GenerateGenesisState creates a randomized GenState of the feegrant module. +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { + // TODO + // simulation.RandomizedGenState(simState) +} + +// ProposalContents returns all the feegrant content functions used to +// simulate governance proposals. +func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent { + return nil +} + +// RandomizedParams creates randomized feegrant param changes for the simulator. +func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { + return nil +} + +// RegisterStoreDecoder registers a decoder for staking module's types +func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { + sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc) +} + +// WeightedOperations returns the all the staking module operations with their respective weights. +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + return simulation.WeightedOperations( + simState.AppParams, simState.Cdc, am.accountKeeper, am.bankKeeper, am.keeper, + ) +} diff --git a/x/feegrant/simulation/decoder.go b/x/feegrant/simulation/decoder.go new file mode 100644 index 000000000000..c7f783c2b6d5 --- /dev/null +++ b/x/feegrant/simulation/decoder.go @@ -0,0 +1,26 @@ +package simulation + +import ( + "bytes" + "fmt" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types/kv" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" +) + +// NewDecodeStore returns a decoder function closure that umarshals the KVPair's +// Value to the corresponding feegrant type. +func NewDecodeStore(cdc codec.Marshaler) func(kvA, kvB kv.Pair) string { + return func(kvA, kvB kv.Pair) string { + switch { + case bytes.Equal(kvA.Key[:1], types.FeeAllowanceKeyPrefix): + var grantA, grantB types.FeeAllowanceGrant + cdc.MustUnmarshalBinaryBare(kvA.Value, &grantA) + cdc.MustUnmarshalBinaryBare(kvB.Value, &grantB) + return fmt.Sprintf("%v\n%v", grantA, grantB) + default: + panic(fmt.Sprintf("invalid feegrant key %X", kvA.Key)) + } + } +} diff --git a/x/feegrant/simulation/decoder_test.go b/x/feegrant/simulation/decoder_test.go new file mode 100644 index 000000000000..68d4cbe4037c --- /dev/null +++ b/x/feegrant/simulation/decoder_test.go @@ -0,0 +1,60 @@ +package simulation_test + +import ( + "fmt" + "testing" + + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/simapp" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/kv" + "github.com/cosmos/cosmos-sdk/x/feegrant/simulation" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/stretchr/testify/require" +) + +var ( + granterPk = ed25519.GenPrivKey().PubKey() + granterAddr = sdk.AccAddress(granterPk.Address()) + granteePk = ed25519.GenPrivKey().PubKey() + granteeAddr = sdk.AccAddress(granterPk.Address()) +) + +func TestDecodeStore(t *testing.T) { + cdc, _ := simapp.MakeCodecs() + dec := simulation.NewDecodeStore(cdc) + + grant := types.NewFeeAllowanceGrant(granterAddr, granteeAddr, &types.BasicFeeAllowance{ + SpendLimit: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100))), + }) + + grantBz, err := cdc.MarshalBinaryBare(&grant) + require.NoError(t, err) + + kvPairs := kv.Pairs{ + Pairs: []kv.Pair{ + {Key: []byte(types.FeeAllowanceKeyPrefix), Value: grantBz}, + {Key: []byte{0x99}, Value: []byte{0x99}}, + }, + } + + tests := []struct { + name string + expectedLog string + }{ + {"Grant", fmt.Sprintf("%v\n%v", grant, grant)}, + {"other", ""}, + } + + for i, tt := range tests { + i, tt := i, tt + t.Run(tt.name, func(t *testing.T) { + switch i { + case len(tests) - 1: + require.Panics(t, func() { dec(kvPairs.Pairs[i], kvPairs.Pairs[i]) }, tt.name) + default: + require.Equal(t, tt.expectedLog, dec(kvPairs.Pairs[i], kvPairs.Pairs[i]), tt.name) + } + }) + } +} From c5abc6eb79f48b92d73804e659065a45f19e576f Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 16 Dec 2020 12:11:11 +0530 Subject: [PATCH 113/184] fix build fail --- x/feegrant/client/cli/query.go | 8 -------- x/feegrant/client/cli/tx.go | 8 -------- 2 files changed, 16 deletions(-) diff --git a/x/feegrant/client/cli/query.go b/x/feegrant/client/cli/query.go index 551436fdbdfe..bf2da17d7e5d 100644 --- a/x/feegrant/client/cli/query.go +++ b/x/feegrant/client/cli/query.go @@ -47,10 +47,6 @@ $ %s query feegrant grant [granter] [grantee] ), RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - clientCtx, err := client.ReadQueryCommandFlags(clientCtx, cmd.Flags()) - if err != nil { - return err - } queryClient := types.NewQueryClient(clientCtx) granterAddr, err := sdk.AccAddressFromBech32(args[0]) @@ -99,10 +95,6 @@ $ %s query feegrant grants [grantee] ), RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - clientCtx, err := client.ReadQueryCommandFlags(clientCtx, cmd.Flags()) - if err != nil { - return err - } queryClient := types.NewQueryClient(clientCtx) granteeAddr, err := sdk.AccAddressFromBech32(args[0]) diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index 582681942e4c..6aee511b659a 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -55,10 +55,6 @@ Examples: Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - clientCtx, err := client.ReadTxCommandFlags(clientCtx, cmd.Flags()) - if err != nil { - return err - } grantee, err := sdk.AccAddressFromBech32(args[0]) if err != nil { @@ -116,10 +112,6 @@ Example: Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - clientCtx, err := client.ReadTxCommandFlags(clientCtx, cmd.Flags()) - if err != nil { - return err - } grantee, err := sdk.AccAddressFromBech32(args[0]) if err != nil { From 5adf5feb73a07f5ce7c5009969fef3927178f9a7 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 16 Dec 2020 12:53:05 +0530 Subject: [PATCH 114/184] added init genesis code --- x/feegrant/module.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/x/feegrant/module.go b/x/feegrant/module.go index 772ed13db0c8..efb386eaf28d 100644 --- a/x/feegrant/module.go +++ b/x/feegrant/module.go @@ -165,11 +165,10 @@ func (AppModule) QuerierRoute() string { // InitGenesis performs genesis initialization for the feegrant module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, bz json.RawMessage) []abci.ValidatorUpdate { - // TODO - // var gs types.GenesisState - // cdc.MustUnmarshalJSON(bz, &gs) + var gs types.GenesisState + cdc.MustUnmarshalJSON(bz, &gs) - // InitGenesis(ctx, am.keeper, &gs) + InitGenesis(ctx, am.keeper, &gs) return []abci.ValidatorUpdate{} } From d2f494c817adfaa1db18299bfc20960f4a39555f Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 16 Dec 2020 13:25:20 +0530 Subject: [PATCH 115/184] update tx.go --- x/feegrant/client/cli/tx.go | 10 ++++++++-- x/feegrant/module.go | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index 6aee511b659a..3b2040c6857b 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -54,7 +54,10 @@ Examples: ), Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } grantee, err := sdk.AccAddressFromBech32(args[0]) if err != nil { @@ -111,7 +114,10 @@ Example: ), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } grantee, err := sdk.AccAddressFromBech32(args[0]) if err != nil { diff --git a/x/feegrant/module.go b/x/feegrant/module.go index efb386eaf28d..038a55ff9e07 100644 --- a/x/feegrant/module.go +++ b/x/feegrant/module.go @@ -68,8 +68,8 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd // DefaultGenesis returns default genesis state as raw bytes for the feegrant // module. -func (AppModuleBasic) DefaultGenesis(_ codec.JSONMarshaler) json.RawMessage { - return []byte("[]") +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesisState()) } // ValidateGenesis performs genesis state validation for the feegrant module. From 14f61831360b757a8f51f65490c7474d74a02108 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 16 Dec 2020 13:29:14 +0530 Subject: [PATCH 116/184] fixed LGTM alert --- x/feegrant/simulation/operations.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x/feegrant/simulation/operations.go b/x/feegrant/simulation/operations.go index 4dd18a210c4c..dca983d1519b 100644 --- a/x/feegrant/simulation/operations.go +++ b/x/feegrant/simulation/operations.go @@ -131,6 +131,9 @@ func SimulateMsgRevokeFeeAllowance(ak types.AccountKeeper, bk types.BankKeeper, account := ak.GetAccount(ctx, granter.Address) spendableCoins := bk.SpendableCoins(ctx, account.GetAddress()) fees, err := simtypes.RandomFees(r, ctx, spendableCoins) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRevokeFeeAllowance, err.Error()), nil, err + } msg := types.NewMsgRevokeFeeAllowance(granterAddr, granteeAddr) From 5f69caa918e938bc028d1fd58597f3cb29cc1ee5 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 16 Dec 2020 14:51:59 +0530 Subject: [PATCH 117/184] modified cli --- x/feegrant/client/cli/cli_test.go | 49 +++++++++++++++++++++++-------- x/feegrant/client/cli/tx.go | 28 +++++++++++------- 2 files changed, 54 insertions(+), 23 deletions(-) diff --git a/x/feegrant/client/cli/cli_test.go b/x/feegrant/client/cli/cli_test.go index 031efc61dafc..be22331cd7f8 100644 --- a/x/feegrant/client/cli/cli_test.go +++ b/x/feegrant/client/cli/cli_test.go @@ -57,6 +57,7 @@ func (s *IntegrationTestSuite) SetupSuite() { args := append( []string{ + granter.String(), grantee.String(), fee.String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), @@ -192,9 +193,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrants() { "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", fmt.Sprintf("--%s=json", tmcli.OutputFlag), }, - false, - &types.QueryFeeAllowancesResponse{}, - 0, + false, &types.QueryFeeAllowancesResponse{}, 0, }, { "valid req", @@ -202,9 +201,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrants() { grantee.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag), }, - false, - &types.QueryFeeAllowancesResponse{}, - 1, + false, &types.QueryFeeAllowancesResponse{}, 1, }, } @@ -245,33 +242,44 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { respType proto.Message expectedCode uint32 }{ + { + "wromg granter address", + append( + []string{ + "wrong_granter", + grantee.String(), + "100steak", + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + }, + commonFlags..., + ), + true, nil, 0, + }, { "wromg grantee address", append( []string{ + granter.String(), "wrong_grantee", "100steak", fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), }, commonFlags..., ), - true, - nil, - 0, + true, nil, 0, }, { "Valid fee grant", append( []string{ + granter.String(), grantee.String(), "100steak", fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), }, commonFlags..., ), - false, - &sdk.TxResponse{}, - 0, + false, &sdk.TxResponse{}, 0, }, } @@ -318,6 +326,21 @@ func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() { "invalid grantee", append( []string{ + "wrong_granter", + grantee.String(), + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + }, + commonFlags..., + ), + true, + nil, + 0, + }, + { + "invalid grantee", + append( + []string{ + granter.String(), "wrong_grantee", fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), }, @@ -331,6 +354,7 @@ func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() { "Non existed grant", append( []string{ + granter.String(), "cosmos1aeuqja06474dfrj7uqsvukm6rael982kk89mqr", fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), }, @@ -344,6 +368,7 @@ func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() { "Valid revoke", append( []string{ + granter.String(), grantee.String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), }, diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index 3b2040c6857b..dc99f75b6ab3 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -39,34 +39,37 @@ func GetTxCmd() *cobra.Command { return feegrantTxCmd } +// NewCmdFeeGrant returns a CLI command handler for creating a MsgGrantFeeAllowance transaction. func NewCmdFeeGrant() *cobra.Command { cmd := &cobra.Command{ - Use: "grant [grantee] [limit] --from [granter]", + Use: "grant [granter] [grantee] [limit] ", Short: "Grant Fee allowance to an address", Long: strings.TrimSpace( fmt.Sprintf( - `Grant authorization to use fee from your address. + `Grant authorization to use fee from your address. Note, the'--from' flag is + ignored as it is implied from [granter]. Examples: -%s tx %s grant cosmos1skjw... 1000stake --from=cosmos1skjw... +%s tx %s grant cosmos1skjw... cosmos1skjw... 100stake `, version.AppName, types.ModuleName, ), ), - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { + cmd.Flags().Set(flags.FlagFrom, args[0]) clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } - grantee, err := sdk.AccAddressFromBech32(args[0]) + grantee, err := sdk.AccAddressFromBech32(args[1]) if err != nil { return err } granter := clientCtx.GetFromAddress() - limit, err := sdk.ParseCoinsNormalized(args[1]) + limit, err := sdk.ParseCoinsNormalized(args[2]) if err != nil { return err } @@ -101,25 +104,28 @@ Examples: return cmd } +// NewCmdRevokeFeegrant returns a CLI command handler for creating a MsgRevokeFeeAllowance transaction. func NewCmdRevokeFeegrant() *cobra.Command { cmd := &cobra.Command{ - Use: "revoke [grantee_address] --from=[granter_address]", + Use: "revoke [granter_address] [grantee_address]", Short: "revoke fee-grant", Long: strings.TrimSpace( - fmt.Sprintf(`revoke fee grant from a granter to a grantee: + fmt.Sprintf(`revoke fee grant from a granter to a grantee. Note, the'--from' flag is + ignored as it is implied from [granter_address]. Example: - $ %s tx %s revoke cosmos1skj.. --from=cosmos1skj.. + $ %s tx %s revoke cosmos1skj.. cosmos1skj.. `, version.AppName, types.ModuleName), ), - Args: cobra.ExactArgs(1), + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { + cmd.Flags().Set(flags.FlagFrom, args[0]) clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } - grantee, err := sdk.AccAddressFromBech32(args[0]) + grantee, err := sdk.AccAddressFromBech32(args[1]) if err != nil { return err } From bd96862c846030d8c01b0aa0437811b1a4d42c81 Mon Sep 17 00:00:00 2001 From: aleem1413 Date: Wed, 16 Dec 2020 17:52:48 +0530 Subject: [PATCH 118/184] remove gogoproto extensions --- proto/cosmos/feegrant/v1beta1/feegrant.proto | 30 +- proto/cosmos/feegrant/v1beta1/query.proto | 6 - x/feegrant/types/feegrant.pb.go | 292 +++++++------------ x/feegrant/types/query.pb.go | 89 ++++-- 4 files changed, 178 insertions(+), 239 deletions(-) mode change 100755 => 100644 proto/cosmos/feegrant/v1beta1/feegrant.proto diff --git a/proto/cosmos/feegrant/v1beta1/feegrant.proto b/proto/cosmos/feegrant/v1beta1/feegrant.proto old mode 100755 new mode 100644 index 652ba1db200a..c8c15151d866 --- a/proto/cosmos/feegrant/v1beta1/feegrant.proto +++ b/proto/cosmos/feegrant/v1beta1/feegrant.proto @@ -12,45 +12,31 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; // BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens // that optionally expires. The delegatee can use up to SpendLimit to cover fees. message BasicFeeAllowance { - option (gogoproto.equal) = true; - option (gogoproto.goproto_getters) = false; option (cosmos_proto.implements_interface) = "FeeAllowanceI"; - repeated cosmos.base.v1beta1.Coin spend_limit = 1 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"spend_limit\"" - ]; + repeated cosmos.base.v1beta1.Coin spend_limit = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; ExpiresAt expiration = 2 [(gogoproto.nullable) = false]; } // PeriodicFeeAllowance extends FeeAllowance to allow for both a maximum cap, // as well as a limit per time period. message PeriodicFeeAllowance { - option (gogoproto.equal) = true; - option (gogoproto.goproto_getters) = false; option (cosmos_proto.implements_interface) = "FeeAllowanceI"; BasicFeeAllowance basic = 1 [(gogoproto.nullable) = false]; Duration period = 2 [(gogoproto.nullable) = false]; - repeated cosmos.base.v1beta1.Coin period_spend_limit = 3 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"period_spend_limit\"" - ]; - repeated cosmos.base.v1beta1.Coin period_can_spend = 4 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"period_can_spend\"" - ]; + repeated cosmos.base.v1beta1.Coin period_spend_limit = 3 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + repeated cosmos.base.v1beta1.Coin period_can_spend = 4 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; - ExpiresAt period_reset = 5 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"period_reset\""]; + ExpiresAt period_reset = 5 [(gogoproto.nullable) = false]; } // Duration is a repeating unit of either clock time or number of blocks. // This is designed to be added to an ExpiresAt struct. message Duration { - option (gogoproto.equal) = true; google.protobuf.Timestamp clock = 1 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; int64 block = 2; @@ -59,7 +45,6 @@ message Duration { // ExpiresAt is a point in time where something expires. // It may be *either* block time or block height message ExpiresAt { - option (gogoproto.equal) = true; google.protobuf.Timestamp time = 1 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; int64 height = 2; @@ -67,7 +52,6 @@ message ExpiresAt { // FeeAllowanceGrant is stored in the KVStore to record a grant with full context message FeeAllowanceGrant { - option (gogoproto.goproto_getters) = false; bytes granter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; bytes grantee = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; diff --git a/proto/cosmos/feegrant/v1beta1/query.proto b/proto/cosmos/feegrant/v1beta1/query.proto index df5021e5a0cc..46eb578e211c 100644 --- a/proto/cosmos/feegrant/v1beta1/query.proto +++ b/proto/cosmos/feegrant/v1beta1/query.proto @@ -23,9 +23,6 @@ service Query { // QueryFeeAllowanceRequest is the request type for the Query/FeeAllowance RPC method. message QueryFeeAllowanceRequest { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - string granter = 1; string grantee = 2; } @@ -38,9 +35,6 @@ message QueryFeeAllowanceResponse { // QueryFeeAllowancesRequest is the request type for the Query/FeeAllowances RPC method. message QueryFeeAllowancesRequest { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - string grantee = 1; // pagination defines an pagination for the request. diff --git a/x/feegrant/types/feegrant.pb.go b/x/feegrant/types/feegrant.pb.go index 8272f29d77ae..d68ba4e76eaa 100644 --- a/x/feegrant/types/feegrant.pb.go +++ b/x/feegrant/types/feegrant.pb.go @@ -34,7 +34,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens // that optionally expires. The delegatee can use up to SpendLimit to cover fees. type BasicFeeAllowance struct { - SpendLimit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=spend_limit,json=spendLimit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"spend_limit" yaml:"spend_limit"` + SpendLimit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=spend_limit,json=spendLimit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"spend_limit"` Expiration ExpiresAt `protobuf:"bytes,2,opt,name=expiration,proto3" json:"expiration"` } @@ -71,14 +71,28 @@ func (m *BasicFeeAllowance) XXX_DiscardUnknown() { var xxx_messageInfo_BasicFeeAllowance proto.InternalMessageInfo +func (m *BasicFeeAllowance) GetSpendLimit() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.SpendLimit + } + return nil +} + +func (m *BasicFeeAllowance) GetExpiration() ExpiresAt { + if m != nil { + return m.Expiration + } + return ExpiresAt{} +} + // PeriodicFeeAllowance extends FeeAllowance to allow for both a maximum cap, // as well as a limit per time period. type PeriodicFeeAllowance struct { Basic BasicFeeAllowance `protobuf:"bytes,1,opt,name=basic,proto3" json:"basic"` Period Duration `protobuf:"bytes,2,opt,name=period,proto3" json:"period"` - PeriodSpendLimit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=period_spend_limit,json=periodSpendLimit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"period_spend_limit" yaml:"period_spend_limit"` - PeriodCanSpend github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=period_can_spend,json=periodCanSpend,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"period_can_spend" yaml:"period_can_spend"` - PeriodReset ExpiresAt `protobuf:"bytes,5,opt,name=period_reset,json=periodReset,proto3" json:"period_reset" yaml:"period_reset"` + PeriodSpendLimit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=period_spend_limit,json=periodSpendLimit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"period_spend_limit"` + PeriodCanSpend github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=period_can_spend,json=periodCanSpend,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"period_can_spend"` + PeriodReset ExpiresAt `protobuf:"bytes,5,opt,name=period_reset,json=periodReset,proto3" json:"period_reset"` } func (m *PeriodicFeeAllowance) Reset() { *m = PeriodicFeeAllowance{} } @@ -114,6 +128,41 @@ func (m *PeriodicFeeAllowance) XXX_DiscardUnknown() { var xxx_messageInfo_PeriodicFeeAllowance proto.InternalMessageInfo +func (m *PeriodicFeeAllowance) GetBasic() BasicFeeAllowance { + if m != nil { + return m.Basic + } + return BasicFeeAllowance{} +} + +func (m *PeriodicFeeAllowance) GetPeriod() Duration { + if m != nil { + return m.Period + } + return Duration{} +} + +func (m *PeriodicFeeAllowance) GetPeriodSpendLimit() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.PeriodSpendLimit + } + return nil +} + +func (m *PeriodicFeeAllowance) GetPeriodCanSpend() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.PeriodCanSpend + } + return nil +} + +func (m *PeriodicFeeAllowance) GetPeriodReset() ExpiresAt { + if m != nil { + return m.PeriodReset + } + return ExpiresAt{} +} + // Duration is a repeating unit of either clock time or number of blocks. // This is designed to be added to an ExpiresAt struct. type Duration struct { @@ -262,6 +311,27 @@ func (m *FeeAllowanceGrant) XXX_DiscardUnknown() { var xxx_messageInfo_FeeAllowanceGrant proto.InternalMessageInfo +func (m *FeeAllowanceGrant) GetGranter() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Granter + } + return nil +} + +func (m *FeeAllowanceGrant) GetGrantee() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Grantee + } + return nil +} + +func (m *FeeAllowanceGrant) GetAllowance() *types1.Any { + if m != nil { + return m.Allowance + } + return nil +} + func init() { proto.RegisterType((*BasicFeeAllowance)(nil), "cosmos.feegrant.v1beta1.BasicFeeAllowance") proto.RegisterType((*PeriodicFeeAllowance)(nil), "cosmos.feegrant.v1beta1.PeriodicFeeAllowance") @@ -275,183 +345,47 @@ func init() { } var fileDescriptor_7279582900c30aea = []byte{ - // 659 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xbd, 0x4f, 0x14, 0x4d, - 0x18, 0xbf, 0x79, 0xef, 0x8e, 0x17, 0xe6, 0xd0, 0xc8, 0x78, 0x91, 0x3b, 0x4c, 0x76, 0x71, 0x0b, - 0x43, 0x4c, 0xd8, 0x0d, 0xd8, 0x98, 0x6b, 0xcc, 0x2d, 0x02, 0x1a, 0x34, 0x31, 0xab, 0x95, 0xcd, - 0x65, 0x76, 0x6f, 0x58, 0x36, 0xec, 0xee, 0x6c, 0x76, 0x06, 0xe5, 0x5a, 0x2b, 0x4b, 0x2a, 0x63, - 0x49, 0x6d, 0xed, 0x1f, 0x41, 0xa8, 0x88, 0x95, 0x15, 0x18, 0x68, 0xac, 0x2d, 0x49, 0x4c, 0xcc, - 0x7c, 0xec, 0xdd, 0x01, 0x01, 0x8e, 0x58, 0xdd, 0x3e, 0x33, 0xcf, 0xef, 0x63, 0x9e, 0xdf, 0x4c, - 0x0e, 0x3e, 0x0c, 0x28, 0x4b, 0x28, 0x73, 0xd6, 0x09, 0x09, 0x73, 0x9c, 0x72, 0xe7, 0xfd, 0x82, - 0x4f, 0x38, 0x5e, 0xe8, 0x2f, 0xd8, 0x59, 0x4e, 0x39, 0x45, 0xd3, 0xaa, 0xcf, 0xee, 0x2f, 0xeb, - 0xbe, 0x99, 0x7a, 0x48, 0x43, 0x2a, 0x7b, 0x1c, 0xf1, 0xa5, 0xda, 0x67, 0x9a, 0x21, 0xa5, 0x61, - 0x4c, 0x1c, 0x59, 0xf9, 0x5b, 0xeb, 0x0e, 0x4e, 0x7b, 0xc5, 0x96, 0x62, 0xea, 0x28, 0x8c, 0xa6, - 0x55, 0x5b, 0x86, 0x36, 0xe3, 0x63, 0x46, 0xfa, 0x46, 0x02, 0x1a, 0xa5, 0x7a, 0xdf, 0x3c, 0xcf, - 0xca, 0xa3, 0x84, 0x30, 0x8e, 0x93, 0x4c, 0x35, 0x58, 0x7f, 0x00, 0x9c, 0x72, 0x31, 0x8b, 0x82, - 0x15, 0x42, 0xda, 0x71, 0x4c, 0x3f, 0xe0, 0x34, 0x20, 0xe8, 0x23, 0x80, 0x35, 0x96, 0x91, 0xb4, - 0xdb, 0x89, 0xa3, 0x24, 0xe2, 0x0d, 0x30, 0x5b, 0x9e, 0xab, 0x2d, 0x36, 0x6d, 0xad, 0x2d, 0xd4, - 0x8a, 0xe3, 0xd8, 0x4b, 0x34, 0x4a, 0xdd, 0x95, 0xbd, 0x43, 0xb3, 0xf4, 0xfb, 0xd0, 0x44, 0x3d, - 0x9c, 0xc4, 0x2d, 0x6b, 0x08, 0x6b, 0x7d, 0x3d, 0x32, 0xe7, 0xc2, 0x88, 0x6f, 0x6c, 0xf9, 0x76, - 0x40, 0x13, 0x6d, 0x5f, 0xff, 0xcc, 0xb3, 0xee, 0xa6, 0xc3, 0x7b, 0x19, 0x61, 0x92, 0x86, 0x79, - 0x50, 0x22, 0x5f, 0x0a, 0x20, 0x7a, 0x0e, 0x21, 0xd9, 0xce, 0xa2, 0x1c, 0xf3, 0x88, 0xa6, 0x8d, - 0xff, 0x66, 0xc1, 0x5c, 0x6d, 0xd1, 0xb2, 0x2f, 0x99, 0xaa, 0xbd, 0x2c, 0x5a, 0x09, 0x6b, 0x73, - 0xb7, 0x22, 0xbc, 0x78, 0x43, 0xd8, 0x56, 0xf3, 0xd3, 0xae, 0x59, 0xfa, 0xb5, 0x6b, 0x82, 0xef, - 0xdf, 0xe6, 0x6f, 0x0d, 0x1f, 0xf4, 0x85, 0xb5, 0x5f, 0x81, 0xf5, 0xd7, 0x24, 0x8f, 0x68, 0xf7, - 0xdc, 0x08, 0x56, 0x60, 0xd5, 0x17, 0x73, 0x69, 0x00, 0x29, 0xfc, 0xe8, 0x52, 0xe1, 0x0b, 0xd3, - 0xd3, 0x06, 0x14, 0x1c, 0x3d, 0x85, 0x63, 0x99, 0xe4, 0xd7, 0x27, 0x78, 0x70, 0x29, 0xd1, 0xb3, - 0x2d, 0x65, 0x57, 0xe3, 0x35, 0x0c, 0x7d, 0x06, 0x10, 0xa9, 0xcf, 0xce, 0x70, 0x24, 0xe5, 0xeb, - 0x22, 0x79, 0xa5, 0x23, 0x69, 0xaa, 0x48, 0x2e, 0x52, 0xdc, 0x2c, 0x99, 0x3b, 0x8a, 0xe0, 0xcd, - 0x20, 0x9f, 0x1d, 0x00, 0xf5, 0x62, 0x27, 0xc0, 0xa9, 0x62, 0x6e, 0x54, 0xae, 0xb3, 0xb5, 0xa6, - 0x6d, 0x4d, 0x9f, 0xb1, 0xd5, 0x27, 0xb8, 0x99, 0xa9, 0xdb, 0x0a, 0xbe, 0x84, 0x53, 0xe9, 0x0b, - 0xf9, 0x70, 0x52, 0x13, 0xe6, 0x84, 0x11, 0xde, 0xa8, 0x8e, 0x7c, 0x69, 0xee, 0x6b, 0x5b, 0x77, - 0xcf, 0xd8, 0x92, 0x2c, 0x96, 0x57, 0x53, 0xa5, 0x27, 0xaa, 0xab, 0x2e, 0x93, 0x0f, 0xc7, 0x8b, - 0x10, 0x51, 0x0b, 0x56, 0x83, 0x98, 0x06, 0x9b, 0xfa, 0xfe, 0xcc, 0xd8, 0xea, 0x25, 0xda, 0xc5, - 0x4b, 0xb4, 0xdf, 0x16, 0x2f, 0xd1, 0x1d, 0x17, 0xda, 0x5f, 0x8e, 0x4c, 0xe0, 0x29, 0x08, 0xaa, - 0xc3, 0xaa, 0x2f, 0xb1, 0xe2, 0xca, 0x94, 0x3d, 0x55, 0xb4, 0x2a, 0x42, 0xd4, 0x0a, 0xe0, 0x44, - 0xdf, 0x35, 0x7a, 0x02, 0x2b, 0xe2, 0x41, 0x8f, 0xaa, 0xb1, 0x23, 0x34, 0x24, 0x02, 0xdd, 0x83, - 0x63, 0x1b, 0x24, 0x0a, 0x37, 0xb8, 0xd6, 0xd0, 0x95, 0x16, 0x39, 0x05, 0x70, 0x6a, 0xf8, 0x68, - 0xab, 0x62, 0x6a, 0x68, 0x0d, 0xfe, 0x2f, 0xc7, 0x47, 0x72, 0x29, 0x38, 0xe9, 0x2e, 0x9c, 0x1e, - 0x9a, 0xf3, 0x23, 0x84, 0xd5, 0x0e, 0x82, 0x76, 0xb7, 0x9b, 0x13, 0xc6, 0xbc, 0x82, 0x61, 0x40, - 0x46, 0xa4, 0x83, 0x7f, 0x21, 0x23, 0x68, 0x19, 0x4e, 0xe0, 0xc2, 0x6b, 0xa3, 0x2c, 0x87, 0x51, - 0xbf, 0x30, 0x8c, 0x76, 0xda, 0x73, 0xa7, 0xf6, 0xcf, 0x87, 0xe6, 0x0d, 0x90, 0xad, 0x8a, 0x88, - 0xd6, 0x5d, 0xdd, 0x3b, 0x36, 0xc0, 0xc1, 0xb1, 0x01, 0x7e, 0x1e, 0x1b, 0x60, 0xe7, 0xc4, 0x28, - 0x1d, 0x9c, 0x18, 0xa5, 0x1f, 0x27, 0x46, 0xe9, 0xdd, 0xd5, 0xf6, 0xb6, 0x07, 0x7f, 0x09, 0xd2, - 0xa9, 0x3f, 0x26, 0xa5, 0x1f, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x74, 0xa3, 0xa5, 0x9f, 0x32, - 0x06, 0x00, 0x00, -} - -func (this *BasicFeeAllowance) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*BasicFeeAllowance) - if !ok { - that2, ok := that.(BasicFeeAllowance) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if len(this.SpendLimit) != len(that1.SpendLimit) { - return false - } - for i := range this.SpendLimit { - if !this.SpendLimit[i].Equal(&that1.SpendLimit[i]) { - return false - } - } - if !this.Expiration.Equal(&that1.Expiration) { - return false - } - return true + // 595 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcb, 0x6e, 0xd3, 0x4c, + 0x14, 0x8e, 0xff, 0x5c, 0xfe, 0x76, 0x52, 0x10, 0x19, 0x45, 0xe0, 0x66, 0xe1, 0x94, 0x2c, 0x50, + 0x84, 0x14, 0x9b, 0x94, 0x0d, 0xea, 0x06, 0xc5, 0xa5, 0x2d, 0xa8, 0x2c, 0x90, 0x61, 0x85, 0x40, + 0xd1, 0xd8, 0x99, 0x3a, 0xa3, 0x3a, 0x1e, 0xcb, 0x33, 0x81, 0xe6, 0x2d, 0xba, 0xe4, 0x19, 0x58, + 0xf3, 0x10, 0x15, 0xab, 0x8a, 0x15, 0xab, 0x14, 0x25, 0x4f, 0x80, 0xc4, 0x8a, 0x15, 0x9a, 0x8b, + 0x93, 0x28, 0x25, 0xa8, 0x88, 0xae, 0xe2, 0x99, 0x39, 0xdf, 0xe5, 0x7c, 0x47, 0x27, 0xe0, 0x5e, + 0x40, 0xd9, 0x80, 0x32, 0xe7, 0x08, 0xe3, 0x30, 0x45, 0x31, 0x77, 0xde, 0xb5, 0x7d, 0xcc, 0x51, + 0x7b, 0x76, 0x61, 0x27, 0x29, 0xe5, 0x14, 0xde, 0x51, 0x75, 0xf6, 0xec, 0x5a, 0xd7, 0xd5, 0xaa, + 0x21, 0x0d, 0xa9, 0xac, 0x71, 0xc4, 0x97, 0x2a, 0xaf, 0x6d, 0x86, 0x94, 0x86, 0x11, 0x76, 0xe4, + 0xc9, 0x1f, 0x1e, 0x39, 0x28, 0x1e, 0x65, 0x4f, 0x8a, 0xa9, 0xab, 0x30, 0x9a, 0x56, 0x3d, 0x59, + 0xda, 0x8c, 0x8f, 0x18, 0x9e, 0x19, 0x09, 0x28, 0x89, 0xf5, 0x7b, 0x7d, 0x99, 0x95, 0x93, 0x01, + 0x66, 0x1c, 0x0d, 0x12, 0x55, 0xd0, 0x18, 0x1b, 0xa0, 0xe2, 0x22, 0x46, 0x82, 0x7d, 0x8c, 0x3b, + 0x51, 0x44, 0xdf, 0xa3, 0x38, 0xc0, 0x30, 0x02, 0x65, 0x96, 0xe0, 0xb8, 0xd7, 0x8d, 0xc8, 0x80, + 0x70, 0xd3, 0xd8, 0xca, 0x37, 0xcb, 0xdb, 0x9b, 0xb6, 0x96, 0x16, 0x62, 0x59, 0x37, 0xf6, 0x2e, + 0x25, 0xb1, 0xfb, 0xe0, 0x6c, 0x5c, 0xcf, 0x7d, 0xbc, 0xa8, 0x37, 0x43, 0xc2, 0xfb, 0x43, 0xdf, + 0x0e, 0xe8, 0x40, 0xfb, 0xd4, 0x3f, 0x2d, 0xd6, 0x3b, 0x76, 0xf8, 0x28, 0xc1, 0x4c, 0x02, 0x98, + 0x07, 0x24, 0xff, 0x73, 0x41, 0x0f, 0x9f, 0x02, 0x80, 0x4f, 0x12, 0x92, 0x22, 0x4e, 0x68, 0x6c, + 0xfe, 0xb7, 0x65, 0x34, 0xcb, 0xdb, 0x0d, 0x7b, 0x45, 0x7c, 0xf6, 0x9e, 0x28, 0xc5, 0xac, 0xc3, + 0xdd, 0x82, 0x50, 0xf5, 0x16, 0xb0, 0x3b, 0x95, 0x2f, 0x9f, 0x5a, 0x37, 0x16, 0x3b, 0x79, 0xd6, + 0xf8, 0x9e, 0x07, 0xd5, 0x17, 0x38, 0x25, 0xb4, 0xb7, 0xd4, 0xe3, 0x3e, 0x28, 0xfa, 0xa2, 0x71, + 0xd3, 0x90, 0x82, 0xf7, 0x57, 0x0a, 0x5e, 0x8a, 0x47, 0x0b, 0x2b, 0x38, 0x7c, 0x0c, 0x4a, 0x89, + 0xe4, 0xd7, 0xce, 0xef, 0xae, 0x24, 0x7a, 0x32, 0x54, 0x36, 0x35, 0x5e, 0xc3, 0xe0, 0x08, 0x40, + 0xf5, 0xd5, 0x5d, 0xcc, 0x3c, 0x7f, 0xfd, 0x99, 0xdf, 0x52, 0x32, 0x2f, 0xe7, 0xc9, 0x0f, 0x81, + 0xbe, 0xeb, 0x06, 0x28, 0x56, 0xf2, 0x66, 0xe1, 0xfa, 0x85, 0x6f, 0x2a, 0x91, 0x5d, 0x14, 0x4b, + 0x6d, 0x78, 0x08, 0x36, 0xb4, 0x6c, 0x8a, 0x19, 0xe6, 0x66, 0xf1, 0x2f, 0x47, 0x5e, 0x56, 0x68, + 0x4f, 0x80, 0x7f, 0x37, 0xf3, 0x37, 0x60, 0x2d, 0xcb, 0x1a, 0xee, 0x80, 0x62, 0x10, 0xd1, 0xe0, + 0x58, 0x8f, 0xb9, 0x66, 0xab, 0x8d, 0xb0, 0xb3, 0x8d, 0xb0, 0x5f, 0x65, 0x1b, 0xe1, 0xae, 0x09, + 0xf2, 0x0f, 0x17, 0x75, 0xc3, 0x53, 0x10, 0x58, 0x05, 0x45, 0x5f, 0x62, 0xc5, 0x64, 0xf3, 0x9e, + 0x3a, 0x34, 0xde, 0x82, 0xf5, 0x99, 0x21, 0xf8, 0x08, 0x14, 0xc4, 0x4a, 0x5d, 0x95, 0xfd, 0x54, + 0xb0, 0x4b, 0x04, 0xbc, 0x0d, 0x4a, 0x7d, 0x4c, 0xc2, 0x3e, 0xd7, 0xec, 0xfa, 0xd4, 0xf8, 0x61, + 0x80, 0xca, 0x62, 0x3b, 0x07, 0x22, 0x0a, 0x78, 0x08, 0xfe, 0x97, 0x99, 0xe0, 0x54, 0x4a, 0x6d, + 0xb8, 0xed, 0x9f, 0xe3, 0x7a, 0xeb, 0x0a, 0x13, 0xe8, 0x04, 0x41, 0xa7, 0xd7, 0x4b, 0x31, 0x63, + 0x5e, 0xc6, 0x30, 0x27, 0xc3, 0x52, 0xfb, 0x5f, 0xc8, 0x30, 0xdc, 0x03, 0xeb, 0x28, 0xf3, 0x6a, + 0xe6, 0x65, 0x0c, 0xd5, 0x4b, 0x31, 0x74, 0xe2, 0x91, 0x5b, 0xf9, 0xbc, 0x3c, 0x28, 0x6f, 0x8e, + 0x74, 0x0f, 0xce, 0x26, 0x96, 0x71, 0x3e, 0xb1, 0x8c, 0x6f, 0x13, 0xcb, 0x38, 0x9d, 0x5a, 0xb9, + 0xf3, 0xa9, 0x95, 0xfb, 0x3a, 0xb5, 0x72, 0xaf, 0xff, 0x6c, 0xec, 0x64, 0xfe, 0x47, 0x2c, 0x3d, + 0xfa, 0x25, 0x29, 0xfa, 0xf0, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x32, 0xd6, 0xb7, 0x92, 0xa8, + 0x05, 0x00, 0x00, } -func (this *PeriodicFeeAllowance) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - that1, ok := that.(*PeriodicFeeAllowance) - if !ok { - that2, ok := that.(PeriodicFeeAllowance) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !this.Basic.Equal(&that1.Basic) { - return false - } - if !this.Period.Equal(&that1.Period) { - return false - } - if len(this.PeriodSpendLimit) != len(that1.PeriodSpendLimit) { - return false - } - for i := range this.PeriodSpendLimit { - if !this.PeriodSpendLimit[i].Equal(&that1.PeriodSpendLimit[i]) { - return false - } - } - if len(this.PeriodCanSpend) != len(that1.PeriodCanSpend) { - return false - } - for i := range this.PeriodCanSpend { - if !this.PeriodCanSpend[i].Equal(&that1.PeriodCanSpend[i]) { - return false - } - } - if !this.PeriodReset.Equal(&that1.PeriodReset) { - return false - } - return true -} -func (this *Duration) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*Duration) - if !ok { - that2, ok := that.(Duration) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if this.Clock != that1.Clock { - return false - } - if this.Block != that1.Block { - return false - } - return true -} -func (this *ExpiresAt) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*ExpiresAt) - if !ok { - that2, ok := that.(ExpiresAt) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !this.Time.Equal(that1.Time) { - return false - } - if this.Height != that1.Height { - return false - } - return true -} func (m *BasicFeeAllowance) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) diff --git a/x/feegrant/types/query.pb.go b/x/feegrant/types/query.pb.go index 0dcfcbbcc567..bd280a601dfb 100644 --- a/x/feegrant/types/query.pb.go +++ b/x/feegrant/types/query.pb.go @@ -69,6 +69,20 @@ func (m *QueryFeeAllowanceRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryFeeAllowanceRequest proto.InternalMessageInfo +func (m *QueryFeeAllowanceRequest) GetGranter() string { + if m != nil { + return m.Granter + } + return "" +} + +func (m *QueryFeeAllowanceRequest) GetGrantee() string { + if m != nil { + return m.Grantee + } + return "" +} + // QueryFeeAllowanceResponse is the response type for the Query/FeeAllowance RPC method. type QueryFeeAllowanceResponse struct { // fee_allowance is a fee_allowance granted for grantee by granter. @@ -155,6 +169,20 @@ func (m *QueryFeeAllowancesRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryFeeAllowancesRequest proto.InternalMessageInfo +func (m *QueryFeeAllowancesRequest) GetGrantee() string { + if m != nil { + return m.Grantee + } + return "" +} + +func (m *QueryFeeAllowancesRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + // QueryFeeAllowancesResponse is the response type for the Query/FeeAllowances RPC method. type QueryFeeAllowancesResponse struct { // fee_allowance is a fee_allowance granted for grantee by granter. @@ -222,37 +250,36 @@ func init() { } var fileDescriptor_59efc303945de53f = []byte{ - // 476 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xbd, 0x6e, 0x13, 0x41, - 0x10, 0xc7, 0x6f, 0x8d, 0xf8, 0xda, 0xc4, 0x14, 0x2b, 0x24, 0x8e, 0x13, 0xba, 0x44, 0x46, 0x0a, - 0x10, 0x94, 0x5b, 0xd9, 0xe9, 0xe8, 0x40, 0xc8, 0x6e, 0x90, 0x20, 0xae, 0x10, 0x0d, 0x5a, 0x9b, - 0xf1, 0x62, 0xe1, 0xdc, 0x5e, 0x6e, 0xd7, 0x40, 0x84, 0x68, 0x68, 0xa0, 0x44, 0xe2, 0x05, 0xd2, - 0xf3, 0x02, 0xf4, 0x34, 0x94, 0x96, 0x68, 0x28, 0x91, 0x4d, 0xc1, 0x3b, 0xd0, 0xa0, 0xdb, 0x0f, - 0x7b, 0x2d, 0xee, 0x88, 0xae, 0xf2, 0x79, 0xe6, 0x3f, 0x33, 0xff, 0xdf, 0xec, 0x2e, 0xbe, 0x3e, - 0x14, 0xf2, 0x50, 0x48, 0x3a, 0x02, 0xe0, 0x39, 0x4b, 0x15, 0x7d, 0xd9, 0x1e, 0x80, 0x62, 0x6d, - 0x7a, 0x34, 0x85, 0xfc, 0x38, 0xc9, 0x72, 0xa1, 0x04, 0xb9, 0x62, 0x44, 0x89, 0x13, 0x25, 0x56, - 0x14, 0x5d, 0xe6, 0x82, 0x0b, 0xad, 0xa1, 0xc5, 0x97, 0x91, 0x47, 0x3b, 0x55, 0x3d, 0x97, 0xf5, - 0x46, 0xb7, 0x6b, 0x75, 0x03, 0x26, 0xc1, 0xcc, 0x5b, 0x2a, 0x33, 0xc6, 0xc7, 0x29, 0x53, 0x63, - 0x91, 0x5a, 0xed, 0x35, 0x2e, 0x04, 0x9f, 0x00, 0x65, 0xd9, 0x98, 0xb2, 0x34, 0x15, 0x4a, 0x27, - 0xa5, 0xc9, 0xb6, 0x1e, 0xe3, 0xf0, 0xa0, 0xa8, 0xef, 0x02, 0xdc, 0x9d, 0x4c, 0xc4, 0x2b, 0x96, - 0x0e, 0xa1, 0x0f, 0x47, 0x53, 0x90, 0x8a, 0x84, 0xf8, 0xbc, 0x1e, 0x0a, 0x79, 0x88, 0xb6, 0xd1, - 0xcd, 0x8b, 0x7d, 0xf7, 0x77, 0x95, 0x81, 0xb0, 0xe1, 0x67, 0xe0, 0xce, 0x85, 0x0f, 0x27, 0x5b, - 0xc1, 0xef, 0x93, 0xad, 0xa0, 0x35, 0xc1, 0x57, 0x4b, 0x3a, 0xcb, 0x4c, 0xa4, 0x12, 0xc8, 0x43, - 0xdc, 0x1c, 0x01, 0x3c, 0x65, 0x2e, 0xa1, 0x07, 0x6c, 0x74, 0x76, 0x93, 0x8a, 0x7d, 0x25, 0x7e, - 0x97, 0x5e, 0x91, 0xe9, 0x6f, 0x8e, 0xbc, 0x50, 0xeb, 0x3d, 0x2a, 0x19, 0x27, 0xff, 0x21, 0x81, - 0x75, 0x12, 0x20, 0x5d, 0x8c, 0x57, 0x1b, 0xd3, 0x30, 0x1b, 0x9d, 0x1d, 0xe7, 0xa2, 0x58, 0x6f, - 0x62, 0x8e, 0xd3, 0xf9, 0x78, 0xc4, 0xb8, 0xdb, 0x4f, 0xdf, 0xab, 0xf4, 0xb8, 0xbf, 0x20, 0x1c, - 0x95, 0x39, 0xb1, 0xe4, 0x07, 0xf8, 0xd2, 0x1a, 0xb9, 0x0c, 0xd1, 0xf6, 0x99, 0x9a, 0xe8, 0x4d, - 0x1f, 0x5d, 0x92, 0x5e, 0x09, 0xc3, 0x8d, 0x53, 0x19, 0x8c, 0x1f, 0x1f, 0xa2, 0xf3, 0xa7, 0x81, - 0xcf, 0x6a, 0xeb, 0xe4, 0x2b, 0xc2, 0x9b, 0xfe, 0x5c, 0xd2, 0xae, 0xb4, 0x57, 0x75, 0x7d, 0xa2, - 0x4e, 0x9d, 0x12, 0xe3, 0xa6, 0xf5, 0xe0, 0xdd, 0xf7, 0x5f, 0x9f, 0x1a, 0x5d, 0x72, 0x9f, 0x56, - 0xbd, 0x04, 0x7b, 0x05, 0x25, 0x7d, 0x63, 0xbf, 0xde, 0xda, 0x10, 0x2c, 0x43, 0x60, 0x43, 0xe4, - 0x33, 0xc2, 0xcd, 0xb5, 0x53, 0x20, 0x35, 0x3c, 0xb9, 0xcb, 0x13, 0xed, 0xd7, 0xaa, 0xb1, 0x20, - 0x6d, 0x0d, 0x72, 0x9b, 0xdc, 0xfa, 0x3f, 0x88, 0xe7, 0xf9, 0x5e, 0xef, 0xdb, 0x3c, 0x46, 0xb3, - 0x79, 0x8c, 0x7e, 0xce, 0x63, 0xf4, 0x71, 0x11, 0x07, 0xb3, 0x45, 0x1c, 0xfc, 0x58, 0xc4, 0xc1, - 0x93, 0x3d, 0x3e, 0x56, 0xcf, 0xa7, 0x83, 0x64, 0x28, 0x0e, 0x5d, 0x3b, 0xf3, 0xb3, 0x27, 0x9f, - 0xbd, 0xa0, 0xaf, 0x57, 0xbd, 0xd5, 0x71, 0x06, 0x72, 0x70, 0x4e, 0x3f, 0xed, 0xfd, 0xbf, 0x01, - 0x00, 0x00, 0xff, 0xff, 0x90, 0xce, 0xea, 0x72, 0xa2, 0x04, 0x00, 0x00, + // 459 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xcf, 0x6e, 0xd3, 0x40, + 0x10, 0xc6, 0xb3, 0x41, 0x80, 0xd8, 0x36, 0x1c, 0x56, 0x48, 0x18, 0x0b, 0x59, 0x95, 0x91, 0x0a, + 0x14, 0xd5, 0xab, 0xa4, 0x4f, 0x00, 0x42, 0xc9, 0x05, 0x01, 0xcd, 0x91, 0x0b, 0xda, 0x84, 0xc9, + 0x62, 0xe1, 0x7a, 0x5d, 0xef, 0x06, 0xa8, 0x50, 0x2f, 0x3c, 0x01, 0x12, 0x8f, 0xc1, 0x0b, 0x70, + 0xe7, 0xc2, 0x31, 0x12, 0x17, 0x8e, 0x28, 0xe1, 0x2d, 0xb8, 0x20, 0xef, 0x9f, 0x64, 0x23, 0x6c, + 0x2a, 0x9f, 0xe2, 0xcc, 0x7c, 0x33, 0xf3, 0xfb, 0xc6, 0x63, 0x7c, 0x67, 0x2a, 0xe4, 0x89, 0x90, + 0x74, 0x06, 0xc0, 0x4b, 0x96, 0x2b, 0xfa, 0xb6, 0x3f, 0x01, 0xc5, 0xfa, 0xf4, 0x74, 0x0e, 0xe5, + 0x59, 0x52, 0x94, 0x42, 0x09, 0x72, 0xd3, 0x88, 0x12, 0x27, 0x4a, 0xac, 0x28, 0xbc, 0xc1, 0x05, + 0x17, 0x5a, 0x43, 0xab, 0x27, 0x23, 0x0f, 0xf7, 0x9b, 0x7a, 0xae, 0xeb, 0x8d, 0xee, 0xc0, 0xea, + 0x26, 0x4c, 0x82, 0x99, 0xb7, 0x56, 0x16, 0x8c, 0xa7, 0x39, 0x53, 0xa9, 0xc8, 0xad, 0xf6, 0x36, + 0x17, 0x82, 0x67, 0x40, 0x59, 0x91, 0x52, 0x96, 0xe7, 0x42, 0xe9, 0xa4, 0x34, 0xd9, 0xf8, 0x29, + 0x0e, 0x8e, 0xab, 0xfa, 0x21, 0xc0, 0xc3, 0x2c, 0x13, 0xef, 0x58, 0x3e, 0x85, 0x31, 0x9c, 0xce, + 0x41, 0x2a, 0x12, 0xe0, 0xab, 0x7a, 0x28, 0x94, 0x01, 0xda, 0x43, 0xf7, 0xae, 0x8d, 0xdd, 0xdf, + 0x4d, 0x06, 0x82, 0xae, 0x9f, 0x81, 0x38, 0xc3, 0xb7, 0x6a, 0xfa, 0xc9, 0x42, 0xe4, 0x12, 0xc8, + 0x33, 0xdc, 0x9b, 0x01, 0xbc, 0x64, 0x2e, 0xa1, 0xdb, 0xee, 0x0c, 0x0e, 0x92, 0x86, 0x2d, 0x25, + 0x7e, 0x97, 0x51, 0x95, 0x19, 0xef, 0xce, 0xbc, 0x50, 0x7c, 0x5e, 0x33, 0x4d, 0xfe, 0x83, 0x0f, + 0xdb, 0xf8, 0x40, 0x86, 0x18, 0x6f, 0xd6, 0xa4, 0x1d, 0xec, 0x0c, 0xf6, 0x1d, 0x44, 0xb5, 0xd3, + 0xc4, 0xbc, 0x43, 0x87, 0xf1, 0x9c, 0x71, 0xb7, 0x94, 0xb1, 0x57, 0x19, 0x7f, 0x45, 0x38, 0xac, + 0x9b, 0x6f, 0xed, 0x1e, 0xe3, 0xeb, 0x5b, 0x76, 0x65, 0x80, 0xf6, 0x2e, 0xb5, 0xf4, 0xdb, 0xf3, + 0xfd, 0x4a, 0x32, 0xaa, 0x21, 0xbf, 0x7b, 0x21, 0xb9, 0xe1, 0xf1, 0xd1, 0x07, 0x7f, 0xba, 0xf8, + 0xb2, 0x46, 0x27, 0xdf, 0x10, 0xde, 0xf5, 0xe7, 0x92, 0x7e, 0x23, 0x5e, 0xd3, 0xa5, 0x84, 0x83, + 0x36, 0x25, 0x86, 0x26, 0x7e, 0xf2, 0xf1, 0xc7, 0xef, 0xcf, 0xdd, 0x21, 0x79, 0x4c, 0x9b, 0x8e, + 0xde, 0x5e, 0x9b, 0xa4, 0x1f, 0xec, 0xd3, 0xb9, 0x0d, 0xc1, 0x3a, 0x04, 0x36, 0x44, 0xbe, 0x20, + 0xdc, 0xdb, 0x7a, 0x0b, 0xa4, 0x05, 0x93, 0x3b, 0x99, 0xf0, 0xa8, 0x55, 0x8d, 0x35, 0xd2, 0xd7, + 0x46, 0x1e, 0x90, 0xfb, 0xff, 0x37, 0xe2, 0x31, 0x3f, 0x1a, 0x7d, 0x5f, 0x46, 0x68, 0xb1, 0x8c, + 0xd0, 0xaf, 0x65, 0x84, 0x3e, 0xad, 0xa2, 0xce, 0x62, 0x15, 0x75, 0x7e, 0xae, 0xa2, 0xce, 0x8b, + 0x43, 0x9e, 0xaa, 0xd7, 0xf3, 0x49, 0x32, 0x15, 0x27, 0xae, 0x9d, 0xf9, 0x39, 0x94, 0xaf, 0xde, + 0xd0, 0xf7, 0x9b, 0xde, 0xea, 0xac, 0x00, 0x39, 0xb9, 0xa2, 0xbf, 0xe2, 0xa3, 0xbf, 0x01, 0x00, + 0x00, 0xff, 0xff, 0x81, 0xca, 0x45, 0x59, 0x8d, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. From 07da6b02b3746a608eeb6a9ba68e548f428e4836 Mon Sep 17 00:00:00 2001 From: aleem1413 Date: Wed, 16 Dec 2020 19:06:02 +0530 Subject: [PATCH 119/184] change acc address type to string --- proto/cosmos/feegrant/v1beta1/feegrant.proto | 4 +- proto/cosmos/feegrant/v1beta1/tx.proto | 9 +- x/feegrant/client/cli/tx.go | 7 +- x/feegrant/genesis.go | 11 +- x/feegrant/keeper/grpc_query.go | 4 +- x/feegrant/keeper/keeper.go | 4 +- x/feegrant/keeper/msg_server.go | 8 +- x/feegrant/simulation/operations.go | 13 +- x/feegrant/simulation/operations_test.go | 4 +- x/feegrant/types/feegrant.pb.go | 119 ++++++++--------- x/feegrant/types/grant.go | 10 +- x/feegrant/types/msgs.go | 26 ++-- x/feegrant/types/tx.pb.go | 132 ++++++++++--------- 13 files changed, 188 insertions(+), 163 deletions(-) diff --git a/proto/cosmos/feegrant/v1beta1/feegrant.proto b/proto/cosmos/feegrant/v1beta1/feegrant.proto index c8c15151d866..4f7ee2777c34 100644 --- a/proto/cosmos/feegrant/v1beta1/feegrant.proto +++ b/proto/cosmos/feegrant/v1beta1/feegrant.proto @@ -53,7 +53,7 @@ message ExpiresAt { // FeeAllowanceGrant is stored in the KVStore to record a grant with full context message FeeAllowanceGrant { - bytes granter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - bytes grantee = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + string granter = 1; + string grantee = 2; google.protobuf.Any allowance = 3 [(cosmos_proto.accepts_interface) = "FeeAllowanceI"]; } diff --git a/proto/cosmos/feegrant/v1beta1/tx.proto b/proto/cosmos/feegrant/v1beta1/tx.proto index ad065ed0c04d..114ebc14a377 100644 --- a/proto/cosmos/feegrant/v1beta1/tx.proto +++ b/proto/cosmos/feegrant/v1beta1/tx.proto @@ -22,10 +22,9 @@ service Msg { // MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance // of fees from the account of Granter. message MsgGrantFeeAllowance { - option (gogoproto.goproto_getters) = false; - bytes granter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - bytes grantee = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + string granter = 1; + string grantee = 2; google.protobuf.Any allowance = 3 [(cosmos_proto.accepts_interface) = "FeeAllowanceI"]; } @@ -34,8 +33,8 @@ message MsgGrantFeeAllowanceResponse {} // MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee. message MsgRevokeFeeAllowance { - bytes granter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - bytes grantee = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + string granter = 1; + string grantee = 2; } // MsgRevokeFeeAllowanceResponse defines the Msg/RevokeFeeAllowanceResponse response type. diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index dc99f75b6ab3..c35c4bb56353 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -130,12 +130,7 @@ Example: return err } - granter := clientCtx.GetFromAddress() - - msg := types.MsgRevokeFeeAllowance{ - Granter: granter, - Grantee: grantee, - } + msg := types.NewMsgRevokeFeeAllowance(clientCtx.GetFromAddress(), grantee) if err := msg.ValidateBasic(); err != nil { return err diff --git a/x/feegrant/genesis.go b/x/feegrant/genesis.go index abe3109f5585..a5c05b7fecc1 100644 --- a/x/feegrant/genesis.go +++ b/x/feegrant/genesis.go @@ -23,7 +23,16 @@ func (g GenesisState) ValidateBasic() error { // InitGenesis will initialize the keeper from a *previously validated* GenesisState func InitGenesis(ctx sdk.Context, k keeper.Keeper, data *types.GenesisState) { for _, f := range data.FeeAllowances { - k.GrantFeeAllowance(ctx, f.Granter, f.Grantee, f.GetFeeGrant()) + granter, err := sdk.AccAddressFromBech32(f.Granter) + if err != nil { + panic(err) + } + grantee, err := sdk.AccAddressFromBech32(f.Grantee) + if err != nil { + panic(err) + } + + k.GrantFeeAllowance(ctx, granter, grantee, f.GetFeeGrant()) } } diff --git a/x/feegrant/keeper/grpc_query.go b/x/feegrant/keeper/grpc_query.go index decab288d887..9f2abdd50e56 100644 --- a/x/feegrant/keeper/grpc_query.go +++ b/x/feegrant/keeper/grpc_query.go @@ -59,8 +59,8 @@ func (q Keeper) FeeAllowance(c context.Context, req *types.QueryFeeAllowanceRequ return &types.QueryFeeAllowanceResponse{ FeeAllowance: &types.FeeAllowanceGrant{ - Granter: granterAddr, - Grantee: granteeAddr, + Granter: granterAddr.String(), + Grantee: granteeAddr.String(), Allowance: feeAllowanceAny, }, }, nil diff --git a/x/feegrant/keeper/keeper.go b/x/feegrant/keeper/keeper.go index 1b62372bffae..c9c07ca6b7bc 100644 --- a/x/feegrant/keeper/keeper.go +++ b/x/feegrant/keeper/keeper.go @@ -39,8 +39,8 @@ func (k Keeper) GrantFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddre ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeSetFeeGrant, - sdk.NewAttribute(types.AttributeKeyGranter, grant.Granter.String()), - sdk.NewAttribute(types.AttributeKeyGrantee, grant.Grantee.String()), + sdk.NewAttribute(types.AttributeKeyGranter, grant.Granter), + sdk.NewAttribute(types.AttributeKeyGrantee, grant.Grantee), ), ) } diff --git a/x/feegrant/keeper/msg_server.go b/x/feegrant/keeper/msg_server.go index 417140e2de6c..482bee4a74d3 100644 --- a/x/feegrant/keeper/msg_server.go +++ b/x/feegrant/keeper/msg_server.go @@ -25,12 +25,12 @@ var _ types.MsgServer = msgServer{} func (k msgServer) GrantFeeAllowance(goCtx context.Context, msg *types.MsgGrantFeeAllowance) (*types.MsgGrantFeeAllowanceResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - grantee, err := sdk.AccAddressFromBech32(msg.Grantee.String()) + grantee, err := sdk.AccAddressFromBech32(msg.Grantee) if err != nil { return nil, err } - granter, err := sdk.AccAddressFromBech32(msg.Granter.String()) + granter, err := sdk.AccAddressFromBech32(msg.Granter) if err != nil { return nil, err } @@ -43,12 +43,12 @@ func (k msgServer) GrantFeeAllowance(goCtx context.Context, msg *types.MsgGrantF func (k msgServer) RevokeFeeAllowance(goCtx context.Context, msg *types.MsgRevokeFeeAllowance) (*types.MsgRevokeFeeAllowanceResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - grantee, err := sdk.AccAddressFromBech32(msg.Grantee.String()) + grantee, err := sdk.AccAddressFromBech32(msg.Grantee) if err != nil { return nil, err } - granter, err := sdk.AccAddressFromBech32(msg.Granter.String()) + granter, err := sdk.AccAddressFromBech32(msg.Granter) if err != nil { return nil, err } diff --git a/x/feegrant/simulation/operations.go b/x/feegrant/simulation/operations.go index dca983d1519b..c737f3f04f77 100644 --- a/x/feegrant/simulation/operations.go +++ b/x/feegrant/simulation/operations.go @@ -113,8 +113,17 @@ func SimulateMsgRevokeFeeAllowance(ak types.AccountKeeper, bk types.BankKeeper, var granterAddr sdk.AccAddress var granteeAddr sdk.AccAddress k.IterateAllFeeAllowances(ctx, func(grant types.FeeAllowanceGrant) bool { - granterAddr = grant.Granter - granteeAddr = grant.Grantee + + granter, err := sdk.AccAddressFromBech32(grant.Granter) + if err != nil { + panic(err) + } + grantee, err := sdk.AccAddressFromBech32(grant.Granter) + if err != nil { + panic(err) + } + granterAddr = granter + granteeAddr = grantee hasGrant = true return true }) diff --git a/x/feegrant/simulation/operations_test.go b/x/feegrant/simulation/operations_test.go index 63f28000282d..fcfc594c7358 100644 --- a/x/feegrant/simulation/operations_test.go +++ b/x/feegrant/simulation/operations_test.go @@ -116,8 +116,8 @@ func (suite *SimTestSuite) TestSimulateMsgGrantFeeAllowance() { types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) require.True(operationMsg.OK) - require.Equal("cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r", msg.Granter.String()) - require.Equal("cosmos1p8wcgrjr4pjju90xg6u9cgq55dxwq8j7u4x9a0", msg.Grantee.String()) + require.Equal("cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r", msg.Granter) + require.Equal("cosmos1p8wcgrjr4pjju90xg6u9cgq55dxwq8j7u4x9a0", msg.Grantee) require.Equal(types.TypeMsgGrantFeeAllowance, msg.Type()) require.Equal(types.ModuleName, msg.Route()) require.Len(futureOperations, 0) diff --git a/x/feegrant/types/feegrant.pb.go b/x/feegrant/types/feegrant.pb.go index d68ba4e76eaa..2a6e0b111210 100644 --- a/x/feegrant/types/feegrant.pb.go +++ b/x/feegrant/types/feegrant.pb.go @@ -273,9 +273,9 @@ func (m *ExpiresAt) GetHeight() int64 { // FeeAllowanceGrant is stored in the KVStore to record a grant with full context type FeeAllowanceGrant struct { - Granter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=granter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"granter,omitempty"` - Grantee github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=grantee,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"grantee,omitempty"` - Allowance *types1.Any `protobuf:"bytes,3,opt,name=allowance,proto3" json:"allowance,omitempty"` + Granter string `protobuf:"bytes,1,opt,name=granter,proto3" json:"granter,omitempty"` + Grantee string `protobuf:"bytes,2,opt,name=grantee,proto3" json:"grantee,omitempty"` + Allowance *types1.Any `protobuf:"bytes,3,opt,name=allowance,proto3" json:"allowance,omitempty"` } func (m *FeeAllowanceGrant) Reset() { *m = FeeAllowanceGrant{} } @@ -311,18 +311,18 @@ func (m *FeeAllowanceGrant) XXX_DiscardUnknown() { var xxx_messageInfo_FeeAllowanceGrant proto.InternalMessageInfo -func (m *FeeAllowanceGrant) GetGranter() github_com_cosmos_cosmos_sdk_types.AccAddress { +func (m *FeeAllowanceGrant) GetGranter() string { if m != nil { return m.Granter } - return nil + return "" } -func (m *FeeAllowanceGrant) GetGrantee() github_com_cosmos_cosmos_sdk_types.AccAddress { +func (m *FeeAllowanceGrant) GetGrantee() string { if m != nil { return m.Grantee } - return nil + return "" } func (m *FeeAllowanceGrant) GetAllowance() *types1.Any { @@ -345,45 +345,44 @@ func init() { } var fileDescriptor_7279582900c30aea = []byte{ - // 595 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcb, 0x6e, 0xd3, 0x4c, - 0x14, 0x8e, 0xff, 0x5c, 0xfe, 0x76, 0x52, 0x10, 0x19, 0x45, 0xe0, 0x66, 0xe1, 0x94, 0x2c, 0x50, - 0x84, 0x14, 0x9b, 0x94, 0x0d, 0xea, 0x06, 0xc5, 0xa5, 0x2d, 0xa8, 0x2c, 0x90, 0x61, 0x85, 0x40, - 0xd1, 0xd8, 0x99, 0x3a, 0xa3, 0x3a, 0x1e, 0xcb, 0x33, 0x81, 0xe6, 0x2d, 0xba, 0xe4, 0x19, 0x58, - 0xf3, 0x10, 0x15, 0xab, 0x8a, 0x15, 0xab, 0x14, 0x25, 0x4f, 0x80, 0xc4, 0x8a, 0x15, 0x9a, 0x8b, - 0x93, 0x28, 0x25, 0xa8, 0x88, 0xae, 0xe2, 0x99, 0x39, 0xdf, 0xe5, 0x7c, 0x47, 0x27, 0xe0, 0x5e, - 0x40, 0xd9, 0x80, 0x32, 0xe7, 0x08, 0xe3, 0x30, 0x45, 0x31, 0x77, 0xde, 0xb5, 0x7d, 0xcc, 0x51, - 0x7b, 0x76, 0x61, 0x27, 0x29, 0xe5, 0x14, 0xde, 0x51, 0x75, 0xf6, 0xec, 0x5a, 0xd7, 0xd5, 0xaa, - 0x21, 0x0d, 0xa9, 0xac, 0x71, 0xc4, 0x97, 0x2a, 0xaf, 0x6d, 0x86, 0x94, 0x86, 0x11, 0x76, 0xe4, - 0xc9, 0x1f, 0x1e, 0x39, 0x28, 0x1e, 0x65, 0x4f, 0x8a, 0xa9, 0xab, 0x30, 0x9a, 0x56, 0x3d, 0x59, - 0xda, 0x8c, 0x8f, 0x18, 0x9e, 0x19, 0x09, 0x28, 0x89, 0xf5, 0x7b, 0x7d, 0x99, 0x95, 0x93, 0x01, - 0x66, 0x1c, 0x0d, 0x12, 0x55, 0xd0, 0x18, 0x1b, 0xa0, 0xe2, 0x22, 0x46, 0x82, 0x7d, 0x8c, 0x3b, - 0x51, 0x44, 0xdf, 0xa3, 0x38, 0xc0, 0x30, 0x02, 0x65, 0x96, 0xe0, 0xb8, 0xd7, 0x8d, 0xc8, 0x80, - 0x70, 0xd3, 0xd8, 0xca, 0x37, 0xcb, 0xdb, 0x9b, 0xb6, 0x96, 0x16, 0x62, 0x59, 0x37, 0xf6, 0x2e, - 0x25, 0xb1, 0xfb, 0xe0, 0x6c, 0x5c, 0xcf, 0x7d, 0xbc, 0xa8, 0x37, 0x43, 0xc2, 0xfb, 0x43, 0xdf, - 0x0e, 0xe8, 0x40, 0xfb, 0xd4, 0x3f, 0x2d, 0xd6, 0x3b, 0x76, 0xf8, 0x28, 0xc1, 0x4c, 0x02, 0x98, - 0x07, 0x24, 0xff, 0x73, 0x41, 0x0f, 0x9f, 0x02, 0x80, 0x4f, 0x12, 0x92, 0x22, 0x4e, 0x68, 0x6c, - 0xfe, 0xb7, 0x65, 0x34, 0xcb, 0xdb, 0x0d, 0x7b, 0x45, 0x7c, 0xf6, 0x9e, 0x28, 0xc5, 0xac, 0xc3, - 0xdd, 0x82, 0x50, 0xf5, 0x16, 0xb0, 0x3b, 0x95, 0x2f, 0x9f, 0x5a, 0x37, 0x16, 0x3b, 0x79, 0xd6, - 0xf8, 0x9e, 0x07, 0xd5, 0x17, 0x38, 0x25, 0xb4, 0xb7, 0xd4, 0xe3, 0x3e, 0x28, 0xfa, 0xa2, 0x71, - 0xd3, 0x90, 0x82, 0xf7, 0x57, 0x0a, 0x5e, 0x8a, 0x47, 0x0b, 0x2b, 0x38, 0x7c, 0x0c, 0x4a, 0x89, - 0xe4, 0xd7, 0xce, 0xef, 0xae, 0x24, 0x7a, 0x32, 0x54, 0x36, 0x35, 0x5e, 0xc3, 0xe0, 0x08, 0x40, - 0xf5, 0xd5, 0x5d, 0xcc, 0x3c, 0x7f, 0xfd, 0x99, 0xdf, 0x52, 0x32, 0x2f, 0xe7, 0xc9, 0x0f, 0x81, - 0xbe, 0xeb, 0x06, 0x28, 0x56, 0xf2, 0x66, 0xe1, 0xfa, 0x85, 0x6f, 0x2a, 0x91, 0x5d, 0x14, 0x4b, - 0x6d, 0x78, 0x08, 0x36, 0xb4, 0x6c, 0x8a, 0x19, 0xe6, 0x66, 0xf1, 0x2f, 0x47, 0x5e, 0x56, 0x68, - 0x4f, 0x80, 0x7f, 0x37, 0xf3, 0x37, 0x60, 0x2d, 0xcb, 0x1a, 0xee, 0x80, 0x62, 0x10, 0xd1, 0xe0, - 0x58, 0x8f, 0xb9, 0x66, 0xab, 0x8d, 0xb0, 0xb3, 0x8d, 0xb0, 0x5f, 0x65, 0x1b, 0xe1, 0xae, 0x09, - 0xf2, 0x0f, 0x17, 0x75, 0xc3, 0x53, 0x10, 0x58, 0x05, 0x45, 0x5f, 0x62, 0xc5, 0x64, 0xf3, 0x9e, - 0x3a, 0x34, 0xde, 0x82, 0xf5, 0x99, 0x21, 0xf8, 0x08, 0x14, 0xc4, 0x4a, 0x5d, 0x95, 0xfd, 0x54, - 0xb0, 0x4b, 0x04, 0xbc, 0x0d, 0x4a, 0x7d, 0x4c, 0xc2, 0x3e, 0xd7, 0xec, 0xfa, 0xd4, 0xf8, 0x61, - 0x80, 0xca, 0x62, 0x3b, 0x07, 0x22, 0x0a, 0x78, 0x08, 0xfe, 0x97, 0x99, 0xe0, 0x54, 0x4a, 0x6d, - 0xb8, 0xed, 0x9f, 0xe3, 0x7a, 0xeb, 0x0a, 0x13, 0xe8, 0x04, 0x41, 0xa7, 0xd7, 0x4b, 0x31, 0x63, - 0x5e, 0xc6, 0x30, 0x27, 0xc3, 0x52, 0xfb, 0x5f, 0xc8, 0x30, 0xdc, 0x03, 0xeb, 0x28, 0xf3, 0x6a, - 0xe6, 0x65, 0x0c, 0xd5, 0x4b, 0x31, 0x74, 0xe2, 0x91, 0x5b, 0xf9, 0xbc, 0x3c, 0x28, 0x6f, 0x8e, - 0x74, 0x0f, 0xce, 0x26, 0x96, 0x71, 0x3e, 0xb1, 0x8c, 0x6f, 0x13, 0xcb, 0x38, 0x9d, 0x5a, 0xb9, - 0xf3, 0xa9, 0x95, 0xfb, 0x3a, 0xb5, 0x72, 0xaf, 0xff, 0x6c, 0xec, 0x64, 0xfe, 0x47, 0x2c, 0x3d, - 0xfa, 0x25, 0x29, 0xfa, 0xf0, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x32, 0xd6, 0xb7, 0x92, 0xa8, - 0x05, 0x00, 0x00, + // 577 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4d, 0x6e, 0xd3, 0x40, + 0x14, 0x8e, 0x49, 0x13, 0x9a, 0x17, 0x40, 0x64, 0x14, 0x81, 0x9b, 0x85, 0x53, 0xb2, 0x40, 0x11, + 0x52, 0x6c, 0x5a, 0x36, 0xa8, 0x1b, 0x14, 0x97, 0xb6, 0x20, 0x58, 0x20, 0xc3, 0x0a, 0x81, 0x22, + 0xdb, 0x99, 0x3a, 0xa3, 0x3a, 0x1e, 0xcb, 0x33, 0x81, 0xe6, 0x12, 0xa8, 0x4b, 0xce, 0xc0, 0x9a, + 0x43, 0x54, 0xac, 0x2a, 0x56, 0xac, 0x5a, 0x94, 0x9c, 0x80, 0x1b, 0xa0, 0xf9, 0x71, 0x12, 0xa5, + 0x04, 0x81, 0xd4, 0x55, 0x3c, 0xf3, 0xde, 0xf7, 0xf3, 0xbe, 0x99, 0x09, 0xdc, 0x0f, 0x29, 0x1b, + 0x52, 0xe6, 0x1c, 0x62, 0x1c, 0x65, 0x7e, 0xc2, 0x9d, 0x0f, 0x5b, 0x01, 0xe6, 0xfe, 0xd6, 0x6c, + 0xc3, 0x4e, 0x33, 0xca, 0x29, 0xba, 0xab, 0xfa, 0xec, 0xd9, 0xb6, 0xee, 0x6b, 0xd4, 0x23, 0x1a, + 0x51, 0xd9, 0xe3, 0x88, 0x2f, 0xd5, 0xde, 0xd8, 0x88, 0x28, 0x8d, 0x62, 0xec, 0xc8, 0x55, 0x30, + 0x3a, 0x74, 0xfc, 0x64, 0x9c, 0x97, 0x14, 0x53, 0x4f, 0x61, 0x34, 0xad, 0x2a, 0x59, 0xda, 0x4c, + 0xe0, 0x33, 0x3c, 0x33, 0x12, 0x52, 0x92, 0xe8, 0x7a, 0x73, 0x99, 0x95, 0x93, 0x21, 0x66, 0xdc, + 0x1f, 0xa6, 0xaa, 0xa1, 0x75, 0x6e, 0x40, 0xcd, 0xf5, 0x19, 0x09, 0xf7, 0x31, 0xee, 0xc6, 0x31, + 0xfd, 0xe8, 0x27, 0x21, 0x46, 0x31, 0x54, 0x59, 0x8a, 0x93, 0x7e, 0x2f, 0x26, 0x43, 0xc2, 0x4d, + 0x63, 0xb3, 0xd8, 0xae, 0x6e, 0x6f, 0xd8, 0x5a, 0x5a, 0x88, 0xe5, 0xd3, 0xd8, 0xbb, 0x94, 0x24, + 0xee, 0xc3, 0xd3, 0xf3, 0x66, 0xe1, 0xcb, 0x45, 0xb3, 0x1d, 0x11, 0x3e, 0x18, 0x05, 0x76, 0x48, + 0x87, 0xda, 0xa7, 0xfe, 0xe9, 0xb0, 0xfe, 0x91, 0xc3, 0xc7, 0x29, 0x66, 0x12, 0xc0, 0x3c, 0x90, + 0xfc, 0x2f, 0x05, 0x3d, 0x7a, 0x06, 0x80, 0x8f, 0x53, 0x92, 0xf9, 0x9c, 0xd0, 0xc4, 0xbc, 0xb6, + 0x69, 0xb4, 0xab, 0xdb, 0x2d, 0x7b, 0x45, 0x7c, 0xf6, 0x9e, 0x68, 0xc5, 0xac, 0xcb, 0xdd, 0x35, + 0xa1, 0xea, 0x2d, 0x60, 0x77, 0x6a, 0xdf, 0xbf, 0x76, 0x6e, 0x2e, 0x4e, 0xf2, 0xbc, 0xf5, 0xab, + 0x08, 0xf5, 0x57, 0x38, 0x23, 0xb4, 0xbf, 0x34, 0xe3, 0x3e, 0x94, 0x02, 0x31, 0xb8, 0x69, 0x48, + 0xc1, 0x07, 0x2b, 0x05, 0x2f, 0xc5, 0xa3, 0x85, 0x15, 0x1c, 0x3d, 0x81, 0x72, 0x2a, 0xf9, 0xb5, + 0xf3, 0x7b, 0x2b, 0x89, 0x9e, 0x8e, 0x94, 0x4d, 0x8d, 0xd7, 0x30, 0x34, 0x06, 0xa4, 0xbe, 0x7a, + 0x8b, 0x99, 0x17, 0xaf, 0x3e, 0xf3, 0xdb, 0x4a, 0xe6, 0xf5, 0x3c, 0xf9, 0x11, 0xe8, 0xbd, 0x5e, + 0xe8, 0x27, 0x4a, 0xde, 0x5c, 0xbb, 0x7a, 0xe1, 0x5b, 0x4a, 0x64, 0xd7, 0x4f, 0xa4, 0x36, 0x7a, + 0x01, 0x37, 0xb4, 0x6c, 0x86, 0x19, 0xe6, 0x66, 0xe9, 0x3f, 0x8f, 0xbc, 0xaa, 0xd0, 0x9e, 0x00, + 0xff, 0xe9, 0xcc, 0xdf, 0xc1, 0x7a, 0x9e, 0x35, 0xda, 0x81, 0x52, 0x18, 0xd3, 0xf0, 0x48, 0x1f, + 0x73, 0xc3, 0x56, 0x2f, 0xc2, 0xce, 0x5f, 0x84, 0xfd, 0x26, 0x7f, 0x11, 0xee, 0xba, 0x20, 0xff, + 0x7c, 0xd1, 0x34, 0x3c, 0x05, 0x41, 0x75, 0x28, 0x05, 0x12, 0x2b, 0x4e, 0xb6, 0xe8, 0xa9, 0x45, + 0xeb, 0x3d, 0x54, 0x66, 0x86, 0xd0, 0x63, 0x58, 0x13, 0x4f, 0xea, 0x5f, 0xd9, 0x4f, 0x04, 0xbb, + 0x44, 0xa0, 0x3b, 0x50, 0x1e, 0x60, 0x12, 0x0d, 0xb8, 0x66, 0xd7, 0xab, 0xd6, 0x27, 0x03, 0x6a, + 0x8b, 0xe3, 0x1c, 0x88, 0x28, 0x90, 0x09, 0xd7, 0x65, 0x26, 0x38, 0x93, 0x52, 0x15, 0x2f, 0x5f, + 0xce, 0x2b, 0x58, 0x12, 0xcd, 0x2a, 0x18, 0xed, 0x41, 0xc5, 0xcf, 0x59, 0xcc, 0xa2, 0x34, 0x58, + 0xbf, 0x64, 0xb0, 0x9b, 0x8c, 0xdd, 0xda, 0xb7, 0xe5, 0x08, 0xbd, 0x39, 0xd2, 0x3d, 0x38, 0x9d, + 0x58, 0xc6, 0xd9, 0xc4, 0x32, 0x7e, 0x4e, 0x2c, 0xe3, 0x64, 0x6a, 0x15, 0xce, 0xa6, 0x56, 0xe1, + 0xc7, 0xd4, 0x2a, 0xbc, 0xed, 0xfc, 0xf5, 0x06, 0x1c, 0xcf, 0xff, 0x22, 0xe5, 0x65, 0x08, 0xca, + 0x52, 0xf4, 0xd1, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07, 0x5c, 0x4a, 0xc1, 0x42, 0x05, 0x00, + 0x00, } func (m *BasicFeeAllowance) Marshal() (dAtA []byte, err error) { @@ -1328,7 +1327,7 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Granter", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowFeegrant @@ -1338,31 +1337,29 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthFeegrant } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthFeegrant } if postIndex > l { return io.ErrUnexpectedEOF } - m.Granter = append(m.Granter[:0], dAtA[iNdEx:postIndex]...) - if m.Granter == nil { - m.Granter = []byte{} - } + m.Granter = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowFeegrant @@ -1372,25 +1369,23 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthFeegrant } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthFeegrant } if postIndex > l { return io.ErrUnexpectedEOF } - m.Grantee = append(m.Grantee[:0], dAtA[iNdEx:postIndex]...) - if m.Grantee == nil { - m.Grantee = []byte{} - } + m.Grantee = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { diff --git a/x/feegrant/types/grant.go b/x/feegrant/types/grant.go index 3bdf40dedde5..5df4303f7d10 100644 --- a/x/feegrant/types/grant.go +++ b/x/feegrant/types/grant.go @@ -26,8 +26,8 @@ func NewFeeAllowanceGrant(granter, grantee sdk.AccAddress, feeAllowance FeeAllow } return FeeAllowanceGrant{ - Granter: granter, - Grantee: grantee, + Granter: granter.String(), + Grantee: grantee.String(), Allowance: any, } } @@ -35,13 +35,13 @@ func NewFeeAllowanceGrant(granter, grantee sdk.AccAddress, feeAllowance FeeAllow // ValidateBasic performs basic validation on // FeeAllowanceGrant func (a FeeAllowanceGrant) ValidateBasic() error { - if a.Granter.Empty() { + if a.Granter == "" { return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "missing granter address") } - if a.Grantee.Empty() { + if a.Grantee == "" { return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "missing grantee address") } - if a.Grantee.Equals(a.Granter) { + if a.Grantee == a.Granter { return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "cannot self-grant fee authorization") } diff --git a/x/feegrant/types/msgs.go b/x/feegrant/types/msgs.go index e0a674cd0810..ad2069497b4c 100644 --- a/x/feegrant/types/msgs.go +++ b/x/feegrant/types/msgs.go @@ -33,8 +33,8 @@ func NewMsgGrantFeeAllowance(feeAllowance FeeAllowanceI, granter, grantee sdk.Ac } return &MsgGrantFeeAllowance{ - Granter: granter, - Grantee: grantee, + Granter: granter.String(), + Grantee: grantee.String(), Allowance: any, }, nil } @@ -55,10 +55,10 @@ func (msg MsgGrantFeeAllowance) Type() string { // ValidateBasic implements the sdk.Msg interface. func (msg MsgGrantFeeAllowance) ValidateBasic() error { - if msg.Granter.Empty() { + if msg.Granter == "" { return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "missing granter address") } - if msg.Grantee.Empty() { + if msg.Grantee == "" { return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "missing grantee address") } @@ -71,7 +71,11 @@ func (msg MsgGrantFeeAllowance) GetSignBytes() []byte { } func (msg MsgGrantFeeAllowance) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{msg.Granter} + granter, err := sdk.AccAddressFromBech32(msg.Granter) + if err != nil { + panic(err) + } + return []sdk.AccAddress{granter} } // GetFeeAllowanceI returns unpacked FeeAllowance @@ -91,7 +95,7 @@ func (msg MsgGrantFeeAllowance) UnpackInterfaces(unpacker types.AnyUnpacker) err } func NewMsgRevokeFeeAllowance(granter sdk.AccAddress, grantee sdk.AccAddress) MsgRevokeFeeAllowance { - return MsgRevokeFeeAllowance{Granter: granter, Grantee: grantee} + return MsgRevokeFeeAllowance{Granter: granter.String(), Grantee: grantee.String()} } func (msg MsgRevokeFeeAllowance) Route() string { @@ -103,10 +107,10 @@ func (msg MsgRevokeFeeAllowance) Type() string { } func (msg MsgRevokeFeeAllowance) ValidateBasic() error { - if msg.Granter.Empty() { + if msg.Granter == "" { return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "missing granter address") } - if msg.Grantee.Empty() { + if msg.Grantee == "" { return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "missing grantee address") } @@ -118,5 +122,9 @@ func (msg MsgRevokeFeeAllowance) GetSignBytes() []byte { } func (msg MsgRevokeFeeAllowance) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{msg.Granter} + granter, err := sdk.AccAddressFromBech32(msg.Granter) + if err != nil { + panic(err) + } + return []sdk.AccAddress{granter} } diff --git a/x/feegrant/types/tx.pb.go b/x/feegrant/types/tx.pb.go index 5c9e2cfee7b0..e28666009e67 100644 --- a/x/feegrant/types/tx.pb.go +++ b/x/feegrant/types/tx.pb.go @@ -7,7 +7,6 @@ import ( context "context" fmt "fmt" types "github.com/cosmos/cosmos-sdk/codec/types" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -34,9 +33,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance // of fees from the account of Granter. type MsgGrantFeeAllowance struct { - Granter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=granter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"granter,omitempty"` - Grantee github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=grantee,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"grantee,omitempty"` - Allowance *types.Any `protobuf:"bytes,3,opt,name=allowance,proto3" json:"allowance,omitempty"` + Granter string `protobuf:"bytes,1,opt,name=granter,proto3" json:"granter,omitempty"` + Grantee string `protobuf:"bytes,2,opt,name=grantee,proto3" json:"grantee,omitempty"` + Allowance *types.Any `protobuf:"bytes,3,opt,name=allowance,proto3" json:"allowance,omitempty"` } func (m *MsgGrantFeeAllowance) Reset() { *m = MsgGrantFeeAllowance{} } @@ -72,6 +71,27 @@ func (m *MsgGrantFeeAllowance) XXX_DiscardUnknown() { var xxx_messageInfo_MsgGrantFeeAllowance proto.InternalMessageInfo +func (m *MsgGrantFeeAllowance) GetGranter() string { + if m != nil { + return m.Granter + } + return "" +} + +func (m *MsgGrantFeeAllowance) GetGrantee() string { + if m != nil { + return m.Grantee + } + return "" +} + +func (m *MsgGrantFeeAllowance) GetAllowance() *types.Any { + if m != nil { + return m.Allowance + } + return nil +} + // MsgGrantFeeAllowanceResponse defines the Msg/GrantFeeAllowanceResponse response type. type MsgGrantFeeAllowanceResponse struct { } @@ -111,8 +131,8 @@ var xxx_messageInfo_MsgGrantFeeAllowanceResponse proto.InternalMessageInfo // MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee. type MsgRevokeFeeAllowance struct { - Granter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=granter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"granter,omitempty"` - Grantee github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=grantee,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"grantee,omitempty"` + Granter string `protobuf:"bytes,1,opt,name=granter,proto3" json:"granter,omitempty"` + Grantee string `protobuf:"bytes,2,opt,name=grantee,proto3" json:"grantee,omitempty"` } func (m *MsgRevokeFeeAllowance) Reset() { *m = MsgRevokeFeeAllowance{} } @@ -148,18 +168,18 @@ func (m *MsgRevokeFeeAllowance) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRevokeFeeAllowance proto.InternalMessageInfo -func (m *MsgRevokeFeeAllowance) GetGranter() github_com_cosmos_cosmos_sdk_types.AccAddress { +func (m *MsgRevokeFeeAllowance) GetGranter() string { if m != nil { return m.Granter } - return nil + return "" } -func (m *MsgRevokeFeeAllowance) GetGrantee() github_com_cosmos_cosmos_sdk_types.AccAddress { +func (m *MsgRevokeFeeAllowance) GetGrantee() string { if m != nil { return m.Grantee } - return nil + return "" } // MsgRevokeFeeAllowanceResponse defines the Msg/RevokeFeeAllowanceResponse response type. @@ -209,31 +229,29 @@ func init() { func init() { proto.RegisterFile("cosmos/feegrant/v1beta1/tx.proto", fileDescriptor_dd44ad7946dad783) } var fileDescriptor_dd44ad7946dad783 = []byte{ - // 375 bytes of a gzipped FileDescriptorProto + // 345 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0x4d, 0x2f, 0x4a, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x87, 0xa8, 0xd0, 0x83, 0xa9, 0xd0, 0x83, 0xaa, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xab, 0xd1, 0x07, 0xb1, 0x20, 0xca, 0xa5, 0x24, 0xd3, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0xc1, 0xbc, 0xa4, 0xd2, 0x34, 0xfd, 0xc4, 0xbc, 0x4a, 0x98, 0x14, 0xc4, 0xa4, 0x78, 0x88, 0x1e, 0xa8, 0xb1, 0x60, 0x8e, - 0xd2, 0x5f, 0x46, 0x2e, 0x11, 0xdf, 0xe2, 0x74, 0x77, 0x90, 0x05, 0x6e, 0xa9, 0xa9, 0x8e, 0x39, - 0x39, 0xf9, 0xe5, 0x89, 0x79, 0xc9, 0xa9, 0x42, 0xde, 0x5c, 0xec, 0x60, 0x5b, 0x53, 0x8b, 0x24, - 0x18, 0x15, 0x18, 0x35, 0x78, 0x9c, 0x0c, 0x7f, 0xdd, 0x93, 0xd7, 0x4d, 0xcf, 0x2c, 0xc9, 0x28, - 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0x85, 0x1a, 0x03, 0xa5, 0x74, 0x8b, 0x53, 0xb2, 0xf5, 0x4b, 0x2a, - 0x0b, 0x52, 0x8b, 0xf5, 0x1c, 0x93, 0x93, 0x1d, 0x53, 0x52, 0x8a, 0x52, 0x8b, 0x8b, 0x83, 0x60, - 0x26, 0x20, 0x0c, 0x4b, 0x95, 0x60, 0xa2, 0xd0, 0xb0, 0x54, 0x21, 0x57, 0x2e, 0xce, 0x44, 0x98, - 0x33, 0x25, 0x98, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0x44, 0xf4, 0x20, 0x9e, 0xd7, 0x83, 0x79, 0x5e, - 0xcf, 0x31, 0xaf, 0xd2, 0x49, 0xf0, 0xd4, 0x16, 0x5d, 0x5e, 0x64, 0x4f, 0x79, 0x06, 0x21, 0x74, - 0x5a, 0xb1, 0x74, 0x2c, 0x90, 0x67, 0x50, 0x92, 0xe3, 0x92, 0xc1, 0xe6, 0xfd, 0xa0, 0xd4, 0xe2, - 0x82, 0xfc, 0xbc, 0xe2, 0x54, 0xa5, 0x8d, 0x8c, 0x5c, 0xa2, 0xbe, 0xc5, 0xe9, 0x41, 0xa9, 0x65, - 0xf9, 0xd9, 0xa9, 0x43, 0x23, 0x80, 0x94, 0xe4, 0xb9, 0x64, 0xb1, 0x3a, 0x19, 0xe6, 0x29, 0xa3, - 0x7f, 0x8c, 0x5c, 0xcc, 0xbe, 0xc5, 0xe9, 0x42, 0x95, 0x5c, 0x82, 0x98, 0x11, 0xaf, 0xab, 0x87, - 0x23, 0xdd, 0xe9, 0x61, 0x0b, 0x28, 0x29, 0x53, 0x92, 0x94, 0xc3, 0x9c, 0x20, 0x54, 0xc3, 0x25, - 0x84, 0x25, 0x4c, 0xf5, 0xf0, 0x19, 0x86, 0xa9, 0x5e, 0xca, 0x8c, 0x34, 0xf5, 0x30, 0xdb, 0x9d, - 0xdc, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, - 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x0a, 0x7f, 0x98, 0x57, 0x20, - 0xb2, 0x2b, 0x38, 0xf8, 0x93, 0xd8, 0xc0, 0x09, 0xce, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x04, - 0x77, 0xff, 0x0b, 0xce, 0x03, 0x00, 0x00, + 0xd2, 0x44, 0x46, 0x2e, 0x11, 0xdf, 0xe2, 0x74, 0x77, 0x90, 0x05, 0x6e, 0xa9, 0xa9, 0x8e, 0x39, + 0x39, 0xf9, 0xe5, 0x89, 0x79, 0xc9, 0xa9, 0x42, 0x12, 0x5c, 0xec, 0x60, 0x5b, 0x53, 0x8b, 0x24, + 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x60, 0x5c, 0x84, 0x4c, 0xaa, 0x04, 0x13, 0xb2, 0x4c, 0xaa, + 0x90, 0x2b, 0x17, 0x67, 0x22, 0xcc, 0x00, 0x09, 0x66, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x11, 0x3d, + 0x88, 0xb3, 0xf4, 0x60, 0xce, 0xd2, 0x73, 0xcc, 0xab, 0x74, 0x12, 0x3c, 0xb5, 0x45, 0x97, 0x17, + 0xd9, 0x3a, 0xcf, 0x20, 0x84, 0x4e, 0x25, 0x39, 0x2e, 0x19, 0x6c, 0x4e, 0x0a, 0x4a, 0x2d, 0x2e, + 0xc8, 0xcf, 0x2b, 0x4e, 0x55, 0xf2, 0xe6, 0x12, 0xf5, 0x2d, 0x4e, 0x0f, 0x4a, 0x2d, 0xcb, 0xcf, + 0x4e, 0xa5, 0xd4, 0xcd, 0x4a, 0xf2, 0x5c, 0xb2, 0x58, 0x0d, 0x83, 0xd9, 0x66, 0xf4, 0x8f, 0x91, + 0x8b, 0xd9, 0xb7, 0x38, 0x5d, 0xa8, 0x92, 0x4b, 0x10, 0x33, 0x94, 0x74, 0xf5, 0x70, 0x44, 0x92, + 0x1e, 0x36, 0x1f, 0x48, 0x99, 0x92, 0xa4, 0x1c, 0xe6, 0x04, 0xa1, 0x1a, 0x2e, 0x21, 0x2c, 0xbe, + 0xd5, 0xc3, 0x67, 0x18, 0xa6, 0x7a, 0x29, 0x33, 0xd2, 0xd4, 0xc3, 0x6c, 0x77, 0x72, 0x3f, 0xf1, + 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, + 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xdd, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, + 0xbd, 0xe4, 0xfc, 0x5c, 0x68, 0xaa, 0x82, 0x52, 0xba, 0xc5, 0x29, 0xd9, 0xfa, 0x15, 0x88, 0xb4, + 0x5d, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x4e, 0x03, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x7b, 0xbe, 0x24, 0x15, 0xfb, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -598,7 +616,7 @@ func (m *MsgGrantFeeAllowance) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Granter", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -608,31 +626,29 @@ func (m *MsgGrantFeeAllowance) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Granter = append(m.Granter[:0], dAtA[iNdEx:postIndex]...) - if m.Granter == nil { - m.Granter = []byte{} - } + m.Granter = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -642,25 +658,23 @@ func (m *MsgGrantFeeAllowance) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Grantee = append(m.Grantee[:0], dAtA[iNdEx:postIndex]...) - if m.Grantee == nil { - m.Grantee = []byte{} - } + m.Grantee = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { @@ -808,7 +822,7 @@ func (m *MsgRevokeFeeAllowance) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Granter", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -818,31 +832,29 @@ func (m *MsgRevokeFeeAllowance) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Granter = append(m.Granter[:0], dAtA[iNdEx:postIndex]...) - if m.Granter == nil { - m.Granter = []byte{} - } + m.Granter = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -852,25 +864,23 @@ func (m *MsgRevokeFeeAllowance) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Grantee = append(m.Grantee[:0], dAtA[iNdEx:postIndex]...) - if m.Grantee == nil { - m.Grantee = []byte{} - } + m.Grantee = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex From eba8213cad3b5b6b4ccd45ef63975b31dc1e00e7 Mon Sep 17 00:00:00 2001 From: aleem1413 Date: Wed, 16 Dec 2020 19:11:23 +0530 Subject: [PATCH 120/184] lint --- x/feegrant/types/grant.go | 1 + x/feegrant/types/msgs.go | 1 + 2 files changed, 2 insertions(+) diff --git a/x/feegrant/types/grant.go b/x/feegrant/types/grant.go index 5df4303f7d10..17508a61a36d 100644 --- a/x/feegrant/types/grant.go +++ b/x/feegrant/types/grant.go @@ -15,6 +15,7 @@ var ( ) // NewFeeAllowanceGrant creates a new FeeAllowanceGrant. +//nolint:interfacer func NewFeeAllowanceGrant(granter, grantee sdk.AccAddress, feeAllowance FeeAllowanceI) FeeAllowanceGrant { msg, ok := feeAllowance.(proto.Message) if !ok { diff --git a/x/feegrant/types/msgs.go b/x/feegrant/types/msgs.go index ad2069497b4c..b22785ca2c23 100644 --- a/x/feegrant/types/msgs.go +++ b/x/feegrant/types/msgs.go @@ -94,6 +94,7 @@ func (msg MsgGrantFeeAllowance) UnpackInterfaces(unpacker types.AnyUnpacker) err return unpacker.UnpackAny(msg.Allowance, &allowance) } +//nolint:interfacer func NewMsgRevokeFeeAllowance(granter sdk.AccAddress, grantee sdk.AccAddress) MsgRevokeFeeAllowance { return MsgRevokeFeeAllowance{Granter: granter.String(), Grantee: grantee.String()} } From 287b6ac4a7539a4d7319fed113aae0c85312e270 Mon Sep 17 00:00:00 2001 From: aleem1413 Date: Wed, 16 Dec 2020 19:28:07 +0530 Subject: [PATCH 121/184] fix simulations --- x/feegrant/simulation/operations.go | 2 +- x/feegrant/simulation/operations_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/x/feegrant/simulation/operations.go b/x/feegrant/simulation/operations.go index c737f3f04f77..836ac1c8d690 100644 --- a/x/feegrant/simulation/operations.go +++ b/x/feegrant/simulation/operations.go @@ -118,7 +118,7 @@ func SimulateMsgRevokeFeeAllowance(ak types.AccountKeeper, bk types.BankKeeper, if err != nil { panic(err) } - grantee, err := sdk.AccAddressFromBech32(grant.Granter) + grantee, err := sdk.AccAddressFromBech32(grant.Grantee) if err != nil { panic(err) } diff --git a/x/feegrant/simulation/operations_test.go b/x/feegrant/simulation/operations_test.go index fcfc594c7358..b59ff479bd21 100644 --- a/x/feegrant/simulation/operations_test.go +++ b/x/feegrant/simulation/operations_test.go @@ -158,8 +158,8 @@ func (suite *SimTestSuite) TestSimulateMsgRevokeFeeAllowance() { types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) require.True(operationMsg.OK) - require.Equal(granter.Address, msg.Granter) - require.Equal(grantee.Address, msg.Grantee) + require.Equal(granter.Address.String(), msg.Granter) + require.Equal(grantee.Address.String(), msg.Grantee) require.Equal(types.TypeMsgRevokeFeeAllowance, msg.Type()) require.Equal(types.ModuleName, msg.Route()) require.Len(futureOperations, 0) From 8b110723d266aaf68eddfc2044aa431cfc804f62 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 16 Dec 2020 21:52:32 +0530 Subject: [PATCH 122/184] Add gen simulations --- x/feegrant/module.go | 3 +-- x/feegrant/simulation/genesis.go | 38 ++++++++++++++++++++++++++ x/feegrant/simulation/genesis_test.go | 39 +++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 x/feegrant/simulation/genesis.go create mode 100644 x/feegrant/simulation/genesis_test.go diff --git a/x/feegrant/module.go b/x/feegrant/module.go index 038a55ff9e07..727e7e277e69 100644 --- a/x/feegrant/module.go +++ b/x/feegrant/module.go @@ -198,8 +198,7 @@ func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.Validato // GenerateGenesisState creates a randomized GenState of the feegrant module. func (AppModule) GenerateGenesisState(simState *module.SimulationState) { - // TODO - // simulation.RandomizedGenState(simState) + simulation.RandomizedGenState(simState) } // ProposalContents returns all the feegrant content functions used to diff --git a/x/feegrant/simulation/genesis.go b/x/feegrant/simulation/genesis.go new file mode 100644 index 000000000000..f9f4c7e12748 --- /dev/null +++ b/x/feegrant/simulation/genesis.go @@ -0,0 +1,38 @@ +package simulation + +import ( + "encoding/json" + "fmt" + "math/rand" + + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" +) + +// Simulation parameter constants +const feegrant = "feegrant" + +// GenFeeGrants returns an empty slice of evidences. +func GenFeeGrants(_ *rand.Rand, _ []simtypes.Account) []types.FeeAllowanceGrant { + return []types.FeeAllowanceGrant{} +} + +// RandomizedGenState generates a random GenesisState for feegrant +func RandomizedGenState(simState *module.SimulationState) { + var feegrants []types.FeeAllowanceGrant + + simState.AppParams.GetOrGenerate( + simState.Cdc, feegrant, &feegrants, simState.Rand, + func(r *rand.Rand) { feegrants = GenFeeGrants(r, simState.Accounts) }, + ) + feegrantGenesis := types.NewGenesisState(feegrants) + + bz, err := json.MarshalIndent(&feegrantGenesis, "", " ") + if err != nil { + panic(err) + } + + fmt.Printf("Selected randomly generated %s parameters:\n%s\n", types.ModuleName, bz) + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(feegrantGenesis) +} diff --git a/x/feegrant/simulation/genesis_test.go b/x/feegrant/simulation/genesis_test.go new file mode 100644 index 000000000000..4f3ae74b56be --- /dev/null +++ b/x/feegrant/simulation/genesis_test.go @@ -0,0 +1,39 @@ +package simulation_test + +import ( + "encoding/json" + "math/rand" + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/feegrant/simulation" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/stretchr/testify/require" +) + +func TestRandomizedGenState(t *testing.T) { + interfaceRegistry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + + s := rand.NewSource(1) + r := rand.New(s) + + simState := module.SimulationState{ + AppParams: make(simtypes.AppParams), + Cdc: cdc, + Rand: r, + NumBonded: 3, + Accounts: simtypes.RandomAccounts(r, 3), + InitialStake: 1000, + GenState: make(map[string]json.RawMessage), + } + + simulation.RandomizedGenState(&simState) + var feegrantGenesis types.GenesisState + simState.Cdc.MustUnmarshalJSON(simState.GenState[types.ModuleName], &feegrantGenesis) + + require.Len(t, feegrantGenesis.FeeAllowances, 0) +} From 1884fb796dc9d6ff4f06f43523ce8695788193ad Mon Sep 17 00:00:00 2001 From: aleem1413 Date: Thu, 17 Dec 2020 19:14:35 +0530 Subject: [PATCH 123/184] remove legacy querier --- x/feegrant/keeper/querier.go | 63 ------------------------ x/feegrant/keeper/querier_test.go | 82 ------------------------------- 2 files changed, 145 deletions(-) delete mode 100644 x/feegrant/keeper/querier.go delete mode 100644 x/feegrant/keeper/querier_test.go diff --git a/x/feegrant/keeper/querier.go b/x/feegrant/keeper/querier.go deleted file mode 100644 index 1073f1be9e2a..000000000000 --- a/x/feegrant/keeper/querier.go +++ /dev/null @@ -1,63 +0,0 @@ -package keeper - -import ( - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" -) - -// querier types -const ( - QueryGetFeeAllowances = "fees" -) - -// NewQuerier creates a new querier -func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { - var ( - res []byte - err error - ) - - switch path[0] { - case QueryGetFeeAllowances: - res, err = queryGetFeeAllowances(ctx, path[1:], keeper, legacyQuerierCdc) - - default: - err = sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown %s query endpoint: %s", types.ModuleName, path[0]) - } - - return res, err - } -} - -func queryGetFeeAllowances(ctx sdk.Context, args []string, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - grantee := args[0] - granteeAddr, err := sdk.AccAddressFromBech32(grantee) - if err != nil { - return nil, sdkerrors.Wrapf(err, "invalid address") - } - - var grants []types.FeeAllowanceGrant - err = keeper.IterateAllGranteeFeeAllowances(ctx, granteeAddr, func(grant types.FeeAllowanceGrant) bool { - grants = append(grants, grant) - return false - }) - if err != nil { - return nil, err - } - - if grants == nil { - return []byte("[]"), nil - } - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, grants) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} diff --git a/x/feegrant/keeper/querier_test.go b/x/feegrant/keeper/querier_test.go deleted file mode 100644 index 0ad795f69190..000000000000 --- a/x/feegrant/keeper/querier_test.go +++ /dev/null @@ -1,82 +0,0 @@ -package keeper_test - -// import ( -// abci "github.com/tendermint/tendermint/abci/types" - -// codec "github.com/cosmos/cosmos-sdk/codec" -// sdk "github.com/cosmos/cosmos-sdk/types" -// "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" -// "github.com/cosmos/cosmos-sdk/x/feegrant/types" -// ) - -// func (suite *KeeperTestSuite) TestQuery() { -// ctx := suite.ctx -// k := suite.dk - -// cdc := codec.New() -// types.RegisterCodec(cdc) - -// // some helpers -// grant1 := types.FeeAllowanceGrant{ -// Granter: suite.addr, -// Grantee: suite.addr3, -// Allowance: &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ -// SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 555)), -// Expiration: types.ExpiresAtHeight(334455), -// }, -// }, -// }, -// } -// grant2 := types.FeeAllowanceGrant{ -// Granter: suite.addr2, -// Grantee: suite.addr3, -// Allowance: &types.FeeAllowance{Sum: &types.FeeAllowance_BasicFeeAllowance{BasicFeeAllowance: &types.BasicFeeAllowance{ -// SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("eth", 123)), -// Expiration: types.ExpiresAtHeight(334455)}}}, -// } -// // let's set up some initial state here -// k.GrantFeeAllowance(ctx, grant1) -// k.GrantFeeAllowance(ctx, grant2) - -// // now try some queries -// cases := map[string]struct { -// path []string -// valid bool -// res []types.FeeAllowanceGrant -// }{ -// "bad path": { -// path: []string{"foo", "bar"}, -// }, -// "no data": { -// // addr in bech32 -// path: []string{"fees", "cosmos157ez5zlaq0scm9aycwphhqhmg3kws4qusmekll"}, -// valid: true, -// }, -// "two grants": { -// // addr3 in bech32 -// path: []string{"fees", "cosmos1qk93t4j0yyzgqgt6k5qf8deh8fq6smpn3ntu3x"}, -// valid: true, -// res: []types.FeeAllowanceGrant{grant1, grant2}, -// }, -// } - -// querier := keeper.NewQuerier(k) -// for name, tc := range cases { -// tc := tc -// suite.Run(name, func() { -// bz, err := querier(ctx, tc.path, abci.RequestQuery{}) -// if !tc.valid { -// suite.Error(err) -// return -// } -// suite.NoError(err) - -// var grants []types.FeeAllowanceGrant -// serr := cdc.UnmarshalJSON(bz, &grants) -// suite.NoError(serr) - -// suite.Equal(tc.res, grants) -// }) -// } - -// } From 5ffc76865ef3d97a98927077dd7d099a36176910 Mon Sep 17 00:00:00 2001 From: aleem1413 Date: Thu, 17 Dec 2020 19:15:00 +0530 Subject: [PATCH 124/184] remove legacy code --- x/feegrant/client/cli/service_msg_client.go | 43 +++ x/feegrant/client/cli/tx.go | 16 +- x/feegrant/handler.go | 28 -- x/feegrant/module.go | 16 +- x/feegrant/simulation/operations.go | 333 +++++++++---------- x/feegrant/simulation/operations_test.go | 336 ++++++++++---------- x/feegrant/types/codec.go | 33 +- x/feegrant/types/msgs.go | 33 +- 8 files changed, 399 insertions(+), 439 deletions(-) create mode 100644 x/feegrant/client/cli/service_msg_client.go delete mode 100644 x/feegrant/handler.go diff --git a/x/feegrant/client/cli/service_msg_client.go b/x/feegrant/client/cli/service_msg_client.go new file mode 100644 index 000000000000..001b37fa4d38 --- /dev/null +++ b/x/feegrant/client/cli/service_msg_client.go @@ -0,0 +1,43 @@ +package cli + +import ( + "context" + "fmt" + + gogogrpc "github.com/gogo/protobuf/grpc" + grpc "google.golang.org/grpc" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ gogogrpc.ClientConn = &serviceMsgClientConn{} + +// serviceMsgClientConn is an instance of grpc.ClientConn that is used to test building +// transactions with MsgClient's. It is intended to be replaced by the work in +// https://github.com/cosmos/cosmos-sdk/issues/7541 when that is ready. +type serviceMsgClientConn struct { + msgs []sdk.Msg +} + +func (t *serviceMsgClientConn) Invoke(_ context.Context, method string, args, _ interface{}, _ ...grpc.CallOption) error { + req, ok := args.(sdk.MsgRequest) + if !ok { + return fmt.Errorf("%T should implement %T", args, (*sdk.MsgRequest)(nil)) + } + + err := req.ValidateBasic() + if err != nil { + return err + } + + t.msgs = append(t.msgs, sdk.ServiceMsg{ + MethodName: method, + Request: req, + }) + + return nil +} + +func (t *serviceMsgClientConn) NewStream(context.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error) { + return nil, fmt.Errorf("not supported") +} diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index c35c4bb56353..9bf793d570ab 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -1,6 +1,7 @@ package cli import ( + "context" "fmt" "strings" "time" @@ -91,11 +92,14 @@ Examples: return err } - if err := msg.ValidateBasic(); err != nil { + svcMsgClientConn := &serviceMsgClientConn{} + feeGrantMsgClient := types.NewMsgClient(svcMsgClientConn) + _, err = feeGrantMsgClient.GrantFeeAllowance(context.Background(), msg) + if err != nil { return err } - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), svcMsgClientConn.msgs...) }, } @@ -131,12 +135,14 @@ Example: } msg := types.NewMsgRevokeFeeAllowance(clientCtx.GetFromAddress(), grantee) - - if err := msg.ValidateBasic(); err != nil { + svcMsgClientConn := &serviceMsgClientConn{} + feeGrantMsgClient := types.NewMsgClient(svcMsgClientConn) + _, err = feeGrantMsgClient.RevokeFeeAllowance(context.Background(), &msg) + if err != nil { return err } - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), svcMsgClientConn.msgs...) }, } diff --git a/x/feegrant/handler.go b/x/feegrant/handler.go deleted file mode 100644 index 8bf04d40df8e..000000000000 --- a/x/feegrant/handler.go +++ /dev/null @@ -1,28 +0,0 @@ -package feegrant - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" -) - -func NewHandler(k keeper.Keeper) sdk.Handler { - return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) - msgServer := keeper.NewMsgServerImpl(k) - - switch msg := msg.(type) { - case *types.MsgGrantFeeAllowance: - res, err := msgServer.GrantFeeAllowance(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgRevokeFeeAllowance: - res, err := msgServer.RevokeFeeAllowance(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) - } - } -} diff --git a/x/feegrant/module.go b/x/feegrant/module.go index 727e7e277e69..ef5ad79af819 100644 --- a/x/feegrant/module.go +++ b/x/feegrant/module.go @@ -53,7 +53,6 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { // RegisterLegacyAminoCodec registers the feegrant module's types for the given codec. func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - types.RegisterLegacyAminoCodec(cdc) } // RegisterInterfaces registers the feegrant module's interface types @@ -63,7 +62,7 @@ func (AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { // LegacyQuerierHandler returns the feegrant module sdk.Querier. func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return keeper.NewQuerier(am.keeper, legacyQuerierCdc) + return nil } // DefaultGenesis returns default genesis state as raw bytes for the feegrant @@ -144,17 +143,17 @@ func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {} // Route returns the message routing key for the feegrant module. func (am AppModule) Route() sdk.Route { - return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) + return sdk.NewRoute(types.RouterKey, nil) } // NewHandler returns an sdk.Handler for the feegrant module. func (am AppModule) NewHandler() sdk.Handler { - return NewHandler(am.keeper) + return nil } // QuerierRoute returns the feegrant module's querier route name. func (AppModule) QuerierRoute() string { - return types.QuerierRoute + return "" } // // NewQuerierHandler returns the feegrant module sdk.Querier. @@ -219,7 +218,8 @@ func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { // WeightedOperations returns the all the staking module operations with their respective weights. func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { - return simulation.WeightedOperations( - simState.AppParams, simState.Cdc, am.accountKeeper, am.bankKeeper, am.keeper, - ) + // return simulation.WeightedOperations( + // simState.AppParams, simState.Cdc, am.accountKeeper, am.bankKeeper, am.keeper, + // ) + return nil } diff --git a/x/feegrant/simulation/operations.go b/x/feegrant/simulation/operations.go index 836ac1c8d690..e0b18a922ead 100644 --- a/x/feegrant/simulation/operations.go +++ b/x/feegrant/simulation/operations.go @@ -1,168 +1,169 @@ package simulation -import ( - "math/rand" - "time" - - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/simapp/helpers" - simappparams "github.com/cosmos/cosmos-sdk/simapp/params" - sdk "github.com/cosmos/cosmos-sdk/types" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" - "github.com/cosmos/cosmos-sdk/x/simulation" -) - -// Simulation operation weights constants -const ( - OpWeightMsgGrantFeeAllowance = "op_weight_msg_grant_fee_allowance" - OpWeightMsgRevokeFeeAllowance = "op_weight_msg_grant_revoke_allowance" -) - -func WeightedOperations( - appParams simtypes.AppParams, cdc codec.JSONMarshaler, - ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, -) simulation.WeightedOperations { - - var ( - weightMsgGrantFeeAllowance int - weightMsgRevokeFeeAllowance int - ) - - appParams.GetOrGenerate(cdc, OpWeightMsgGrantFeeAllowance, &weightMsgGrantFeeAllowance, nil, - func(_ *rand.Rand) { - weightMsgGrantFeeAllowance = simappparams.DefaultWeightGrantFeeAllowance - }, - ) - - appParams.GetOrGenerate(cdc, OpWeightMsgRevokeFeeAllowance, &weightMsgRevokeFeeAllowance, nil, - func(_ *rand.Rand) { - weightMsgRevokeFeeAllowance = simappparams.DefaultWeightRevokeFeeAllowance - }, - ) - - return simulation.WeightedOperations{ - simulation.NewWeightedOperation( - weightMsgGrantFeeAllowance, - SimulateMsgGrantFeeAllowance(ak, bk, k), - ), - simulation.NewWeightedOperation( - weightMsgRevokeFeeAllowance, - SimulateMsgRevokeFeeAllowance(ak, bk, k), - ), - } -} - -func SimulateMsgGrantFeeAllowance(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { - return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, - ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - granter, _ := simtypes.RandomAcc(r, accs) - grantee, _ := simtypes.RandomAcc(r, accs) - - account := ak.GetAccount(ctx, granter.Address) - - spendableCoins := bk.SpendableCoins(ctx, account.GetAddress()) - fees, err := simtypes.RandomFees(r, ctx, spendableCoins) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgGrantFeeAllowance, err.Error()), nil, err - } - - spendableCoins = spendableCoins.Sub(fees) - - msg, err := types.NewMsgGrantFeeAllowance(&types.BasicFeeAllowance{ - SpendLimit: spendableCoins, - Expiration: types.ExpiresAtTime(ctx.BlockTime().Add(30 * time.Hour)), - }, granter.Address, grantee.Address) - - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgGrantFeeAllowance, err.Error()), nil, err - } - txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( - txGen, - []sdk.Msg{msg}, - fees, - helpers.DefaultGenTxGas, - chainID, - []uint64{account.GetAccountNumber()}, - []uint64{account.GetSequence()}, - granter.PrivKey, - ) - - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgGrantFeeAllowance, "unable to generate mock tx"), nil, err - } - - _, _, err = app.Deliver(txGen.TxEncoder(), tx) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err - } - return simtypes.NewOperationMsg(msg, true, ""), nil, err - } -} - -func SimulateMsgRevokeFeeAllowance(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { - return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, - ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - - hasGrant := false - var granterAddr sdk.AccAddress - var granteeAddr sdk.AccAddress - k.IterateAllFeeAllowances(ctx, func(grant types.FeeAllowanceGrant) bool { - - granter, err := sdk.AccAddressFromBech32(grant.Granter) - if err != nil { - panic(err) - } - grantee, err := sdk.AccAddressFromBech32(grant.Grantee) - if err != nil { - panic(err) - } - granterAddr = granter - granteeAddr = grantee - hasGrant = true - return true - }) - - if !hasGrant { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRevokeFeeAllowance, "no grants"), nil, nil - } - granter, ok := simtypes.FindAccount(accs, granterAddr) - - if !ok { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRevokeFeeAllowance, "Account not found"), nil, nil - } - - account := ak.GetAccount(ctx, granter.Address) - spendableCoins := bk.SpendableCoins(ctx, account.GetAddress()) - fees, err := simtypes.RandomFees(r, ctx, spendableCoins) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRevokeFeeAllowance, err.Error()), nil, err - } - - msg := types.NewMsgRevokeFeeAllowance(granterAddr, granteeAddr) - - txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( - txGen, - []sdk.Msg{&msg}, - fees, - helpers.DefaultGenTxGas, - chainID, - []uint64{account.GetAccountNumber()}, - []uint64{account.GetSequence()}, - granter.PrivKey, - ) - - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRevokeFeeAllowance, err.Error()), nil, err - } - - _, _, err = app.Deliver(txGen.TxEncoder(), tx) - return simtypes.NewOperationMsg(&msg, true, ""), nil, err - } -} +// import ( +// "math/rand" +// "time" + +// "github.com/cosmos/cosmos-sdk/baseapp" +// "github.com/cosmos/cosmos-sdk/codec" +// "github.com/cosmos/cosmos-sdk/simapp/helpers" +// simappparams "github.com/cosmos/cosmos-sdk/simapp/params" +// sdk "github.com/cosmos/cosmos-sdk/types" +// simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +// "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" +// "github.com/cosmos/cosmos-sdk/x/feegrant/types" +// "github.com/cosmos/cosmos-sdk/x/simulation" +// ) + +// // Simulation operation weights constants +// const ( +// OpWeightMsgGrantFeeAllowance = "op_weight_msg_grant_fee_allowance" +// OpWeightMsgRevokeFeeAllowance = "op_weight_msg_grant_revoke_allowance" +// ) + +// func WeightedOperations( +// appParams simtypes.AppParams, cdc codec.JSONMarshaler, +// ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, +// ) simulation.WeightedOperations { + +// var ( +// weightMsgGrantFeeAllowance int +// weightMsgRevokeFeeAllowance int +// ) + +// appParams.GetOrGenerate(cdc, OpWeightMsgGrantFeeAllowance, &weightMsgGrantFeeAllowance, nil, +// func(_ *rand.Rand) { +// weightMsgGrantFeeAllowance = simappparams.DefaultWeightGrantFeeAllowance +// }, +// ) + +// appParams.GetOrGenerate(cdc, OpWeightMsgRevokeFeeAllowance, &weightMsgRevokeFeeAllowance, nil, +// func(_ *rand.Rand) { +// weightMsgRevokeFeeAllowance = simappparams.DefaultWeightRevokeFeeAllowance +// }, +// ) + +// return simulation.WeightedOperations{ +// simulation.NewWeightedOperation( +// weightMsgGrantFeeAllowance, +// SimulateMsgGrantFeeAllowance(ak, bk, k), +// ), +// simulation.NewWeightedOperation( +// weightMsgRevokeFeeAllowance, +// SimulateMsgRevokeFeeAllowance(ak, bk, k), +// ), +// } +// } + +// func SimulateMsgGrantFeeAllowance(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { +// return func( +// r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, +// ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { +// granter, _ := simtypes.RandomAcc(r, accs) +// grantee, _ := simtypes.RandomAcc(r, accs) + +// account := ak.GetAccount(ctx, granter.Address) + +// spendableCoins := bk.SpendableCoins(ctx, account.GetAddress()) +// fees, err := simtypes.RandomFees(r, ctx, spendableCoins) +// if err != nil { +// return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgGrantFeeAllowance, err.Error()), nil, err +// } + +// spendableCoins = spendableCoins.Sub(fees) + +// msg, err := types.NewMsgGrantFeeAllowance(&types.BasicFeeAllowance{ +// SpendLimit: spendableCoins, +// Expiration: types.ExpiresAtTime(ctx.BlockTime().Add(30 * time.Hour)), +// }, granter.Address, grantee.Address) + +// if err != nil { +// return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgGrantFeeAllowance, err.Error()), nil, err +// } +// txGen := simappparams.MakeTestEncodingConfig().TxConfig +// tx, err := helpers.GenTx( +// txGen, +// []sdk.Msg{msg}, +// fees, +// helpers.DefaultGenTxGas, +// chainID, +// []uint64{account.GetAccountNumber()}, +// []uint64{account.GetSequence()}, +// granter.PrivKey, +// ) + +// if err != nil { +// return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgGrantFeeAllowance, "unable to generate mock tx"), nil, err +// } + +// _, _, err = app.Deliver(txGen.TxEncoder(), tx) + +// if err != nil { +// return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err +// } +// return simtypes.NewOperationMsg(msg, true, ""), nil, err +// } +// } + +// func SimulateMsgRevokeFeeAllowance(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { +// return func( +// r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, +// ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + +// hasGrant := false +// var granterAddr sdk.AccAddress +// var granteeAddr sdk.AccAddress +// k.IterateAllFeeAllowances(ctx, func(grant types.FeeAllowanceGrant) bool { + +// granter, err := sdk.AccAddressFromBech32(grant.Granter) +// if err != nil { +// panic(err) +// } +// grantee, err := sdk.AccAddressFromBech32(grant.Grantee) +// if err != nil { +// panic(err) +// } +// granterAddr = granter +// granteeAddr = grantee +// hasGrant = true +// return true +// }) + +// if !hasGrant { +// return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRevokeFeeAllowance, "no grants"), nil, nil +// } +// granter, ok := simtypes.FindAccount(accs, granterAddr) + +// if !ok { +// return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRevokeFeeAllowance, "Account not found"), nil, nil +// } + +// account := ak.GetAccount(ctx, granter.Address) +// spendableCoins := bk.SpendableCoins(ctx, account.GetAddress()) +// fees, err := simtypes.RandomFees(r, ctx, spendableCoins) +// if err != nil { +// return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRevokeFeeAllowance, err.Error()), nil, err +// } + +// msg := types.NewMsgRevokeFeeAllowance(granterAddr, granteeAddr) + +// txGen := simappparams.MakeTestEncodingConfig().TxConfig +// tx, err := helpers.GenTx( +// txGen, +// []sdk.Msg{&msg}, +// fees, +// helpers.DefaultGenTxGas, +// chainID, +// []uint64{account.GetAccountNumber()}, +// []uint64{account.GetSequence()}, +// granter.PrivKey, +// ) + +// if err != nil { +// return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRevokeFeeAllowance, err.Error()), nil, err +// } + +// _, _, err = app.Deliver(txGen.TxEncoder(), tx) +// return simtypes.NewOperationMsg(&msg, true, ""), nil, err +// } +// } diff --git a/x/feegrant/simulation/operations_test.go b/x/feegrant/simulation/operations_test.go index b59ff479bd21..e01c2db01f67 100644 --- a/x/feegrant/simulation/operations_test.go +++ b/x/feegrant/simulation/operations_test.go @@ -1,170 +1,170 @@ package simulation_test -import ( - "math/rand" - "testing" - "time" - - abci "github.com/tendermint/tendermint/abci/types" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - - "github.com/cosmos/cosmos-sdk/simapp" - simappparams "github.com/cosmos/cosmos-sdk/simapp/params" - sdk "github.com/cosmos/cosmos-sdk/types" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/feegrant/simulation" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" - "github.com/stretchr/testify/suite" -) - -type SimTestSuite struct { - suite.Suite - - ctx sdk.Context - app *simapp.SimApp -} - -func (suite *SimTestSuite) SetupTest() { - checkTx := false - app := simapp.Setup(checkTx) - suite.app = app - suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{}) -} - -func (suite *SimTestSuite) getTestingAccounts(r *rand.Rand, n int) []simtypes.Account { - app, ctx := suite.app, suite.ctx - accounts := simtypes.RandomAccounts(r, n) - require := suite.Require() - - initAmt := sdk.TokensFromConsensusPower(200) - initCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initAmt)) - - // add coins to the accounts - for _, account := range accounts { - acc := app.AccountKeeper.NewAccountWithAddress(ctx, account.Address) - app.AccountKeeper.SetAccount(ctx, acc) - err := app.BankKeeper.SetBalances(ctx, account.Address, initCoins) - require.NoError(err) - } - - return accounts -} - -func (suite *SimTestSuite) TestWeightedOperations() { - app, ctx := suite.app, suite.ctx - require := suite.Require() - - ctx.WithChainID("test-chain") - - cdc := app.AppCodec() - appParams := make(simtypes.AppParams) - - weightesOps := simulation.WeightedOperations( - appParams, cdc, app.AccountKeeper, - app.BankKeeper, app.FeeGrantKeeper, - ) - - s := rand.NewSource(1) - r := rand.New(s) - accs := suite.getTestingAccounts(r, 3) - - expected := []struct { - weight int - opMsgRoute string - opMsgName string - }{ - { - simappparams.DefaultWeightGrantFeeAllowance, - types.ModuleName, - types.TypeMsgGrantFeeAllowance, - }, - { - simappparams.DefaultWeightRevokeFeeAllowance, - types.ModuleName, - types.TypeMsgRevokeFeeAllowance, - }, - } - - for i, w := range weightesOps { - operationMsg, _, _ := w.Op()(r, app.BaseApp, ctx, accs, ctx.ChainID()) - // the following checks are very much dependent from the ordering of the output given - // by WeightedOperations. if the ordering in WeightedOperations changes some tests - // will fail - require.Equal(expected[i].weight, w.Weight(), "weight should be the same") - require.Equal(expected[i].opMsgRoute, operationMsg.Route, "route should be the same") - require.Equal(expected[i].opMsgName, operationMsg.Name, "operation Msg name should be the same") - } -} - -func (suite *SimTestSuite) TestSimulateMsgGrantFeeAllowance() { - app, ctx := suite.app, suite.ctx - require := suite.Require() - - s := rand.NewSource(1) - r := rand.New(s) - accounts := suite.getTestingAccounts(r, 3) - - // begin a new block - app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash}}) - - // execute operation - op := simulation.SimulateMsgGrantFeeAllowance(app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper) - operationMsg, futureOperations, err := op(r, app.BaseApp, ctx, accounts, "") - require.NoError(err) - - var msg types.MsgGrantFeeAllowance - types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) - - require.True(operationMsg.OK) - require.Equal("cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r", msg.Granter) - require.Equal("cosmos1p8wcgrjr4pjju90xg6u9cgq55dxwq8j7u4x9a0", msg.Grantee) - require.Equal(types.TypeMsgGrantFeeAllowance, msg.Type()) - require.Equal(types.ModuleName, msg.Route()) - require.Len(futureOperations, 0) -} - -func (suite *SimTestSuite) TestSimulateMsgRevokeFeeAllowance() { - app, ctx := suite.app, suite.ctx - require := suite.Require() - - s := rand.NewSource(1) - r := rand.New(s) - accounts := suite.getTestingAccounts(r, 3) - - // begin a new block - app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}}) - - feeAmt := sdk.TokensFromConsensusPower(200000) - feeCoins := sdk.NewCoins(sdk.NewCoin("foo", feeAmt)) - - granter, grantee := accounts[0], accounts[1] - - app.FeeGrantKeeper.GrantFeeAllowance( - ctx, - granter.Address, - grantee.Address, - &types.BasicFeeAllowance{ - SpendLimit: feeCoins, - Expiration: types.ExpiresAtTime(ctx.BlockTime().Add(30 * time.Hour)), - }, - ) - - // execute operation - op := simulation.SimulateMsgRevokeFeeAllowance(app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper) - operationMsg, futureOperations, err := op(r, app.BaseApp, ctx, accounts, "") - require.NoError(err) - - var msg types.MsgRevokeFeeAllowance - types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) - - require.True(operationMsg.OK) - require.Equal(granter.Address.String(), msg.Granter) - require.Equal(grantee.Address.String(), msg.Grantee) - require.Equal(types.TypeMsgRevokeFeeAllowance, msg.Type()) - require.Equal(types.ModuleName, msg.Route()) - require.Len(futureOperations, 0) -} - -func TestSimTestSuite(t *testing.T) { - suite.Run(t, new(SimTestSuite)) -} +// import ( +// "math/rand" +// "testing" +// "time" + +// abci "github.com/tendermint/tendermint/abci/types" +// tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + +// "github.com/cosmos/cosmos-sdk/simapp" +// simappparams "github.com/cosmos/cosmos-sdk/simapp/params" +// sdk "github.com/cosmos/cosmos-sdk/types" +// simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +// "github.com/cosmos/cosmos-sdk/x/feegrant/simulation" +// "github.com/cosmos/cosmos-sdk/x/feegrant/types" +// "github.com/stretchr/testify/suite" +// ) + +// type SimTestSuite struct { +// suite.Suite + +// ctx sdk.Context +// app *simapp.SimApp +// } + +// func (suite *SimTestSuite) SetupTest() { +// checkTx := false +// app := simapp.Setup(checkTx) +// suite.app = app +// suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{}) +// } + +// func (suite *SimTestSuite) getTestingAccounts(r *rand.Rand, n int) []simtypes.Account { +// app, ctx := suite.app, suite.ctx +// accounts := simtypes.RandomAccounts(r, n) +// require := suite.Require() + +// initAmt := sdk.TokensFromConsensusPower(200) +// initCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initAmt)) + +// // add coins to the accounts +// for _, account := range accounts { +// acc := app.AccountKeeper.NewAccountWithAddress(ctx, account.Address) +// app.AccountKeeper.SetAccount(ctx, acc) +// err := app.BankKeeper.SetBalances(ctx, account.Address, initCoins) +// require.NoError(err) +// } + +// return accounts +// } + +// func (suite *SimTestSuite) TestWeightedOperations() { +// app, ctx := suite.app, suite.ctx +// require := suite.Require() + +// ctx.WithChainID("test-chain") + +// cdc := app.AppCodec() +// appParams := make(simtypes.AppParams) + +// weightesOps := simulation.WeightedOperations( +// appParams, cdc, app.AccountKeeper, +// app.BankKeeper, app.FeeGrantKeeper, +// ) + +// s := rand.NewSource(1) +// r := rand.New(s) +// accs := suite.getTestingAccounts(r, 3) + +// expected := []struct { +// weight int +// opMsgRoute string +// opMsgName string +// }{ +// { +// simappparams.DefaultWeightGrantFeeAllowance, +// types.ModuleName, +// types.TypeMsgGrantFeeAllowance, +// }, +// { +// simappparams.DefaultWeightRevokeFeeAllowance, +// types.ModuleName, +// types.TypeMsgRevokeFeeAllowance, +// }, +// } + +// for i, w := range weightesOps { +// operationMsg, _, _ := w.Op()(r, app.BaseApp, ctx, accs, ctx.ChainID()) +// // the following checks are very much dependent from the ordering of the output given +// // by WeightedOperations. if the ordering in WeightedOperations changes some tests +// // will fail +// require.Equal(expected[i].weight, w.Weight(), "weight should be the same") +// require.Equal(expected[i].opMsgRoute, operationMsg.Route, "route should be the same") +// require.Equal(expected[i].opMsgName, operationMsg.Name, "operation Msg name should be the same") +// } +// } + +// func (suite *SimTestSuite) TestSimulateMsgGrantFeeAllowance() { +// app, ctx := suite.app, suite.ctx +// require := suite.Require() + +// s := rand.NewSource(1) +// r := rand.New(s) +// accounts := suite.getTestingAccounts(r, 3) + +// // begin a new block +// app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash}}) + +// // execute operation +// op := simulation.SimulateMsgGrantFeeAllowance(app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper) +// operationMsg, futureOperations, err := op(r, app.BaseApp, ctx, accounts, "") +// require.NoError(err) + +// var msg types.MsgGrantFeeAllowance +// types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) + +// require.True(operationMsg.OK) +// require.Equal("cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r", msg.Granter) +// require.Equal("cosmos1p8wcgrjr4pjju90xg6u9cgq55dxwq8j7u4x9a0", msg.Grantee) +// require.Equal(types.TypeMsgGrantFeeAllowance, msg.Type()) +// require.Equal(types.ModuleName, msg.Route()) +// require.Len(futureOperations, 0) +// } + +// func (suite *SimTestSuite) TestSimulateMsgRevokeFeeAllowance() { +// app, ctx := suite.app, suite.ctx +// require := suite.Require() + +// s := rand.NewSource(1) +// r := rand.New(s) +// accounts := suite.getTestingAccounts(r, 3) + +// // begin a new block +// app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}}) + +// feeAmt := sdk.TokensFromConsensusPower(200000) +// feeCoins := sdk.NewCoins(sdk.NewCoin("foo", feeAmt)) + +// granter, grantee := accounts[0], accounts[1] + +// app.FeeGrantKeeper.GrantFeeAllowance( +// ctx, +// granter.Address, +// grantee.Address, +// &types.BasicFeeAllowance{ +// SpendLimit: feeCoins, +// Expiration: types.ExpiresAtTime(ctx.BlockTime().Add(30 * time.Hour)), +// }, +// ) + +// // execute operation +// op := simulation.SimulateMsgRevokeFeeAllowance(app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper) +// operationMsg, futureOperations, err := op(r, app.BaseApp, ctx, accounts, "") +// require.NoError(err) + +// var msg types.MsgRevokeFeeAllowance +// types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) + +// require.True(operationMsg.OK) +// require.Equal(granter.Address.String(), msg.Granter) +// require.Equal(grantee.Address.String(), msg.Grantee) +// require.Equal(types.TypeMsgRevokeFeeAllowance, msg.Type()) +// require.Equal(types.ModuleName, msg.Route()) +// require.Len(futureOperations, 0) +// } + +// func TestSimTestSuite(t *testing.T) { +// suite.Run(t, new(SimTestSuite)) +// } diff --git a/x/feegrant/types/codec.go b/x/feegrant/types/codec.go index d1df61df0f6b..37c3b1f04037 100644 --- a/x/feegrant/types/codec.go +++ b/x/feegrant/types/codec.go @@ -1,27 +1,14 @@ package types import ( - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) -// RegisterLegacyAminoCodec registers concrete types and interfaces on the given codec. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterInterface((*FeeAllowanceI)(nil), nil) - cdc.RegisterInterface((*sdk.MsgRequest)(nil), nil) - cdc.RegisterConcrete(&MsgGrantFeeAllowance{}, "cosmos-sdk/MsgGrantFeeAllowance", nil) - cdc.RegisterConcrete(&MsgRevokeFeeAllowance{}, "cosmos-sdk/MsgRevokeFeeAllowance", nil) - cdc.RegisterConcrete(&BasicFeeAllowance{}, "cosmos-sdk/BasicFeeAllowance", nil) - cdc.RegisterConcrete(&PeriodicFeeAllowance{}, "cosmos-sdk/PeriodicFeeAllowance", nil) - // cdc.RegisterConcrete(FeeGrantTx{}, "cosmos-sdk/FeeGrantTx", nil) -} - // RegisterInterfaces registers the interfaces types with the interface registry func RegisterInterfaces(registry types.InterfaceRegistry) { - registry.RegisterImplementations((*sdk.Msg)(nil), + registry.RegisterImplementations((*sdk.MsgRequest)(nil), &MsgGrantFeeAllowance{}, &MsgRevokeFeeAllowance{}, ) @@ -35,21 +22,3 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } - -var ( - amino = codec.NewLegacyAmino() - - // ModuleCdc references the global x/feegrant module codec. Note, the codec should - // ONLY be used in certain instances of tests and for JSON encoding as Amino is - // still used for that purpose. - // - // The actual codec used for serialization should be provided to x/feegrant and - // defined at the application level. - ModuleCdc = codec.NewAminoCodec(amino) -) - -func init() { - RegisterLegacyAminoCodec(amino) - cryptocodec.RegisterCrypto(amino) - amino.Seal() -} diff --git a/x/feegrant/types/msgs.go b/x/feegrant/types/msgs.go index b22785ca2c23..0614a8397be8 100644 --- a/x/feegrant/types/msgs.go +++ b/x/feegrant/types/msgs.go @@ -10,7 +10,7 @@ import ( ) var ( - _, _ sdk.Msg = &MsgGrantFeeAllowance{}, &MsgRevokeFeeAllowance{} + _, _ sdk.MsgRequest = &MsgGrantFeeAllowance{}, &MsgRevokeFeeAllowance{} _ types.UnpackInterfacesMessage = &MsgGrantFeeAllowance{} ) @@ -39,20 +39,6 @@ func NewMsgGrantFeeAllowance(feeAllowance FeeAllowanceI, granter, grantee sdk.Ac }, nil } -// func (msg MsgGrantFeeAllowance) GetFeeGrant() FeeAllowanceI { -// return msg.GetFeeAllowanceI() -// } - -// Route implements the sdk.Msg interface. -func (msg MsgGrantFeeAllowance) Route() string { - return RouterKey -} - -// Type implements the sdk.Msg interface. -func (msg MsgGrantFeeAllowance) Type() string { - return TypeMsgGrantFeeAllowance -} - // ValidateBasic implements the sdk.Msg interface. func (msg MsgGrantFeeAllowance) ValidateBasic() error { if msg.Granter == "" { @@ -65,11 +51,6 @@ func (msg MsgGrantFeeAllowance) ValidateBasic() error { return nil } -// GetSignBytes returns the message bytes to sign over. -func (msg MsgGrantFeeAllowance) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - func (msg MsgGrantFeeAllowance) GetSigners() []sdk.AccAddress { granter, err := sdk.AccAddressFromBech32(msg.Granter) if err != nil { @@ -99,14 +80,6 @@ func NewMsgRevokeFeeAllowance(granter sdk.AccAddress, grantee sdk.AccAddress) Ms return MsgRevokeFeeAllowance{Granter: granter.String(), Grantee: grantee.String()} } -func (msg MsgRevokeFeeAllowance) Route() string { - return RouterKey -} - -func (msg MsgRevokeFeeAllowance) Type() string { - return TypeMsgRevokeFeeAllowance -} - func (msg MsgRevokeFeeAllowance) ValidateBasic() error { if msg.Granter == "" { return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "missing granter address") @@ -118,10 +91,6 @@ func (msg MsgRevokeFeeAllowance) ValidateBasic() error { return nil } -func (msg MsgRevokeFeeAllowance) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - func (msg MsgRevokeFeeAllowance) GetSigners() []sdk.AccAddress { granter, err := sdk.AccAddressFromBech32(msg.Granter) if err != nil { From e735ad81fdc117f43899f63d5b210d0a5bc546ba Mon Sep 17 00:00:00 2001 From: aleem1413 Date: Thu, 17 Dec 2020 20:11:56 +0530 Subject: [PATCH 125/184] add grpc queries tests --- x/feegrant/client/rest/grpc_query_test.go | 210 ++++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 x/feegrant/client/rest/grpc_query_test.go diff --git a/x/feegrant/client/rest/grpc_query_test.go b/x/feegrant/client/rest/grpc_query_test.go new file mode 100644 index 000000000000..5403fe3036ee --- /dev/null +++ b/x/feegrant/client/rest/grpc_query_test.go @@ -0,0 +1,210 @@ +package rest_test + +import ( + "fmt" + "testing" + + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/cosmos/cosmos-sdk/testutil/network" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/rest" + banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil" + "github.com/cosmos/cosmos-sdk/x/feegrant/client/cli" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/stretchr/testify/suite" +) + +type IntegrationTestSuite struct { + suite.Suite + cfg network.Config + network *network.Network + grantee sdk.AccAddress +} + +func (s *IntegrationTestSuite) SetupSuite() { + s.T().Log("setting up integration test suite") + + cfg := network.DefaultConfig() + + cfg.NumValidators = 1 + s.cfg = cfg + s.network = network.New(s.T(), cfg) + + val := s.network.Validators[0] + // Create new account in the keyring. + info, _, err := val.ClientCtx.Keyring.NewMnemonic("grantee", keyring.English, sdk.FullFundraiserPath, hd.Secp256k1) + s.Require().NoError(err) + newAddr := sdk.AccAddress(info.GetPubKey().Address()) + + // Send some funds to the new account. + _, err = banktestutil.MsgSendExec( + val.ClientCtx, + val.Address, + newAddr, + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(200))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + ) + s.Require().NoError(err) + + s.grantee = newAddr + _, err = s.network.WaitForHeight(1) + s.Require().NoError(err) +} + +func (s *IntegrationTestSuite) TearDownSuite() { + s.T().Log("tearing down integration test suite") + s.network.Cleanup() +} + +func (s *IntegrationTestSuite) TestQueryFeeAllowence() { + val := s.network.Validators[0] + baseURL := val.APIAddress + testCases := []struct { + name string + url string + expectErr bool + errorMsg string + preRun func() + postRun func(_ types.QueryFeeAllowanceResponse) + }{ + { + "fail: invalid granter", + fmt.Sprintf("%s/cosmos/feegrant/v1beta1/granters/%s/grantees/%s/grant", baseURL, "invalid_granter", s.grantee.String()), + true, + "decoding bech32 failed: invalid index of 1: invalid request", + func() {}, + func(types.QueryFeeAllowanceResponse) {}, + }, + { + "fail: invalid grantee", + fmt.Sprintf("%s/cosmos/feegrant/v1beta1/granters/%s/grantees/%s/grant", baseURL, val.Address.String(), "invalid_grantee"), + true, + "decoding bech32 failed: invalid index of 1: invalid request", + func() {}, + func(types.QueryFeeAllowanceResponse) {}, + }, + { + "fail: no grants", + fmt.Sprintf("%s/cosmos/feegrant/v1beta1/granters/%s/grantees/%s/grant", baseURL, val.Address.String(), s.grantee.String()), + true, + "no fee allowance found", + func() {}, + func(types.QueryFeeAllowanceResponse) {}, + }, + { + "valid query: expect single grant", + fmt.Sprintf("%s/cosmos/feegrant/v1beta1/granters/%s/grantees/%s/grant", baseURL, val.Address.String(), s.grantee.String()), + false, + "", + func() { + execFeeAllowence(val, s) + }, + func(allowence types.QueryFeeAllowanceResponse) { + s.Require().Equal(allowence.FeeAllowance.Granter, val.Address.String()) + s.Require().Equal(allowence.FeeAllowance.Grantee, s.grantee.String()) + }, + }, + } + for _, tc := range testCases { + s.Run(tc.name, func() { + tc.preRun() + resp, _ := rest.GetRequest(tc.url) + if tc.expectErr { + s.Require().Contains(string(resp), tc.errorMsg) + } else { + var allowence types.QueryFeeAllowanceResponse + err := val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &allowence) + s.Require().NoError(err) + tc.postRun(allowence) + } + }) + } +} + +func (s *IntegrationTestSuite) TestQueryGranteeAllowences() { + val := s.network.Validators[0] + baseURL := val.APIAddress + testCases := []struct { + name string + url string + expectErr bool + errorMsg string + preRun func() + postRun func(_ types.QueryFeeAllowancesResponse) + }{ + { + "fail: invalid grantee", + fmt.Sprintf("%s/cosmos/feegrant/v1beta1/grants/%s", baseURL, "invalid_grantee"), + true, + "decoding bech32 failed: invalid index of 1: invalid request", + func() {}, + func(types.QueryFeeAllowancesResponse) {}, + }, + { + "success: no grants", + fmt.Sprintf("%s/cosmos/feegrant/v1beta1/grants/%s?pagination.offset=1", baseURL, s.grantee.String()), + false, + "", + func() {}, + func(allowences types.QueryFeeAllowancesResponse) { + s.Require().Equal(len(allowences.FeeAllowances), 0) + }, + }, + { + "valid query: expect single grant", + fmt.Sprintf("%s/cosmos/feegrant/v1beta1/grants/%s", baseURL, s.grantee.String()), + false, + "", + func() { + execFeeAllowence(val, s) + }, + func(allowences types.QueryFeeAllowancesResponse) { + s.Require().Equal(len(allowences.FeeAllowances), 1) + s.Require().Equal(allowences.FeeAllowances[0].Granter, val.Address.String()) + s.Require().Equal(allowences.FeeAllowances[0].Grantee, s.grantee.String()) + }, + }, + } + for _, tc := range testCases { + s.Run(tc.name, func() { + tc.preRun() + resp, _ := rest.GetRequest(tc.url) + if tc.expectErr { + s.Require().Contains(string(resp), tc.errorMsg) + } else { + var allowence types.QueryFeeAllowancesResponse + err := val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &allowence) + s.Require().NoError(err) + tc.postRun(allowence) + } + }) + } +} + +func execFeeAllowence(val *network.Validator, s *IntegrationTestSuite) { + fee := sdk.NewCoin("steak", sdk.NewInt(100)) + duration := 365 * 24 * 60 * 60 + args := []string{ + val.Address.String(), + s.grantee.String(), + fee.String(), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=%v", cli.FlagExpiration, duration), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + cmd := cli.NewCmdFeeGrant() + _, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args) + s.Require().NoError(err) + +} + +func TestIntegrationTestSuite(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) +} From dff0c6359101c7e9360fe0dccc82bfedaae52b05 Mon Sep 17 00:00:00 2001 From: aleem1413 Date: Sat, 19 Dec 2020 10:43:15 +0530 Subject: [PATCH 126/184] fix simulations --- simapp/helpers/service_msg_client.go | 50 ++++ types/simulation/types.go | 11 +- x/bank/simulation/operations.go | 4 +- x/distribution/simulation/operations.go | 8 +- x/feegrant/simulation/operations.go | 347 ++++++++++++----------- x/feegrant/simulation/operations_test.go | 338 +++++++++++----------- x/gov/simulation/operations.go | 6 +- x/slashing/simulation/operations.go | 10 +- x/staking/simulation/operations.go | 10 +- 9 files changed, 429 insertions(+), 355 deletions(-) create mode 100644 simapp/helpers/service_msg_client.go diff --git a/simapp/helpers/service_msg_client.go b/simapp/helpers/service_msg_client.go new file mode 100644 index 000000000000..2c8a273ce68e --- /dev/null +++ b/simapp/helpers/service_msg_client.go @@ -0,0 +1,50 @@ +package helpers + +import ( + "context" + "fmt" + + gogogrpc "github.com/gogo/protobuf/grpc" + grpc "google.golang.org/grpc" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ gogogrpc.ClientConn = &ServiceMsgClientConn{} + +// ServiceMsgClientConn is an instance of grpc.ClientConn that is used to test building +// transactions with MsgClient's. It is intended to be replaced by the work in +// https://github.com/cosmos/cosmos-sdk/issues/7541 when that is ready. +type ServiceMsgClientConn struct { + msgs []sdk.Msg +} + +// Invoke implements the grpc ClientConn.Invoke method +func (t *ServiceMsgClientConn) Invoke(_ context.Context, method string, args, _ interface{}, _ ...grpc.CallOption) error { + req, ok := args.(sdk.MsgRequest) + if !ok { + return fmt.Errorf("%T should implement %T", args, (*sdk.MsgRequest)(nil)) + } + + err := req.ValidateBasic() + if err != nil { + return err + } + + t.msgs = append(t.msgs, sdk.ServiceMsg{ + MethodName: method, + Request: req, + }) + + return nil +} + +// NewStream implements the grpc ClientConn.NewStream method +func (t *ServiceMsgClientConn) NewStream(context.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error) { + return nil, fmt.Errorf("not supported") +} + +// GetMsgs returns ServiceMsgClientConn.msgs +func (t *ServiceMsgClientConn) GetMsgs() []sdk.Msg { + return t.msgs +} diff --git a/types/simulation/types.go b/types/simulation/types.go index f541b1d764de..41cc1a65619d 100644 --- a/types/simulation/types.go +++ b/types/simulation/types.go @@ -3,6 +3,7 @@ package simulation import ( "encoding/json" "math/rand" + "reflect" "time" "github.com/cosmos/cosmos-sdk/baseapp" @@ -75,7 +76,15 @@ func NewOperationMsgBasic(route, name, comment string, ok bool, msg []byte) Oper } // NewOperationMsg - create a new operation message from sdk.Msg -func NewOperationMsg(msg sdk.Msg, ok bool, comment string) OperationMsg { +func NewOperationMsg(msg sdk.Msg, ok bool, comment string, cdc *codec.ProtoCodec) OperationMsg { + if reflect.TypeOf(msg) == reflect.TypeOf(sdk.ServiceMsg{}) { + srvMsg, ok := msg.(sdk.ServiceMsg) + if !ok { + panic("failed: type assert") + } + bz := cdc.MustMarshalJSON(srvMsg.Request) + return NewOperationMsgBasic(srvMsg.MethodName, srvMsg.MethodName, comment, ok, bz) + } return NewOperationMsgBasic(msg.Route(), msg.Type(), comment, ok, msg.GetSignBytes()) } diff --git a/x/bank/simulation/operations.go b/x/bank/simulation/operations.go index 9fcc80f0fe45..40be2feeb4a0 100644 --- a/x/bank/simulation/operations.go +++ b/x/bank/simulation/operations.go @@ -76,7 +76,7 @@ func SimulateMsgSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Operatio return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "invalid transfers"), nil, err } - return simtypes.NewOperationMsg(msg, true, ""), nil, nil + return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil } } @@ -217,7 +217,7 @@ func SimulateMsgMultiSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Ope return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "invalid transfers"), nil, err } - return simtypes.NewOperationMsg(msg, true, ""), nil, nil + return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil } } diff --git a/x/distribution/simulation/operations.go b/x/distribution/simulation/operations.go index 09090d1f64d6..b83e6f8a4e4b 100644 --- a/x/distribution/simulation/operations.go +++ b/x/distribution/simulation/operations.go @@ -120,7 +120,7 @@ func SimulateMsgSetWithdrawAddress(ak types.AccountKeeper, bk types.BankKeeper, return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } - return simtypes.NewOperationMsg(msg, true, ""), nil, nil + return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil } } @@ -172,7 +172,7 @@ func SimulateMsgWithdrawDelegatorReward(ak types.AccountKeeper, bk types.BankKee return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } - return simtypes.NewOperationMsg(msg, true, ""), nil, nil + return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil } } @@ -227,7 +227,7 @@ func SimulateMsgWithdrawValidatorCommission(ak types.AccountKeeper, bk types.Ban return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } - return simtypes.NewOperationMsg(msg, true, ""), nil, nil + return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil } } @@ -282,6 +282,6 @@ func SimulateMsgFundCommunityPool(ak types.AccountKeeper, bk types.BankKeeper, k return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } - return simtypes.NewOperationMsg(msg, true, ""), nil, nil + return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil } } diff --git a/x/feegrant/simulation/operations.go b/x/feegrant/simulation/operations.go index e0b18a922ead..39f52007baf6 100644 --- a/x/feegrant/simulation/operations.go +++ b/x/feegrant/simulation/operations.go @@ -1,169 +1,182 @@ package simulation -// import ( -// "math/rand" -// "time" - -// "github.com/cosmos/cosmos-sdk/baseapp" -// "github.com/cosmos/cosmos-sdk/codec" -// "github.com/cosmos/cosmos-sdk/simapp/helpers" -// simappparams "github.com/cosmos/cosmos-sdk/simapp/params" -// sdk "github.com/cosmos/cosmos-sdk/types" -// simtypes "github.com/cosmos/cosmos-sdk/types/simulation" -// "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" -// "github.com/cosmos/cosmos-sdk/x/feegrant/types" -// "github.com/cosmos/cosmos-sdk/x/simulation" -// ) - -// // Simulation operation weights constants -// const ( -// OpWeightMsgGrantFeeAllowance = "op_weight_msg_grant_fee_allowance" -// OpWeightMsgRevokeFeeAllowance = "op_weight_msg_grant_revoke_allowance" -// ) - -// func WeightedOperations( -// appParams simtypes.AppParams, cdc codec.JSONMarshaler, -// ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, -// ) simulation.WeightedOperations { - -// var ( -// weightMsgGrantFeeAllowance int -// weightMsgRevokeFeeAllowance int -// ) - -// appParams.GetOrGenerate(cdc, OpWeightMsgGrantFeeAllowance, &weightMsgGrantFeeAllowance, nil, -// func(_ *rand.Rand) { -// weightMsgGrantFeeAllowance = simappparams.DefaultWeightGrantFeeAllowance -// }, -// ) - -// appParams.GetOrGenerate(cdc, OpWeightMsgRevokeFeeAllowance, &weightMsgRevokeFeeAllowance, nil, -// func(_ *rand.Rand) { -// weightMsgRevokeFeeAllowance = simappparams.DefaultWeightRevokeFeeAllowance -// }, -// ) - -// return simulation.WeightedOperations{ -// simulation.NewWeightedOperation( -// weightMsgGrantFeeAllowance, -// SimulateMsgGrantFeeAllowance(ak, bk, k), -// ), -// simulation.NewWeightedOperation( -// weightMsgRevokeFeeAllowance, -// SimulateMsgRevokeFeeAllowance(ak, bk, k), -// ), -// } -// } - -// func SimulateMsgGrantFeeAllowance(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { -// return func( -// r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, -// ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { -// granter, _ := simtypes.RandomAcc(r, accs) -// grantee, _ := simtypes.RandomAcc(r, accs) - -// account := ak.GetAccount(ctx, granter.Address) - -// spendableCoins := bk.SpendableCoins(ctx, account.GetAddress()) -// fees, err := simtypes.RandomFees(r, ctx, spendableCoins) -// if err != nil { -// return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgGrantFeeAllowance, err.Error()), nil, err -// } - -// spendableCoins = spendableCoins.Sub(fees) - -// msg, err := types.NewMsgGrantFeeAllowance(&types.BasicFeeAllowance{ -// SpendLimit: spendableCoins, -// Expiration: types.ExpiresAtTime(ctx.BlockTime().Add(30 * time.Hour)), -// }, granter.Address, grantee.Address) - -// if err != nil { -// return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgGrantFeeAllowance, err.Error()), nil, err -// } -// txGen := simappparams.MakeTestEncodingConfig().TxConfig -// tx, err := helpers.GenTx( -// txGen, -// []sdk.Msg{msg}, -// fees, -// helpers.DefaultGenTxGas, -// chainID, -// []uint64{account.GetAccountNumber()}, -// []uint64{account.GetSequence()}, -// granter.PrivKey, -// ) - -// if err != nil { -// return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgGrantFeeAllowance, "unable to generate mock tx"), nil, err -// } - -// _, _, err = app.Deliver(txGen.TxEncoder(), tx) - -// if err != nil { -// return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err -// } -// return simtypes.NewOperationMsg(msg, true, ""), nil, err -// } -// } - -// func SimulateMsgRevokeFeeAllowance(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { -// return func( -// r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, -// ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - -// hasGrant := false -// var granterAddr sdk.AccAddress -// var granteeAddr sdk.AccAddress -// k.IterateAllFeeAllowances(ctx, func(grant types.FeeAllowanceGrant) bool { - -// granter, err := sdk.AccAddressFromBech32(grant.Granter) -// if err != nil { -// panic(err) -// } -// grantee, err := sdk.AccAddressFromBech32(grant.Grantee) -// if err != nil { -// panic(err) -// } -// granterAddr = granter -// granteeAddr = grantee -// hasGrant = true -// return true -// }) - -// if !hasGrant { -// return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRevokeFeeAllowance, "no grants"), nil, nil -// } -// granter, ok := simtypes.FindAccount(accs, granterAddr) - -// if !ok { -// return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRevokeFeeAllowance, "Account not found"), nil, nil -// } - -// account := ak.GetAccount(ctx, granter.Address) -// spendableCoins := bk.SpendableCoins(ctx, account.GetAddress()) -// fees, err := simtypes.RandomFees(r, ctx, spendableCoins) -// if err != nil { -// return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRevokeFeeAllowance, err.Error()), nil, err -// } - -// msg := types.NewMsgRevokeFeeAllowance(granterAddr, granteeAddr) - -// txGen := simappparams.MakeTestEncodingConfig().TxConfig -// tx, err := helpers.GenTx( -// txGen, -// []sdk.Msg{&msg}, -// fees, -// helpers.DefaultGenTxGas, -// chainID, -// []uint64{account.GetAccountNumber()}, -// []uint64{account.GetSequence()}, -// granter.PrivKey, -// ) - -// if err != nil { -// return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRevokeFeeAllowance, err.Error()), nil, err -// } - -// _, _, err = app.Deliver(txGen.TxEncoder(), tx) -// return simtypes.NewOperationMsg(&msg, true, ""), nil, err -// } -// } +import ( + "context" + "math/rand" + "time" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/simapp/helpers" + simappparams "github.com/cosmos/cosmos-sdk/simapp/params" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/simulation" +) + +// Simulation operation weights constants +const ( + OpWeightMsgGrantFeeAllowance = "op_weight_msg_grant_fee_allowance" + OpWeightMsgRevokeFeeAllowance = "op_weight_msg_grant_revoke_allowance" + TypeMsgGrantFeeAllowance = "/cosmos.feegrant.v1beta1.Msg/GrantFeeAllowance" + TypeMsgRevokeFeeAllowance = "/cosmos.feegrant.v1beta1.Msg/RevokeFeeAllowance" +) + +func WeightedOperations( + appParams simtypes.AppParams, cdc codec.JSONMarshaler, + ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, + protoCdc *codec.ProtoCodec, +) simulation.WeightedOperations { + + var ( + weightMsgGrantFeeAllowance int + weightMsgRevokeFeeAllowance int + ) + + appParams.GetOrGenerate(cdc, OpWeightMsgGrantFeeAllowance, &weightMsgGrantFeeAllowance, nil, + func(_ *rand.Rand) { + weightMsgGrantFeeAllowance = simappparams.DefaultWeightGrantFeeAllowance + }, + ) + + appParams.GetOrGenerate(cdc, OpWeightMsgRevokeFeeAllowance, &weightMsgRevokeFeeAllowance, nil, + func(_ *rand.Rand) { + weightMsgRevokeFeeAllowance = simappparams.DefaultWeightRevokeFeeAllowance + }, + ) + + return simulation.WeightedOperations{ + simulation.NewWeightedOperation( + weightMsgGrantFeeAllowance, + SimulateMsgGrantFeeAllowance(ak, bk, k, protoCdc), + ), + simulation.NewWeightedOperation( + weightMsgRevokeFeeAllowance, + SimulateMsgRevokeFeeAllowance(ak, bk, k, protoCdc), + ), + } +} + +// SimulateMsgGrantFeeAllowance generates MsgGrantFeeAllowance with random values. +func SimulateMsgGrantFeeAllowance(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, protoCdc *codec.ProtoCodec) simtypes.Operation { + return func( + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + granter, _ := simtypes.RandomAcc(r, accs) + grantee, _ := simtypes.RandomAcc(r, accs) + + account := ak.GetAccount(ctx, granter.Address) + + spendableCoins := bk.SpendableCoins(ctx, account.GetAddress()) + fees, err := simtypes.RandomFees(r, ctx, spendableCoins) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgGrantFeeAllowance, err.Error()), nil, err + } + + spendableCoins = spendableCoins.Sub(fees) + + msg, err := types.NewMsgGrantFeeAllowance(&types.BasicFeeAllowance{ + SpendLimit: spendableCoins, + Expiration: types.ExpiresAtTime(ctx.BlockTime().Add(30 * time.Hour)), + }, granter.Address, grantee.Address) + + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgGrantFeeAllowance, err.Error()), nil, err + } + txGen := simappparams.MakeTestEncodingConfig().TxConfig + svcMsgClientConn := &helpers.ServiceMsgClientConn{} + feegrantMsgClient := types.NewMsgClient(svcMsgClientConn) + _, err = feegrantMsgClient.GrantFeeAllowance(context.Background(), msg) + + tx, err := helpers.GenTx( + txGen, + svcMsgClientConn.GetMsgs(), + fees, + helpers.DefaultGenTxGas, + chainID, + []uint64{account.GetAccountNumber()}, + []uint64{account.GetSequence()}, + granter.PrivKey, + ) + + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, TypeMsgGrantFeeAllowance, "unable to generate mock tx"), nil, err + } + + _, _, err = app.Deliver(txGen.TxEncoder(), tx) + + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, svcMsgClientConn.GetMsgs()[0].Type(), "unable to deliver tx"), nil, err + } + return simtypes.NewOperationMsg(svcMsgClientConn.GetMsgs()[0], true, "", protoCdc), nil, err + } +} + +// SimulateMsgRevokeFeeAllowance generates a MsgRevokeFeeAllowance with random values. +func SimulateMsgRevokeFeeAllowance(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, protoCdc *codec.ProtoCodec) simtypes.Operation { + return func( + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + + hasGrant := false + var granterAddr sdk.AccAddress + var granteeAddr sdk.AccAddress + k.IterateAllFeeAllowances(ctx, func(grant types.FeeAllowanceGrant) bool { + + granter, err := sdk.AccAddressFromBech32(grant.Granter) + if err != nil { + panic(err) + } + grantee, err := sdk.AccAddressFromBech32(grant.Grantee) + if err != nil { + panic(err) + } + granterAddr = granter + granteeAddr = grantee + hasGrant = true + return true + }) + + if !hasGrant { + return simtypes.NoOpMsg(types.ModuleName, TypeMsgRevokeFeeAllowance, "no grants"), nil, nil + } + granter, ok := simtypes.FindAccount(accs, granterAddr) + + if !ok { + return simtypes.NoOpMsg(types.ModuleName, TypeMsgRevokeFeeAllowance, "Account not found"), nil, nil + } + + account := ak.GetAccount(ctx, granter.Address) + spendableCoins := bk.SpendableCoins(ctx, account.GetAddress()) + fees, err := simtypes.RandomFees(r, ctx, spendableCoins) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, TypeMsgRevokeFeeAllowance, err.Error()), nil, err + } + + msg := types.NewMsgRevokeFeeAllowance(granterAddr, granteeAddr) + + txGen := simappparams.MakeTestEncodingConfig().TxConfig + svcMsgClientConn := &helpers.ServiceMsgClientConn{} + feegrantMsgClient := types.NewMsgClient(svcMsgClientConn) + _, err = feegrantMsgClient.RevokeFeeAllowance(context.Background(), &msg) + tx, err := helpers.GenTx( + txGen, + svcMsgClientConn.GetMsgs(), + fees, + helpers.DefaultGenTxGas, + chainID, + []uint64{account.GetAccountNumber()}, + []uint64{account.GetSequence()}, + granter.PrivKey, + ) + + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, TypeMsgRevokeFeeAllowance, err.Error()), nil, err + } + + _, _, err = app.Deliver(txGen.TxEncoder(), tx) + return simtypes.NewOperationMsg(svcMsgClientConn.GetMsgs()[0], true, "", protoCdc), nil, err + } +} diff --git a/x/feegrant/simulation/operations_test.go b/x/feegrant/simulation/operations_test.go index e01c2db01f67..173e3772e581 100644 --- a/x/feegrant/simulation/operations_test.go +++ b/x/feegrant/simulation/operations_test.go @@ -1,170 +1,172 @@ package simulation_test -// import ( -// "math/rand" -// "testing" -// "time" - -// abci "github.com/tendermint/tendermint/abci/types" -// tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - -// "github.com/cosmos/cosmos-sdk/simapp" -// simappparams "github.com/cosmos/cosmos-sdk/simapp/params" -// sdk "github.com/cosmos/cosmos-sdk/types" -// simtypes "github.com/cosmos/cosmos-sdk/types/simulation" -// "github.com/cosmos/cosmos-sdk/x/feegrant/simulation" -// "github.com/cosmos/cosmos-sdk/x/feegrant/types" -// "github.com/stretchr/testify/suite" -// ) - -// type SimTestSuite struct { -// suite.Suite - -// ctx sdk.Context -// app *simapp.SimApp -// } - -// func (suite *SimTestSuite) SetupTest() { -// checkTx := false -// app := simapp.Setup(checkTx) -// suite.app = app -// suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{}) -// } - -// func (suite *SimTestSuite) getTestingAccounts(r *rand.Rand, n int) []simtypes.Account { -// app, ctx := suite.app, suite.ctx -// accounts := simtypes.RandomAccounts(r, n) -// require := suite.Require() - -// initAmt := sdk.TokensFromConsensusPower(200) -// initCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initAmt)) - -// // add coins to the accounts -// for _, account := range accounts { -// acc := app.AccountKeeper.NewAccountWithAddress(ctx, account.Address) -// app.AccountKeeper.SetAccount(ctx, acc) -// err := app.BankKeeper.SetBalances(ctx, account.Address, initCoins) -// require.NoError(err) -// } - -// return accounts -// } - -// func (suite *SimTestSuite) TestWeightedOperations() { -// app, ctx := suite.app, suite.ctx -// require := suite.Require() - -// ctx.WithChainID("test-chain") - -// cdc := app.AppCodec() -// appParams := make(simtypes.AppParams) - -// weightesOps := simulation.WeightedOperations( -// appParams, cdc, app.AccountKeeper, -// app.BankKeeper, app.FeeGrantKeeper, -// ) - -// s := rand.NewSource(1) -// r := rand.New(s) -// accs := suite.getTestingAccounts(r, 3) - -// expected := []struct { -// weight int -// opMsgRoute string -// opMsgName string -// }{ -// { -// simappparams.DefaultWeightGrantFeeAllowance, -// types.ModuleName, -// types.TypeMsgGrantFeeAllowance, -// }, -// { -// simappparams.DefaultWeightRevokeFeeAllowance, -// types.ModuleName, -// types.TypeMsgRevokeFeeAllowance, -// }, -// } - -// for i, w := range weightesOps { -// operationMsg, _, _ := w.Op()(r, app.BaseApp, ctx, accs, ctx.ChainID()) -// // the following checks are very much dependent from the ordering of the output given -// // by WeightedOperations. if the ordering in WeightedOperations changes some tests -// // will fail -// require.Equal(expected[i].weight, w.Weight(), "weight should be the same") -// require.Equal(expected[i].opMsgRoute, operationMsg.Route, "route should be the same") -// require.Equal(expected[i].opMsgName, operationMsg.Name, "operation Msg name should be the same") -// } -// } - -// func (suite *SimTestSuite) TestSimulateMsgGrantFeeAllowance() { -// app, ctx := suite.app, suite.ctx -// require := suite.Require() - -// s := rand.NewSource(1) -// r := rand.New(s) -// accounts := suite.getTestingAccounts(r, 3) - -// // begin a new block -// app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash}}) - -// // execute operation -// op := simulation.SimulateMsgGrantFeeAllowance(app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper) -// operationMsg, futureOperations, err := op(r, app.BaseApp, ctx, accounts, "") -// require.NoError(err) - -// var msg types.MsgGrantFeeAllowance -// types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) - -// require.True(operationMsg.OK) -// require.Equal("cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r", msg.Granter) -// require.Equal("cosmos1p8wcgrjr4pjju90xg6u9cgq55dxwq8j7u4x9a0", msg.Grantee) -// require.Equal(types.TypeMsgGrantFeeAllowance, msg.Type()) -// require.Equal(types.ModuleName, msg.Route()) -// require.Len(futureOperations, 0) -// } - -// func (suite *SimTestSuite) TestSimulateMsgRevokeFeeAllowance() { -// app, ctx := suite.app, suite.ctx -// require := suite.Require() - -// s := rand.NewSource(1) -// r := rand.New(s) -// accounts := suite.getTestingAccounts(r, 3) - -// // begin a new block -// app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}}) - -// feeAmt := sdk.TokensFromConsensusPower(200000) -// feeCoins := sdk.NewCoins(sdk.NewCoin("foo", feeAmt)) - -// granter, grantee := accounts[0], accounts[1] - -// app.FeeGrantKeeper.GrantFeeAllowance( -// ctx, -// granter.Address, -// grantee.Address, -// &types.BasicFeeAllowance{ -// SpendLimit: feeCoins, -// Expiration: types.ExpiresAtTime(ctx.BlockTime().Add(30 * time.Hour)), -// }, -// ) - -// // execute operation -// op := simulation.SimulateMsgRevokeFeeAllowance(app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper) -// operationMsg, futureOperations, err := op(r, app.BaseApp, ctx, accounts, "") -// require.NoError(err) - -// var msg types.MsgRevokeFeeAllowance -// types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) - -// require.True(operationMsg.OK) -// require.Equal(granter.Address.String(), msg.Granter) -// require.Equal(grantee.Address.String(), msg.Grantee) -// require.Equal(types.TypeMsgRevokeFeeAllowance, msg.Type()) -// require.Equal(types.ModuleName, msg.Route()) -// require.Len(futureOperations, 0) -// } - -// func TestSimTestSuite(t *testing.T) { -// suite.Run(t, new(SimTestSuite)) -// } +import ( + "math/rand" + "testing" + "time" + + "github.com/stretchr/testify/suite" + + abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/simapp" + simappparams "github.com/cosmos/cosmos-sdk/simapp/params" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/feegrant/simulation" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" +) + +type SimTestSuite struct { + suite.Suite + + ctx sdk.Context + app *simapp.SimApp + protoCdc *codec.ProtoCodec +} + +func (suite *SimTestSuite) SetupTest() { + checkTx := false + app := simapp.Setup(checkTx) + suite.app = app + suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{}) + suite.protoCdc = codec.NewProtoCodec(suite.app.InterfaceRegistry()) + +} + +func (suite *SimTestSuite) getTestingAccounts(r *rand.Rand, n int) []simtypes.Account { + app, ctx := suite.app, suite.ctx + accounts := simtypes.RandomAccounts(r, n) + require := suite.Require() + + initAmt := sdk.TokensFromConsensusPower(200) + initCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initAmt)) + + // add coins to the accounts + for _, account := range accounts { + acc := app.AccountKeeper.NewAccountWithAddress(ctx, account.Address) + app.AccountKeeper.SetAccount(ctx, acc) + err := app.BankKeeper.SetBalances(ctx, account.Address, initCoins) + require.NoError(err) + } + + return accounts +} + +func (suite *SimTestSuite) TestWeightedOperations() { + app, ctx := suite.app, suite.ctx + require := suite.Require() + + ctx.WithChainID("test-chain") + + cdc := app.AppCodec() + appParams := make(simtypes.AppParams) + + weightesOps := simulation.WeightedOperations( + appParams, cdc, app.AccountKeeper, + app.BankKeeper, app.FeeGrantKeeper, + suite.protoCdc, + ) + + s := rand.NewSource(1) + r := rand.New(s) + accs := suite.getTestingAccounts(r, 3) + + expected := []struct { + weight int + opMsgRoute string + opMsgName string + }{ + { + simappparams.DefaultWeightGrantFeeAllowance, + types.ModuleName, + simulation.TypeMsgGrantFeeAllowance, + }, + { + simappparams.DefaultWeightRevokeFeeAllowance, + types.ModuleName, + simulation.TypeMsgRevokeFeeAllowance, + }, + } + + for i, w := range weightesOps { + operationMsg, _, _ := w.Op()(r, app.BaseApp, ctx, accs, ctx.ChainID()) + // the following checks are very much dependent from the ordering of the output given + // by WeightedOperations. if the ordering in WeightedOperations changes some tests + // will fail + require.Equal(expected[i].weight, w.Weight(), "weight should be the same") + require.Equal(expected[i].opMsgRoute, operationMsg.Route, "route should be the same") + require.Equal(expected[i].opMsgName, operationMsg.Name, "operation Msg name should be the same") + } +} + +func (suite *SimTestSuite) TestSimulateMsgGrantFeeAllowance() { + app, ctx := suite.app, suite.ctx + require := suite.Require() + + s := rand.NewSource(1) + r := rand.New(s) + accounts := suite.getTestingAccounts(r, 3) + + // begin a new block + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash}}) + + // execute operation + op := simulation.SimulateMsgGrantFeeAllowance(app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, suite.protoCdc) + operationMsg, futureOperations, err := op(r, app.BaseApp, ctx, accounts, "") + require.NoError(err) + + var msg types.MsgGrantFeeAllowance + suite.app.AppCodec().UnmarshalJSON(operationMsg.Msg, &msg) + + require.True(operationMsg.OK) + require.Equal("cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r", msg.Granter) + require.Equal("cosmos1p8wcgrjr4pjju90xg6u9cgq55dxwq8j7u4x9a0", msg.Grantee) + require.Len(futureOperations, 0) +} + +func (suite *SimTestSuite) TestSimulateMsgRevokeFeeAllowance() { + app, ctx := suite.app, suite.ctx + require := suite.Require() + + s := rand.NewSource(1) + r := rand.New(s) + accounts := suite.getTestingAccounts(r, 3) + + // begin a new block + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}}) + + feeAmt := sdk.TokensFromConsensusPower(200000) + feeCoins := sdk.NewCoins(sdk.NewCoin("foo", feeAmt)) + + granter, grantee := accounts[0], accounts[1] + + app.FeeGrantKeeper.GrantFeeAllowance( + ctx, + granter.Address, + grantee.Address, + &types.BasicFeeAllowance{ + SpendLimit: feeCoins, + Expiration: types.ExpiresAtTime(ctx.BlockTime().Add(30 * time.Hour)), + }, + ) + + // execute operation + op := simulation.SimulateMsgRevokeFeeAllowance(app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, suite.protoCdc) + operationMsg, futureOperations, err := op(r, app.BaseApp, ctx, accounts, "") + require.NoError(err) + + var msg types.MsgRevokeFeeAllowance + suite.app.AppCodec().UnmarshalJSON(operationMsg.Msg, &msg) + + require.True(operationMsg.OK) + require.Equal(granter.Address.String(), msg.Granter) + require.Equal(grantee.Address.String(), msg.Grantee) + require.Len(futureOperations, 0) +} + +func TestSimTestSuite(t *testing.T) { + suite.Run(t, new(SimTestSuite)) +} diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index 2ea89ca97bb1..d90ca07d5ccc 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -162,7 +162,7 @@ func SimulateMsgSubmitProposal( return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } - opMsg := simtypes.NewOperationMsg(msg, true, "") + opMsg := simtypes.NewOperationMsg(msg, true, "", nil) // get the submitted proposal ID proposalID, err := k.GetProposalID(ctx) @@ -248,7 +248,7 @@ func SimulateMsgDeposit(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Ke return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } - return simtypes.NewOperationMsg(msg, true, ""), nil, nil + return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil } } @@ -311,7 +311,7 @@ func operationSimulateMsgVote(ak types.AccountKeeper, bk types.BankKeeper, k kee return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } - return simtypes.NewOperationMsg(msg, true, ""), nil, nil + return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil } } diff --git a/x/slashing/simulation/operations.go b/x/slashing/simulation/operations.go index 20acc9e91a88..1c49775cc193 100644 --- a/x/slashing/simulation/operations.go +++ b/x/slashing/simulation/operations.go @@ -115,23 +115,23 @@ func SimulateMsgUnjail(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Kee validator.TokensFromShares(selfDel.GetShares()).TruncateInt().LT(validator.GetMinSelfDelegation()) { if res != nil && err == nil { if info.Tombstoned { - return simtypes.NewOperationMsg(msg, true, ""), nil, errors.New("validator should not have been unjailed if validator tombstoned") + return simtypes.NewOperationMsg(msg, true, "", nil), nil, errors.New("validator should not have been unjailed if validator tombstoned") } if ctx.BlockHeader().Time.Before(info.JailedUntil) { - return simtypes.NewOperationMsg(msg, true, ""), nil, errors.New("validator unjailed while validator still in jail period") + return simtypes.NewOperationMsg(msg, true, "", nil), nil, errors.New("validator unjailed while validator still in jail period") } if validator.TokensFromShares(selfDel.GetShares()).TruncateInt().LT(validator.GetMinSelfDelegation()) { - return simtypes.NewOperationMsg(msg, true, ""), nil, errors.New("validator unjailed even though self-delegation too low") + return simtypes.NewOperationMsg(msg, true, "", nil), nil, errors.New("validator unjailed even though self-delegation too low") } } // msg failed as expected - return simtypes.NewOperationMsg(msg, false, ""), nil, nil + return simtypes.NewOperationMsg(msg, false, "", nil), nil, nil } if err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, errors.New(res.Log) } - return simtypes.NewOperationMsg(msg, true, ""), nil, nil + return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil } } diff --git a/x/staking/simulation/operations.go b/x/staking/simulation/operations.go index 0bcb274ed717..d9621bc7321c 100644 --- a/x/staking/simulation/operations.go +++ b/x/staking/simulation/operations.go @@ -173,7 +173,7 @@ func SimulateMsgCreateValidator(ak types.AccountKeeper, bk types.BankKeeper, k k return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } - return simtypes.NewOperationMsg(msg, true, ""), nil, nil + return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil } } @@ -244,7 +244,7 @@ func SimulateMsgEditValidator(ak types.AccountKeeper, bk types.BankKeeper, k kee return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } - return simtypes.NewOperationMsg(msg, true, ""), nil, nil + return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil } } @@ -317,7 +317,7 @@ func SimulateMsgDelegate(ak types.AccountKeeper, bk types.BankKeeper, k keeper.K return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } - return simtypes.NewOperationMsg(msg, true, ""), nil, nil + return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil } } @@ -407,7 +407,7 @@ func SimulateMsgUndelegate(ak types.AccountKeeper, bk types.BankKeeper, k keeper return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } - return simtypes.NewOperationMsg(msg, true, ""), nil, nil + return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil } } @@ -520,6 +520,6 @@ func SimulateMsgBeginRedelegate(ak types.AccountKeeper, bk types.BankKeeper, k k return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } - return simtypes.NewOperationMsg(msg, true, ""), nil, nil + return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil } } From b8f2f025e80833f3f5ffde1032feb4b1f75d68c0 Mon Sep 17 00:00:00 2001 From: aleem1413 Date: Sat, 19 Dec 2020 10:44:00 +0530 Subject: [PATCH 127/184] update module.go --- simapp/app.go | 2 +- x/feegrant/module.go | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index c00acc356781..857a6eeffbc1 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -345,7 +345,7 @@ func NewSimApp( bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), capability.NewAppModule(appCodec, *app.CapabilityKeeper), crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants), - feegrant.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper), + feegrant.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), diff --git a/x/feegrant/module.go b/x/feegrant/module.go index ef5ad79af819..6e43077e80a3 100644 --- a/x/feegrant/module.go +++ b/x/feegrant/module.go @@ -121,15 +121,17 @@ type AppModule struct { keeper keeper.Keeper accountKeeper types.AccountKeeper bankKeeper types.BankKeeper + registry cdctypes.InterfaceRegistry } // NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Marshaler, ak types.AccountKeeper, bk types.BankKeeper, keeper keeper.Keeper) AppModule { +func NewAppModule(cdc codec.Marshaler, ak types.AccountKeeper, bk types.BankKeeper, keeper keeper.Keeper, registry cdctypes.InterfaceRegistry) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, keeper: keeper, accountKeeper: ak, bankKeeper: bk, + registry: registry, } } @@ -218,8 +220,8 @@ func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { // WeightedOperations returns the all the staking module operations with their respective weights. func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { - // return simulation.WeightedOperations( - // simState.AppParams, simState.Cdc, am.accountKeeper, am.bankKeeper, am.keeper, - // ) - return nil + protoCdc := codec.NewProtoCodec(am.registry) + return simulation.WeightedOperations( + simState.AppParams, simState.Cdc, am.accountKeeper, am.bankKeeper, am.keeper, protoCdc, + ) } From 79e71adc391f3bf95bf6f5c250ea2213b4237ba0 Mon Sep 17 00:00:00 2001 From: aleem1413 Date: Sat, 19 Dec 2020 11:02:08 +0530 Subject: [PATCH 128/184] lint --- x/feegrant/simulation/operations.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/x/feegrant/simulation/operations.go b/x/feegrant/simulation/operations.go index 39f52007baf6..8b5365587970 100644 --- a/x/feegrant/simulation/operations.go +++ b/x/feegrant/simulation/operations.go @@ -89,7 +89,9 @@ func SimulateMsgGrantFeeAllowance(ak types.AccountKeeper, bk types.BankKeeper, k svcMsgClientConn := &helpers.ServiceMsgClientConn{} feegrantMsgClient := types.NewMsgClient(svcMsgClientConn) _, err = feegrantMsgClient.GrantFeeAllowance(context.Background(), msg) - + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgGrantFeeAllowance, err.Error()), nil, err + } tx, err := helpers.GenTx( txGen, svcMsgClientConn.GetMsgs(), @@ -161,6 +163,10 @@ func SimulateMsgRevokeFeeAllowance(ak types.AccountKeeper, bk types.BankKeeper, svcMsgClientConn := &helpers.ServiceMsgClientConn{} feegrantMsgClient := types.NewMsgClient(svcMsgClientConn) _, err = feegrantMsgClient.RevokeFeeAllowance(context.Background(), &msg) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgGrantFeeAllowance, err.Error()), nil, err + } + tx, err := helpers.GenTx( txGen, svcMsgClientConn.GetMsgs(), From 7e74e358c6590bb2b5c6397a404a548fa7c4241c Mon Sep 17 00:00:00 2001 From: aleem1413 Date: Sat, 19 Dec 2020 12:22:09 +0530 Subject: [PATCH 129/184] register feegrant NewSimulationManager --- simapp/app.go | 1 + 1 file changed, 1 insertion(+) diff --git a/simapp/app.go b/simapp/app.go index 857a6eeffbc1..352e9641a77c 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -394,6 +394,7 @@ func NewSimApp( auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts), bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), capability.NewAppModule(appCodec, *app.CapabilityKeeper), + feegrant.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), From 1ea308a04bf7fb19faeed6cce6fb431541244d85 Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 21 Dec 2020 13:35:31 +0530 Subject: [PATCH 130/184] fix sims --- x/feegrant/genesis.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/x/feegrant/genesis.go b/x/feegrant/genesis.go index a5c05b7fecc1..c9e4c8975891 100644 --- a/x/feegrant/genesis.go +++ b/x/feegrant/genesis.go @@ -23,16 +23,18 @@ func (g GenesisState) ValidateBasic() error { // InitGenesis will initialize the keeper from a *previously validated* GenesisState func InitGenesis(ctx sdk.Context, k keeper.Keeper, data *types.GenesisState) { for _, f := range data.FeeAllowances { - granter, err := sdk.AccAddressFromBech32(f.Granter) - if err != nil { - panic(err) - } - grantee, err := sdk.AccAddressFromBech32(f.Grantee) - if err != nil { - panic(err) + if err := f.ValidateBasic(); err == nil { + granter, err := sdk.AccAddressFromBech32(f.Granter) + if err != nil { + panic(err) + } + grantee, err := sdk.AccAddressFromBech32(f.Grantee) + if err != nil { + panic(err) + } + + k.GrantFeeAllowance(ctx, granter, grantee, f.GetFeeGrant()) } - - k.GrantFeeAllowance(ctx, granter, grantee, f.GetFeeGrant()) } } From 89ef367108593e3764fa0d7c0b71a239fbea729f Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 21 Dec 2020 20:38:53 +0530 Subject: [PATCH 131/184] fix sims --- x/feegrant/genesis.go | 20 +++++++++----------- x/feegrant/types/grant.go | 15 +++++++++++++-- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/x/feegrant/genesis.go b/x/feegrant/genesis.go index c9e4c8975891..a5c05b7fecc1 100644 --- a/x/feegrant/genesis.go +++ b/x/feegrant/genesis.go @@ -23,18 +23,16 @@ func (g GenesisState) ValidateBasic() error { // InitGenesis will initialize the keeper from a *previously validated* GenesisState func InitGenesis(ctx sdk.Context, k keeper.Keeper, data *types.GenesisState) { for _, f := range data.FeeAllowances { - if err := f.ValidateBasic(); err == nil { - granter, err := sdk.AccAddressFromBech32(f.Granter) - if err != nil { - panic(err) - } - grantee, err := sdk.AccAddressFromBech32(f.Grantee) - if err != nil { - panic(err) - } - - k.GrantFeeAllowance(ctx, granter, grantee, f.GetFeeGrant()) + granter, err := sdk.AccAddressFromBech32(f.Granter) + if err != nil { + panic(err) + } + grantee, err := sdk.AccAddressFromBech32(f.Grantee) + if err != nil { + panic(err) } + + k.GrantFeeAllowance(ctx, granter, grantee, f.GetFeeGrant()) } } diff --git a/x/feegrant/types/grant.go b/x/feegrant/types/grant.go index 17508a61a36d..73d785617c9b 100644 --- a/x/feegrant/types/grant.go +++ b/x/feegrant/types/grant.go @@ -68,9 +68,20 @@ func (a FeeAllowanceGrant) UnpackInterfaces(unpacker types.AnyUnpacker) error { // PrepareForExport will m ake all needed changes to the allowance to prepare to be // re-imported at height 0, and return a copy of this grant. func (a FeeAllowanceGrant) PrepareForExport(dumpTime time.Time, dumpHeight int64) FeeAllowanceGrant { - err := a.GetFeeGrant().PrepareForExport(dumpTime, dumpHeight) + feegrant := a.GetFeeGrant().PrepareForExport(dumpTime, dumpHeight) + if feegrant == nil { + return FeeAllowanceGrant{} + } + + granter, err := sdk.AccAddressFromBech32(a.Granter) + if err != nil { + return FeeAllowanceGrant{} + } + + grantee, err := sdk.AccAddressFromBech32(a.Grantee) if err != nil { return FeeAllowanceGrant{} } - return a + + return NewFeeAllowanceGrant(granter, grantee, feegrant) } From 9bd77aeab163a9ea635c6e5593beefe086c1037f Mon Sep 17 00:00:00 2001 From: aleem1413 Date: Tue, 22 Dec 2020 14:25:23 +0530 Subject: [PATCH 132/184] add genesis test --- x/feegrant/genesis_test.go | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 x/feegrant/genesis_test.go diff --git a/x/feegrant/genesis_test.go b/x/feegrant/genesis_test.go new file mode 100644 index 000000000000..d8628e031fe0 --- /dev/null +++ b/x/feegrant/genesis_test.go @@ -0,0 +1,55 @@ +package feegrant_test + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/simapp" + sdk "github.com/cosmos/cosmos-sdk/types" + feegrant "github.com/cosmos/cosmos-sdk/x/feegrant" + "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +) + +type GenesisTestSuite struct { + suite.Suite + ctx sdk.Context + keeper keeper.Keeper +} + +func (suite *GenesisTestSuite) SetupTest() { + checkTx := false + app := simapp.Setup(checkTx) + suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1}) + suite.keeper = app.FeeGrantKeeper +} + +var ( + granteePub = secp256k1.GenPrivKey().PubKey() + granterPub = secp256k1.GenPrivKey().PubKey() + granteeAddr = sdk.AccAddress(granteePub.Address()) + granterAddr = sdk.AccAddress(granterPub.Address()) +) + +func (suite *GenesisTestSuite) TestImportExportGenesis() { + coins := sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1_000))) + now := suite.ctx.BlockHeader().Time + allowance := &types.BasicFeeAllowance{SpendLimit: coins, Expiration: types.ExpiresAt{ + Time: now.AddDate(1, 0, 0), + }} + suite.keeper.GrantFeeAllowance(suite.ctx, granterAddr, granteeAddr, allowance) + genesis, err := feegrant.ExportGenesis(suite.ctx, suite.keeper) + suite.Require().NoError(err) + // Clear keeper + suite.keeper.RevokeFeeAllowance(suite.ctx, granterAddr, granteeAddr) + feegrant.InitGenesis(suite.ctx, suite.keeper, genesis) + newGenesis, err := feegrant.ExportGenesis(suite.ctx, suite.keeper) + suite.Require().NoError(err) + suite.Require().Equal(genesis, newGenesis) +} + +func TestGenesisTestSuite(t *testing.T) { + suite.Run(t, new(GenesisTestSuite)) +} From 26238b2ead767b828d70735f99504202c1c855ad Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 23 Dec 2020 13:08:31 +0530 Subject: [PATCH 133/184] add periodic grant --- x/feegrant/client/cli/tx.go | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index 9bf793d570ab..8d38c6a5c8b8 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -3,6 +3,7 @@ package cli import ( "context" "fmt" + "strconv" "strings" "time" @@ -43,7 +44,7 @@ func GetTxCmd() *cobra.Command { // NewCmdFeeGrant returns a CLI command handler for creating a MsgGrantFeeAllowance transaction. func NewCmdFeeGrant() *cobra.Command { cmd := &cobra.Command{ - Use: "grant [granter] [grantee] [limit] ", + Use: "grant [granter] [grantee] [limit]", Short: "Grant Fee allowance to an address", Long: strings.TrimSpace( fmt.Sprintf( @@ -87,7 +88,34 @@ Examples: Expiration: types.ExpiresAtTime(time.Now().Add(period)), } - msg, err := types.NewMsgGrantFeeAllowance(&basic, granter, grantee) + var grant types.FeeAllowanceI + grant = &basic + + if args[3] != "" { + periodClock, err := strconv.ParseInt(args[3], 10, 64) + if err != nil { + return err + } + + periodLimit, err := sdk.ParseCoinsNormalized(args[4]) + if err != nil { + return err + } + + periodClock = periodClock * 24 * 60 * 60 + + periodic := types.PeriodicFeeAllowance{ + Basic: basic, + Period: types.ClockDuration(time.Duration(periodClock)), //days + PeriodReset: types.ExpiresAtTime(time.Now().Add(time.Duration(periodClock))), + PeriodSpendLimit: periodLimit, + PeriodCanSpend: periodLimit, + } + + grant = &periodic + } + + msg, err := types.NewMsgGrantFeeAllowance(grant, granter, grantee) if err != nil { return err } From bef09b7f7ec3cbb42bfba972f00ef0efc128ec93 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 23 Dec 2020 13:12:27 +0530 Subject: [PATCH 134/184] updated cmd --- x/feegrant/client/cli/tx.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index 8d38c6a5c8b8..1955445ddc60 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -44,7 +44,7 @@ func GetTxCmd() *cobra.Command { // NewCmdFeeGrant returns a CLI command handler for creating a MsgGrantFeeAllowance transaction. func NewCmdFeeGrant() *cobra.Command { cmd := &cobra.Command{ - Use: "grant [granter] [grantee] [limit]", + Use: "grant [granter] [grantee] [limit] or grant [granter] [grantee] [limit] [period] [periodLimit]", Short: "Grant Fee allowance to an address", Long: strings.TrimSpace( fmt.Sprintf( @@ -52,11 +52,12 @@ func NewCmdFeeGrant() *cobra.Command { ignored as it is implied from [granter]. Examples: -%s tx %s grant cosmos1skjw... cosmos1skjw... 100stake - `, version.AppName, types.ModuleName, +%s tx %s grant cosmos1skjw... cosmos1skjw... 100stake or +%s tx %s grant cosmos1skjw... cosmos1skjw... 100stake 10 10stake + `, version.AppName, types.ModuleName, version.AppName, types.ModuleName, ), ), - Args: cobra.ExactArgs(3), + Args: cobra.RangeArgs(3, 5), RunE: func(cmd *cobra.Command, args []string) error { cmd.Flags().Set(flags.FlagFrom, args[0]) clientCtx, err := client.GetClientTxContext(cmd) From d8fd446b1e24ddca714005693043a9d358c4621d Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 23 Dec 2020 13:19:33 +0530 Subject: [PATCH 135/184] changed times --- x/feegrant/client/cli/tx.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index 1955445ddc60..344237e75f5e 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -107,8 +107,8 @@ Examples: periodic := types.PeriodicFeeAllowance{ Basic: basic, - Period: types.ClockDuration(time.Duration(periodClock)), //days - PeriodReset: types.ExpiresAtTime(time.Now().Add(time.Duration(periodClock))), + Period: types.ClockDuration(time.Duration(periodClock) * time.Second), //days + PeriodReset: types.ExpiresAtTime(time.Now().Add(time.Duration(periodClock) * time.Second)), PeriodSpendLimit: periodLimit, PeriodCanSpend: periodLimit, } From d7c63fb59a0a0c41c69cfa773682068db36059ca Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 23 Dec 2020 13:22:21 +0530 Subject: [PATCH 136/184] updated flags --- x/feegrant/client/cli/tx.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index 344237e75f5e..33c7812bf7ae 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -52,8 +52,8 @@ func NewCmdFeeGrant() *cobra.Command { ignored as it is implied from [granter]. Examples: -%s tx %s grant cosmos1skjw... cosmos1skjw... 100stake or -%s tx %s grant cosmos1skjw... cosmos1skjw... 100stake 10 10stake +%s tx %s grant cosmos1skjw... cosmos1skjw... 100stake --expiration 36000 or +%s tx %s grant cosmos1skjw... cosmos1skjw... 100stake 3600 10stake --expiration 36000 `, version.AppName, types.ModuleName, version.AppName, types.ModuleName, ), ), From b656a14efb94bfec4aae9a6f0e760091686cd0e2 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 23 Dec 2020 13:23:35 +0530 Subject: [PATCH 137/184] removed days as period clock --- x/feegrant/client/cli/tx.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index 33c7812bf7ae..d918fc405fd4 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -103,8 +103,6 @@ Examples: return err } - periodClock = periodClock * 24 * 60 * 60 - periodic := types.PeriodicFeeAllowance{ Basic: basic, Period: types.ClockDuration(time.Duration(periodClock) * time.Second), //days From 458e76e45b62443e40def5a58c46ef3abc37a5eb Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 23 Dec 2020 13:38:31 +0530 Subject: [PATCH 138/184] added condition for period and exp --- x/feegrant/client/cli/tx.go | 12 ++++++++++-- x/feegrant/types/msgs.go | 5 ++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index d918fc405fd4..5e76a6031fe5 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -92,7 +92,7 @@ Examples: var grant types.FeeAllowanceI grant = &basic - if args[3] != "" { + if args[3] != "" { // if period mentioned it can be treated as periodic fee allowance periodClock, err := strconv.ParseInt(args[3], 10, 64) if err != nil { return err @@ -103,9 +103,13 @@ Examples: return err } + if periodClock > exp { + return fmt.Errorf("Period(%d) cannot be greater than the expiration(%d)", periodClock, exp) + } + periodic := types.PeriodicFeeAllowance{ Basic: basic, - Period: types.ClockDuration(time.Duration(periodClock) * time.Second), //days + Period: types.ClockDuration(time.Duration(periodClock) * time.Second), PeriodReset: types.ExpiresAtTime(time.Now().Add(time.Duration(periodClock) * time.Second)), PeriodSpendLimit: periodLimit, PeriodCanSpend: periodLimit, @@ -119,6 +123,10 @@ Examples: return err } + if err := msg.ValidateBasic(); err != nil { + return err + } + svcMsgClientConn := &serviceMsgClientConn{} feeGrantMsgClient := types.NewMsgClient(svcMsgClientConn) _, err = feeGrantMsgClient.GrantFeeAllowance(context.Background(), msg) diff --git a/x/feegrant/types/msgs.go b/x/feegrant/types/msgs.go index 0614a8397be8..22438e08d6b1 100644 --- a/x/feegrant/types/msgs.go +++ b/x/feegrant/types/msgs.go @@ -47,8 +47,11 @@ func (msg MsgGrantFeeAllowance) ValidateBasic() error { if msg.Grantee == "" { return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "missing grantee address") } + if msg.Grantee == msg.Granter { + return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "cannot self-grant fee authorization") + } - return nil + return msg.GetFeeAllowanceI().ValidateBasic() } func (msg MsgGrantFeeAllowance) GetSigners() []sdk.AccAddress { From d5d948cfc1db96c82438f93b6a9b610e9377c2fd Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 23 Dec 2020 14:00:11 +0530 Subject: [PATCH 139/184] add periodic fee cli tests --- x/feegrant/client/cli/cli_test.go | 49 ++++++++++++++++++++++++++++- x/feegrant/client/cli/tx.go | 52 +++++++++++++++++-------------- 2 files changed, 77 insertions(+), 24 deletions(-) diff --git a/x/feegrant/client/cli/cli_test.go b/x/feegrant/client/cli/cli_test.go index be22331cd7f8..1c0d9c9fa13a 100644 --- a/x/feegrant/client/cli/cli_test.go +++ b/x/feegrant/client/cli/cli_test.go @@ -269,7 +269,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { true, nil, 0, }, { - "Valid fee grant", + "Valid basic fee grant", append( []string{ granter.String(), @@ -281,6 +281,53 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { ), false, &sdk.TxResponse{}, 0, }, + { + "invalid number of args(periodic fee grant)", + append( + []string{ + granter.String(), + grantee.String(), + "100steak", + "10steak", + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + fmt.Sprintf("--%s=%d", cli.FlagExpiration, 10*60*60), + }, + commonFlags..., + ), + true, nil, 0, + }, + { + "invalid period(periodic fee grant)", + append( + []string{ + granter.String(), + grantee.String(), + "100steak", + fmt.Sprintf("%d", 10*60*60), + "10steak", + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + fmt.Sprintf("--%s=%d", cli.FlagExpiration, 60*60), + }, + commonFlags..., + ), + true, nil, 0, + }, + { + "Valid periodic fee grant", + append( + []string{ + granter.String(), + grantee.String(), + "100steak", + fmt.Sprintf("%d", 60*60), + "10steak", + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + fmt.Sprintf("--%s=%d", cli.FlagExpiration, 10*60*60), + }, + commonFlags..., + ), + false, &sdk.TxResponse{}, 0, + }, } for _, tc := range testCases { diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index 5e76a6031fe5..75be73c07346 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -92,30 +92,36 @@ Examples: var grant types.FeeAllowanceI grant = &basic - if args[3] != "" { // if period mentioned it can be treated as periodic fee allowance - periodClock, err := strconv.ParseInt(args[3], 10, 64) - if err != nil { - return err + if len(args) > 3 { // if period mentioned it can be treated as periodic fee allowance + if len(args) >= 5 { + + periodClock, err := strconv.ParseInt(args[3], 10, 64) + if err != nil { + return err + } + + periodLimit, err := sdk.ParseCoinsNormalized(args[4]) + if err != nil { + return err + } + + if periodClock > exp { + return fmt.Errorf("Period(%d) cannot be greater than the expiration(%d)", periodClock, exp) + } + + periodic := types.PeriodicFeeAllowance{ + Basic: basic, + Period: types.ClockDuration(time.Duration(periodClock) * time.Second), + PeriodReset: types.ExpiresAtTime(time.Now().Add(time.Duration(periodClock) * time.Second)), + PeriodSpendLimit: periodLimit, + PeriodCanSpend: periodLimit, + } + + grant = &periodic + + } else { + return fmt.Errorf("Invalid number of args %d", len(args)) } - - periodLimit, err := sdk.ParseCoinsNormalized(args[4]) - if err != nil { - return err - } - - if periodClock > exp { - return fmt.Errorf("Period(%d) cannot be greater than the expiration(%d)", periodClock, exp) - } - - periodic := types.PeriodicFeeAllowance{ - Basic: basic, - Period: types.ClockDuration(time.Duration(periodClock) * time.Second), - PeriodReset: types.ExpiresAtTime(time.Now().Add(time.Duration(periodClock) * time.Second)), - PeriodSpendLimit: periodLimit, - PeriodCanSpend: periodLimit, - } - - grant = &periodic } msg, err := types.NewMsgGrantFeeAllowance(grant, granter, grantee) From fc9b0dc82ce9f8c375b5c06a24b846e19e0b0390 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 23 Dec 2020 14:03:50 +0530 Subject: [PATCH 140/184] udpated tests --- x/feegrant/client/cli/cli_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/feegrant/client/cli/cli_test.go b/x/feegrant/client/cli/cli_test.go index 1c0d9c9fa13a..fa053a264c0b 100644 --- a/x/feegrant/client/cli/cli_test.go +++ b/x/feegrant/client/cli/cli_test.go @@ -297,13 +297,13 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { true, nil, 0, }, { - "invalid period(periodic fee grant)", + "period cannot be greater than the actual expiration(periodic fee grant)", append( []string{ granter.String(), grantee.String(), "100steak", - fmt.Sprintf("%d", 10*60*60), + fmt.Sprintf("%d", 10*60*60), //period "10steak", fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), fmt.Sprintf("--%s=%d", cli.FlagExpiration, 60*60), From 35fe6a778aa6f458af313ef9b046daed47470c72 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 23 Dec 2020 14:24:29 +0530 Subject: [PATCH 141/184] fix lint --- x/feegrant/client/cli/tx.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index 75be73c07346..e5c74a2aa737 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -106,7 +106,7 @@ Examples: } if periodClock > exp { - return fmt.Errorf("Period(%d) cannot be greater than the expiration(%d)", periodClock, exp) + return fmt.Errorf("period(%d) cannot be greater than the expiration(%d)", periodClock, exp) } periodic := types.PeriodicFeeAllowance{ @@ -120,7 +120,7 @@ Examples: grant = &periodic } else { - return fmt.Errorf("Invalid number of args %d", len(args)) + return fmt.Errorf("invalid number of args %d", len(args)) } } From db78a922b5a3533ebc537523c519fb948a03c9ee Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 23 Dec 2020 14:52:48 +0530 Subject: [PATCH 142/184] fix tests --- x/feegrant/client/cli/tx.go | 4 ---- x/feegrant/types/msgs.go | 5 +---- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index e5c74a2aa737..648aed8373d7 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -129,10 +129,6 @@ Examples: return err } - if err := msg.ValidateBasic(); err != nil { - return err - } - svcMsgClientConn := &serviceMsgClientConn{} feeGrantMsgClient := types.NewMsgClient(svcMsgClientConn) _, err = feeGrantMsgClient.GrantFeeAllowance(context.Background(), msg) diff --git a/x/feegrant/types/msgs.go b/x/feegrant/types/msgs.go index 22438e08d6b1..0614a8397be8 100644 --- a/x/feegrant/types/msgs.go +++ b/x/feegrant/types/msgs.go @@ -47,11 +47,8 @@ func (msg MsgGrantFeeAllowance) ValidateBasic() error { if msg.Grantee == "" { return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "missing grantee address") } - if msg.Grantee == msg.Granter { - return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "cannot self-grant fee authorization") - } - return msg.GetFeeAllowanceI().ValidateBasic() + return nil } func (msg MsgGrantFeeAllowance) GetSigners() []sdk.AccAddress { From 0692eb082962fe869cbe7a509780f217fc194e47 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 23 Dec 2020 15:17:03 +0530 Subject: [PATCH 143/184] fix sims --- x/feegrant/simulation/operations.go | 6 ++++++ x/feegrant/types/msgs.go | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/x/feegrant/simulation/operations.go b/x/feegrant/simulation/operations.go index 8b5365587970..8874cc005e6c 100644 --- a/x/feegrant/simulation/operations.go +++ b/x/feegrant/simulation/operations.go @@ -66,6 +66,9 @@ func SimulateMsgGrantFeeAllowance(ak types.AccountKeeper, bk types.BankKeeper, k ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { granter, _ := simtypes.RandomAcc(r, accs) grantee, _ := simtypes.RandomAcc(r, accs) + if grantee.Address.String() == granter.Address.String() { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgGrantFeeAllowance, "grantee and granter cannot be same"), nil, nil + } account := ak.GetAccount(ctx, granter.Address) @@ -76,6 +79,9 @@ func SimulateMsgGrantFeeAllowance(ak types.AccountKeeper, bk types.BankKeeper, k } spendableCoins = spendableCoins.Sub(fees) + if spendableCoins.Empty() { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgGrantFeeAllowance, "unable to grant empty coins as SpendLimit"), nil, nil + } msg, err := types.NewMsgGrantFeeAllowance(&types.BasicFeeAllowance{ SpendLimit: spendableCoins, diff --git a/x/feegrant/types/msgs.go b/x/feegrant/types/msgs.go index 0614a8397be8..22438e08d6b1 100644 --- a/x/feegrant/types/msgs.go +++ b/x/feegrant/types/msgs.go @@ -47,8 +47,11 @@ func (msg MsgGrantFeeAllowance) ValidateBasic() error { if msg.Grantee == "" { return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "missing grantee address") } + if msg.Grantee == msg.Granter { + return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "cannot self-grant fee authorization") + } - return nil + return msg.GetFeeAllowanceI().ValidateBasic() } func (msg MsgGrantFeeAllowance) GetSigners() []sdk.AccAddress { From a1538734ef189a506b177bf04bcb9509090bdbde Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 11 Jan 2021 21:13:21 +0530 Subject: [PATCH 144/184] renaming to `fee_grant` --- proto/cosmos/feegrant/v1beta1/feegrant.proto | 2 +- proto/cosmos/feegrant/v1beta1/genesis.proto | 2 +- proto/cosmos/feegrant/v1beta1/query.proto | 2 +- proto/cosmos/feegrant/v1beta1/tx.proto | 2 +- simapp/ante.go | 6 +- simapp/app.go | 6 +- x/{feegrant => fee_grant}/ante/fee.go | 4 +- x/{feegrant => fee_grant}/ante/fee_test.go | 4 +- .../client/cli/cli_test.go | 4 +- x/{feegrant => fee_grant}/client/cli/query.go | 2 +- .../client/cli/service_msg_client.go | 0 x/{feegrant => fee_grant}/client/cli/tx.go | 2 +- .../client/rest/grpc_query_test.go | 4 +- x/{feegrant => fee_grant}/doc.go | 0 x/{feegrant => fee_grant}/genesis.go | 4 +- x/{feegrant => fee_grant}/genesis_test.go | 6 +- .../keeper/grpc_query.go | 2 +- x/{feegrant => fee_grant}/keeper/keeper.go | 2 +- .../keeper/keeper_test.go | 2 +- .../keeper/msg_server.go | 2 +- x/{feegrant => fee_grant}/module.go | 8 +- .../simulation/decoder.go | 2 +- .../simulation/decoder_test.go | 4 +- .../simulation/genesis.go | 2 +- .../simulation/genesis_test.go | 4 +- .../simulation/operations.go | 4 +- .../simulation/operations_test.go | 4 +- x/{feegrant => fee_grant}/types/basic_fee.go | 0 .../types/basic_fee_test.go | 2 +- x/{feegrant => fee_grant}/types/codec.go | 0 x/{feegrant => fee_grant}/types/errors.go | 0 x/{feegrant => fee_grant}/types/events.go | 0 .../types/expected_keepers.go | 0 x/{feegrant => fee_grant}/types/expiration.go | 0 .../types/expiration_test.go | 2 +- .../types/feegrant.pb.go | 76 +++++++++---------- x/{feegrant => fee_grant}/types/fees.go | 0 x/{feegrant => fee_grant}/types/genesis.go | 0 x/{feegrant => fee_grant}/types/genesis.pb.go | 10 +-- x/{feegrant => fee_grant}/types/grant.go | 0 x/{feegrant => fee_grant}/types/grant_test.go | 2 +- x/{feegrant => fee_grant}/types/key.go | 0 x/{feegrant => fee_grant}/types/msgs.go | 0 .../types/periodic_fee.go | 0 .../types/periodic_fee_test.go | 2 +- x/{feegrant => fee_grant}/types/query.pb.go | 60 +++++++-------- .../types/query.pb.gw.go | 0 x/{feegrant => fee_grant}/types/tx.pb.go | 46 +++++------ 48 files changed, 143 insertions(+), 143 deletions(-) rename x/{feegrant => fee_grant}/ante/fee.go (97%) rename x/{feegrant => fee_grant}/ante/fee_test.go (98%) rename x/{feegrant => fee_grant}/client/cli/cli_test.go (98%) rename x/{feegrant => fee_grant}/client/cli/query.go (98%) rename x/{feegrant => fee_grant}/client/cli/service_msg_client.go (100%) rename x/{feegrant => fee_grant}/client/cli/tx.go (99%) rename x/{feegrant => fee_grant}/client/rest/grpc_query_test.go (98%) rename x/{feegrant => fee_grant}/doc.go (100%) rename x/{feegrant => fee_grant}/genesis.go (94%) rename x/{feegrant => fee_grant}/genesis_test.go (91%) rename x/{feegrant => fee_grant}/keeper/grpc_query.go (98%) rename x/{feegrant => fee_grant}/keeper/keeper.go (99%) rename x/{feegrant => fee_grant}/keeper/keeper_test.go (99%) rename x/{feegrant => fee_grant}/keeper/msg_server.go (96%) rename x/{feegrant => fee_grant}/module.go (97%) rename x/{feegrant => fee_grant}/simulation/decoder.go (93%) rename x/{feegrant => fee_grant}/simulation/decoder_test.go (93%) rename x/{feegrant => fee_grant}/simulation/genesis.go (95%) rename x/{feegrant => fee_grant}/simulation/genesis_test.go (90%) rename x/{feegrant => fee_grant}/simulation/operations.go (98%) rename x/{feegrant => fee_grant}/simulation/operations_test.go (97%) rename x/{feegrant => fee_grant}/types/basic_fee.go (100%) rename x/{feegrant => fee_grant}/types/basic_fee_test.go (97%) rename x/{feegrant => fee_grant}/types/codec.go (100%) rename x/{feegrant => fee_grant}/types/errors.go (100%) rename x/{feegrant => fee_grant}/types/events.go (100%) rename x/{feegrant => fee_grant}/types/expected_keepers.go (100%) rename x/{feegrant => fee_grant}/types/expiration.go (100%) rename x/{feegrant => fee_grant}/types/expiration_test.go (98%) rename x/{feegrant => fee_grant}/types/feegrant.pb.go (91%) rename x/{feegrant => fee_grant}/types/fees.go (100%) rename x/{feegrant => fee_grant}/types/genesis.go (100%) rename x/{feegrant => fee_grant}/types/genesis.pb.go (96%) rename x/{feegrant => fee_grant}/types/grant.go (100%) rename x/{feegrant => fee_grant}/types/grant_test.go (97%) rename x/{feegrant => fee_grant}/types/key.go (100%) rename x/{feegrant => fee_grant}/types/msgs.go (100%) rename x/{feegrant => fee_grant}/types/periodic_fee.go (100%) rename x/{feegrant => fee_grant}/types/periodic_fee_test.go (99%) rename x/{feegrant => fee_grant}/types/query.pb.go (91%) rename x/{feegrant => fee_grant}/types/query.pb.gw.go (100%) rename x/{feegrant => fee_grant}/types/tx.pb.go (92%) diff --git a/proto/cosmos/feegrant/v1beta1/feegrant.proto b/proto/cosmos/feegrant/v1beta1/feegrant.proto index 4f7ee2777c34..3423dd2ac12f 100644 --- a/proto/cosmos/feegrant/v1beta1/feegrant.proto +++ b/proto/cosmos/feegrant/v1beta1/feegrant.proto @@ -7,7 +7,7 @@ import "cosmos_proto/cosmos.proto"; import "cosmos/base/v1beta1/coin.proto"; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; +option go_package = "github.com/cosmos/cosmos-sdk/x/fee_grant/types"; // BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens // that optionally expires. The delegatee can use up to SpendLimit to cover fees. diff --git a/proto/cosmos/feegrant/v1beta1/genesis.proto b/proto/cosmos/feegrant/v1beta1/genesis.proto index 9460a27d42cc..75321f44726e 100644 --- a/proto/cosmos/feegrant/v1beta1/genesis.proto +++ b/proto/cosmos/feegrant/v1beta1/genesis.proto @@ -4,7 +4,7 @@ package cosmos.feegrant.v1beta1; import "gogoproto/gogo.proto"; import "cosmos/feegrant/v1beta1/feegrant.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; +option go_package = "github.com/cosmos/cosmos-sdk/x/fee_grant/types"; // GenesisState contains a set of fee allowances, persisted from the store message GenesisState { diff --git a/proto/cosmos/feegrant/v1beta1/query.proto b/proto/cosmos/feegrant/v1beta1/query.proto index 46eb578e211c..3e18c5d97d86 100644 --- a/proto/cosmos/feegrant/v1beta1/query.proto +++ b/proto/cosmos/feegrant/v1beta1/query.proto @@ -6,7 +6,7 @@ import "cosmos/feegrant/v1beta1/feegrant.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "google/api/annotations.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; +option go_package = "github.com/cosmos/cosmos-sdk/x/fee_grant/types"; // Query defines the gRPC querier service. service Query { diff --git a/proto/cosmos/feegrant/v1beta1/tx.proto b/proto/cosmos/feegrant/v1beta1/tx.proto index 114ebc14a377..d4583beb0e8d 100644 --- a/proto/cosmos/feegrant/v1beta1/tx.proto +++ b/proto/cosmos/feegrant/v1beta1/tx.proto @@ -5,7 +5,7 @@ import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; import "cosmos_proto/cosmos.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; +option go_package = "github.com/cosmos/cosmos-sdk/x/fee_grant/types"; // Msg defines the feegrant msg service. service Msg { diff --git a/simapp/ante.go b/simapp/ante.go index 0af65940ced4..889efd8d3099 100644 --- a/simapp/ante.go +++ b/simapp/ante.go @@ -5,9 +5,9 @@ import ( authante "github.com/cosmos/cosmos-sdk/x/auth/ante" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/signing" - feegrantante "github.com/cosmos/cosmos-sdk/x/feegrant/ante" - feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" - feegranttypes "github.com/cosmos/cosmos-sdk/x/feegrant/types" + feegrantante "github.com/cosmos/cosmos-sdk/x/fee_grant/ante" + feegrantkeeper "github.com/cosmos/cosmos-sdk/x/fee_grant/keeper" + feegranttypes "github.com/cosmos/cosmos-sdk/x/fee_grant/types" ) // NewAnteHandler returns an AnteHandler that checks and increments sequence diff --git a/simapp/app.go b/simapp/app.go index 352e9641a77c..371f677d138f 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -54,9 +54,9 @@ import ( "github.com/cosmos/cosmos-sdk/x/evidence" evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - "github.com/cosmos/cosmos-sdk/x/feegrant" - feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" - feegranttypes "github.com/cosmos/cosmos-sdk/x/feegrant/types" + feegrant "github.com/cosmos/cosmos-sdk/x/fee_grant" + feegrantkeeper "github.com/cosmos/cosmos-sdk/x/fee_grant/keeper" + feegranttypes "github.com/cosmos/cosmos-sdk/x/fee_grant/types" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/cosmos/cosmos-sdk/x/gov" diff --git a/x/feegrant/ante/fee.go b/x/fee_grant/ante/fee.go similarity index 97% rename from x/feegrant/ante/fee.go rename to x/fee_grant/ante/fee.go index 3f13bf16e08a..f3c9ef35a91d 100644 --- a/x/feegrant/ante/fee.go +++ b/x/fee_grant/ante/fee.go @@ -7,8 +7,8 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/keeper" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" ) // var ( diff --git a/x/feegrant/ante/fee_test.go b/x/fee_grant/ante/fee_test.go similarity index 98% rename from x/feegrant/ante/fee_test.go rename to x/fee_grant/ante/fee_test.go index f1cd718491e9..c273ec6eb133 100644 --- a/x/feegrant/ante/fee_test.go +++ b/x/fee_grant/ante/fee_test.go @@ -17,8 +17,8 @@ import ( authante "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/feegrant/ante" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/ante" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" ) // AnteTestSuite is a test suite to be used with ante handler tests. diff --git a/x/feegrant/client/cli/cli_test.go b/x/fee_grant/client/cli/cli_test.go similarity index 98% rename from x/feegrant/client/cli/cli_test.go rename to x/fee_grant/client/cli/cli_test.go index fa053a264c0b..a8405c4697ad 100644 --- a/x/feegrant/client/cli/cli_test.go +++ b/x/fee_grant/client/cli/cli_test.go @@ -8,8 +8,8 @@ import ( clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/feegrant/client/cli" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/client/cli" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/suite" tmcli "github.com/tendermint/tendermint/libs/cli" diff --git a/x/feegrant/client/cli/query.go b/x/fee_grant/client/cli/query.go similarity index 98% rename from x/feegrant/client/cli/query.go rename to x/fee_grant/client/cli/query.go index bf2da17d7e5d..10fc029883dc 100644 --- a/x/feegrant/client/cli/query.go +++ b/x/fee_grant/client/cli/query.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" "github.com/spf13/cobra" ) diff --git a/x/feegrant/client/cli/service_msg_client.go b/x/fee_grant/client/cli/service_msg_client.go similarity index 100% rename from x/feegrant/client/cli/service_msg_client.go rename to x/fee_grant/client/cli/service_msg_client.go diff --git a/x/feegrant/client/cli/tx.go b/x/fee_grant/client/cli/tx.go similarity index 99% rename from x/feegrant/client/cli/tx.go rename to x/fee_grant/client/cli/tx.go index 648aed8373d7..b41844325317 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/fee_grant/client/cli/tx.go @@ -14,7 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/tx" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" ) // flag for feegrant module diff --git a/x/feegrant/client/rest/grpc_query_test.go b/x/fee_grant/client/rest/grpc_query_test.go similarity index 98% rename from x/feegrant/client/rest/grpc_query_test.go rename to x/fee_grant/client/rest/grpc_query_test.go index 5403fe3036ee..ef6314d67e88 100644 --- a/x/feegrant/client/rest/grpc_query_test.go +++ b/x/fee_grant/client/rest/grpc_query_test.go @@ -12,8 +12,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil" - "github.com/cosmos/cosmos-sdk/x/feegrant/client/cli" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/client/cli" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" "github.com/stretchr/testify/suite" ) diff --git a/x/feegrant/doc.go b/x/fee_grant/doc.go similarity index 100% rename from x/feegrant/doc.go rename to x/fee_grant/doc.go diff --git a/x/feegrant/genesis.go b/x/fee_grant/genesis.go similarity index 94% rename from x/feegrant/genesis.go rename to x/fee_grant/genesis.go index a5c05b7fecc1..0f7214f6ec6d 100644 --- a/x/feegrant/genesis.go +++ b/x/fee_grant/genesis.go @@ -2,8 +2,8 @@ package feegrant import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/keeper" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" ) // GenesisState contains a set of fee allowances, persisted from the store diff --git a/x/feegrant/genesis_test.go b/x/fee_grant/genesis_test.go similarity index 91% rename from x/feegrant/genesis_test.go rename to x/fee_grant/genesis_test.go index d8628e031fe0..82f1e17ab56a 100644 --- a/x/feegrant/genesis_test.go +++ b/x/fee_grant/genesis_test.go @@ -6,9 +6,9 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - feegrant "github.com/cosmos/cosmos-sdk/x/feegrant" - "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + feegrant "github.com/cosmos/cosmos-sdk/x/fee_grant" + "github.com/cosmos/cosmos-sdk/x/fee_grant/keeper" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) diff --git a/x/feegrant/keeper/grpc_query.go b/x/fee_grant/keeper/grpc_query.go similarity index 98% rename from x/feegrant/keeper/grpc_query.go rename to x/fee_grant/keeper/grpc_query.go index 9f2abdd50e56..ccffc6a6a8d9 100644 --- a/x/feegrant/keeper/grpc_query.go +++ b/x/fee_grant/keeper/grpc_query.go @@ -11,7 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" ) var _ types.QueryServer = Keeper{} diff --git a/x/feegrant/keeper/keeper.go b/x/fee_grant/keeper/keeper.go similarity index 99% rename from x/feegrant/keeper/keeper.go rename to x/fee_grant/keeper/keeper.go index c9c07ca6b7bc..d4d4b54a5982 100644 --- a/x/feegrant/keeper/keeper.go +++ b/x/fee_grant/keeper/keeper.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" ) // Keeper manages state of all fee grants, as well as calculating approval. diff --git a/x/feegrant/keeper/keeper_test.go b/x/fee_grant/keeper/keeper_test.go similarity index 99% rename from x/feegrant/keeper/keeper_test.go rename to x/fee_grant/keeper/keeper_test.go index 0f7fdfeedd91..62bea9be9761 100644 --- a/x/feegrant/keeper/keeper_test.go +++ b/x/fee_grant/keeper/keeper_test.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" ) type KeeperTestSuite struct { diff --git a/x/feegrant/keeper/msg_server.go b/x/fee_grant/keeper/msg_server.go similarity index 96% rename from x/feegrant/keeper/msg_server.go rename to x/fee_grant/keeper/msg_server.go index 482bee4a74d3..db819bf820d2 100644 --- a/x/feegrant/keeper/msg_server.go +++ b/x/fee_grant/keeper/msg_server.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" ) type msgServer struct { diff --git a/x/feegrant/module.go b/x/fee_grant/module.go similarity index 97% rename from x/feegrant/module.go rename to x/fee_grant/module.go index 6e43077e80a3..9b47d83602be 100644 --- a/x/feegrant/module.go +++ b/x/fee_grant/module.go @@ -18,10 +18,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/feegrant/client/cli" - "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" - "github.com/cosmos/cosmos-sdk/x/feegrant/simulation" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/client/cli" + "github.com/cosmos/cosmos-sdk/x/fee_grant/keeper" + "github.com/cosmos/cosmos-sdk/x/fee_grant/simulation" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" ) var ( diff --git a/x/feegrant/simulation/decoder.go b/x/fee_grant/simulation/decoder.go similarity index 93% rename from x/feegrant/simulation/decoder.go rename to x/fee_grant/simulation/decoder.go index c7f783c2b6d5..0f98b4b4856f 100644 --- a/x/feegrant/simulation/decoder.go +++ b/x/fee_grant/simulation/decoder.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types/kv" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" ) // NewDecodeStore returns a decoder function closure that umarshals the KVPair's diff --git a/x/feegrant/simulation/decoder_test.go b/x/fee_grant/simulation/decoder_test.go similarity index 93% rename from x/feegrant/simulation/decoder_test.go rename to x/fee_grant/simulation/decoder_test.go index 68d4cbe4037c..0876de2ff84e 100644 --- a/x/feegrant/simulation/decoder_test.go +++ b/x/fee_grant/simulation/decoder_test.go @@ -8,8 +8,8 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" - "github.com/cosmos/cosmos-sdk/x/feegrant/simulation" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/simulation" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" "github.com/stretchr/testify/require" ) diff --git a/x/feegrant/simulation/genesis.go b/x/fee_grant/simulation/genesis.go similarity index 95% rename from x/feegrant/simulation/genesis.go rename to x/fee_grant/simulation/genesis.go index f9f4c7e12748..e3701e33db1f 100644 --- a/x/feegrant/simulation/genesis.go +++ b/x/fee_grant/simulation/genesis.go @@ -7,7 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" ) // Simulation parameter constants diff --git a/x/feegrant/simulation/genesis_test.go b/x/fee_grant/simulation/genesis_test.go similarity index 90% rename from x/feegrant/simulation/genesis_test.go rename to x/fee_grant/simulation/genesis_test.go index 4f3ae74b56be..c507ac7e6dc3 100644 --- a/x/feegrant/simulation/genesis_test.go +++ b/x/fee_grant/simulation/genesis_test.go @@ -9,8 +9,8 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/feegrant/simulation" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/simulation" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" "github.com/stretchr/testify/require" ) diff --git a/x/feegrant/simulation/operations.go b/x/fee_grant/simulation/operations.go similarity index 98% rename from x/feegrant/simulation/operations.go rename to x/fee_grant/simulation/operations.go index 8874cc005e6c..6989607bbaf1 100644 --- a/x/feegrant/simulation/operations.go +++ b/x/fee_grant/simulation/operations.go @@ -11,8 +11,8 @@ import ( simappparams "github.com/cosmos/cosmos-sdk/simapp/params" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/keeper" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" "github.com/cosmos/cosmos-sdk/x/simulation" ) diff --git a/x/feegrant/simulation/operations_test.go b/x/fee_grant/simulation/operations_test.go similarity index 97% rename from x/feegrant/simulation/operations_test.go rename to x/fee_grant/simulation/operations_test.go index 173e3772e581..73b821e8889a 100644 --- a/x/feegrant/simulation/operations_test.go +++ b/x/fee_grant/simulation/operations_test.go @@ -15,8 +15,8 @@ import ( simappparams "github.com/cosmos/cosmos-sdk/simapp/params" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/feegrant/simulation" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/simulation" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" ) type SimTestSuite struct { diff --git a/x/feegrant/types/basic_fee.go b/x/fee_grant/types/basic_fee.go similarity index 100% rename from x/feegrant/types/basic_fee.go rename to x/fee_grant/types/basic_fee.go diff --git a/x/feegrant/types/basic_fee_test.go b/x/fee_grant/types/basic_fee_test.go similarity index 97% rename from x/feegrant/types/basic_fee_test.go rename to x/fee_grant/types/basic_fee_test.go index 440aaeaf49da..1d032708f043 100644 --- a/x/feegrant/types/basic_fee_test.go +++ b/x/fee_grant/types/basic_fee_test.go @@ -5,7 +5,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/x/feegrant/types/codec.go b/x/fee_grant/types/codec.go similarity index 100% rename from x/feegrant/types/codec.go rename to x/fee_grant/types/codec.go diff --git a/x/feegrant/types/errors.go b/x/fee_grant/types/errors.go similarity index 100% rename from x/feegrant/types/errors.go rename to x/fee_grant/types/errors.go diff --git a/x/feegrant/types/events.go b/x/fee_grant/types/events.go similarity index 100% rename from x/feegrant/types/events.go rename to x/fee_grant/types/events.go diff --git a/x/feegrant/types/expected_keepers.go b/x/fee_grant/types/expected_keepers.go similarity index 100% rename from x/feegrant/types/expected_keepers.go rename to x/fee_grant/types/expected_keepers.go diff --git a/x/feegrant/types/expiration.go b/x/fee_grant/types/expiration.go similarity index 100% rename from x/feegrant/types/expiration.go rename to x/fee_grant/types/expiration.go diff --git a/x/feegrant/types/expiration_test.go b/x/fee_grant/types/expiration_test.go similarity index 98% rename from x/feegrant/types/expiration_test.go rename to x/fee_grant/types/expiration_test.go index 9cc7684b5065..5e7b1749ea76 100644 --- a/x/feegrant/types/expiration_test.go +++ b/x/fee_grant/types/expiration_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/x/feegrant/types/feegrant.pb.go b/x/fee_grant/types/feegrant.pb.go similarity index 91% rename from x/feegrant/types/feegrant.pb.go rename to x/fee_grant/types/feegrant.pb.go index 2a6e0b111210..2158d637a65b 100644 --- a/x/feegrant/types/feegrant.pb.go +++ b/x/fee_grant/types/feegrant.pb.go @@ -345,44 +345,44 @@ func init() { } var fileDescriptor_7279582900c30aea = []byte{ - // 577 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4d, 0x6e, 0xd3, 0x40, - 0x14, 0x8e, 0x49, 0x13, 0x9a, 0x17, 0x40, 0x64, 0x14, 0x81, 0x9b, 0x85, 0x53, 0xb2, 0x40, 0x11, - 0x52, 0x6c, 0x5a, 0x36, 0xa8, 0x1b, 0x14, 0x97, 0xb6, 0x20, 0x58, 0x20, 0xc3, 0x0a, 0x81, 0x22, - 0xdb, 0x99, 0x3a, 0xa3, 0x3a, 0x1e, 0xcb, 0x33, 0x81, 0xe6, 0x12, 0xa8, 0x4b, 0xce, 0xc0, 0x9a, - 0x43, 0x54, 0xac, 0x2a, 0x56, 0xac, 0x5a, 0x94, 0x9c, 0x80, 0x1b, 0xa0, 0xf9, 0x71, 0x12, 0xa5, - 0x04, 0x81, 0xd4, 0x55, 0x3c, 0xf3, 0xde, 0xf7, 0xf3, 0xbe, 0x99, 0x09, 0xdc, 0x0f, 0x29, 0x1b, - 0x52, 0xe6, 0x1c, 0x62, 0x1c, 0x65, 0x7e, 0xc2, 0x9d, 0x0f, 0x5b, 0x01, 0xe6, 0xfe, 0xd6, 0x6c, - 0xc3, 0x4e, 0x33, 0xca, 0x29, 0xba, 0xab, 0xfa, 0xec, 0xd9, 0xb6, 0xee, 0x6b, 0xd4, 0x23, 0x1a, - 0x51, 0xd9, 0xe3, 0x88, 0x2f, 0xd5, 0xde, 0xd8, 0x88, 0x28, 0x8d, 0x62, 0xec, 0xc8, 0x55, 0x30, - 0x3a, 0x74, 0xfc, 0x64, 0x9c, 0x97, 0x14, 0x53, 0x4f, 0x61, 0x34, 0xad, 0x2a, 0x59, 0xda, 0x4c, - 0xe0, 0x33, 0x3c, 0x33, 0x12, 0x52, 0x92, 0xe8, 0x7a, 0x73, 0x99, 0x95, 0x93, 0x21, 0x66, 0xdc, - 0x1f, 0xa6, 0xaa, 0xa1, 0x75, 0x6e, 0x40, 0xcd, 0xf5, 0x19, 0x09, 0xf7, 0x31, 0xee, 0xc6, 0x31, - 0xfd, 0xe8, 0x27, 0x21, 0x46, 0x31, 0x54, 0x59, 0x8a, 0x93, 0x7e, 0x2f, 0x26, 0x43, 0xc2, 0x4d, - 0x63, 0xb3, 0xd8, 0xae, 0x6e, 0x6f, 0xd8, 0x5a, 0x5a, 0x88, 0xe5, 0xd3, 0xd8, 0xbb, 0x94, 0x24, - 0xee, 0xc3, 0xd3, 0xf3, 0x66, 0xe1, 0xcb, 0x45, 0xb3, 0x1d, 0x11, 0x3e, 0x18, 0x05, 0x76, 0x48, - 0x87, 0xda, 0xa7, 0xfe, 0xe9, 0xb0, 0xfe, 0x91, 0xc3, 0xc7, 0x29, 0x66, 0x12, 0xc0, 0x3c, 0x90, - 0xfc, 0x2f, 0x05, 0x3d, 0x7a, 0x06, 0x80, 0x8f, 0x53, 0x92, 0xf9, 0x9c, 0xd0, 0xc4, 0xbc, 0xb6, - 0x69, 0xb4, 0xab, 0xdb, 0x2d, 0x7b, 0x45, 0x7c, 0xf6, 0x9e, 0x68, 0xc5, 0xac, 0xcb, 0xdd, 0x35, - 0xa1, 0xea, 0x2d, 0x60, 0x77, 0x6a, 0xdf, 0xbf, 0x76, 0x6e, 0x2e, 0x4e, 0xf2, 0xbc, 0xf5, 0xab, - 0x08, 0xf5, 0x57, 0x38, 0x23, 0xb4, 0xbf, 0x34, 0xe3, 0x3e, 0x94, 0x02, 0x31, 0xb8, 0x69, 0x48, - 0xc1, 0x07, 0x2b, 0x05, 0x2f, 0xc5, 0xa3, 0x85, 0x15, 0x1c, 0x3d, 0x81, 0x72, 0x2a, 0xf9, 0xb5, - 0xf3, 0x7b, 0x2b, 0x89, 0x9e, 0x8e, 0x94, 0x4d, 0x8d, 0xd7, 0x30, 0x34, 0x06, 0xa4, 0xbe, 0x7a, - 0x8b, 0x99, 0x17, 0xaf, 0x3e, 0xf3, 0xdb, 0x4a, 0xe6, 0xf5, 0x3c, 0xf9, 0x11, 0xe8, 0xbd, 0x5e, - 0xe8, 0x27, 0x4a, 0xde, 0x5c, 0xbb, 0x7a, 0xe1, 0x5b, 0x4a, 0x64, 0xd7, 0x4f, 0xa4, 0x36, 0x7a, - 0x01, 0x37, 0xb4, 0x6c, 0x86, 0x19, 0xe6, 0x66, 0xe9, 0x3f, 0x8f, 0xbc, 0xaa, 0xd0, 0x9e, 0x00, - 0xff, 0xe9, 0xcc, 0xdf, 0xc1, 0x7a, 0x9e, 0x35, 0xda, 0x81, 0x52, 0x18, 0xd3, 0xf0, 0x48, 0x1f, - 0x73, 0xc3, 0x56, 0x2f, 0xc2, 0xce, 0x5f, 0x84, 0xfd, 0x26, 0x7f, 0x11, 0xee, 0xba, 0x20, 0xff, - 0x7c, 0xd1, 0x34, 0x3c, 0x05, 0x41, 0x75, 0x28, 0x05, 0x12, 0x2b, 0x4e, 0xb6, 0xe8, 0xa9, 0x45, - 0xeb, 0x3d, 0x54, 0x66, 0x86, 0xd0, 0x63, 0x58, 0x13, 0x4f, 0xea, 0x5f, 0xd9, 0x4f, 0x04, 0xbb, - 0x44, 0xa0, 0x3b, 0x50, 0x1e, 0x60, 0x12, 0x0d, 0xb8, 0x66, 0xd7, 0xab, 0xd6, 0x27, 0x03, 0x6a, - 0x8b, 0xe3, 0x1c, 0x88, 0x28, 0x90, 0x09, 0xd7, 0x65, 0x26, 0x38, 0x93, 0x52, 0x15, 0x2f, 0x5f, - 0xce, 0x2b, 0x58, 0x12, 0xcd, 0x2a, 0x18, 0xed, 0x41, 0xc5, 0xcf, 0x59, 0xcc, 0xa2, 0x34, 0x58, - 0xbf, 0x64, 0xb0, 0x9b, 0x8c, 0xdd, 0xda, 0xb7, 0xe5, 0x08, 0xbd, 0x39, 0xd2, 0x3d, 0x38, 0x9d, - 0x58, 0xc6, 0xd9, 0xc4, 0x32, 0x7e, 0x4e, 0x2c, 0xe3, 0x64, 0x6a, 0x15, 0xce, 0xa6, 0x56, 0xe1, - 0xc7, 0xd4, 0x2a, 0xbc, 0xed, 0xfc, 0xf5, 0x06, 0x1c, 0xcf, 0xff, 0x22, 0xe5, 0x65, 0x08, 0xca, - 0x52, 0xf4, 0xd1, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07, 0x5c, 0x4a, 0xc1, 0x42, 0x05, 0x00, - 0x00, + // 579 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x6e, 0xd3, 0x30, + 0x1c, 0x6f, 0xe8, 0x07, 0xab, 0x0b, 0x88, 0x5a, 0x15, 0x64, 0x3d, 0xa4, 0xa3, 0x07, 0x54, 0x21, + 0xcd, 0x61, 0xe3, 0x82, 0x76, 0x41, 0xcd, 0xd8, 0x18, 0x82, 0x03, 0x0a, 0x9c, 0x10, 0xa8, 0x72, + 0x52, 0x2f, 0xb5, 0x96, 0xc6, 0x51, 0xec, 0xc2, 0xfa, 0x12, 0x68, 0x47, 0x9e, 0x81, 0x33, 0x0f, + 0x31, 0x71, 0x9a, 0x38, 0x71, 0xda, 0x50, 0xfb, 0x04, 0xbc, 0x01, 0xf2, 0x47, 0xda, 0xaa, 0xa3, + 0x08, 0xa4, 0x9d, 0x12, 0xfb, 0xff, 0xff, 0x7d, 0xfc, 0x7f, 0x8e, 0x03, 0xee, 0x87, 0x8c, 0x0f, + 0x19, 0x77, 0x0f, 0x09, 0x89, 0x32, 0x9c, 0x08, 0xf7, 0xc3, 0x56, 0x40, 0x04, 0xde, 0x9a, 0x6d, + 0xa0, 0x34, 0x63, 0x82, 0xc1, 0xbb, 0xba, 0x0f, 0xcd, 0xb6, 0x4d, 0x5f, 0xb3, 0x11, 0xb1, 0x88, + 0xa9, 0x1e, 0x57, 0xbe, 0xe9, 0xf6, 0xe6, 0x7a, 0xc4, 0x58, 0x14, 0x13, 0x57, 0xad, 0x82, 0xd1, + 0xa1, 0x8b, 0x93, 0x71, 0x5e, 0xd2, 0x4c, 0x3d, 0x8d, 0x31, 0xb4, 0xba, 0xe4, 0x18, 0x33, 0x01, + 0xe6, 0x64, 0x66, 0x24, 0x64, 0x34, 0x31, 0xf5, 0xd6, 0x32, 0xab, 0xa0, 0x43, 0xc2, 0x05, 0x1e, + 0xa6, 0xba, 0xa1, 0x7d, 0x6e, 0x81, 0xba, 0x87, 0x39, 0x0d, 0xf7, 0x09, 0xe9, 0xc6, 0x31, 0xfb, + 0x88, 0x93, 0x90, 0xc0, 0x18, 0xd4, 0x78, 0x4a, 0x92, 0x7e, 0x2f, 0xa6, 0x43, 0x2a, 0x6c, 0x6b, + 0xa3, 0xd8, 0xa9, 0x6d, 0xaf, 0x23, 0x23, 0x2d, 0xc5, 0xf2, 0x69, 0xd0, 0x2e, 0xa3, 0x89, 0xf7, + 0xf0, 0xf4, 0xbc, 0x55, 0xf8, 0x72, 0xd1, 0xea, 0x44, 0x54, 0x0c, 0x46, 0x01, 0x0a, 0xd9, 0xd0, + 0xf8, 0x34, 0x8f, 0x4d, 0xde, 0x3f, 0x72, 0xc5, 0x38, 0x25, 0x5c, 0x01, 0xb8, 0x0f, 0x14, 0xff, + 0x4b, 0x49, 0x0f, 0x0f, 0x00, 0x20, 0xc7, 0x29, 0xcd, 0xb0, 0xa0, 0x2c, 0xb1, 0xaf, 0x6d, 0x58, + 0x9d, 0xda, 0x76, 0x1b, 0xad, 0x88, 0x0f, 0xed, 0xc9, 0x56, 0xc2, 0xbb, 0xc2, 0x2b, 0x49, 0x55, + 0x7f, 0x01, 0xbb, 0x53, 0xff, 0xfe, 0x75, 0xf3, 0xe6, 0xe2, 0x24, 0xcf, 0xdb, 0xbf, 0x8a, 0xa0, + 0xf1, 0x8a, 0x64, 0x94, 0xf5, 0x97, 0x66, 0xdc, 0x07, 0xe5, 0x40, 0x0e, 0x6e, 0x5b, 0x4a, 0xf0, + 0xc1, 0x4a, 0xc1, 0x4b, 0xf1, 0x18, 0x61, 0x0d, 0x87, 0x4f, 0x40, 0x25, 0x55, 0xfc, 0xc6, 0xf9, + 0xbd, 0x95, 0x44, 0x4f, 0x47, 0xda, 0xa6, 0xc1, 0x1b, 0x18, 0x1c, 0x03, 0xa8, 0xdf, 0x7a, 0x8b, + 0x99, 0x17, 0xaf, 0x3e, 0xf3, 0xdb, 0x5a, 0xe6, 0xf5, 0x3c, 0xf9, 0x11, 0x30, 0x7b, 0xbd, 0x10, + 0x27, 0x5a, 0xde, 0x2e, 0x5d, 0xbd, 0xf0, 0x2d, 0x2d, 0xb2, 0x8b, 0x13, 0xa5, 0x0d, 0x5f, 0x80, + 0x1b, 0x46, 0x36, 0x23, 0x9c, 0x08, 0xbb, 0xfc, 0x9f, 0x47, 0x5e, 0xd3, 0x68, 0x5f, 0x82, 0xff, + 0x74, 0xe6, 0xef, 0xc0, 0x5a, 0x9e, 0x35, 0xdc, 0x01, 0xe5, 0x30, 0x66, 0xe1, 0x91, 0x39, 0xe6, + 0x26, 0xd2, 0x37, 0x02, 0xe5, 0x37, 0x02, 0xbd, 0xc9, 0x6f, 0x84, 0xb7, 0x26, 0xc9, 0x3f, 0x5f, + 0xb4, 0x2c, 0x5f, 0x43, 0x60, 0x03, 0x94, 0x03, 0x85, 0x95, 0x27, 0x5b, 0xf4, 0xf5, 0xa2, 0xfd, + 0x1e, 0x54, 0x67, 0x86, 0xe0, 0x63, 0x50, 0x92, 0x57, 0xea, 0x5f, 0xd9, 0x4f, 0x24, 0xbb, 0x42, + 0xc0, 0x3b, 0xa0, 0x32, 0x20, 0x34, 0x1a, 0x08, 0xc3, 0x6e, 0x56, 0xed, 0x4f, 0x16, 0xa8, 0x2f, + 0x8e, 0xf3, 0x4c, 0x46, 0x01, 0x6d, 0x70, 0x5d, 0x65, 0x42, 0x32, 0x25, 0x55, 0xf5, 0xf3, 0xe5, + 0xbc, 0x42, 0x14, 0xd1, 0xac, 0x42, 0xe0, 0x1e, 0xa8, 0xe2, 0x9c, 0xc5, 0x2e, 0x2a, 0x83, 0x8d, + 0x4b, 0x06, 0xbb, 0xc9, 0xd8, 0xab, 0x7f, 0x5b, 0x8e, 0xd0, 0x9f, 0x23, 0xbd, 0x83, 0xd3, 0x89, + 0x63, 0x9d, 0x4d, 0x1c, 0xeb, 0xe7, 0xc4, 0xb1, 0x4e, 0xa6, 0x4e, 0xe1, 0x6c, 0xea, 0x14, 0x7e, + 0x4c, 0x9d, 0xc2, 0x5b, 0xf4, 0xd7, 0x2f, 0xe0, 0x58, 0xfe, 0x11, 0x7b, 0xfa, 0x1f, 0xa9, 0xbe, + 0x86, 0xa0, 0xa2, 0x54, 0x1f, 0xfd, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x60, 0x04, 0xee, 0x43, + 0x05, 0x00, 0x00, } func (m *BasicFeeAllowance) Marshal() (dAtA []byte, err error) { diff --git a/x/feegrant/types/fees.go b/x/fee_grant/types/fees.go similarity index 100% rename from x/feegrant/types/fees.go rename to x/fee_grant/types/fees.go diff --git a/x/feegrant/types/genesis.go b/x/fee_grant/types/genesis.go similarity index 100% rename from x/feegrant/types/genesis.go rename to x/fee_grant/types/genesis.go diff --git a/x/feegrant/types/genesis.pb.go b/x/fee_grant/types/genesis.pb.go similarity index 96% rename from x/feegrant/types/genesis.pb.go rename to x/fee_grant/types/genesis.pb.go index 6af384084557..0f44e3337880 100644 --- a/x/feegrant/types/genesis.pb.go +++ b/x/fee_grant/types/genesis.pb.go @@ -77,7 +77,7 @@ func init() { } var fileDescriptor_ac719d2d0954d1bf = []byte{ - // 221 bytes of a gzipped FileDescriptorProto + // 224 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4d, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0x4d, 0x2f, 0x4a, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, @@ -87,11 +87,11 @@ var fileDescriptor_ac719d2d0954d1bf = []byte{ 0x2f, 0x2d, 0x35, 0x35, 0x3e, 0x31, 0x27, 0x27, 0xbf, 0x3c, 0x31, 0x2f, 0x39, 0xb5, 0x58, 0x82, 0x51, 0x81, 0x59, 0x83, 0xdb, 0x48, 0x4b, 0x0f, 0x87, 0xfd, 0x7a, 0x6e, 0xa9, 0xa9, 0x8e, 0x30, 0xd5, 0xee, 0x20, 0x19, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0x78, 0xd3, 0x90, 0x24, 0x8a, - 0x9d, 0xdc, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, - 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x37, 0x3d, 0xb3, + 0x9d, 0x3c, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, + 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x2f, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xea, 0x6a, 0x08, 0xa5, 0x5b, 0x9c, 0x92, - 0xad, 0x5f, 0x81, 0xf0, 0x42, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0xe1, 0xc6, 0x80, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xaf, 0x53, 0x6e, 0xc5, 0x38, 0x01, 0x00, 0x00, + 0xad, 0x5f, 0x01, 0x72, 0x71, 0x3c, 0xc4, 0x0f, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, + 0x97, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xca, 0x6f, 0x0d, 0x36, 0x39, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/feegrant/types/grant.go b/x/fee_grant/types/grant.go similarity index 100% rename from x/feegrant/types/grant.go rename to x/fee_grant/types/grant.go diff --git a/x/feegrant/types/grant_test.go b/x/fee_grant/types/grant_test.go similarity index 97% rename from x/feegrant/types/grant_test.go rename to x/fee_grant/types/grant_test.go index c826889c7bf5..716aa61c919a 100644 --- a/x/feegrant/types/grant_test.go +++ b/x/fee_grant/types/grant_test.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/x/feegrant/types/key.go b/x/fee_grant/types/key.go similarity index 100% rename from x/feegrant/types/key.go rename to x/fee_grant/types/key.go diff --git a/x/feegrant/types/msgs.go b/x/fee_grant/types/msgs.go similarity index 100% rename from x/feegrant/types/msgs.go rename to x/fee_grant/types/msgs.go diff --git a/x/feegrant/types/periodic_fee.go b/x/fee_grant/types/periodic_fee.go similarity index 100% rename from x/feegrant/types/periodic_fee.go rename to x/fee_grant/types/periodic_fee.go diff --git a/x/feegrant/types/periodic_fee_test.go b/x/fee_grant/types/periodic_fee_test.go similarity index 99% rename from x/feegrant/types/periodic_fee_test.go rename to x/fee_grant/types/periodic_fee_test.go index 0f853da28a60..9a92fc19a492 100644 --- a/x/feegrant/types/periodic_fee_test.go +++ b/x/fee_grant/types/periodic_fee_test.go @@ -5,7 +5,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/feegrant/types" + "github.com/cosmos/cosmos-sdk/x/fee_grant/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/x/feegrant/types/query.pb.go b/x/fee_grant/types/query.pb.go similarity index 91% rename from x/feegrant/types/query.pb.go rename to x/fee_grant/types/query.pb.go index bd280a601dfb..d7dc2cfd6b60 100644 --- a/x/feegrant/types/query.pb.go +++ b/x/fee_grant/types/query.pb.go @@ -250,36 +250,36 @@ func init() { } var fileDescriptor_59efc303945de53f = []byte{ - // 459 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xcf, 0x6e, 0xd3, 0x40, - 0x10, 0xc6, 0xb3, 0x41, 0x80, 0xd8, 0x36, 0x1c, 0x56, 0x48, 0x18, 0x0b, 0x59, 0x95, 0x91, 0x0a, - 0x14, 0xd5, 0xab, 0xa4, 0x4f, 0x00, 0x42, 0xc9, 0x05, 0x01, 0xcd, 0x91, 0x0b, 0xda, 0x84, 0xc9, - 0x62, 0xe1, 0x7a, 0x5d, 0xef, 0x06, 0xa8, 0x50, 0x2f, 0x3c, 0x01, 0x12, 0x8f, 0xc1, 0x0b, 0x70, - 0xe7, 0xc2, 0x31, 0x12, 0x17, 0x8e, 0x28, 0xe1, 0x2d, 0xb8, 0x20, 0xef, 0x9f, 0x64, 0x23, 0x6c, - 0x2a, 0x9f, 0xe2, 0xcc, 0x7c, 0x33, 0xf3, 0xfb, 0xc6, 0x63, 0x7c, 0x67, 0x2a, 0xe4, 0x89, 0x90, - 0x74, 0x06, 0xc0, 0x4b, 0x96, 0x2b, 0xfa, 0xb6, 0x3f, 0x01, 0xc5, 0xfa, 0xf4, 0x74, 0x0e, 0xe5, - 0x59, 0x52, 0x94, 0x42, 0x09, 0x72, 0xd3, 0x88, 0x12, 0x27, 0x4a, 0xac, 0x28, 0xbc, 0xc1, 0x05, - 0x17, 0x5a, 0x43, 0xab, 0x27, 0x23, 0x0f, 0xf7, 0x9b, 0x7a, 0xae, 0xeb, 0x8d, 0xee, 0xc0, 0xea, - 0x26, 0x4c, 0x82, 0x99, 0xb7, 0x56, 0x16, 0x8c, 0xa7, 0x39, 0x53, 0xa9, 0xc8, 0xad, 0xf6, 0x36, - 0x17, 0x82, 0x67, 0x40, 0x59, 0x91, 0x52, 0x96, 0xe7, 0x42, 0xe9, 0xa4, 0x34, 0xd9, 0xf8, 0x29, - 0x0e, 0x8e, 0xab, 0xfa, 0x21, 0xc0, 0xc3, 0x2c, 0x13, 0xef, 0x58, 0x3e, 0x85, 0x31, 0x9c, 0xce, - 0x41, 0x2a, 0x12, 0xe0, 0xab, 0x7a, 0x28, 0x94, 0x01, 0xda, 0x43, 0xf7, 0xae, 0x8d, 0xdd, 0xdf, - 0x4d, 0x06, 0x82, 0xae, 0x9f, 0x81, 0x38, 0xc3, 0xb7, 0x6a, 0xfa, 0xc9, 0x42, 0xe4, 0x12, 0xc8, - 0x33, 0xdc, 0x9b, 0x01, 0xbc, 0x64, 0x2e, 0xa1, 0xdb, 0xee, 0x0c, 0x0e, 0x92, 0x86, 0x2d, 0x25, - 0x7e, 0x97, 0x51, 0x95, 0x19, 0xef, 0xce, 0xbc, 0x50, 0x7c, 0x5e, 0x33, 0x4d, 0xfe, 0x83, 0x0f, - 0xdb, 0xf8, 0x40, 0x86, 0x18, 0x6f, 0xd6, 0xa4, 0x1d, 0xec, 0x0c, 0xf6, 0x1d, 0x44, 0xb5, 0xd3, - 0xc4, 0xbc, 0x43, 0x87, 0xf1, 0x9c, 0x71, 0xb7, 0x94, 0xb1, 0x57, 0x19, 0x7f, 0x45, 0x38, 0xac, - 0x9b, 0x6f, 0xed, 0x1e, 0xe3, 0xeb, 0x5b, 0x76, 0x65, 0x80, 0xf6, 0x2e, 0xb5, 0xf4, 0xdb, 0xf3, - 0xfd, 0x4a, 0x32, 0xaa, 0x21, 0xbf, 0x7b, 0x21, 0xb9, 0xe1, 0xf1, 0xd1, 0x07, 0x7f, 0xba, 0xf8, - 0xb2, 0x46, 0x27, 0xdf, 0x10, 0xde, 0xf5, 0xe7, 0x92, 0x7e, 0x23, 0x5e, 0xd3, 0xa5, 0x84, 0x83, - 0x36, 0x25, 0x86, 0x26, 0x7e, 0xf2, 0xf1, 0xc7, 0xef, 0xcf, 0xdd, 0x21, 0x79, 0x4c, 0x9b, 0x8e, - 0xde, 0x5e, 0x9b, 0xa4, 0x1f, 0xec, 0xd3, 0xb9, 0x0d, 0xc1, 0x3a, 0x04, 0x36, 0x44, 0xbe, 0x20, - 0xdc, 0xdb, 0x7a, 0x0b, 0xa4, 0x05, 0x93, 0x3b, 0x99, 0xf0, 0xa8, 0x55, 0x8d, 0x35, 0xd2, 0xd7, - 0x46, 0x1e, 0x90, 0xfb, 0xff, 0x37, 0xe2, 0x31, 0x3f, 0x1a, 0x7d, 0x5f, 0x46, 0x68, 0xb1, 0x8c, - 0xd0, 0xaf, 0x65, 0x84, 0x3e, 0xad, 0xa2, 0xce, 0x62, 0x15, 0x75, 0x7e, 0xae, 0xa2, 0xce, 0x8b, - 0x43, 0x9e, 0xaa, 0xd7, 0xf3, 0x49, 0x32, 0x15, 0x27, 0xae, 0x9d, 0xf9, 0x39, 0x94, 0xaf, 0xde, - 0xd0, 0xf7, 0x9b, 0xde, 0xea, 0xac, 0x00, 0x39, 0xb9, 0xa2, 0xbf, 0xe2, 0xa3, 0xbf, 0x01, 0x00, - 0x00, 0xff, 0xff, 0x81, 0xca, 0x45, 0x59, 0x8d, 0x04, 0x00, 0x00, + // 461 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0xcd, 0x6e, 0x13, 0x31, + 0x10, 0x8e, 0x83, 0x00, 0xe1, 0x36, 0x1c, 0x2c, 0x24, 0x96, 0x15, 0x5a, 0x55, 0x8b, 0x54, 0xa0, + 0x08, 0x5b, 0x49, 0x9f, 0x00, 0x84, 0x52, 0x0e, 0x08, 0x68, 0x8e, 0x5c, 0x2a, 0x27, 0x4c, 0x4c, + 0xc4, 0x76, 0xbd, 0x5d, 0x3b, 0x40, 0x85, 0x7a, 0xe1, 0x09, 0x90, 0x78, 0x0c, 0x5e, 0x80, 0x3b, + 0x17, 0x8e, 0x95, 0xb8, 0x70, 0x44, 0x09, 0x6f, 0xc1, 0x05, 0xad, 0x7f, 0x12, 0x47, 0xec, 0x82, + 0xf6, 0xb4, 0xde, 0x99, 0x6f, 0xbe, 0xf9, 0xbe, 0xf1, 0x18, 0xdf, 0x9a, 0x48, 0x75, 0x2c, 0x15, + 0x9b, 0x02, 0x88, 0x92, 0xe7, 0x9a, 0xbd, 0xe9, 0x8f, 0x41, 0xf3, 0x3e, 0x3b, 0x99, 0x43, 0x79, + 0x4a, 0x8b, 0x52, 0x6a, 0x49, 0xae, 0x5b, 0x10, 0xf5, 0x20, 0xea, 0x40, 0xf1, 0x35, 0x21, 0x85, + 0x34, 0x18, 0x56, 0x9d, 0x2c, 0x3c, 0xde, 0x6d, 0xe2, 0x5c, 0xd5, 0x5b, 0xdc, 0x9e, 0xc3, 0x8d, + 0xb9, 0x02, 0xdb, 0x6f, 0x85, 0x2c, 0xb8, 0x98, 0xe5, 0x5c, 0xcf, 0x64, 0xee, 0xb0, 0x37, 0x85, + 0x94, 0x22, 0x03, 0xc6, 0x8b, 0x19, 0xe3, 0x79, 0x2e, 0xb5, 0x49, 0x2a, 0x9b, 0x4d, 0x9f, 0xe2, + 0xe8, 0xb0, 0xaa, 0x1f, 0x02, 0x3c, 0xc8, 0x32, 0xf9, 0x96, 0xe7, 0x13, 0x18, 0xc1, 0xc9, 0x1c, + 0x94, 0x26, 0x11, 0xbe, 0x6c, 0x9a, 0x42, 0x19, 0xa1, 0x1d, 0x74, 0xe7, 0xca, 0xc8, 0xff, 0xae, + 0x33, 0x10, 0x75, 0xc3, 0x0c, 0xa4, 0x19, 0xbe, 0x51, 0xc3, 0xa7, 0x0a, 0x99, 0x2b, 0x20, 0xcf, + 0x70, 0x6f, 0x0a, 0x70, 0xc4, 0x7d, 0xc2, 0xd0, 0x6e, 0x0d, 0xf6, 0x68, 0xc3, 0x94, 0x68, 0xc8, + 0x72, 0x50, 0x65, 0x46, 0xdb, 0xd3, 0x20, 0x94, 0x9e, 0xd5, 0x74, 0x53, 0x7f, 0xc9, 0x87, 0x4d, + 0xf9, 0x40, 0x86, 0x18, 0xaf, 0xc7, 0x64, 0x1c, 0x6c, 0x0d, 0x76, 0xbd, 0x88, 0x6a, 0xa6, 0xd4, + 0xde, 0xa1, 0x97, 0xf1, 0x9c, 0x0b, 0x3f, 0x94, 0x51, 0x50, 0x99, 0x7e, 0x41, 0x38, 0xae, 0xeb, + 0xef, 0xec, 0x1e, 0xe2, 0xab, 0x1b, 0x76, 0x55, 0x84, 0x76, 0x2e, 0xb4, 0xf4, 0xdb, 0x0b, 0xfd, + 0x2a, 0x72, 0x50, 0xa3, 0xfc, 0xf6, 0x7f, 0x95, 0x5b, 0x3d, 0xa1, 0xf4, 0xc1, 0xef, 0x2e, 0xbe, + 0x68, 0xa4, 0x93, 0xaf, 0x08, 0x6f, 0x87, 0x7d, 0x49, 0xbf, 0x51, 0x5e, 0xd3, 0xa6, 0xc4, 0x83, + 0x36, 0x25, 0x56, 0x4d, 0xfa, 0xe4, 0xc3, 0xf7, 0x5f, 0x9f, 0xba, 0x43, 0xf2, 0x88, 0x35, 0x2d, + 0xbd, 0xdb, 0x36, 0xc5, 0xde, 0xbb, 0xd3, 0x99, 0x0b, 0xc1, 0x2a, 0x04, 0x2e, 0x44, 0x3e, 0x23, + 0xdc, 0xdb, 0xb8, 0x05, 0xd2, 0x42, 0x93, 0x5f, 0x99, 0x78, 0xbf, 0x55, 0x8d, 0x33, 0xd2, 0x37, + 0x46, 0xee, 0x91, 0xbb, 0xff, 0x36, 0x12, 0x68, 0x7e, 0xf8, 0xf8, 0xdb, 0x22, 0x41, 0xe7, 0x8b, + 0x04, 0xfd, 0x5c, 0x24, 0xe8, 0xe3, 0x32, 0xe9, 0x9c, 0x2f, 0x93, 0xce, 0x8f, 0x65, 0xd2, 0x79, + 0x41, 0xc5, 0x4c, 0xbf, 0x9a, 0x8f, 0xe9, 0x44, 0x1e, 0x7b, 0x3a, 0xfb, 0xb9, 0xaf, 0x5e, 0xbe, + 0x66, 0xef, 0x2a, 0xee, 0x23, 0x4b, 0xae, 0x4f, 0x0b, 0x50, 0xe3, 0x4b, 0xe6, 0x19, 0xef, 0xff, + 0x09, 0x00, 0x00, 0xff, 0xff, 0x9c, 0x49, 0x47, 0xea, 0x8e, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/feegrant/types/query.pb.gw.go b/x/fee_grant/types/query.pb.gw.go similarity index 100% rename from x/feegrant/types/query.pb.gw.go rename to x/fee_grant/types/query.pb.gw.go diff --git a/x/feegrant/types/tx.pb.go b/x/fee_grant/types/tx.pb.go similarity index 92% rename from x/feegrant/types/tx.pb.go rename to x/fee_grant/types/tx.pb.go index e28666009e67..ec51dc9f0336 100644 --- a/x/feegrant/types/tx.pb.go +++ b/x/fee_grant/types/tx.pb.go @@ -229,29 +229,29 @@ func init() { func init() { proto.RegisterFile("cosmos/feegrant/v1beta1/tx.proto", fileDescriptor_dd44ad7946dad783) } var fileDescriptor_dd44ad7946dad783 = []byte{ - // 345 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0x4d, 0x2f, 0x4a, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, - 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x87, 0xa8, - 0xd0, 0x83, 0xa9, 0xd0, 0x83, 0xaa, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xab, 0xd1, 0x07, - 0xb1, 0x20, 0xca, 0xa5, 0x24, 0xd3, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0xc1, 0xbc, 0xa4, 0xd2, - 0x34, 0xfd, 0xc4, 0xbc, 0x4a, 0x98, 0x14, 0xc4, 0xa4, 0x78, 0x88, 0x1e, 0xa8, 0xb1, 0x60, 0x8e, - 0xd2, 0x44, 0x46, 0x2e, 0x11, 0xdf, 0xe2, 0x74, 0x77, 0x90, 0x05, 0x6e, 0xa9, 0xa9, 0x8e, 0x39, - 0x39, 0xf9, 0xe5, 0x89, 0x79, 0xc9, 0xa9, 0x42, 0x12, 0x5c, 0xec, 0x60, 0x5b, 0x53, 0x8b, 0x24, - 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x60, 0x5c, 0x84, 0x4c, 0xaa, 0x04, 0x13, 0xb2, 0x4c, 0xaa, - 0x90, 0x2b, 0x17, 0x67, 0x22, 0xcc, 0x00, 0x09, 0x66, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x11, 0x3d, - 0x88, 0xb3, 0xf4, 0x60, 0xce, 0xd2, 0x73, 0xcc, 0xab, 0x74, 0x12, 0x3c, 0xb5, 0x45, 0x97, 0x17, - 0xd9, 0x3a, 0xcf, 0x20, 0x84, 0x4e, 0x25, 0x39, 0x2e, 0x19, 0x6c, 0x4e, 0x0a, 0x4a, 0x2d, 0x2e, - 0xc8, 0xcf, 0x2b, 0x4e, 0x55, 0xf2, 0xe6, 0x12, 0xf5, 0x2d, 0x4e, 0x0f, 0x4a, 0x2d, 0xcb, 0xcf, - 0x4e, 0xa5, 0xd4, 0xcd, 0x4a, 0xf2, 0x5c, 0xb2, 0x58, 0x0d, 0x83, 0xd9, 0x66, 0xf4, 0x8f, 0x91, - 0x8b, 0xd9, 0xb7, 0x38, 0x5d, 0xa8, 0x92, 0x4b, 0x10, 0x33, 0x94, 0x74, 0xf5, 0x70, 0x44, 0x92, - 0x1e, 0x36, 0x1f, 0x48, 0x99, 0x92, 0xa4, 0x1c, 0xe6, 0x04, 0xa1, 0x1a, 0x2e, 0x21, 0x2c, 0xbe, - 0xd5, 0xc3, 0x67, 0x18, 0xa6, 0x7a, 0x29, 0x33, 0xd2, 0xd4, 0xc3, 0x6c, 0x77, 0x72, 0x3f, 0xf1, - 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, - 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xdd, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, - 0xbd, 0xe4, 0xfc, 0x5c, 0x68, 0xaa, 0x82, 0x52, 0xba, 0xc5, 0x29, 0xd9, 0xfa, 0x15, 0x88, 0xb4, - 0x5d, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x4e, 0x03, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x7b, 0xbe, 0x24, 0x15, 0xfb, 0x02, 0x00, 0x00, + // 348 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x92, 0xcd, 0x4e, 0xc2, 0x40, + 0x14, 0x85, 0x19, 0x49, 0x34, 0x8c, 0x71, 0x41, 0x83, 0xb1, 0x36, 0x3a, 0x92, 0xae, 0xd8, 0x30, + 0x13, 0x30, 0xba, 0x87, 0xc4, 0xbf, 0x18, 0x36, 0x5d, 0xba, 0x21, 0x2d, 0x5e, 0x46, 0x03, 0xf4, + 0x12, 0xa6, 0x20, 0x4d, 0x7c, 0x08, 0x7d, 0x17, 0x1f, 0xc2, 0xb8, 0x62, 0xe9, 0xd2, 0xc0, 0x7b, + 0x18, 0xd3, 0x9f, 0x09, 0x24, 0x54, 0x13, 0xe2, 0xaa, 0xbd, 0xb9, 0xdf, 0x9c, 0x73, 0xa6, 0x3d, + 0xb4, 0xdc, 0x41, 0x35, 0x40, 0x25, 0xba, 0x00, 0x72, 0xe4, 0xfa, 0x81, 0x98, 0xd4, 0x3c, 0x08, + 0xdc, 0x9a, 0x08, 0xa6, 0x7c, 0x38, 0xc2, 0x00, 0x8d, 0x83, 0x84, 0xe0, 0x9a, 0xe0, 0x29, 0x61, + 0x95, 0x24, 0x4a, 0x8c, 0x19, 0x11, 0xbd, 0x25, 0xb8, 0x75, 0x28, 0x11, 0x65, 0x1f, 0x44, 0x3c, + 0x79, 0xe3, 0xae, 0x70, 0xfd, 0x50, 0xaf, 0x12, 0xa5, 0x76, 0x72, 0x26, 0x95, 0x8d, 0x07, 0xfb, + 0x95, 0xd0, 0x52, 0x4b, 0xc9, 0xab, 0xc8, 0xe0, 0x12, 0xa0, 0xd1, 0xef, 0xe3, 0x93, 0xeb, 0x77, + 0xc0, 0x30, 0xe9, 0x4e, 0xec, 0x0a, 0x23, 0x93, 0x94, 0x49, 0xa5, 0xe0, 0xe8, 0x71, 0xb9, 0x01, + 0x73, 0x6b, 0x75, 0x03, 0xc6, 0x05, 0x2d, 0xb8, 0x5a, 0xc0, 0xcc, 0x97, 0x49, 0x65, 0xb7, 0x5e, + 0xe2, 0x49, 0x2c, 0xae, 0x63, 0xf1, 0x86, 0x1f, 0x36, 0x8b, 0x1f, 0x6f, 0xd5, 0xbd, 0x55, 0xbb, + 0x1b, 0x67, 0x79, 0xd2, 0x66, 0xf4, 0x28, 0x2b, 0x92, 0x03, 0x6a, 0x88, 0xbe, 0x02, 0xfb, 0x96, + 0xee, 0xb7, 0x94, 0x74, 0x60, 0x82, 0x3d, 0xf8, 0x6f, 0x66, 0xfb, 0x84, 0x1e, 0x67, 0x8a, 0x69, + 0xb7, 0xfa, 0x37, 0xa1, 0xf9, 0x96, 0x92, 0x46, 0x48, 0x8b, 0xeb, 0x5f, 0xa9, 0xca, 0x7f, 0xf9, + 0x49, 0x3c, 0xeb, 0x06, 0xd6, 0xd9, 0x46, 0xb8, 0x8e, 0x60, 0x3c, 0x53, 0x23, 0xe3, 0xb6, 0xfc, + 0x2f, 0xb1, 0x75, 0xde, 0x3a, 0xdf, 0x8c, 0xd7, 0xee, 0xcd, 0xeb, 0xf7, 0x39, 0x23, 0xb3, 0x39, + 0x23, 0x5f, 0x73, 0x46, 0x5e, 0x16, 0x2c, 0x37, 0x5b, 0xb0, 0xdc, 0xe7, 0x82, 0xe5, 0xee, 0xb8, + 0x7c, 0x0c, 0x1e, 0xc6, 0x1e, 0xef, 0xe0, 0x20, 0x6d, 0x55, 0xfa, 0xa8, 0xaa, 0xfb, 0x9e, 0x98, + 0x46, 0xdd, 0x6e, 0x27, 0xe5, 0x0e, 0xc2, 0x21, 0x28, 0x6f, 0x3b, 0x2e, 0xc1, 0xe9, 0x4f, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xea, 0x33, 0x63, 0xb7, 0xfc, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. From cf547d9ce98889d1ead0244454c51d5a1333a9d3 Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 11 Jan 2021 22:31:40 +0530 Subject: [PATCH 145/184] review changes --- .../v1beta1/fee_grant.proto} | 2 +- .../v1beta1/genesis.proto | 4 +- .../v1beta1/query.proto | 12 +- .../{feegrant => fee_grant}/v1beta1/tx.proto | 2 +- x/fee_grant/ante/fee.go | 14 - x/fee_grant/client/rest/grpc_query_test.go | 14 +- x/fee_grant/keeper/msg_server.go | 8 + .../types/{feegrant.pb.go => fee_grant.pb.go} | 299 +++++++++--------- x/fee_grant/types/genesis.pb.go | 40 +-- x/fee_grant/types/query.pb.go | 94 +++--- x/fee_grant/types/query.pb.gw.go | 6 +- x/fee_grant/types/tx.pb.go | 80 ++--- 12 files changed, 284 insertions(+), 291 deletions(-) rename proto/cosmos/{feegrant/v1beta1/feegrant.proto => fee_grant/v1beta1/fee_grant.proto} (98%) rename proto/cosmos/{feegrant => fee_grant}/v1beta1/genesis.proto (78%) rename proto/cosmos/{feegrant => fee_grant}/v1beta1/query.proto (78%) rename proto/cosmos/{feegrant => fee_grant}/v1beta1/tx.proto (97%) rename x/fee_grant/types/{feegrant.pb.go => fee_grant.pb.go} (79%) diff --git a/proto/cosmos/feegrant/v1beta1/feegrant.proto b/proto/cosmos/fee_grant/v1beta1/fee_grant.proto similarity index 98% rename from proto/cosmos/feegrant/v1beta1/feegrant.proto rename to proto/cosmos/fee_grant/v1beta1/fee_grant.proto index 3423dd2ac12f..878a0fe9ae54 100644 --- a/proto/cosmos/feegrant/v1beta1/feegrant.proto +++ b/proto/cosmos/fee_grant/v1beta1/fee_grant.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package cosmos.feegrant.v1beta1; +package cosmos.fee_grant.v1beta1; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; diff --git a/proto/cosmos/feegrant/v1beta1/genesis.proto b/proto/cosmos/fee_grant/v1beta1/genesis.proto similarity index 78% rename from proto/cosmos/feegrant/v1beta1/genesis.proto rename to proto/cosmos/fee_grant/v1beta1/genesis.proto index 75321f44726e..6c0b5e3b91b5 100644 --- a/proto/cosmos/feegrant/v1beta1/genesis.proto +++ b/proto/cosmos/fee_grant/v1beta1/genesis.proto @@ -1,8 +1,8 @@ syntax = "proto3"; -package cosmos.feegrant.v1beta1; +package cosmos.fee_grant.v1beta1; import "gogoproto/gogo.proto"; -import "cosmos/feegrant/v1beta1/feegrant.proto"; +import "cosmos/fee_grant/v1beta1/fee_grant.proto"; option go_package = "github.com/cosmos/cosmos-sdk/x/fee_grant/types"; diff --git a/proto/cosmos/feegrant/v1beta1/query.proto b/proto/cosmos/fee_grant/v1beta1/query.proto similarity index 78% rename from proto/cosmos/feegrant/v1beta1/query.proto rename to proto/cosmos/fee_grant/v1beta1/query.proto index 3e18c5d97d86..d22002d6348b 100644 --- a/proto/cosmos/feegrant/v1beta1/query.proto +++ b/proto/cosmos/fee_grant/v1beta1/query.proto @@ -1,8 +1,8 @@ syntax = "proto3"; -package cosmos.feegrant.v1beta1; +package cosmos.fee_grant.v1beta1; import "gogoproto/gogo.proto"; -import "cosmos/feegrant/v1beta1/feegrant.proto"; +import "cosmos/fee_grant/v1beta1/fee_grant.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "google/api/annotations.proto"; @@ -12,12 +12,12 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/fee_grant/types"; service Query { // FeeAllowance returns fee granted to the grantee by the granter. rpc FeeAllowance(QueryFeeAllowanceRequest) returns (QueryFeeAllowanceResponse) { - option (google.api.http).get = "/cosmos/feegrant/v1beta1/granters/{granter}/grantees/{grantee}/grant"; + option (google.api.http).get = "/cosmos/feegrant/v1beta1/fee_allowance/{granter}/{grantee}"; } // FeeAllowances returns all the grants for address. rpc FeeAllowances(QueryFeeAllowancesRequest) returns (QueryFeeAllowancesResponse) { - option (google.api.http).get = "/cosmos/feegrant/v1beta1/grants/{grantee}"; + option (google.api.http).get = "/cosmos/feegrant/v1beta1/fee_allowances/{grantee}"; } } @@ -30,7 +30,7 @@ message QueryFeeAllowanceRequest { // QueryFeeAllowanceResponse is the response type for the Query/FeeAllowance RPC method. message QueryFeeAllowanceResponse { // fee_allowance is a fee_allowance granted for grantee by granter. - cosmos.feegrant.v1beta1.FeeAllowanceGrant fee_allowance = 1; + cosmos.fee_grant.v1beta1.FeeAllowanceGrant fee_allowance = 1; } // QueryFeeAllowancesRequest is the request type for the Query/FeeAllowances RPC method. @@ -44,7 +44,7 @@ message QueryFeeAllowancesRequest { // QueryFeeAllowancesResponse is the response type for the Query/FeeAllowances RPC method. message QueryFeeAllowancesResponse { // fee_allowance is a fee_allowance granted for grantee by granter. - repeated cosmos.feegrant.v1beta1.FeeAllowanceGrant fee_allowances = 1; + repeated cosmos.fee_grant.v1beta1.FeeAllowanceGrant fee_allowances = 1; // pagination defines an pagination for the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; diff --git a/proto/cosmos/feegrant/v1beta1/tx.proto b/proto/cosmos/fee_grant/v1beta1/tx.proto similarity index 97% rename from proto/cosmos/feegrant/v1beta1/tx.proto rename to proto/cosmos/fee_grant/v1beta1/tx.proto index d4583beb0e8d..6becf92434d3 100644 --- a/proto/cosmos/feegrant/v1beta1/tx.proto +++ b/proto/cosmos/fee_grant/v1beta1/tx.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package cosmos.feegrant.v1beta1; +package cosmos.fee_grant.v1beta1; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; diff --git a/x/fee_grant/ante/fee.go b/x/fee_grant/ante/fee.go index f3c9ef35a91d..405434406f0e 100644 --- a/x/fee_grant/ante/fee.go +++ b/x/fee_grant/ante/fee.go @@ -11,20 +11,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/fee_grant/types" ) -// var ( -// _ GrantedFeeTx = (*types.FeeGrantTx)(nil) // assert FeeGrantTx implements GrantedFeeTx -// ) - -// // GrantedFeeTx defines the interface to be implemented by Tx to use the GrantedFeeDecorator -// type GrantedFeeTx interface { -// sdk.Tx - -// GetGas() uint64 -// GetFee() sdk.Coins -// FeePayer() sdk.AccAddress -// MainSigner() sdk.AccAddress -// } - // DeductGrantedFeeDecorator deducts fees from the first signer of the tx // If the first signer does not have the funds to pay for the fees, return with InsufficientFunds error // Call next AnteHandler if fees successfully deducted diff --git a/x/fee_grant/client/rest/grpc_query_test.go b/x/fee_grant/client/rest/grpc_query_test.go index ef6314d67e88..a573bcdf21e7 100644 --- a/x/fee_grant/client/rest/grpc_query_test.go +++ b/x/fee_grant/client/rest/grpc_query_test.go @@ -73,7 +73,7 @@ func (s *IntegrationTestSuite) TestQueryFeeAllowence() { }{ { "fail: invalid granter", - fmt.Sprintf("%s/cosmos/feegrant/v1beta1/granters/%s/grantees/%s/grant", baseURL, "invalid_granter", s.grantee.String()), + fmt.Sprintf("%s/cosmos/feegrant/v1beta1/fee_allowance/%s/%s", baseURL, "invalid_granter", s.grantee.String()), true, "decoding bech32 failed: invalid index of 1: invalid request", func() {}, @@ -81,7 +81,7 @@ func (s *IntegrationTestSuite) TestQueryFeeAllowence() { }, { "fail: invalid grantee", - fmt.Sprintf("%s/cosmos/feegrant/v1beta1/granters/%s/grantees/%s/grant", baseURL, val.Address.String(), "invalid_grantee"), + fmt.Sprintf("%s/cosmos/feegrant/v1beta1/fee_allowance/%s/%s", baseURL, val.Address.String(), "invalid_grantee"), true, "decoding bech32 failed: invalid index of 1: invalid request", func() {}, @@ -89,7 +89,7 @@ func (s *IntegrationTestSuite) TestQueryFeeAllowence() { }, { "fail: no grants", - fmt.Sprintf("%s/cosmos/feegrant/v1beta1/granters/%s/grantees/%s/grant", baseURL, val.Address.String(), s.grantee.String()), + fmt.Sprintf("%s/cosmos/feegrant/v1beta1/fee_allowance/%s/%s", baseURL, val.Address.String(), s.grantee.String()), true, "no fee allowance found", func() {}, @@ -97,7 +97,7 @@ func (s *IntegrationTestSuite) TestQueryFeeAllowence() { }, { "valid query: expect single grant", - fmt.Sprintf("%s/cosmos/feegrant/v1beta1/granters/%s/grantees/%s/grant", baseURL, val.Address.String(), s.grantee.String()), + fmt.Sprintf("%s/cosmos/feegrant/v1beta1/fee_allowance/%s/%s", baseURL, val.Address.String(), s.grantee.String()), false, "", func() { @@ -138,7 +138,7 @@ func (s *IntegrationTestSuite) TestQueryGranteeAllowences() { }{ { "fail: invalid grantee", - fmt.Sprintf("%s/cosmos/feegrant/v1beta1/grants/%s", baseURL, "invalid_grantee"), + fmt.Sprintf("%s/cosmos/feegrant/v1beta1/fee_allowances/%s", baseURL, "invalid_grantee"), true, "decoding bech32 failed: invalid index of 1: invalid request", func() {}, @@ -146,7 +146,7 @@ func (s *IntegrationTestSuite) TestQueryGranteeAllowences() { }, { "success: no grants", - fmt.Sprintf("%s/cosmos/feegrant/v1beta1/grants/%s?pagination.offset=1", baseURL, s.grantee.String()), + fmt.Sprintf("%s/cosmos/feegrant/v1beta1/fee_allowances/%s?pagination.offset=1", baseURL, s.grantee.String()), false, "", func() {}, @@ -156,7 +156,7 @@ func (s *IntegrationTestSuite) TestQueryGranteeAllowences() { }, { "valid query: expect single grant", - fmt.Sprintf("%s/cosmos/feegrant/v1beta1/grants/%s", baseURL, s.grantee.String()), + fmt.Sprintf("%s/cosmos/feegrant/v1beta1/fee_allowances/%s", baseURL, s.grantee.String()), false, "", func() { diff --git a/x/fee_grant/keeper/msg_server.go b/x/fee_grant/keeper/msg_server.go index db819bf820d2..6c89a32e74c8 100644 --- a/x/fee_grant/keeper/msg_server.go +++ b/x/fee_grant/keeper/msg_server.go @@ -4,6 +4,8 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "github.com/cosmos/cosmos-sdk/x/fee_grant/types" ) @@ -35,6 +37,12 @@ func (k msgServer) GrantFeeAllowance(goCtx context.Context, msg *types.MsgGrantF return nil, err } + // Checking for duplicate entry + f := k.Keeper.GetFeeAllowance(ctx, granter, grantee) + if f != nil { + return nil, status.Errorf(codes.AlreadyExists, "grant already exist") + } + k.Keeper.GrantFeeAllowance(ctx, granter, grantee, msg.GetFeeAllowanceI()) return &types.MsgGrantFeeAllowanceResponse{}, nil diff --git a/x/fee_grant/types/feegrant.pb.go b/x/fee_grant/types/fee_grant.pb.go similarity index 79% rename from x/fee_grant/types/feegrant.pb.go rename to x/fee_grant/types/fee_grant.pb.go index 2158d637a65b..093d9acb54e8 100644 --- a/x/fee_grant/types/feegrant.pb.go +++ b/x/fee_grant/types/fee_grant.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmos/feegrant/v1beta1/feegrant.proto +// source: cosmos/fee_grant/v1beta1/fee_grant.proto package types @@ -42,7 +42,7 @@ func (m *BasicFeeAllowance) Reset() { *m = BasicFeeAllowance{} } func (m *BasicFeeAllowance) String() string { return proto.CompactTextString(m) } func (*BasicFeeAllowance) ProtoMessage() {} func (*BasicFeeAllowance) Descriptor() ([]byte, []int) { - return fileDescriptor_7279582900c30aea, []int{0} + return fileDescriptor_5dd8ff02de9d10f0, []int{0} } func (m *BasicFeeAllowance) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -99,7 +99,7 @@ func (m *PeriodicFeeAllowance) Reset() { *m = PeriodicFeeAllowance{} } func (m *PeriodicFeeAllowance) String() string { return proto.CompactTextString(m) } func (*PeriodicFeeAllowance) ProtoMessage() {} func (*PeriodicFeeAllowance) Descriptor() ([]byte, []int) { - return fileDescriptor_7279582900c30aea, []int{1} + return fileDescriptor_5dd8ff02de9d10f0, []int{1} } func (m *PeriodicFeeAllowance) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -174,7 +174,7 @@ func (m *Duration) Reset() { *m = Duration{} } func (m *Duration) String() string { return proto.CompactTextString(m) } func (*Duration) ProtoMessage() {} func (*Duration) Descriptor() ([]byte, []int) { - return fileDescriptor_7279582900c30aea, []int{2} + return fileDescriptor_5dd8ff02de9d10f0, []int{2} } func (m *Duration) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -228,7 +228,7 @@ func (m *ExpiresAt) Reset() { *m = ExpiresAt{} } func (m *ExpiresAt) String() string { return proto.CompactTextString(m) } func (*ExpiresAt) ProtoMessage() {} func (*ExpiresAt) Descriptor() ([]byte, []int) { - return fileDescriptor_7279582900c30aea, []int{3} + return fileDescriptor_5dd8ff02de9d10f0, []int{3} } func (m *ExpiresAt) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -282,7 +282,7 @@ func (m *FeeAllowanceGrant) Reset() { *m = FeeAllowanceGrant{} } func (m *FeeAllowanceGrant) String() string { return proto.CompactTextString(m) } func (*FeeAllowanceGrant) ProtoMessage() {} func (*FeeAllowanceGrant) Descriptor() ([]byte, []int) { - return fileDescriptor_7279582900c30aea, []int{4} + return fileDescriptor_5dd8ff02de9d10f0, []int{4} } func (m *FeeAllowanceGrant) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -333,56 +333,55 @@ func (m *FeeAllowanceGrant) GetAllowance() *types1.Any { } func init() { - proto.RegisterType((*BasicFeeAllowance)(nil), "cosmos.feegrant.v1beta1.BasicFeeAllowance") - proto.RegisterType((*PeriodicFeeAllowance)(nil), "cosmos.feegrant.v1beta1.PeriodicFeeAllowance") - proto.RegisterType((*Duration)(nil), "cosmos.feegrant.v1beta1.Duration") - proto.RegisterType((*ExpiresAt)(nil), "cosmos.feegrant.v1beta1.ExpiresAt") - proto.RegisterType((*FeeAllowanceGrant)(nil), "cosmos.feegrant.v1beta1.FeeAllowanceGrant") + proto.RegisterType((*BasicFeeAllowance)(nil), "cosmos.fee_grant.v1beta1.BasicFeeAllowance") + proto.RegisterType((*PeriodicFeeAllowance)(nil), "cosmos.fee_grant.v1beta1.PeriodicFeeAllowance") + proto.RegisterType((*Duration)(nil), "cosmos.fee_grant.v1beta1.Duration") + proto.RegisterType((*ExpiresAt)(nil), "cosmos.fee_grant.v1beta1.ExpiresAt") + proto.RegisterType((*FeeAllowanceGrant)(nil), "cosmos.fee_grant.v1beta1.FeeAllowanceGrant") } func init() { - proto.RegisterFile("cosmos/feegrant/v1beta1/feegrant.proto", fileDescriptor_7279582900c30aea) + proto.RegisterFile("cosmos/fee_grant/v1beta1/fee_grant.proto", fileDescriptor_5dd8ff02de9d10f0) } -var fileDescriptor_7279582900c30aea = []byte{ - // 579 bytes of a gzipped FileDescriptorProto +var fileDescriptor_5dd8ff02de9d10f0 = []byte{ + // 576 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x6e, 0xd3, 0x30, - 0x1c, 0x6f, 0xe8, 0x07, 0xab, 0x0b, 0x88, 0x5a, 0x15, 0x64, 0x3d, 0xa4, 0xa3, 0x07, 0x54, 0x21, - 0xcd, 0x61, 0xe3, 0x82, 0x76, 0x41, 0xcd, 0xd8, 0x18, 0x82, 0x03, 0x0a, 0x9c, 0x10, 0xa8, 0x72, - 0x52, 0x2f, 0xb5, 0x96, 0xc6, 0x51, 0xec, 0xc2, 0xfa, 0x12, 0x68, 0x47, 0x9e, 0x81, 0x33, 0x0f, - 0x31, 0x71, 0x9a, 0x38, 0x71, 0xda, 0x50, 0xfb, 0x04, 0xbc, 0x01, 0xf2, 0x47, 0xda, 0xaa, 0xa3, - 0x08, 0xa4, 0x9d, 0x12, 0xfb, 0xff, 0xff, 0x7d, 0xfc, 0x7f, 0x8e, 0x03, 0xee, 0x87, 0x8c, 0x0f, - 0x19, 0x77, 0x0f, 0x09, 0x89, 0x32, 0x9c, 0x08, 0xf7, 0xc3, 0x56, 0x40, 0x04, 0xde, 0x9a, 0x6d, - 0xa0, 0x34, 0x63, 0x82, 0xc1, 0xbb, 0xba, 0x0f, 0xcd, 0xb6, 0x4d, 0x5f, 0xb3, 0x11, 0xb1, 0x88, - 0xa9, 0x1e, 0x57, 0xbe, 0xe9, 0xf6, 0xe6, 0x7a, 0xc4, 0x58, 0x14, 0x13, 0x57, 0xad, 0x82, 0xd1, - 0xa1, 0x8b, 0x93, 0x71, 0x5e, 0xd2, 0x4c, 0x3d, 0x8d, 0x31, 0xb4, 0xba, 0xe4, 0x18, 0x33, 0x01, - 0xe6, 0x64, 0x66, 0x24, 0x64, 0x34, 0x31, 0xf5, 0xd6, 0x32, 0xab, 0xa0, 0x43, 0xc2, 0x05, 0x1e, - 0xa6, 0xba, 0xa1, 0x7d, 0x6e, 0x81, 0xba, 0x87, 0x39, 0x0d, 0xf7, 0x09, 0xe9, 0xc6, 0x31, 0xfb, + 0x1c, 0x6f, 0xe8, 0x07, 0xab, 0x0b, 0x88, 0x5a, 0x15, 0xca, 0x7a, 0x48, 0xa7, 0x72, 0xa9, 0x84, + 0xe6, 0xb0, 0x71, 0x41, 0x3b, 0xd1, 0x8c, 0x31, 0x26, 0xed, 0x80, 0x02, 0x27, 0x04, 0xaa, 0x9c, + 0xd4, 0x4b, 0xad, 0xa5, 0x71, 0x14, 0xbb, 0xb0, 0xbe, 0x04, 0xda, 0x91, 0x67, 0xe0, 0xcc, 0x43, + 0x4c, 0x9c, 0x26, 0x4e, 0x9c, 0x28, 0x6a, 0x5f, 0x81, 0x07, 0x40, 0xfe, 0x48, 0x5b, 0x75, 0x14, + 0x31, 0x69, 0xa7, 0xc6, 0xfe, 0xff, 0x7f, 0x1f, 0xff, 0x9f, 0xed, 0x82, 0x4e, 0xc8, 0xf8, 0x90, + 0x71, 0xf7, 0x84, 0x90, 0x5e, 0x94, 0xe1, 0x44, 0xb8, 0x1f, 0x76, 0x02, 0x22, 0xf0, 0xce, 0x62, + 0x07, 0xa5, 0x19, 0x13, 0x0c, 0xda, 0xba, 0x13, 0x2d, 0xf6, 0x4d, 0x67, 0xb3, 0x11, 0xb1, 0x88, + 0xa9, 0x26, 0x57, 0x7e, 0xe9, 0xfe, 0xe6, 0x66, 0xc4, 0x58, 0x14, 0x13, 0x57, 0xad, 0x82, 0xd1, + 0x89, 0x8b, 0x93, 0x71, 0x5e, 0xd2, 0x54, 0x3d, 0x8d, 0x31, 0xbc, 0xba, 0xe4, 0x18, 0x3f, 0x01, + 0xe6, 0x64, 0x6e, 0x25, 0x64, 0x34, 0x31, 0xf5, 0xd6, 0x2a, 0xab, 0xa0, 0x43, 0xc2, 0x05, 0x1e, + 0xa6, 0xba, 0xa1, 0x3d, 0xb1, 0x40, 0xdd, 0xc3, 0x9c, 0x86, 0x2f, 0x08, 0xe9, 0xc6, 0x31, 0xfb, 0x88, 0x93, 0x90, 0xc0, 0x18, 0xd4, 0x78, 0x4a, 0x92, 0x7e, 0x2f, 0xa6, 0x43, 0x2a, 0x6c, 0x6b, - 0xa3, 0xd8, 0xa9, 0x6d, 0xaf, 0x23, 0x23, 0x2d, 0xc5, 0xf2, 0x69, 0xd0, 0x2e, 0xa3, 0x89, 0xf7, - 0xf0, 0xf4, 0xbc, 0x55, 0xf8, 0x72, 0xd1, 0xea, 0x44, 0x54, 0x0c, 0x46, 0x01, 0x0a, 0xd9, 0xd0, - 0xf8, 0x34, 0x8f, 0x4d, 0xde, 0x3f, 0x72, 0xc5, 0x38, 0x25, 0x5c, 0x01, 0xb8, 0x0f, 0x14, 0xff, - 0x4b, 0x49, 0x0f, 0x0f, 0x00, 0x20, 0xc7, 0x29, 0xcd, 0xb0, 0xa0, 0x2c, 0xb1, 0xaf, 0x6d, 0x58, - 0x9d, 0xda, 0x76, 0x1b, 0xad, 0x88, 0x0f, 0xed, 0xc9, 0x56, 0xc2, 0xbb, 0xc2, 0x2b, 0x49, 0x55, - 0x7f, 0x01, 0xbb, 0x53, 0xff, 0xfe, 0x75, 0xf3, 0xe6, 0xe2, 0x24, 0xcf, 0xdb, 0xbf, 0x8a, 0xa0, - 0xf1, 0x8a, 0x64, 0x94, 0xf5, 0x97, 0x66, 0xdc, 0x07, 0xe5, 0x40, 0x0e, 0x6e, 0x5b, 0x4a, 0xf0, - 0xc1, 0x4a, 0xc1, 0x4b, 0xf1, 0x18, 0x61, 0x0d, 0x87, 0x4f, 0x40, 0x25, 0x55, 0xfc, 0xc6, 0xf9, - 0xbd, 0x95, 0x44, 0x4f, 0x47, 0xda, 0xa6, 0xc1, 0x1b, 0x18, 0x1c, 0x03, 0xa8, 0xdf, 0x7a, 0x8b, - 0x99, 0x17, 0xaf, 0x3e, 0xf3, 0xdb, 0x5a, 0xe6, 0xf5, 0x3c, 0xf9, 0x11, 0x30, 0x7b, 0xbd, 0x10, - 0x27, 0x5a, 0xde, 0x2e, 0x5d, 0xbd, 0xf0, 0x2d, 0x2d, 0xb2, 0x8b, 0x13, 0xa5, 0x0d, 0x5f, 0x80, - 0x1b, 0x46, 0x36, 0x23, 0x9c, 0x08, 0xbb, 0xfc, 0x9f, 0x47, 0x5e, 0xd3, 0x68, 0x5f, 0x82, 0xff, - 0x74, 0xe6, 0xef, 0xc0, 0x5a, 0x9e, 0x35, 0xdc, 0x01, 0xe5, 0x30, 0x66, 0xe1, 0x91, 0x39, 0xe6, - 0x26, 0xd2, 0x37, 0x02, 0xe5, 0x37, 0x02, 0xbd, 0xc9, 0x6f, 0x84, 0xb7, 0x26, 0xc9, 0x3f, 0x5f, - 0xb4, 0x2c, 0x5f, 0x43, 0x60, 0x03, 0x94, 0x03, 0x85, 0x95, 0x27, 0x5b, 0xf4, 0xf5, 0xa2, 0xfd, - 0x1e, 0x54, 0x67, 0x86, 0xe0, 0x63, 0x50, 0x92, 0x57, 0xea, 0x5f, 0xd9, 0x4f, 0x24, 0xbb, 0x42, - 0xc0, 0x3b, 0xa0, 0x32, 0x20, 0x34, 0x1a, 0x08, 0xc3, 0x6e, 0x56, 0xed, 0x4f, 0x16, 0xa8, 0x2f, - 0x8e, 0xf3, 0x4c, 0x46, 0x01, 0x6d, 0x70, 0x5d, 0x65, 0x42, 0x32, 0x25, 0x55, 0xf5, 0xf3, 0xe5, - 0xbc, 0x42, 0x14, 0xd1, 0xac, 0x42, 0xe0, 0x1e, 0xa8, 0xe2, 0x9c, 0xc5, 0x2e, 0x2a, 0x83, 0x8d, - 0x4b, 0x06, 0xbb, 0xc9, 0xd8, 0xab, 0x7f, 0x5b, 0x8e, 0xd0, 0x9f, 0x23, 0xbd, 0x83, 0xd3, 0x89, - 0x63, 0x9d, 0x4d, 0x1c, 0xeb, 0xe7, 0xc4, 0xb1, 0x4e, 0xa6, 0x4e, 0xe1, 0x6c, 0xea, 0x14, 0x7e, - 0x4c, 0x9d, 0xc2, 0x5b, 0xf4, 0xd7, 0x2f, 0xe0, 0x58, 0xfe, 0x11, 0x7b, 0xfa, 0x1f, 0xa9, 0xbe, - 0x86, 0xa0, 0xa2, 0x54, 0x1f, 0xfd, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x60, 0x04, 0xee, 0x43, - 0x05, 0x00, 0x00, + 0xab, 0xd8, 0xa9, 0xed, 0x6e, 0x22, 0x23, 0x2d, 0xc5, 0xf2, 0x69, 0xd0, 0x3e, 0xa3, 0x89, 0xf7, + 0xf8, 0xe2, 0x67, 0xab, 0xf0, 0x65, 0xd2, 0xea, 0x44, 0x54, 0x0c, 0x46, 0x01, 0x0a, 0xd9, 0xd0, + 0xf8, 0x34, 0x3f, 0xdb, 0xbc, 0x7f, 0xea, 0x8a, 0x71, 0x4a, 0xb8, 0x02, 0x70, 0x1f, 0x28, 0xfe, + 0x63, 0x49, 0x0f, 0x8f, 0x00, 0x20, 0x67, 0x29, 0xcd, 0xb0, 0xa0, 0x2c, 0xb1, 0x6f, 0x6d, 0x59, + 0x9d, 0xda, 0xee, 0x43, 0xb4, 0x2e, 0x3f, 0x74, 0x20, 0x7b, 0x09, 0xef, 0x0a, 0xaf, 0x24, 0x65, + 0xfd, 0x25, 0xf0, 0x5e, 0xfd, 0xfb, 0xd7, 0xed, 0xbb, 0xcb, 0xa3, 0x1c, 0xb5, 0x7f, 0x17, 0x41, + 0xe3, 0x15, 0xc9, 0x28, 0xeb, 0xaf, 0x0c, 0x79, 0x08, 0xca, 0x81, 0x9c, 0xdc, 0xb6, 0x94, 0xe2, + 0xa3, 0xf5, 0x8a, 0x57, 0x02, 0x32, 0xca, 0x1a, 0x0f, 0x9f, 0x81, 0x4a, 0xaa, 0x04, 0x8c, 0xf7, + 0xf6, 0x7a, 0xa6, 0xe7, 0x23, 0x6d, 0xd4, 0x10, 0x18, 0x1c, 0x1c, 0x03, 0xa8, 0xbf, 0x7a, 0xcb, + 0xb1, 0x17, 0x6f, 0x3e, 0xf6, 0xfb, 0x5a, 0xe6, 0xf5, 0x22, 0xfc, 0x11, 0x30, 0x7b, 0xbd, 0x10, + 0x27, 0x5a, 0xde, 0x2e, 0xdd, 0xbc, 0xf0, 0x3d, 0x2d, 0xb2, 0x8f, 0x13, 0xa5, 0x0d, 0x8f, 0xc1, + 0x1d, 0x23, 0x9b, 0x11, 0x4e, 0x84, 0x5d, 0xbe, 0xee, 0xa9, 0xd7, 0x34, 0xdc, 0x97, 0xe8, 0xbf, + 0x1d, 0xfb, 0x3b, 0xb0, 0x91, 0x87, 0x0d, 0xf7, 0x40, 0x39, 0x8c, 0x59, 0x78, 0x6a, 0x4e, 0xba, + 0x89, 0xf4, 0xab, 0x40, 0xf9, 0xab, 0x40, 0x6f, 0xf2, 0x57, 0xe1, 0x6d, 0x48, 0xf2, 0xcf, 0x93, + 0x96, 0xe5, 0x6b, 0x08, 0x6c, 0x80, 0x72, 0xa0, 0xb0, 0xf2, 0x6c, 0x8b, 0xbe, 0x5e, 0xb4, 0xdf, + 0x83, 0xea, 0xdc, 0x10, 0x7c, 0x0a, 0x4a, 0xf2, 0x59, 0xfd, 0x2f, 0xfb, 0xb9, 0x64, 0x57, 0x08, + 0xf8, 0x00, 0x54, 0x06, 0x84, 0x46, 0x03, 0x61, 0xd8, 0xcd, 0xaa, 0xfd, 0xc9, 0x02, 0xf5, 0xe5, + 0x71, 0x0e, 0x65, 0x14, 0xd0, 0x06, 0xb7, 0x55, 0x26, 0x24, 0x53, 0x52, 0x55, 0x3f, 0x5f, 0x2e, + 0x2a, 0x44, 0x11, 0xcd, 0x2b, 0x04, 0x1e, 0x80, 0x2a, 0xce, 0x59, 0xec, 0xa2, 0x32, 0xd8, 0xb8, + 0x62, 0xb0, 0x9b, 0x8c, 0xbd, 0xfa, 0xb7, 0xd5, 0x08, 0xfd, 0x05, 0xd2, 0x7b, 0x79, 0x31, 0x75, + 0xac, 0xcb, 0xa9, 0x63, 0xfd, 0x9a, 0x3a, 0xd6, 0xf9, 0xcc, 0x29, 0x5c, 0xce, 0x9c, 0xc2, 0x8f, + 0x99, 0x53, 0x78, 0x8b, 0xfe, 0x79, 0x05, 0xce, 0x96, 0xfe, 0x29, 0xd5, 0x75, 0x08, 0x2a, 0x4a, + 0xf5, 0xc9, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x93, 0x69, 0x7d, 0x9a, 0x4a, 0x05, 0x00, 0x00, } func (m *BasicFeeAllowance) Marshal() (dAtA []byte, err error) { @@ -411,7 +410,7 @@ func (m *BasicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintFeegrant(dAtA, i, uint64(size)) + i = encodeVarintFeeGrant(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x12 @@ -423,7 +422,7 @@ func (m *BasicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintFeegrant(dAtA, i, uint64(size)) + i = encodeVarintFeeGrant(dAtA, i, uint64(size)) } i-- dAtA[i] = 0xa @@ -458,7 +457,7 @@ func (m *PeriodicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintFeegrant(dAtA, i, uint64(size)) + i = encodeVarintFeeGrant(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x2a @@ -470,7 +469,7 @@ func (m *PeriodicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintFeegrant(dAtA, i, uint64(size)) + i = encodeVarintFeeGrant(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x22 @@ -484,7 +483,7 @@ func (m *PeriodicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintFeegrant(dAtA, i, uint64(size)) + i = encodeVarintFeeGrant(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x1a @@ -496,7 +495,7 @@ func (m *PeriodicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintFeegrant(dAtA, i, uint64(size)) + i = encodeVarintFeeGrant(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x12 @@ -506,7 +505,7 @@ func (m *PeriodicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintFeegrant(dAtA, i, uint64(size)) + i = encodeVarintFeeGrant(dAtA, i, uint64(size)) } i-- dAtA[i] = 0xa @@ -534,7 +533,7 @@ func (m *Duration) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if m.Block != 0 { - i = encodeVarintFeegrant(dAtA, i, uint64(m.Block)) + i = encodeVarintFeeGrant(dAtA, i, uint64(m.Block)) i-- dAtA[i] = 0x10 } @@ -543,7 +542,7 @@ func (m *Duration) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err5 } i -= n5 - i = encodeVarintFeegrant(dAtA, i, uint64(n5)) + i = encodeVarintFeeGrant(dAtA, i, uint64(n5)) i-- dAtA[i] = 0xa return len(dAtA) - i, nil @@ -570,7 +569,7 @@ func (m *ExpiresAt) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if m.Height != 0 { - i = encodeVarintFeegrant(dAtA, i, uint64(m.Height)) + i = encodeVarintFeeGrant(dAtA, i, uint64(m.Height)) i-- dAtA[i] = 0x10 } @@ -579,7 +578,7 @@ func (m *ExpiresAt) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err6 } i -= n6 - i = encodeVarintFeegrant(dAtA, i, uint64(n6)) + i = encodeVarintFeeGrant(dAtA, i, uint64(n6)) i-- dAtA[i] = 0xa return len(dAtA) - i, nil @@ -612,7 +611,7 @@ func (m *FeeAllowanceGrant) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintFeegrant(dAtA, i, uint64(size)) + i = encodeVarintFeeGrant(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x1a @@ -620,22 +619,22 @@ func (m *FeeAllowanceGrant) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.Grantee) > 0 { i -= len(m.Grantee) copy(dAtA[i:], m.Grantee) - i = encodeVarintFeegrant(dAtA, i, uint64(len(m.Grantee))) + i = encodeVarintFeeGrant(dAtA, i, uint64(len(m.Grantee))) i-- dAtA[i] = 0x12 } if len(m.Granter) > 0 { i -= len(m.Granter) copy(dAtA[i:], m.Granter) - i = encodeVarintFeegrant(dAtA, i, uint64(len(m.Granter))) + i = encodeVarintFeeGrant(dAtA, i, uint64(len(m.Granter))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func encodeVarintFeegrant(dAtA []byte, offset int, v uint64) int { - offset -= sovFeegrant(v) +func encodeVarintFeeGrant(dAtA []byte, offset int, v uint64) int { + offset -= sovFeeGrant(v) base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -654,11 +653,11 @@ func (m *BasicFeeAllowance) Size() (n int) { if len(m.SpendLimit) > 0 { for _, e := range m.SpendLimit { l = e.Size() - n += 1 + l + sovFeegrant(uint64(l)) + n += 1 + l + sovFeeGrant(uint64(l)) } } l = m.Expiration.Size() - n += 1 + l + sovFeegrant(uint64(l)) + n += 1 + l + sovFeeGrant(uint64(l)) return n } @@ -669,23 +668,23 @@ func (m *PeriodicFeeAllowance) Size() (n int) { var l int _ = l l = m.Basic.Size() - n += 1 + l + sovFeegrant(uint64(l)) + n += 1 + l + sovFeeGrant(uint64(l)) l = m.Period.Size() - n += 1 + l + sovFeegrant(uint64(l)) + n += 1 + l + sovFeeGrant(uint64(l)) if len(m.PeriodSpendLimit) > 0 { for _, e := range m.PeriodSpendLimit { l = e.Size() - n += 1 + l + sovFeegrant(uint64(l)) + n += 1 + l + sovFeeGrant(uint64(l)) } } if len(m.PeriodCanSpend) > 0 { for _, e := range m.PeriodCanSpend { l = e.Size() - n += 1 + l + sovFeegrant(uint64(l)) + n += 1 + l + sovFeeGrant(uint64(l)) } } l = m.PeriodReset.Size() - n += 1 + l + sovFeegrant(uint64(l)) + n += 1 + l + sovFeeGrant(uint64(l)) return n } @@ -696,9 +695,9 @@ func (m *Duration) Size() (n int) { var l int _ = l l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.Clock) - n += 1 + l + sovFeegrant(uint64(l)) + n += 1 + l + sovFeeGrant(uint64(l)) if m.Block != 0 { - n += 1 + sovFeegrant(uint64(m.Block)) + n += 1 + sovFeeGrant(uint64(m.Block)) } return n } @@ -710,9 +709,9 @@ func (m *ExpiresAt) Size() (n int) { var l int _ = l l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Time) - n += 1 + l + sovFeegrant(uint64(l)) + n += 1 + l + sovFeeGrant(uint64(l)) if m.Height != 0 { - n += 1 + sovFeegrant(uint64(m.Height)) + n += 1 + sovFeeGrant(uint64(m.Height)) } return n } @@ -725,24 +724,24 @@ func (m *FeeAllowanceGrant) Size() (n int) { _ = l l = len(m.Granter) if l > 0 { - n += 1 + l + sovFeegrant(uint64(l)) + n += 1 + l + sovFeeGrant(uint64(l)) } l = len(m.Grantee) if l > 0 { - n += 1 + l + sovFeegrant(uint64(l)) + n += 1 + l + sovFeeGrant(uint64(l)) } if m.Allowance != nil { l = m.Allowance.Size() - n += 1 + l + sovFeegrant(uint64(l)) + n += 1 + l + sovFeeGrant(uint64(l)) } return n } -func sovFeegrant(x uint64) (n int) { +func sovFeeGrant(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } -func sozFeegrant(x uint64) (n int) { - return sovFeegrant(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func sozFeeGrant(x uint64) (n int) { + return sovFeeGrant(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } func (m *BasicFeeAllowance) Unmarshal(dAtA []byte) error { l := len(dAtA) @@ -752,7 +751,7 @@ func (m *BasicFeeAllowance) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeegrant + return ErrIntOverflowFeeGrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -780,7 +779,7 @@ func (m *BasicFeeAllowance) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeegrant + return ErrIntOverflowFeeGrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -793,11 +792,11 @@ func (m *BasicFeeAllowance) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -814,7 +813,7 @@ func (m *BasicFeeAllowance) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeegrant + return ErrIntOverflowFeeGrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -827,11 +826,11 @@ func (m *BasicFeeAllowance) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -842,15 +841,15 @@ func (m *BasicFeeAllowance) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipFeegrant(dAtA[iNdEx:]) + skippy, err := skipFeeGrant(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if (iNdEx + skippy) < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -872,7 +871,7 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeegrant + return ErrIntOverflowFeeGrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -900,7 +899,7 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeegrant + return ErrIntOverflowFeeGrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -913,11 +912,11 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -933,7 +932,7 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeegrant + return ErrIntOverflowFeeGrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -946,11 +945,11 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -966,7 +965,7 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeegrant + return ErrIntOverflowFeeGrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -979,11 +978,11 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -1000,7 +999,7 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeegrant + return ErrIntOverflowFeeGrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1013,11 +1012,11 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -1034,7 +1033,7 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeegrant + return ErrIntOverflowFeeGrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1047,11 +1046,11 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -1062,15 +1061,15 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipFeegrant(dAtA[iNdEx:]) + skippy, err := skipFeeGrant(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if (iNdEx + skippy) < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1092,7 +1091,7 @@ func (m *Duration) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeegrant + return ErrIntOverflowFeeGrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1120,7 +1119,7 @@ func (m *Duration) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeegrant + return ErrIntOverflowFeeGrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1133,11 +1132,11 @@ func (m *Duration) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -1153,7 +1152,7 @@ func (m *Duration) Unmarshal(dAtA []byte) error { m.Block = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeegrant + return ErrIntOverflowFeeGrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1167,15 +1166,15 @@ func (m *Duration) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipFeegrant(dAtA[iNdEx:]) + skippy, err := skipFeeGrant(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if (iNdEx + skippy) < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1197,7 +1196,7 @@ func (m *ExpiresAt) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeegrant + return ErrIntOverflowFeeGrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1225,7 +1224,7 @@ func (m *ExpiresAt) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeegrant + return ErrIntOverflowFeeGrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1238,11 +1237,11 @@ func (m *ExpiresAt) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -1258,7 +1257,7 @@ func (m *ExpiresAt) Unmarshal(dAtA []byte) error { m.Height = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeegrant + return ErrIntOverflowFeeGrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1272,15 +1271,15 @@ func (m *ExpiresAt) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipFeegrant(dAtA[iNdEx:]) + skippy, err := skipFeeGrant(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if (iNdEx + skippy) < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1302,7 +1301,7 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeegrant + return ErrIntOverflowFeeGrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1330,7 +1329,7 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeegrant + return ErrIntOverflowFeeGrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1344,11 +1343,11 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -1362,7 +1361,7 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeegrant + return ErrIntOverflowFeeGrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1376,11 +1375,11 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -1394,7 +1393,7 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeegrant + return ErrIntOverflowFeeGrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1407,11 +1406,11 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -1425,15 +1424,15 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipFeegrant(dAtA[iNdEx:]) + skippy, err := skipFeeGrant(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if (iNdEx + skippy) < 0 { - return ErrInvalidLengthFeegrant + return ErrInvalidLengthFeeGrant } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1447,7 +1446,7 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { } return nil } -func skipFeegrant(dAtA []byte) (n int, err error) { +func skipFeeGrant(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 depth := 0 @@ -1455,7 +1454,7 @@ func skipFeegrant(dAtA []byte) (n int, err error) { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowFeegrant + return 0, ErrIntOverflowFeeGrant } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -1472,7 +1471,7 @@ func skipFeegrant(dAtA []byte) (n int, err error) { case 0: for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowFeegrant + return 0, ErrIntOverflowFeeGrant } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -1488,7 +1487,7 @@ func skipFeegrant(dAtA []byte) (n int, err error) { var length int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowFeegrant + return 0, ErrIntOverflowFeeGrant } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -1501,14 +1500,14 @@ func skipFeegrant(dAtA []byte) (n int, err error) { } } if length < 0 { - return 0, ErrInvalidLengthFeegrant + return 0, ErrInvalidLengthFeeGrant } iNdEx += length case 3: depth++ case 4: if depth == 0 { - return 0, ErrUnexpectedEndOfGroupFeegrant + return 0, ErrUnexpectedEndOfGroupFeeGrant } depth-- case 5: @@ -1517,7 +1516,7 @@ func skipFeegrant(dAtA []byte) (n int, err error) { return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } if iNdEx < 0 { - return 0, ErrInvalidLengthFeegrant + return 0, ErrInvalidLengthFeeGrant } if depth == 0 { return iNdEx, nil @@ -1527,7 +1526,7 @@ func skipFeegrant(dAtA []byte) (n int, err error) { } var ( - ErrInvalidLengthFeegrant = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowFeegrant = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupFeegrant = fmt.Errorf("proto: unexpected end of group") + ErrInvalidLengthFeeGrant = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowFeeGrant = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupFeeGrant = fmt.Errorf("proto: unexpected end of group") ) diff --git a/x/fee_grant/types/genesis.pb.go b/x/fee_grant/types/genesis.pb.go index 0f44e3337880..00961b3bb9b8 100644 --- a/x/fee_grant/types/genesis.pb.go +++ b/x/fee_grant/types/genesis.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmos/feegrant/v1beta1/genesis.proto +// source: cosmos/fee_grant/v1beta1/genesis.proto package types @@ -32,7 +32,7 @@ func (m *GenesisState) Reset() { *m = GenesisState{} } func (m *GenesisState) String() string { return proto.CompactTextString(m) } func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_ac719d2d0954d1bf, []int{0} + return fileDescriptor_2ab54f02a586cbd9, []int{0} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -69,29 +69,29 @@ func (m *GenesisState) GetFeeAllowances() []FeeAllowanceGrant { } func init() { - proto.RegisterType((*GenesisState)(nil), "cosmos.feegrant.v1beta1.GenesisState") + proto.RegisterType((*GenesisState)(nil), "cosmos.fee_grant.v1beta1.GenesisState") } func init() { - proto.RegisterFile("cosmos/feegrant/v1beta1/genesis.proto", fileDescriptor_ac719d2d0954d1bf) + proto.RegisterFile("cosmos/fee_grant/v1beta1/genesis.proto", fileDescriptor_2ab54f02a586cbd9) } -var fileDescriptor_ac719d2d0954d1bf = []byte{ - // 224 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4d, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0x4d, 0x2f, 0x4a, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, - 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, - 0xc9, 0x17, 0x12, 0x87, 0x28, 0xd3, 0x83, 0x29, 0xd3, 0x83, 0x2a, 0x93, 0x12, 0x49, 0xcf, 0x4f, - 0xcf, 0x07, 0xab, 0xd1, 0x07, 0xb1, 0x20, 0xca, 0xa5, 0xd4, 0x70, 0x99, 0x0a, 0xd7, 0x0f, 0x56, - 0xa7, 0x94, 0xce, 0xc5, 0xe3, 0x0e, 0xb1, 0x27, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0x28, 0x9c, 0x8b, - 0x2f, 0x2d, 0x35, 0x35, 0x3e, 0x31, 0x27, 0x27, 0xbf, 0x3c, 0x31, 0x2f, 0x39, 0xb5, 0x58, 0x82, - 0x51, 0x81, 0x59, 0x83, 0xdb, 0x48, 0x4b, 0x0f, 0x87, 0xfd, 0x7a, 0x6e, 0xa9, 0xa9, 0x8e, 0x30, - 0xd5, 0xee, 0x20, 0x19, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0x78, 0xd3, 0x90, 0x24, 0x8a, - 0x9d, 0x3c, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, - 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x2f, 0x3d, 0xb3, - 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xea, 0x6a, 0x08, 0xa5, 0x5b, 0x9c, 0x92, - 0xad, 0x5f, 0x01, 0x72, 0x71, 0x3c, 0xc4, 0x0f, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, - 0x97, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xca, 0x6f, 0x0d, 0x36, 0x39, 0x01, 0x00, 0x00, +var fileDescriptor_2ab54f02a586cbd9 = []byte{ + // 220 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4b, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0x8d, 0x4f, 0x2f, 0x4a, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, + 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, + 0x2f, 0xc9, 0x17, 0x92, 0x80, 0xa8, 0xd3, 0x83, 0xab, 0xd3, 0x83, 0xaa, 0x93, 0x12, 0x49, 0xcf, + 0x4f, 0xcf, 0x07, 0x2b, 0xd2, 0x07, 0xb1, 0x20, 0xea, 0xa5, 0x34, 0x70, 0x9a, 0x8b, 0x30, 0x01, + 0xac, 0x52, 0x29, 0x83, 0x8b, 0xc7, 0x1d, 0x62, 0x55, 0x70, 0x49, 0x62, 0x49, 0xaa, 0x50, 0x04, + 0x17, 0x1f, 0x48, 0x49, 0x62, 0x4e, 0x4e, 0x7e, 0x79, 0x62, 0x5e, 0x72, 0x6a, 0xb1, 0x04, 0xa3, + 0x02, 0xb3, 0x06, 0xb7, 0x91, 0xb6, 0x1e, 0x2e, 0x27, 0xe8, 0xb9, 0xa5, 0xa6, 0x3a, 0xc2, 0x94, + 0xbb, 0x83, 0x64, 0x9c, 0x58, 0x4e, 0xdc, 0x93, 0x67, 0x08, 0xe2, 0x4d, 0x43, 0x92, 0x28, 0x76, + 0xf2, 0x38, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, + 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xbd, 0xf4, 0xcc, 0x92, + 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0xa8, 0xc3, 0x21, 0x94, 0x6e, 0x71, 0x4a, 0xb6, + 0x7e, 0x05, 0x92, 0x2f, 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x4e, 0x37, 0x06, 0x04, + 0x00, 0x00, 0xff, 0xff, 0x27, 0x5c, 0xbd, 0x8c, 0x3e, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/fee_grant/types/query.pb.go b/x/fee_grant/types/query.pb.go index d7dc2cfd6b60..dd30ff171bce 100644 --- a/x/fee_grant/types/query.pb.go +++ b/x/fee_grant/types/query.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmos/feegrant/v1beta1/query.proto +// source: cosmos/fee_grant/v1beta1/query.proto package types @@ -40,7 +40,7 @@ func (m *QueryFeeAllowanceRequest) Reset() { *m = QueryFeeAllowanceReque func (m *QueryFeeAllowanceRequest) String() string { return proto.CompactTextString(m) } func (*QueryFeeAllowanceRequest) ProtoMessage() {} func (*QueryFeeAllowanceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_59efc303945de53f, []int{0} + return fileDescriptor_2264e3bbfc7b20e4, []int{0} } func (m *QueryFeeAllowanceRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -93,7 +93,7 @@ func (m *QueryFeeAllowanceResponse) Reset() { *m = QueryFeeAllowanceResp func (m *QueryFeeAllowanceResponse) String() string { return proto.CompactTextString(m) } func (*QueryFeeAllowanceResponse) ProtoMessage() {} func (*QueryFeeAllowanceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_59efc303945de53f, []int{1} + return fileDescriptor_2264e3bbfc7b20e4, []int{1} } func (m *QueryFeeAllowanceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -140,7 +140,7 @@ func (m *QueryFeeAllowancesRequest) Reset() { *m = QueryFeeAllowancesReq func (m *QueryFeeAllowancesRequest) String() string { return proto.CompactTextString(m) } func (*QueryFeeAllowancesRequest) ProtoMessage() {} func (*QueryFeeAllowancesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_59efc303945de53f, []int{2} + return fileDescriptor_2264e3bbfc7b20e4, []int{2} } func (m *QueryFeeAllowancesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -195,7 +195,7 @@ func (m *QueryFeeAllowancesResponse) Reset() { *m = QueryFeeAllowancesRe func (m *QueryFeeAllowancesResponse) String() string { return proto.CompactTextString(m) } func (*QueryFeeAllowancesResponse) ProtoMessage() {} func (*QueryFeeAllowancesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_59efc303945de53f, []int{3} + return fileDescriptor_2264e3bbfc7b20e4, []int{3} } func (m *QueryFeeAllowancesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -239,47 +239,47 @@ func (m *QueryFeeAllowancesResponse) GetPagination() *query.PageResponse { } func init() { - proto.RegisterType((*QueryFeeAllowanceRequest)(nil), "cosmos.feegrant.v1beta1.QueryFeeAllowanceRequest") - proto.RegisterType((*QueryFeeAllowanceResponse)(nil), "cosmos.feegrant.v1beta1.QueryFeeAllowanceResponse") - proto.RegisterType((*QueryFeeAllowancesRequest)(nil), "cosmos.feegrant.v1beta1.QueryFeeAllowancesRequest") - proto.RegisterType((*QueryFeeAllowancesResponse)(nil), "cosmos.feegrant.v1beta1.QueryFeeAllowancesResponse") + proto.RegisterType((*QueryFeeAllowanceRequest)(nil), "cosmos.fee_grant.v1beta1.QueryFeeAllowanceRequest") + proto.RegisterType((*QueryFeeAllowanceResponse)(nil), "cosmos.fee_grant.v1beta1.QueryFeeAllowanceResponse") + proto.RegisterType((*QueryFeeAllowancesRequest)(nil), "cosmos.fee_grant.v1beta1.QueryFeeAllowancesRequest") + proto.RegisterType((*QueryFeeAllowancesResponse)(nil), "cosmos.fee_grant.v1beta1.QueryFeeAllowancesResponse") } func init() { - proto.RegisterFile("cosmos/feegrant/v1beta1/query.proto", fileDescriptor_59efc303945de53f) + proto.RegisterFile("cosmos/fee_grant/v1beta1/query.proto", fileDescriptor_2264e3bbfc7b20e4) } -var fileDescriptor_59efc303945de53f = []byte{ - // 461 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0xcd, 0x6e, 0x13, 0x31, - 0x10, 0x8e, 0x83, 0x00, 0xe1, 0x36, 0x1c, 0x2c, 0x24, 0x96, 0x15, 0x5a, 0x55, 0x8b, 0x54, 0xa0, - 0x08, 0x5b, 0x49, 0x9f, 0x00, 0x84, 0x52, 0x0e, 0x08, 0x68, 0x8e, 0x5c, 0x2a, 0x27, 0x4c, 0x4c, - 0xc4, 0x76, 0xbd, 0x5d, 0x3b, 0x40, 0x85, 0x7a, 0xe1, 0x09, 0x90, 0x78, 0x0c, 0x5e, 0x80, 0x3b, - 0x17, 0x8e, 0x95, 0xb8, 0x70, 0x44, 0x09, 0x6f, 0xc1, 0x05, 0xad, 0x7f, 0x12, 0x47, 0xec, 0x82, - 0xf6, 0xb4, 0xde, 0x99, 0x6f, 0xbe, 0xf9, 0xbe, 0xf1, 0x18, 0xdf, 0x9a, 0x48, 0x75, 0x2c, 0x15, - 0x9b, 0x02, 0x88, 0x92, 0xe7, 0x9a, 0xbd, 0xe9, 0x8f, 0x41, 0xf3, 0x3e, 0x3b, 0x99, 0x43, 0x79, - 0x4a, 0x8b, 0x52, 0x6a, 0x49, 0xae, 0x5b, 0x10, 0xf5, 0x20, 0xea, 0x40, 0xf1, 0x35, 0x21, 0x85, - 0x34, 0x18, 0x56, 0x9d, 0x2c, 0x3c, 0xde, 0x6d, 0xe2, 0x5c, 0xd5, 0x5b, 0xdc, 0x9e, 0xc3, 0x8d, - 0xb9, 0x02, 0xdb, 0x6f, 0x85, 0x2c, 0xb8, 0x98, 0xe5, 0x5c, 0xcf, 0x64, 0xee, 0xb0, 0x37, 0x85, - 0x94, 0x22, 0x03, 0xc6, 0x8b, 0x19, 0xe3, 0x79, 0x2e, 0xb5, 0x49, 0x2a, 0x9b, 0x4d, 0x9f, 0xe2, - 0xe8, 0xb0, 0xaa, 0x1f, 0x02, 0x3c, 0xc8, 0x32, 0xf9, 0x96, 0xe7, 0x13, 0x18, 0xc1, 0xc9, 0x1c, - 0x94, 0x26, 0x11, 0xbe, 0x6c, 0x9a, 0x42, 0x19, 0xa1, 0x1d, 0x74, 0xe7, 0xca, 0xc8, 0xff, 0xae, - 0x33, 0x10, 0x75, 0xc3, 0x0c, 0xa4, 0x19, 0xbe, 0x51, 0xc3, 0xa7, 0x0a, 0x99, 0x2b, 0x20, 0xcf, - 0x70, 0x6f, 0x0a, 0x70, 0xc4, 0x7d, 0xc2, 0xd0, 0x6e, 0x0d, 0xf6, 0x68, 0xc3, 0x94, 0x68, 0xc8, - 0x72, 0x50, 0x65, 0x46, 0xdb, 0xd3, 0x20, 0x94, 0x9e, 0xd5, 0x74, 0x53, 0x7f, 0xc9, 0x87, 0x4d, - 0xf9, 0x40, 0x86, 0x18, 0xaf, 0xc7, 0x64, 0x1c, 0x6c, 0x0d, 0x76, 0xbd, 0x88, 0x6a, 0xa6, 0xd4, - 0xde, 0xa1, 0x97, 0xf1, 0x9c, 0x0b, 0x3f, 0x94, 0x51, 0x50, 0x99, 0x7e, 0x41, 0x38, 0xae, 0xeb, - 0xef, 0xec, 0x1e, 0xe2, 0xab, 0x1b, 0x76, 0x55, 0x84, 0x76, 0x2e, 0xb4, 0xf4, 0xdb, 0x0b, 0xfd, - 0x2a, 0x72, 0x50, 0xa3, 0xfc, 0xf6, 0x7f, 0x95, 0x5b, 0x3d, 0xa1, 0xf4, 0xc1, 0xef, 0x2e, 0xbe, - 0x68, 0xa4, 0x93, 0xaf, 0x08, 0x6f, 0x87, 0x7d, 0x49, 0xbf, 0x51, 0x5e, 0xd3, 0xa6, 0xc4, 0x83, - 0x36, 0x25, 0x56, 0x4d, 0xfa, 0xe4, 0xc3, 0xf7, 0x5f, 0x9f, 0xba, 0x43, 0xf2, 0x88, 0x35, 0x2d, - 0xbd, 0xdb, 0x36, 0xc5, 0xde, 0xbb, 0xd3, 0x99, 0x0b, 0xc1, 0x2a, 0x04, 0x2e, 0x44, 0x3e, 0x23, - 0xdc, 0xdb, 0xb8, 0x05, 0xd2, 0x42, 0x93, 0x5f, 0x99, 0x78, 0xbf, 0x55, 0x8d, 0x33, 0xd2, 0x37, - 0x46, 0xee, 0x91, 0xbb, 0xff, 0x36, 0x12, 0x68, 0x7e, 0xf8, 0xf8, 0xdb, 0x22, 0x41, 0xe7, 0x8b, - 0x04, 0xfd, 0x5c, 0x24, 0xe8, 0xe3, 0x32, 0xe9, 0x9c, 0x2f, 0x93, 0xce, 0x8f, 0x65, 0xd2, 0x79, - 0x41, 0xc5, 0x4c, 0xbf, 0x9a, 0x8f, 0xe9, 0x44, 0x1e, 0x7b, 0x3a, 0xfb, 0xb9, 0xaf, 0x5e, 0xbe, - 0x66, 0xef, 0x2a, 0xee, 0x23, 0x4b, 0xae, 0x4f, 0x0b, 0x50, 0xe3, 0x4b, 0xe6, 0x19, 0xef, 0xff, - 0x09, 0x00, 0x00, 0xff, 0xff, 0x9c, 0x49, 0x47, 0xea, 0x8e, 0x04, 0x00, 0x00, +var fileDescriptor_2264e3bbfc7b20e4 = []byte{ + // 460 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x41, 0x8b, 0xd3, 0x40, + 0x14, 0xc7, 0x3b, 0x15, 0x15, 0x67, 0xb7, 0x1e, 0x06, 0x0f, 0x31, 0x48, 0x58, 0x82, 0xe8, 0xa2, + 0x38, 0x43, 0x5b, 0x2f, 0x8a, 0x17, 0xf7, 0xb0, 0xeb, 0x49, 0xd6, 0x1c, 0xbd, 0xc8, 0xb4, 0xbe, + 0x1d, 0x8b, 0x6d, 0x26, 0x9b, 0x99, 0xaa, 0x8b, 0xf4, 0xe2, 0x27, 0x10, 0xfc, 0x2c, 0x1e, 0xc4, + 0x2f, 0xe0, 0x71, 0xc1, 0x8b, 0x47, 0x69, 0xfd, 0x1a, 0x82, 0x64, 0x26, 0xd3, 0x4c, 0x69, 0x82, + 0x9b, 0x53, 0x26, 0x79, 0xff, 0xf7, 0xde, 0xef, 0xff, 0xf2, 0x12, 0x7c, 0x7b, 0x2c, 0xd5, 0x4c, + 0x2a, 0x76, 0x02, 0xf0, 0x4a, 0xe4, 0x3c, 0xd5, 0xec, 0x5d, 0x7f, 0x04, 0x9a, 0xf7, 0xd9, 0xe9, + 0x1c, 0xf2, 0x33, 0x9a, 0xe5, 0x52, 0x4b, 0x12, 0x58, 0x15, 0x5d, 0xab, 0x68, 0xa9, 0x0a, 0x6f, + 0x08, 0x29, 0xa4, 0x11, 0xb1, 0xe2, 0x64, 0xf5, 0xe1, 0x7e, 0x63, 0xd5, 0xaa, 0x82, 0x55, 0xde, + 0x2b, 0x95, 0x23, 0xae, 0xc0, 0xb6, 0x5c, 0x4b, 0x33, 0x2e, 0x26, 0x29, 0xd7, 0x13, 0x99, 0x96, + 0xda, 0x5b, 0x42, 0x4a, 0x31, 0x05, 0xc6, 0xb3, 0x09, 0xe3, 0x69, 0x2a, 0xb5, 0x09, 0x2a, 0x1b, + 0x8d, 0x9f, 0xe3, 0xe0, 0x45, 0x91, 0x7f, 0x08, 0xf0, 0x74, 0x3a, 0x95, 0xef, 0x79, 0x3a, 0x86, + 0x04, 0x4e, 0xe7, 0xa0, 0x34, 0x09, 0xf0, 0x55, 0xd3, 0x14, 0xf2, 0x00, 0xed, 0xa1, 0xfd, 0x6b, + 0x89, 0xbb, 0xad, 0x22, 0x10, 0x74, 0xfd, 0x08, 0xc4, 0x33, 0x7c, 0xb3, 0xa6, 0x9e, 0xca, 0x64, + 0xaa, 0x80, 0x1c, 0xe3, 0x5e, 0xe1, 0x84, 0xbb, 0x80, 0x29, 0xbb, 0x33, 0xb8, 0x4f, 0x9b, 0x06, + 0x45, 0xfd, 0x32, 0x47, 0x45, 0x24, 0xd9, 0x3d, 0xf1, 0x1e, 0xc5, 0x8b, 0x9a, 0x76, 0x6a, 0x8b, + 0x1f, 0x36, 0xf9, 0x81, 0x1c, 0x62, 0x5c, 0xcd, 0xc9, 0x58, 0xd8, 0x19, 0xdc, 0x71, 0x14, 0xc5, + 0x50, 0xa9, 0x7d, 0x8f, 0x0e, 0xe3, 0x98, 0x0b, 0x37, 0x95, 0xc4, 0xcb, 0x8c, 0xbf, 0x21, 0x1c, + 0xd6, 0xf5, 0x2f, 0xfd, 0x26, 0xf8, 0xfa, 0x86, 0x5f, 0x15, 0xa0, 0xbd, 0x4b, 0x6d, 0x0d, 0xf7, + 0x7c, 0xc3, 0x8a, 0x1c, 0xd5, 0xa0, 0xdf, 0xfd, 0x2f, 0xba, 0x05, 0xf2, 0xd9, 0x07, 0x7f, 0xbb, + 0xf8, 0xb2, 0x61, 0x27, 0xdf, 0x11, 0xde, 0xf5, 0xfb, 0x92, 0x41, 0x33, 0x5f, 0xd3, 0xb2, 0x84, + 0xc3, 0x56, 0x39, 0x96, 0x27, 0x3e, 0xf8, 0xf4, 0xf3, 0xcf, 0x97, 0xee, 0x13, 0xf2, 0x98, 0x55, + 0xab, 0xbf, 0xbd, 0xf9, 0xeb, 0xf9, 0xb1, 0x8f, 0xe5, 0x02, 0x2e, 0xdc, 0x09, 0x16, 0xe4, 0x2b, + 0xc2, 0xbd, 0x8d, 0xf1, 0x93, 0x36, 0x28, 0x6e, 0x59, 0xc2, 0x87, 0xed, 0x92, 0x4a, 0x03, 0x8f, + 0x8c, 0x81, 0x21, 0xe9, 0x5f, 0xcc, 0x80, 0xaa, 0xb8, 0x0f, 0x9e, 0xfd, 0x58, 0x46, 0xe8, 0x7c, + 0x19, 0xa1, 0xdf, 0xcb, 0x08, 0x7d, 0x5e, 0x45, 0x9d, 0xf3, 0x55, 0xd4, 0xf9, 0xb5, 0x8a, 0x3a, + 0x2f, 0xa9, 0x98, 0xe8, 0x37, 0xf3, 0x11, 0x1d, 0xcb, 0x99, 0x2b, 0x6b, 0x2f, 0x0f, 0xd4, 0xeb, + 0xb7, 0xec, 0x83, 0xf7, 0x7f, 0xd0, 0x67, 0x19, 0xa8, 0xd1, 0x15, 0xf3, 0x29, 0x0f, 0xff, 0x05, + 0x00, 0x00, 0xff, 0xff, 0x38, 0x5c, 0xd5, 0x1e, 0x96, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -310,7 +310,7 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { func (c *queryClient) FeeAllowance(ctx context.Context, in *QueryFeeAllowanceRequest, opts ...grpc.CallOption) (*QueryFeeAllowanceResponse, error) { out := new(QueryFeeAllowanceResponse) - err := c.cc.Invoke(ctx, "/cosmos.feegrant.v1beta1.Query/FeeAllowance", in, out, opts...) + err := c.cc.Invoke(ctx, "/cosmos.fee_grant.v1beta1.Query/FeeAllowance", in, out, opts...) if err != nil { return nil, err } @@ -319,7 +319,7 @@ func (c *queryClient) FeeAllowance(ctx context.Context, in *QueryFeeAllowanceReq func (c *queryClient) FeeAllowances(ctx context.Context, in *QueryFeeAllowancesRequest, opts ...grpc.CallOption) (*QueryFeeAllowancesResponse, error) { out := new(QueryFeeAllowancesResponse) - err := c.cc.Invoke(ctx, "/cosmos.feegrant.v1beta1.Query/FeeAllowances", in, out, opts...) + err := c.cc.Invoke(ctx, "/cosmos.fee_grant.v1beta1.Query/FeeAllowances", in, out, opts...) if err != nil { return nil, err } @@ -359,7 +359,7 @@ func _Query_FeeAllowance_Handler(srv interface{}, ctx context.Context, dec func( } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/cosmos.feegrant.v1beta1.Query/FeeAllowance", + FullMethod: "/cosmos.fee_grant.v1beta1.Query/FeeAllowance", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).FeeAllowance(ctx, req.(*QueryFeeAllowanceRequest)) @@ -377,7 +377,7 @@ func _Query_FeeAllowances_Handler(srv interface{}, ctx context.Context, dec func } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/cosmos.feegrant.v1beta1.Query/FeeAllowances", + FullMethod: "/cosmos.fee_grant.v1beta1.Query/FeeAllowances", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).FeeAllowances(ctx, req.(*QueryFeeAllowancesRequest)) @@ -386,7 +386,7 @@ func _Query_FeeAllowances_Handler(srv interface{}, ctx context.Context, dec func } var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "cosmos.feegrant.v1beta1.Query", + ServiceName: "cosmos.fee_grant.v1beta1.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { @@ -399,7 +399,7 @@ var _Query_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "cosmos/feegrant/v1beta1/query.proto", + Metadata: "cosmos/fee_grant/v1beta1/query.proto", } func (m *QueryFeeAllowanceRequest) Marshal() (dAtA []byte, err error) { diff --git a/x/fee_grant/types/query.pb.gw.go b/x/fee_grant/types/query.pb.gw.go index 448e7beb63f6..0a86d05e44bb 100644 --- a/x/fee_grant/types/query.pb.gw.go +++ b/x/fee_grant/types/query.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: cosmos/feegrant/v1beta1/query.proto +// source: cosmos/fee_grant/v1beta1/query.proto /* Package types is a reverse proxy. @@ -310,9 +310,9 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_FeeAllowance_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7}, []string{"cosmos", "feegrant", "v1beta1", "granters", "granter", "grantees", "grantee", "grant"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_FeeAllowance_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"cosmos", "feegrant", "v1beta1", "fee_allowance", "granter", "grantee"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_FeeAllowances_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "feegrant", "v1beta1", "grants", "grantee"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_FeeAllowances_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "feegrant", "v1beta1", "fee_allowances", "grantee"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( diff --git a/x/fee_grant/types/tx.pb.go b/x/fee_grant/types/tx.pb.go index ec51dc9f0336..8bda6ce8f975 100644 --- a/x/fee_grant/types/tx.pb.go +++ b/x/fee_grant/types/tx.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmos/feegrant/v1beta1/tx.proto +// source: cosmos/fee_grant/v1beta1/tx.proto package types @@ -42,7 +42,7 @@ func (m *MsgGrantFeeAllowance) Reset() { *m = MsgGrantFeeAllowance{} } func (m *MsgGrantFeeAllowance) String() string { return proto.CompactTextString(m) } func (*MsgGrantFeeAllowance) ProtoMessage() {} func (*MsgGrantFeeAllowance) Descriptor() ([]byte, []int) { - return fileDescriptor_dd44ad7946dad783, []int{0} + return fileDescriptor_12c787f073d65b9c, []int{0} } func (m *MsgGrantFeeAllowance) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -100,7 +100,7 @@ func (m *MsgGrantFeeAllowanceResponse) Reset() { *m = MsgGrantFeeAllowan func (m *MsgGrantFeeAllowanceResponse) String() string { return proto.CompactTextString(m) } func (*MsgGrantFeeAllowanceResponse) ProtoMessage() {} func (*MsgGrantFeeAllowanceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dd44ad7946dad783, []int{1} + return fileDescriptor_12c787f073d65b9c, []int{1} } func (m *MsgGrantFeeAllowanceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -139,7 +139,7 @@ func (m *MsgRevokeFeeAllowance) Reset() { *m = MsgRevokeFeeAllowance{} } func (m *MsgRevokeFeeAllowance) String() string { return proto.CompactTextString(m) } func (*MsgRevokeFeeAllowance) ProtoMessage() {} func (*MsgRevokeFeeAllowance) Descriptor() ([]byte, []int) { - return fileDescriptor_dd44ad7946dad783, []int{2} + return fileDescriptor_12c787f073d65b9c, []int{2} } func (m *MsgRevokeFeeAllowance) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -190,7 +190,7 @@ func (m *MsgRevokeFeeAllowanceResponse) Reset() { *m = MsgRevokeFeeAllow func (m *MsgRevokeFeeAllowanceResponse) String() string { return proto.CompactTextString(m) } func (*MsgRevokeFeeAllowanceResponse) ProtoMessage() {} func (*MsgRevokeFeeAllowanceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dd44ad7946dad783, []int{3} + return fileDescriptor_12c787f073d65b9c, []int{3} } func (m *MsgRevokeFeeAllowanceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -220,38 +220,38 @@ func (m *MsgRevokeFeeAllowanceResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRevokeFeeAllowanceResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgGrantFeeAllowance)(nil), "cosmos.feegrant.v1beta1.MsgGrantFeeAllowance") - proto.RegisterType((*MsgGrantFeeAllowanceResponse)(nil), "cosmos.feegrant.v1beta1.MsgGrantFeeAllowanceResponse") - proto.RegisterType((*MsgRevokeFeeAllowance)(nil), "cosmos.feegrant.v1beta1.MsgRevokeFeeAllowance") - proto.RegisterType((*MsgRevokeFeeAllowanceResponse)(nil), "cosmos.feegrant.v1beta1.MsgRevokeFeeAllowanceResponse") + proto.RegisterType((*MsgGrantFeeAllowance)(nil), "cosmos.fee_grant.v1beta1.MsgGrantFeeAllowance") + proto.RegisterType((*MsgGrantFeeAllowanceResponse)(nil), "cosmos.fee_grant.v1beta1.MsgGrantFeeAllowanceResponse") + proto.RegisterType((*MsgRevokeFeeAllowance)(nil), "cosmos.fee_grant.v1beta1.MsgRevokeFeeAllowance") + proto.RegisterType((*MsgRevokeFeeAllowanceResponse)(nil), "cosmos.fee_grant.v1beta1.MsgRevokeFeeAllowanceResponse") } -func init() { proto.RegisterFile("cosmos/feegrant/v1beta1/tx.proto", fileDescriptor_dd44ad7946dad783) } +func init() { proto.RegisterFile("cosmos/fee_grant/v1beta1/tx.proto", fileDescriptor_12c787f073d65b9c) } -var fileDescriptor_dd44ad7946dad783 = []byte{ - // 348 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x92, 0xcd, 0x4e, 0xc2, 0x40, - 0x14, 0x85, 0x19, 0x49, 0x34, 0x8c, 0x71, 0x41, 0x83, 0xb1, 0x36, 0x3a, 0x92, 0xae, 0xd8, 0x30, - 0x13, 0x30, 0xba, 0x87, 0xc4, 0xbf, 0x18, 0x36, 0x5d, 0xba, 0x21, 0x2d, 0x5e, 0x46, 0x03, 0xf4, - 0x12, 0xa6, 0x20, 0x4d, 0x7c, 0x08, 0x7d, 0x17, 0x1f, 0xc2, 0xb8, 0x62, 0xe9, 0xd2, 0xc0, 0x7b, - 0x18, 0xd3, 0x9f, 0x09, 0x24, 0x54, 0x13, 0xe2, 0xaa, 0xbd, 0xb9, 0xdf, 0x9c, 0x73, 0xa6, 0x3d, - 0xb4, 0xdc, 0x41, 0x35, 0x40, 0x25, 0xba, 0x00, 0x72, 0xe4, 0xfa, 0x81, 0x98, 0xd4, 0x3c, 0x08, - 0xdc, 0x9a, 0x08, 0xa6, 0x7c, 0x38, 0xc2, 0x00, 0x8d, 0x83, 0x84, 0xe0, 0x9a, 0xe0, 0x29, 0x61, - 0x95, 0x24, 0x4a, 0x8c, 0x19, 0x11, 0xbd, 0x25, 0xb8, 0x75, 0x28, 0x11, 0x65, 0x1f, 0x44, 0x3c, - 0x79, 0xe3, 0xae, 0x70, 0xfd, 0x50, 0xaf, 0x12, 0xa5, 0x76, 0x72, 0x26, 0x95, 0x8d, 0x07, 0xfb, - 0x95, 0xd0, 0x52, 0x4b, 0xc9, 0xab, 0xc8, 0xe0, 0x12, 0xa0, 0xd1, 0xef, 0xe3, 0x93, 0xeb, 0x77, - 0xc0, 0x30, 0xe9, 0x4e, 0xec, 0x0a, 0x23, 0x93, 0x94, 0x49, 0xa5, 0xe0, 0xe8, 0x71, 0xb9, 0x01, - 0x73, 0x6b, 0x75, 0x03, 0xc6, 0x05, 0x2d, 0xb8, 0x5a, 0xc0, 0xcc, 0x97, 0x49, 0x65, 0xb7, 0x5e, - 0xe2, 0x49, 0x2c, 0xae, 0x63, 0xf1, 0x86, 0x1f, 0x36, 0x8b, 0x1f, 0x6f, 0xd5, 0xbd, 0x55, 0xbb, - 0x1b, 0x67, 0x79, 0xd2, 0x66, 0xf4, 0x28, 0x2b, 0x92, 0x03, 0x6a, 0x88, 0xbe, 0x02, 0xfb, 0x96, - 0xee, 0xb7, 0x94, 0x74, 0x60, 0x82, 0x3d, 0xf8, 0x6f, 0x66, 0xfb, 0x84, 0x1e, 0x67, 0x8a, 0x69, - 0xb7, 0xfa, 0x37, 0xa1, 0xf9, 0x96, 0x92, 0x46, 0x48, 0x8b, 0xeb, 0x5f, 0xa9, 0xca, 0x7f, 0xf9, - 0x49, 0x3c, 0xeb, 0x06, 0xd6, 0xd9, 0x46, 0xb8, 0x8e, 0x60, 0x3c, 0x53, 0x23, 0xe3, 0xb6, 0xfc, - 0x2f, 0xb1, 0x75, 0xde, 0x3a, 0xdf, 0x8c, 0xd7, 0xee, 0xcd, 0xeb, 0xf7, 0x39, 0x23, 0xb3, 0x39, - 0x23, 0x5f, 0x73, 0x46, 0x5e, 0x16, 0x2c, 0x37, 0x5b, 0xb0, 0xdc, 0xe7, 0x82, 0xe5, 0xee, 0xb8, - 0x7c, 0x0c, 0x1e, 0xc6, 0x1e, 0xef, 0xe0, 0x20, 0x6d, 0x55, 0xfa, 0xa8, 0xaa, 0xfb, 0x9e, 0x98, - 0x46, 0xdd, 0x6e, 0x27, 0xe5, 0x0e, 0xc2, 0x21, 0x28, 0x6f, 0x3b, 0x2e, 0xc1, 0xe9, 0x4f, 0x00, - 0x00, 0x00, 0xff, 0xff, 0xea, 0x33, 0x63, 0xb7, 0xfc, 0x02, 0x00, 0x00, +var fileDescriptor_12c787f073d65b9c = []byte{ + // 346 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0x8d, 0x4f, 0x2f, 0x4a, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, + 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x80, + 0x28, 0xd1, 0x83, 0x2b, 0xd1, 0x83, 0x2a, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, 0xd2, + 0x07, 0xb1, 0x20, 0xea, 0xa5, 0x24, 0xd3, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0xc1, 0xbc, 0xa4, + 0xd2, 0x34, 0xfd, 0xc4, 0xbc, 0x4a, 0x98, 0x14, 0xc4, 0xa8, 0x78, 0x88, 0x1e, 0xa8, 0xb9, 0x60, + 0x8e, 0xd2, 0x44, 0x46, 0x2e, 0x11, 0xdf, 0xe2, 0x74, 0x77, 0x90, 0x05, 0x6e, 0xa9, 0xa9, 0x8e, + 0x39, 0x39, 0xf9, 0xe5, 0x89, 0x79, 0xc9, 0xa9, 0x42, 0x12, 0x5c, 0xec, 0x60, 0x5b, 0x53, 0x8b, + 0x24, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x60, 0x5c, 0x84, 0x4c, 0xaa, 0x04, 0x13, 0xb2, 0x4c, + 0xaa, 0x90, 0x2b, 0x17, 0x67, 0x22, 0xcc, 0x00, 0x09, 0x66, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x11, + 0x3d, 0x88, 0xb3, 0xf4, 0x60, 0xce, 0xd2, 0x73, 0xcc, 0xab, 0x74, 0x12, 0x3c, 0xb5, 0x45, 0x97, + 0x17, 0xd9, 0x3a, 0xcf, 0x20, 0x84, 0x4e, 0x25, 0x39, 0x2e, 0x19, 0x6c, 0x4e, 0x0a, 0x4a, 0x2d, + 0x2e, 0xc8, 0xcf, 0x2b, 0x4e, 0x55, 0xf2, 0xe6, 0x12, 0xf5, 0x2d, 0x4e, 0x0f, 0x4a, 0x2d, 0xcb, + 0xcf, 0x4e, 0xa5, 0xd4, 0xcd, 0x4a, 0xf2, 0x5c, 0xb2, 0x58, 0x0d, 0x83, 0xd9, 0x66, 0xd4, 0xc4, + 0xc4, 0xc5, 0xec, 0x5b, 0x9c, 0x2e, 0x54, 0xcd, 0x25, 0x88, 0x19, 0x4a, 0x7a, 0x7a, 0xb8, 0x62, + 0x49, 0x0f, 0x9b, 0x17, 0xa4, 0xcc, 0x48, 0x53, 0x0f, 0x73, 0x84, 0x50, 0x1d, 0x97, 0x10, 0x16, + 0xff, 0xea, 0xe3, 0x35, 0x0d, 0x53, 0x83, 0x94, 0x39, 0x89, 0x1a, 0x60, 0xf6, 0x3b, 0x79, 0x9c, + 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, + 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x5e, 0x7a, 0x66, 0x49, 0x46, 0x69, + 0x92, 0x5e, 0x72, 0x7e, 0x2e, 0x34, 0x65, 0x41, 0x29, 0xdd, 0xe2, 0x94, 0x6c, 0xfd, 0x0a, 0xa4, + 0x14, 0x5e, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x4e, 0x08, 0xc6, 0x80, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x04, 0xa2, 0x6d, 0xe9, 0x02, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -284,7 +284,7 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { func (c *msgClient) GrantFeeAllowance(ctx context.Context, in *MsgGrantFeeAllowance, opts ...grpc.CallOption) (*MsgGrantFeeAllowanceResponse, error) { out := new(MsgGrantFeeAllowanceResponse) - err := c.cc.Invoke(ctx, "/cosmos.feegrant.v1beta1.Msg/GrantFeeAllowance", in, out, opts...) + err := c.cc.Invoke(ctx, "/cosmos.fee_grant.v1beta1.Msg/GrantFeeAllowance", in, out, opts...) if err != nil { return nil, err } @@ -293,7 +293,7 @@ func (c *msgClient) GrantFeeAllowance(ctx context.Context, in *MsgGrantFeeAllowa func (c *msgClient) RevokeFeeAllowance(ctx context.Context, in *MsgRevokeFeeAllowance, opts ...grpc.CallOption) (*MsgRevokeFeeAllowanceResponse, error) { out := new(MsgRevokeFeeAllowanceResponse) - err := c.cc.Invoke(ctx, "/cosmos.feegrant.v1beta1.Msg/RevokeFeeAllowance", in, out, opts...) + err := c.cc.Invoke(ctx, "/cosmos.fee_grant.v1beta1.Msg/RevokeFeeAllowance", in, out, opts...) if err != nil { return nil, err } @@ -335,7 +335,7 @@ func _Msg_GrantFeeAllowance_Handler(srv interface{}, ctx context.Context, dec fu } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/cosmos.feegrant.v1beta1.Msg/GrantFeeAllowance", + FullMethod: "/cosmos.fee_grant.v1beta1.Msg/GrantFeeAllowance", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).GrantFeeAllowance(ctx, req.(*MsgGrantFeeAllowance)) @@ -353,7 +353,7 @@ func _Msg_RevokeFeeAllowance_Handler(srv interface{}, ctx context.Context, dec f } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/cosmos.feegrant.v1beta1.Msg/RevokeFeeAllowance", + FullMethod: "/cosmos.fee_grant.v1beta1.Msg/RevokeFeeAllowance", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).RevokeFeeAllowance(ctx, req.(*MsgRevokeFeeAllowance)) @@ -362,7 +362,7 @@ func _Msg_RevokeFeeAllowance_Handler(srv interface{}, ctx context.Context, dec f } var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "cosmos.feegrant.v1beta1.Msg", + ServiceName: "cosmos.fee_grant.v1beta1.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { @@ -375,7 +375,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "cosmos/feegrant/v1beta1/tx.proto", + Metadata: "cosmos/fee_grant/v1beta1/tx.proto", } func (m *MsgGrantFeeAllowance) Marshal() (dAtA []byte, err error) { From a893e92db60f357c13e36e9efd8da8f10c65f17d Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 12 Jan 2021 13:59:29 +0530 Subject: [PATCH 146/184] fix test --- x/fee_grant/simulation/decoder_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/fee_grant/simulation/decoder_test.go b/x/fee_grant/simulation/decoder_test.go index 0876de2ff84e..561de05a3a40 100644 --- a/x/fee_grant/simulation/decoder_test.go +++ b/x/fee_grant/simulation/decoder_test.go @@ -21,7 +21,7 @@ var ( ) func TestDecodeStore(t *testing.T) { - cdc, _ := simapp.MakeCodecs() + cdc := simapp.MakeTestEncodingConfig().Marshaler dec := simulation.NewDecodeStore(cdc) grant := types.NewFeeAllowanceGrant(granterAddr, granteeAddr, &types.BasicFeeAllowance{ From 9a68d5175b3b048f71cd9b274cd7e4dd8cd02c5a Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 12 Jan 2021 15:26:56 +0530 Subject: [PATCH 147/184] add condition for duplicate grants --- x/fee_grant/client/cli/cli_test.go | 8 ++++---- x/fee_grant/client/cli/tx.go | 5 +++++ x/fee_grant/keeper/msg_server.go | 5 ++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/x/fee_grant/client/cli/cli_test.go b/x/fee_grant/client/cli/cli_test.go index a8405c4697ad..71c048ace7f7 100644 --- a/x/fee_grant/client/cli/cli_test.go +++ b/x/fee_grant/client/cli/cli_test.go @@ -243,7 +243,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { expectedCode uint32 }{ { - "wromg granter address", + "wrong granter address", append( []string{ "wrong_granter", @@ -256,7 +256,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { true, nil, 0, }, { - "wromg grantee address", + "wrong grantee address", append( []string{ granter.String(), @@ -273,7 +273,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { append( []string{ granter.String(), - grantee.String(), + "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", "100steak", fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), }, @@ -317,7 +317,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { append( []string{ granter.String(), - grantee.String(), + "cosmos1w55kgcf3ltaqdy4ww49nge3klxmrdavrr6frmp", "100steak", fmt.Sprintf("%d", 60*60), "10steak", diff --git a/x/fee_grant/client/cli/tx.go b/x/fee_grant/client/cli/tx.go index b41844325317..9449ac42f2af 100644 --- a/x/fee_grant/client/cli/tx.go +++ b/x/fee_grant/client/cli/tx.go @@ -59,6 +59,11 @@ Examples: ), Args: cobra.RangeArgs(3, 5), RunE: func(cmd *cobra.Command, args []string) error { + _, err := sdk.AccAddressFromBech32(args[0]) + if err != nil { + return err + } + cmd.Flags().Set(flags.FlagFrom, args[0]) clientCtx, err := client.GetClientTxContext(cmd) if err != nil { diff --git a/x/fee_grant/keeper/msg_server.go b/x/fee_grant/keeper/msg_server.go index 6c89a32e74c8..ba529192fb07 100644 --- a/x/fee_grant/keeper/msg_server.go +++ b/x/fee_grant/keeper/msg_server.go @@ -4,9 +4,8 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/fee_grant/types" ) @@ -40,7 +39,7 @@ func (k msgServer) GrantFeeAllowance(goCtx context.Context, msg *types.MsgGrantF // Checking for duplicate entry f := k.Keeper.GetFeeAllowance(ctx, granter, grantee) if f != nil { - return nil, status.Errorf(codes.AlreadyExists, "grant already exist") + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "fee allowance already exist") } k.Keeper.GrantFeeAllowance(ctx, granter, grantee, msg.GetFeeAllowanceI()) From 90c3e7f38af825721f6a41686da7f5bbad096a41 Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 12 Jan 2021 15:43:27 +0530 Subject: [PATCH 148/184] fix tests --- x/fee_grant/simulation/operations.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/fee_grant/simulation/operations.go b/x/fee_grant/simulation/operations.go index 6989607bbaf1..4bd7d2eda624 100644 --- a/x/fee_grant/simulation/operations.go +++ b/x/fee_grant/simulation/operations.go @@ -20,8 +20,8 @@ import ( const ( OpWeightMsgGrantFeeAllowance = "op_weight_msg_grant_fee_allowance" OpWeightMsgRevokeFeeAllowance = "op_weight_msg_grant_revoke_allowance" - TypeMsgGrantFeeAllowance = "/cosmos.feegrant.v1beta1.Msg/GrantFeeAllowance" - TypeMsgRevokeFeeAllowance = "/cosmos.feegrant.v1beta1.Msg/RevokeFeeAllowance" + TypeMsgGrantFeeAllowance = "/cosmos.fee_grant.v1beta1.Msg/GrantFeeAllowance" + TypeMsgRevokeFeeAllowance = "/cosmos.fee_grant.v1beta1.Msg/RevokeFeeAllowance" ) func WeightedOperations( From 1a056a987098da88de585eed3e2da93f40ff3e86 Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 12 Jan 2021 15:52:18 +0530 Subject: [PATCH 149/184] add `genTxWithFeeGranter` in tests --- client/tx_config.go | 1 + simapp/helpers/test_helpers.go | 69 ------------------------- x/auth/legacy/legacytx/stdtx_builder.go | 1 + x/fee_grant/ante/fee_test.go | 69 ++++++++++++++++++++++++- 4 files changed, 70 insertions(+), 70 deletions(-) diff --git a/client/tx_config.go b/client/tx_config.go index 6992a7a2402d..8220e917b2bb 100644 --- a/client/tx_config.go +++ b/client/tx_config.go @@ -42,5 +42,6 @@ type ( SetFeeAmount(amount sdk.Coins) SetGasLimit(limit uint64) SetTimeoutHeight(height uint64) + SetFeeGranter(feeGranter sdk.AccAddress) } ) diff --git a/simapp/helpers/test_helpers.go b/simapp/helpers/test_helpers.go index b82bc2b4a8f1..9ccecbd976c4 100644 --- a/simapp/helpers/test_helpers.go +++ b/simapp/helpers/test_helpers.go @@ -18,12 +18,6 @@ const ( SimAppChainID = "simulation-app" ) -type txBuilder interface { - client.TxBuilder - - SetFeeGranter(feeGranter sdk.AccAddress) -} - // GenTx generates a signed mock transaction. func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey) (sdk.Tx, error) { sigs := make([]signing.SignatureV2, len(priv)) @@ -84,66 +78,3 @@ func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, ch return tx.GetTx(), nil } - -// GenTxWithFeeGranter generates a signed mock transaction with fee granter field set with a given address. -func GenTxWithFeeGranter(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, - accSeqs []uint64, feeGranter sdk.AccAddress, priv ...cryptotypes.PrivKey) (sdk.Tx, error) { - sigs := make([]signing.SignatureV2, len(priv)) - - // create a random length memo - r := rand.New(rand.NewSource(time.Now().UnixNano())) - - memo := simulation.RandStringOfLength(r, simulation.RandIntBetween(r, 0, 100)) - - signMode := gen.SignModeHandler().DefaultMode() - - // 1st round: set SignatureV2 with empty signatures, to set correct - // signer infos. - for i, p := range priv { - sigs[i] = signing.SignatureV2{ - PubKey: p.PubKey(), - Data: &signing.SingleSignatureData{ - SignMode: signMode, - }, - Sequence: accSeqs[i], - } - } - - tx := gen.NewTxBuilder().(txBuilder) - err := tx.SetMsgs(msgs...) - if err != nil { - return nil, err - } - err = tx.SetSignatures(sigs...) - if err != nil { - return nil, err - } - tx.SetMemo(memo) - tx.SetFeeAmount(feeAmt) - tx.SetGasLimit(gas) - tx.SetFeeGranter(feeGranter) - - // 2nd round: once all signer infos are set, every signer can sign. - for i, p := range priv { - signerData := authsign.SignerData{ - ChainID: chainID, - AccountNumber: accNums[i], - Sequence: accSeqs[i], - } - signBytes, err := gen.SignModeHandler().GetSignBytes(signMode, signerData, tx.GetTx()) - if err != nil { - panic(err) - } - sig, err := p.Sign(signBytes) - if err != nil { - panic(err) - } - sigs[i].Data.(*signing.SingleSignatureData).Signature = sig - err = tx.SetSignatures(sigs...) - if err != nil { - panic(err) - } - } - - return tx.GetTx(), nil -} diff --git a/x/auth/legacy/legacytx/stdtx_builder.go b/x/auth/legacy/legacytx/stdtx_builder.go index 83bb2f9ae48f..ae0e97a3f34c 100644 --- a/x/auth/legacy/legacytx/stdtx_builder.go +++ b/x/auth/legacy/legacytx/stdtx_builder.go @@ -84,6 +84,7 @@ func (s *StdTxBuilder) SetTimeoutHeight(height uint64) { s.TimeoutHeight = height } +// SetFeeGranter does nothing for stdtx func (s *StdTxBuilder) SetFeeGranter(_ sdk.AccAddress) {} // StdTxConfig is a context.TxConfig for StdTx diff --git a/x/fee_grant/ante/fee_test.go b/x/fee_grant/ante/fee_test.go index c273ec6eb133..b134e0b44995 100644 --- a/x/fee_grant/ante/fee_test.go +++ b/x/fee_grant/ante/fee_test.go @@ -1,7 +1,9 @@ package ante_test import ( + "math/rand" "testing" + "time" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -14,7 +16,10 @@ import ( "github.com/cosmos/cosmos-sdk/simapp/helpers" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/types/tx/signing" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" + authsign "github.com/cosmos/cosmos-sdk/x/auth/signing" "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/fee_grant/ante" @@ -262,7 +267,7 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { accNums, seqs = []uint64{acc.GetAccountNumber()}, []uint64{acc.GetSequence()} } - tx, err := helpers.GenTxWithFeeGranter(protoTxCfg, msgs, fee, helpers.DefaultGenTxGas, ctx.ChainID(), accNums, seqs, tc.feeAccount, privs...) + tx, err := genTxWithFeeGranter(protoTxCfg, msgs, fee, helpers.DefaultGenTxGas, ctx.ChainID(), accNums, seqs, tc.feeAccount, privs...) suite.Require().NoError(err) _, err = tc.handler(ctx, tx, false) @@ -289,6 +294,68 @@ func SigGasNoConsumer(meter sdk.GasMeter, sig []byte, pubkey crypto.PubKey, para return nil } +func genTxWithFeeGranter(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, + accSeqs []uint64, feeGranter sdk.AccAddress, priv ...cryptotypes.PrivKey) (sdk.Tx, error) { + sigs := make([]signing.SignatureV2, len(priv)) + + // create a random length memo + r := rand.New(rand.NewSource(time.Now().UnixNano())) + + memo := simulation.RandStringOfLength(r, simulation.RandIntBetween(r, 0, 100)) + + signMode := gen.SignModeHandler().DefaultMode() + + // 1st round: set SignatureV2 with empty signatures, to set correct + // signer infos. + for i, p := range priv { + sigs[i] = signing.SignatureV2{ + PubKey: p.PubKey(), + Data: &signing.SingleSignatureData{ + SignMode: signMode, + }, + Sequence: accSeqs[i], + } + } + + tx := gen.NewTxBuilder() + err := tx.SetMsgs(msgs...) + if err != nil { + return nil, err + } + err = tx.SetSignatures(sigs...) + if err != nil { + return nil, err + } + tx.SetMemo(memo) + tx.SetFeeAmount(feeAmt) + tx.SetGasLimit(gas) + tx.SetFeeGranter(feeGranter) + + // 2nd round: once all signer infos are set, every signer can sign. + for i, p := range priv { + signerData := authsign.SignerData{ + ChainID: chainID, + AccountNumber: accNums[i], + Sequence: accSeqs[i], + } + signBytes, err := gen.SignModeHandler().GetSignBytes(signMode, signerData, tx.GetTx()) + if err != nil { + panic(err) + } + sig, err := p.Sign(signBytes) + if err != nil { + panic(err) + } + sigs[i].Data.(*signing.SingleSignatureData).Signature = sig + err = tx.SetSignatures(sigs...) + if err != nil { + panic(err) + } + } + + return tx.GetTx(), nil +} + func TestAnteTestSuite(t *testing.T) { suite.Run(t, new(AnteTestSuite)) } From ec5129afd7e68373d12894a99ec29a46df59105c Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 12 Jan 2021 16:22:42 +0530 Subject: [PATCH 150/184] fix simulation --- x/fee_grant/simulation/operations.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/x/fee_grant/simulation/operations.go b/x/fee_grant/simulation/operations.go index 4bd7d2eda624..5d85d501829a 100644 --- a/x/fee_grant/simulation/operations.go +++ b/x/fee_grant/simulation/operations.go @@ -70,6 +70,11 @@ func SimulateMsgGrantFeeAllowance(ak types.AccountKeeper, bk types.BankKeeper, k return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgGrantFeeAllowance, "grantee and granter cannot be same"), nil, nil } + f := k.GetFeeAllowance(ctx, granter.Address, grantee.Address) + if f != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgGrantFeeAllowance, "fee allowance exists"), nil, nil + } + account := ak.GetAccount(ctx, granter.Address) spendableCoins := bk.SpendableCoins(ctx, account.GetAddress()) From de83e0124c86659678800f59ff73312906e15178 Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 18 Jan 2021 16:03:42 +0530 Subject: [PATCH 151/184] one of changes & test fixes --- docs/core/proto-docs.md | 336 ++++++++++++++++- go.mod | 4 +- go.sum | 8 +- .../cosmos/fee_grant/v1beta1/fee_grant.proto | 17 +- x/fee_grant/genesis_test.go | 5 +- x/fee_grant/types/basic_fee.go | 2 +- x/fee_grant/types/expiration.go | 65 ++-- x/fee_grant/types/expiration_test.go | 26 +- x/fee_grant/types/fee_grant.pb.go | 347 +++++++++++++----- x/fee_grant/types/periodic_fee.go | 6 +- 10 files changed, 665 insertions(+), 151 deletions(-) mode change 100644 => 100755 proto/cosmos/fee_grant/v1beta1/fee_grant.proto diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 6c4f113995db..b9f3402ae8b8 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -233,6 +233,32 @@ - [Msg](#cosmos.evidence.v1beta1.Msg) +- [cosmos/fee_grant/v1beta1/fee_grant.proto](#cosmos/fee_grant/v1beta1/fee_grant.proto) + - [BasicFeeAllowance](#cosmos.fee_grant.v1beta1.BasicFeeAllowance) + - [Duration](#cosmos.fee_grant.v1beta1.Duration) + - [ExpiresAt](#cosmos.fee_grant.v1beta1.ExpiresAt) + - [FeeAllowanceGrant](#cosmos.fee_grant.v1beta1.FeeAllowanceGrant) + - [PeriodicFeeAllowance](#cosmos.fee_grant.v1beta1.PeriodicFeeAllowance) + +- [cosmos/fee_grant/v1beta1/genesis.proto](#cosmos/fee_grant/v1beta1/genesis.proto) + - [GenesisState](#cosmos.fee_grant.v1beta1.GenesisState) + +- [cosmos/fee_grant/v1beta1/query.proto](#cosmos/fee_grant/v1beta1/query.proto) + - [QueryFeeAllowanceRequest](#cosmos.fee_grant.v1beta1.QueryFeeAllowanceRequest) + - [QueryFeeAllowanceResponse](#cosmos.fee_grant.v1beta1.QueryFeeAllowanceResponse) + - [QueryFeeAllowancesRequest](#cosmos.fee_grant.v1beta1.QueryFeeAllowancesRequest) + - [QueryFeeAllowancesResponse](#cosmos.fee_grant.v1beta1.QueryFeeAllowancesResponse) + + - [Query](#cosmos.fee_grant.v1beta1.Query) + +- [cosmos/fee_grant/v1beta1/tx.proto](#cosmos/fee_grant/v1beta1/tx.proto) + - [MsgGrantFeeAllowance](#cosmos.fee_grant.v1beta1.MsgGrantFeeAllowance) + - [MsgGrantFeeAllowanceResponse](#cosmos.fee_grant.v1beta1.MsgGrantFeeAllowanceResponse) + - [MsgRevokeFeeAllowance](#cosmos.fee_grant.v1beta1.MsgRevokeFeeAllowance) + - [MsgRevokeFeeAllowanceResponse](#cosmos.fee_grant.v1beta1.MsgRevokeFeeAllowanceResponse) + + - [Msg](#cosmos.fee_grant.v1beta1.Msg) + - [cosmos/genutil/v1beta1/genesis.proto](#cosmos/genutil/v1beta1/genesis.proto) - [GenesisState](#cosmos.genutil.v1beta1.GenesisState) @@ -2222,8 +2248,8 @@ Service defines the gRPC querier service for tendermint queries. | `GetSyncing` | [GetSyncingRequest](#cosmos.base.tendermint.v1beta1.GetSyncingRequest) | [GetSyncingResponse](#cosmos.base.tendermint.v1beta1.GetSyncingResponse) | GetSyncing queries node syncing. | GET|/cosmos/base/tendermint/v1beta1/syncing| | `GetLatestBlock` | [GetLatestBlockRequest](#cosmos.base.tendermint.v1beta1.GetLatestBlockRequest) | [GetLatestBlockResponse](#cosmos.base.tendermint.v1beta1.GetLatestBlockResponse) | GetLatestBlock returns the latest block. | GET|/cosmos/base/tendermint/v1beta1/blocks/latest| | `GetBlockByHeight` | [GetBlockByHeightRequest](#cosmos.base.tendermint.v1beta1.GetBlockByHeightRequest) | [GetBlockByHeightResponse](#cosmos.base.tendermint.v1beta1.GetBlockByHeightResponse) | GetBlockByHeight queries block for given height. | GET|/cosmos/base/tendermint/v1beta1/blocks/{height}| -| `GetLatestValidatorSet` | [GetLatestValidatorSetRequest](#cosmos.base.tendermint.v1beta1.GetLatestValidatorSetRequest) | [GetLatestValidatorSetResponse](#cosmos.base.tendermint.v1beta1.GetLatestValidatorSetResponse) | GetLatestValidatorSet queries latest validator-set. | GET|/cosmos/base/tendermint/v1beta1/validators/latest| -| `GetValidatorSetByHeight` | [GetValidatorSetByHeightRequest](#cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightRequest) | [GetValidatorSetByHeightResponse](#cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightResponse) | GetValidatorSetByHeight queries validator-set at a given height. | GET|/cosmos/base/tendermint/v1beta1/validators/{height}| +| `GetLatestValidatorSet` | [GetLatestValidatorSetRequest](#cosmos.base.tendermint.v1beta1.GetLatestValidatorSetRequest) | [GetLatestValidatorSetResponse](#cosmos.base.tendermint.v1beta1.GetLatestValidatorSetResponse) | GetLatestValidatorSet queries latest validator-set. | GET|/cosmos/base/tendermint/v1beta1/validatorsets/latest| +| `GetValidatorSetByHeight` | [GetValidatorSetByHeightRequest](#cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightRequest) | [GetValidatorSetByHeightResponse](#cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightResponse) | GetValidatorSetByHeight queries validator-set at a given height. | GET|/cosmos/base/tendermint/v1beta1/validatorsets/{height}| @@ -3677,6 +3703,312 @@ Msg defines the evidence Msg service. + +

Top

+ +## cosmos/fee_grant/v1beta1/fee_grant.proto + + + + + +### BasicFeeAllowance +BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens +that optionally expires. The delegatee can use up to SpendLimit to cover fees. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `spend_limit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `expiration` | [ExpiresAt](#cosmos.fee_grant.v1beta1.ExpiresAt) | | | + + + + + + + + +### Duration +Duration is a repeating unit of either clock time or number of blocks. +This is designed to be added to an ExpiresAt struct. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `duration` | [google.protobuf.Duration](#google.protobuf.Duration) | | | +| `block` | [int64](#int64) | | | + + + + + + + + +### ExpiresAt +ExpiresAt is a point in time where something expires. +It may be *either* block time or block height + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | +| `height` | [int64](#int64) | | | + + + + + + + + +### FeeAllowanceGrant +FeeAllowanceGrant is stored in the KVStore to record a grant with full context + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `granter` | [string](#string) | | | +| `grantee` | [string](#string) | | | +| `allowance` | [google.protobuf.Any](#google.protobuf.Any) | | | + + + + + + + + +### PeriodicFeeAllowance +PeriodicFeeAllowance extends FeeAllowance to allow for both a maximum cap, +as well as a limit per time period. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `basic` | [BasicFeeAllowance](#cosmos.fee_grant.v1beta1.BasicFeeAllowance) | | | +| `period` | [Duration](#cosmos.fee_grant.v1beta1.Duration) | | | +| `period_spend_limit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `period_can_spend` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `period_reset` | [ExpiresAt](#cosmos.fee_grant.v1beta1.ExpiresAt) | | | + + + + + + + + + + + + + + + + +

Top

+ +## cosmos/fee_grant/v1beta1/genesis.proto + + + + + +### GenesisState +GenesisState contains a set of fee allowances, persisted from the store + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `fee_allowances` | [FeeAllowanceGrant](#cosmos.fee_grant.v1beta1.FeeAllowanceGrant) | repeated | | + + + + + + + + + + + + + + + + +

Top

+ +## cosmos/fee_grant/v1beta1/query.proto + + + + + +### QueryFeeAllowanceRequest +QueryFeeAllowanceRequest is the request type for the Query/FeeAllowance RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `granter` | [string](#string) | | | +| `grantee` | [string](#string) | | | + + + + + + + + +### QueryFeeAllowanceResponse +QueryFeeAllowanceResponse is the response type for the Query/FeeAllowance RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `fee_allowance` | [FeeAllowanceGrant](#cosmos.fee_grant.v1beta1.FeeAllowanceGrant) | | fee_allowance is a fee_allowance granted for grantee by granter. | + + + + + + + + +### QueryFeeAllowancesRequest +QueryFeeAllowancesRequest is the request type for the Query/FeeAllowances RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `grantee` | [string](#string) | | | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an pagination for the request. | + + + + + + + + +### QueryFeeAllowancesResponse +QueryFeeAllowancesResponse is the response type for the Query/FeeAllowances RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `fee_allowances` | [FeeAllowanceGrant](#cosmos.fee_grant.v1beta1.FeeAllowanceGrant) | repeated | fee_allowance is a fee_allowance granted for grantee by granter. | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines an pagination for the response. | + + + + + + + + + + + + + + +### Query +Query defines the gRPC querier service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `FeeAllowance` | [QueryFeeAllowanceRequest](#cosmos.fee_grant.v1beta1.QueryFeeAllowanceRequest) | [QueryFeeAllowanceResponse](#cosmos.fee_grant.v1beta1.QueryFeeAllowanceResponse) | FeeAllowance returns fee granted to the grantee by the granter. | GET|/cosmos/feegrant/v1beta1/fee_allowance/{granter}/{grantee}| +| `FeeAllowances` | [QueryFeeAllowancesRequest](#cosmos.fee_grant.v1beta1.QueryFeeAllowancesRequest) | [QueryFeeAllowancesResponse](#cosmos.fee_grant.v1beta1.QueryFeeAllowancesResponse) | FeeAllowances returns all the grants for address. | GET|/cosmos/feegrant/v1beta1/fee_allowances/{grantee}| + + + + + + +

Top

+ +## cosmos/fee_grant/v1beta1/tx.proto + + + + + +### MsgGrantFeeAllowance +MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance +of fees from the account of Granter. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `granter` | [string](#string) | | | +| `grantee` | [string](#string) | | | +| `allowance` | [google.protobuf.Any](#google.protobuf.Any) | | | + + + + + + + + +### MsgGrantFeeAllowanceResponse +MsgGrantFeeAllowanceResponse defines the Msg/GrantFeeAllowanceResponse response type. + + + + + + + + +### MsgRevokeFeeAllowance +MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `granter` | [string](#string) | | | +| `grantee` | [string](#string) | | | + + + + + + + + +### MsgRevokeFeeAllowanceResponse +MsgRevokeFeeAllowanceResponse defines the Msg/RevokeFeeAllowanceResponse response type. + + + + + + + + + + + + + + +### Msg +Msg defines the feegrant msg service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `GrantFeeAllowance` | [MsgGrantFeeAllowance](#cosmos.fee_grant.v1beta1.MsgGrantFeeAllowance) | [MsgGrantFeeAllowanceResponse](#cosmos.fee_grant.v1beta1.MsgGrantFeeAllowanceResponse) | GrantFeeAllowance grants fee allowance to the grantee on the granter's account with the provided expiration time. | | +| `RevokeFeeAllowance` | [MsgRevokeFeeAllowance](#cosmos.fee_grant.v1beta1.MsgRevokeFeeAllowance) | [MsgRevokeFeeAllowanceResponse](#cosmos.fee_grant.v1beta1.MsgRevokeFeeAllowanceResponse) | RevokeFeeAllowance revokes any fee allowance of granter's account that has been granted to the grantee. | | + + + + +

Top

diff --git a/go.mod b/go.mod index 185962ff44a6..45910d641e33 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,7 @@ require ( github.com/prometheus/client_golang v1.8.0 github.com/prometheus/common v0.15.0 github.com/rakyll/statik v0.1.7 - github.com/regen-network/cosmos-proto v0.3.0 + github.com/regen-network/cosmos-proto v0.3.1 github.com/rs/zerolog v1.20.0 github.com/spf13/afero v1.3.4 // indirect github.com/spf13/cast v1.3.1 @@ -50,7 +50,7 @@ require ( github.com/tendermint/tm-db v0.6.3 golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad golang.org/x/net v0.0.0-20200930145003-4acb6c075d10 // indirect - google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d + google.golang.org/genproto v0.0.0-20210114201628-6edceaf6022f google.golang.org/grpc v1.33.2 google.golang.org/protobuf v1.25.0 gopkg.in/yaml.v2 v2.4.0 diff --git a/go.sum b/go.sum index b9231e178ea5..476cb9b085b5 100644 --- a/go.sum +++ b/go.sum @@ -478,8 +478,8 @@ github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Ung github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 h1:MkV+77GLUNo5oJ0jf870itWm3D0Sjh7+Za9gazKc5LQ= github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/regen-network/cosmos-proto v0.3.0 h1:24dVpPrPi0GDoPVLesf2Ug98iK5QgVscPl0ga4Eoub0= -github.com/regen-network/cosmos-proto v0.3.0/go.mod h1:zuP2jVPHab6+IIyOx3nXHFN+euFNeS3W8XQkcdd4s7A= +github.com/regen-network/cosmos-proto v0.3.1 h1:rV7iM4SSFAagvy8RiyhiACbWEGotmqzywPxOvwMdxcg= +github.com/regen-network/cosmos-proto v0.3.1/go.mod h1:jO0sVX6a1B36nmE8C9xBFXpNwWejXC7QqCOnH3O0+YM= github.com/regen-network/protobuf v1.3.2-alpha.regen.4 h1:c9jEnU+xm6vqyrQe3M94UFWqiXxRIKKnqBOh2EACmBE= github.com/regen-network/protobuf v1.3.2-alpha.regen.4/go.mod h1:/J8/bR1T/NXyIdQDLUaq15LjNE83nRzkyrLAMcPewig= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= @@ -789,8 +789,8 @@ google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20201111145450-ac7456db90a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201119123407-9b1e624d6bc4 h1:Rt0FRalMgdSlXAVJvX4pr65KfqaxHXSLkSJRD9pw6g0= google.golang.org/genproto v0.0.0-20201119123407-9b1e624d6bc4/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d h1:HV9Z9qMhQEsdlvxNFELgQ11RkMzO3CMkjEySjCtuLes= -google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210114201628-6edceaf6022f h1:izedQ6yVIc5mZsRuXzmSreCOlzI0lCU1HpG8yEdMiKw= +google.golang.org/genproto v0.0.0-20210114201628-6edceaf6022f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= diff --git a/proto/cosmos/fee_grant/v1beta1/fee_grant.proto b/proto/cosmos/fee_grant/v1beta1/fee_grant.proto old mode 100644 new mode 100755 index 878a0fe9ae54..b44f89a12757 --- a/proto/cosmos/fee_grant/v1beta1/fee_grant.proto +++ b/proto/cosmos/fee_grant/v1beta1/fee_grant.proto @@ -6,6 +6,7 @@ import "google/protobuf/any.proto"; import "cosmos_proto/cosmos.proto"; import "cosmos/base/v1beta1/coin.proto"; import "google/protobuf/timestamp.proto"; +import "google/protobuf/duration.proto"; option go_package = "github.com/cosmos/cosmos-sdk/x/fee_grant/types"; @@ -37,17 +38,21 @@ message PeriodicFeeAllowance { // Duration is a repeating unit of either clock time or number of blocks. // This is designed to be added to an ExpiresAt struct. message Duration { - - google.protobuf.Timestamp clock = 1 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; - int64 block = 2; + // sum is the oneof that represents either duration or block + oneof sum { + google.protobuf.Duration duration = 1 [(gogoproto.stdduration) = true]; + int64 block = 2; + } } // ExpiresAt is a point in time where something expires. // It may be *either* block time or block height message ExpiresAt { - - google.protobuf.Timestamp time = 1 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; - int64 height = 2; + // sum is the oneof that represents either time or height + oneof sum { + google.protobuf.Timestamp time = 1 [(gogoproto.stdtime) = true]; + int64 height = 2; + } } // FeeAllowanceGrant is stored in the KVStore to record a grant with full context diff --git a/x/fee_grant/genesis_test.go b/x/fee_grant/genesis_test.go index 82f1e17ab56a..24a7b7a378b7 100644 --- a/x/fee_grant/genesis_test.go +++ b/x/fee_grant/genesis_test.go @@ -36,9 +36,8 @@ var ( func (suite *GenesisTestSuite) TestImportExportGenesis() { coins := sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1_000))) now := suite.ctx.BlockHeader().Time - allowance := &types.BasicFeeAllowance{SpendLimit: coins, Expiration: types.ExpiresAt{ - Time: now.AddDate(1, 0, 0), - }} + + allowance := &types.BasicFeeAllowance{SpendLimit: coins, Expiration: types.ExpiresAtTime(now.AddDate(1, 0, 0))} suite.keeper.GrantFeeAllowance(suite.ctx, granterAddr, granteeAddr, allowance) genesis, err := feegrant.ExportGenesis(suite.ctx, suite.keeper) suite.Require().NoError(err) diff --git a/x/fee_grant/types/basic_fee.go b/x/fee_grant/types/basic_fee.go index 52c079ca64ee..173ff7b9260d 100644 --- a/x/fee_grant/types/basic_fee.go +++ b/x/fee_grant/types/basic_fee.go @@ -20,7 +20,7 @@ var _ FeeAllowanceI = (*BasicFeeAllowance)(nil) // If remove is true (regardless of the error), the FeeAllowance will be deleted from storage // (eg. when it is used up). (See call to RevokeFeeAllowance in Keeper.UseGrantedFees) func (a *BasicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockHeight int64) (bool, error) { - if a.Expiration.IsExpired(blockTime, blockHeight) { + if a.Expiration.IsExpired(&blockTime, blockHeight) { return true, sdkerrors.Wrap(ErrFeeLimitExpired, "basic allowance") } diff --git a/x/fee_grant/types/expiration.go b/x/fee_grant/types/expiration.go index 2bfdc3e412d0..429695d12905 100644 --- a/x/fee_grant/types/expiration.go +++ b/x/fee_grant/types/expiration.go @@ -8,21 +8,29 @@ import ( // ExpiresAtTime creates an expiration at the given time func ExpiresAtTime(t time.Time) ExpiresAt { - return ExpiresAt{Time: t} + return ExpiresAt{ + Sum: &ExpiresAt_Time{ + Time: &t, + }, + } } // ExpiresAtHeight creates an expiration at the given height func ExpiresAtHeight(h int64) ExpiresAt { - return ExpiresAt{Height: h} + return ExpiresAt{ + &ExpiresAt_Height{ + Height: h, + }, + } } // ValidateBasic performs basic sanity checks. // Note that empty expiration is allowed func (e ExpiresAt) ValidateBasic() error { - if !e.Time.IsZero() && e.Height != 0 { + if e.GetTime() != nil && !e.GetTime().IsZero() && e.GetHeight() != 0 { return sdkerrors.Wrap(ErrInvalidDuration, "both time and height are set") } - if e.Height < 0 { + if e.GetHeight() < 0 { return sdkerrors.Wrap(ErrInvalidDuration, "negative height") } return nil @@ -30,13 +38,13 @@ func (e ExpiresAt) ValidateBasic() error { // IsZero returns true for an uninitialized struct func (e ExpiresAt) IsZero() bool { - return e.Time.IsZero() && e.Height == 0 + return e.GetTime() == nil && e.GetHeight() == 0 } // FastForward produces a new Expiration with the time or height set to the // new value, depending on what was set on the original expiration func (e ExpiresAt) FastForward(t time.Time, h int64) ExpiresAt { - if !e.Time.IsZero() { + if e.GetTime() != nil && !e.GetTime().IsZero() { return ExpiresAtTime(t) } return ExpiresAtHeight(h) @@ -47,34 +55,36 @@ func (e ExpiresAt) FastForward(t time.Time, h int64) ExpiresAt { // an exact match. // // Note a "zero" ExpiresAt is never expired -func (e ExpiresAt) IsExpired(t time.Time, h int64) bool { - if !e.Time.IsZero() && !t.Before(e.Time) { +func (e ExpiresAt) IsExpired(t *time.Time, h int64) bool { + if e.GetTime() != nil && !e.GetTime().IsZero() && !t.Before(*e.GetTime()) { return true } - return e.Height != 0 && h >= e.Height + + return e.GetHeight() != 0 && h >= e.GetHeight() } // IsCompatible returns true iff the two use the same units. // If false, they cannot be added. func (e ExpiresAt) IsCompatible(d Duration) bool { - if !e.Time.IsZero() { - return d.Clock > 0 + if e.GetTime() != nil && !e.GetTime().IsZero() { + return d.GetDuration() != nil && d.GetDuration().Seconds() > float64(0) } - return d.Block > 0 + return d.GetBlock() > 0 } // Step will increase the expiration point by one Duration // It returns an error if the Duration is incompatible func (e ExpiresAt) Step(d Duration) (ExpiresAt, error) { + exp := ExpiresAt{} if !e.IsCompatible(d) { return ExpiresAt{}, sdkerrors.Wrap(ErrInvalidDuration, "expiration time and provided duration have different units") } - if !e.Time.IsZero() { - e.Time = e.Time.Add(d.Clock) + if e.GetTime() != nil && !e.GetTime().IsZero() { + exp = ExpiresAtTime(e.GetTime().Add(*d.GetDuration())) } else { - e.Height += d.Block + exp = ExpiresAtHeight(e.GetHeight() + d.GetBlock()) } - return e, nil + return exp, nil } // MustStep is like Step, but panics on error @@ -89,35 +99,40 @@ func (e ExpiresAt) MustStep(d Duration) ExpiresAt { // PrepareForExport will deduct the dumpHeight from the expiration, so when this is // reloaded after a hard fork, the actual number of allowed blocks is constant func (e ExpiresAt) PrepareForExport(dumpTime time.Time, dumpHeight int64) ExpiresAt { - if e.Height != 0 { - e.Height -= dumpHeight + exp := ExpiresAt{} + if e.GetHeight() != 0 { + exp = ExpiresAtHeight(e.GetHeight() - dumpHeight) } - return e + return exp } // ClockDuration creates an Duration by clock time func ClockDuration(d time.Duration) Duration { - return Duration{Clock: d} + return Duration{Sum: &Duration_Duration{ + Duration: &d, + }} } // BlockDuration creates an Duration by block height func BlockDuration(h int64) Duration { - return Duration{Block: h} + return Duration{Sum: &Duration_Block{ + Block: h, + }} } // ValidateBasic performs basic sanity checks // Note that exactly one must be set and it must be positive func (d Duration) ValidateBasic() error { - if d.Block == 0 && d.Clock == 0 { + if d.GetBlock() == 0 && d.GetDuration() == nil { return sdkerrors.Wrap(ErrInvalidDuration, "neither time and height are set") } - if d.Block != 0 && d.Clock != 0 { + if d.GetBlock() != 0 && d.GetDuration() != nil && d.GetDuration().Seconds() != float64(0) { return sdkerrors.Wrap(ErrInvalidDuration, "both time and height are set") } - if d.Block < 0 { + if d.GetBlock() < 0 { return sdkerrors.Wrap(ErrInvalidDuration, "negative block step") } - if d.Clock < 0 { + if d.GetDuration() != nil && d.GetDuration().Seconds() < 0 { return sdkerrors.Wrap(ErrInvalidDuration, "negative clock step") } return nil diff --git a/x/fee_grant/types/expiration_test.go b/x/fee_grant/types/expiration_test.go index 5e7b1749ea76..95d3e1cbc842 100644 --- a/x/fee_grant/types/expiration_test.go +++ b/x/fee_grant/types/expiration_test.go @@ -22,30 +22,26 @@ func TestExpiresAt(t *testing.T) { "basic": { example: types.ExpiresAtHeight(100), valid: true, - before: types.ExpiresAt{Height: 50, Time: now}, - after: types.ExpiresAt{Height: 122, Time: now}, + before: types.ExpiresAtHeight(50), + after: types.ExpiresAtHeight(122), }, "zero": { example: types.ExpiresAt{}, zero: true, valid: true, - before: types.ExpiresAt{Height: 1}, - }, - "double": { - example: types.ExpiresAt{Height: 100, Time: now}, - valid: false, + before: types.ExpiresAtHeight(1), }, "match height": { example: types.ExpiresAtHeight(1000), valid: true, - before: types.ExpiresAt{Height: 999, Time: now}, - after: types.ExpiresAt{Height: 1000, Time: now}, + before: types.ExpiresAtHeight(999), + after: types.ExpiresAtHeight(1000), }, "match time": { example: types.ExpiresAtTime(now), valid: true, - before: types.ExpiresAt{Height: 43, Time: now.Add(-1 * time.Second)}, - after: types.ExpiresAt{Height: 76, Time: now}, + before: types.ExpiresAtTime(now.Add(-1 * time.Second)), + after: types.ExpiresAtTime(now), }, } @@ -61,10 +57,10 @@ func TestExpiresAt(t *testing.T) { require.NoError(t, err) if !tc.before.IsZero() { - assert.Equal(t, false, tc.example.IsExpired(tc.before.Time, tc.before.Height)) + assert.Equal(t, false, tc.example.IsExpired(tc.before.GetTime(), tc.before.GetHeight())) } if !tc.after.IsZero() { - assert.Equal(t, true, tc.example.IsExpired(tc.after.Time, tc.after.Height)) + assert.Equal(t, true, tc.example.IsExpired(tc.after.GetTime(), tc.after.GetHeight())) } }) } @@ -95,10 +91,6 @@ func TestDurationValid(t *testing.T) { period: types.Duration{}, valid: false, }, - "double": { - period: types.Duration{Block: 100, Clock: time.Hour}, - valid: false, - }, "negative clock": { period: types.ClockDuration(-1 * time.Hour), valid: false, diff --git a/x/fee_grant/types/fee_grant.pb.go b/x/fee_grant/types/fee_grant.pb.go index 093d9acb54e8..79c98c7a25bb 100644 --- a/x/fee_grant/types/fee_grant.pb.go +++ b/x/fee_grant/types/fee_grant.pb.go @@ -11,6 +11,7 @@ import ( _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + _ "github.com/golang/protobuf/ptypes/duration" _ "github.com/golang/protobuf/ptypes/timestamp" _ "github.com/regen-network/cosmos-proto" io "io" @@ -166,8 +167,12 @@ func (m *PeriodicFeeAllowance) GetPeriodReset() ExpiresAt { // Duration is a repeating unit of either clock time or number of blocks. // This is designed to be added to an ExpiresAt struct. type Duration struct { - Clock time.Duration `protobuf:"bytes,1,opt,name=clock,proto3,stdduration" json:"clock"` - Block int64 `protobuf:"varint,2,opt,name=block,proto3" json:"block,omitempty"` + // sum is the oneof that represents either duration or block + // + // Types that are valid to be assigned to Sum: + // *Duration_Duration + // *Duration_Block + Sum isDuration_Sum `protobuf_oneof:"sum"` } func (m *Duration) Reset() { *m = Duration{} } @@ -203,25 +208,60 @@ func (m *Duration) XXX_DiscardUnknown() { var xxx_messageInfo_Duration proto.InternalMessageInfo -func (m *Duration) GetClock() time.Duration { +type isDuration_Sum interface { + isDuration_Sum() + MarshalTo([]byte) (int, error) + Size() int +} + +type Duration_Duration struct { + Duration *time.Duration `protobuf:"bytes,1,opt,name=duration,proto3,oneof,stdduration" json:"duration,omitempty"` +} +type Duration_Block struct { + Block int64 `protobuf:"varint,2,opt,name=block,proto3,oneof" json:"block,omitempty"` +} + +func (*Duration_Duration) isDuration_Sum() {} +func (*Duration_Block) isDuration_Sum() {} + +func (m *Duration) GetSum() isDuration_Sum { if m != nil { - return m.Clock + return m.Sum } - return 0 + return nil +} + +func (m *Duration) GetDuration() *time.Duration { + if x, ok := m.GetSum().(*Duration_Duration); ok { + return x.Duration + } + return nil } func (m *Duration) GetBlock() int64 { - if m != nil { - return m.Block + if x, ok := m.GetSum().(*Duration_Block); ok { + return x.Block } return 0 } +// XXX_OneofWrappers is for the internal use of the proto package. +func (*Duration) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*Duration_Duration)(nil), + (*Duration_Block)(nil), + } +} + // ExpiresAt is a point in time where something expires. // It may be *either* block time or block height type ExpiresAt struct { - Time time.Time `protobuf:"bytes,1,opt,name=time,proto3,stdtime" json:"time"` - Height int64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` + // sum is the oneof that represents either time or height + // + // Types that are valid to be assigned to Sum: + // *ExpiresAt_Time + // *ExpiresAt_Height + Sum isExpiresAt_Sum `protobuf_oneof:"sum"` } func (m *ExpiresAt) Reset() { *m = ExpiresAt{} } @@ -257,20 +297,51 @@ func (m *ExpiresAt) XXX_DiscardUnknown() { var xxx_messageInfo_ExpiresAt proto.InternalMessageInfo -func (m *ExpiresAt) GetTime() time.Time { +type isExpiresAt_Sum interface { + isExpiresAt_Sum() + MarshalTo([]byte) (int, error) + Size() int +} + +type ExpiresAt_Time struct { + Time *time.Time `protobuf:"bytes,1,opt,name=time,proto3,oneof,stdtime" json:"time,omitempty"` +} +type ExpiresAt_Height struct { + Height int64 `protobuf:"varint,2,opt,name=height,proto3,oneof" json:"height,omitempty"` +} + +func (*ExpiresAt_Time) isExpiresAt_Sum() {} +func (*ExpiresAt_Height) isExpiresAt_Sum() {} + +func (m *ExpiresAt) GetSum() isExpiresAt_Sum { if m != nil { - return m.Time + return m.Sum } - return time.Time{} + return nil +} + +func (m *ExpiresAt) GetTime() *time.Time { + if x, ok := m.GetSum().(*ExpiresAt_Time); ok { + return x.Time + } + return nil } func (m *ExpiresAt) GetHeight() int64 { - if m != nil { - return m.Height + if x, ok := m.GetSum().(*ExpiresAt_Height); ok { + return x.Height } return 0 } +// XXX_OneofWrappers is for the internal use of the proto package. +func (*ExpiresAt) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*ExpiresAt_Time)(nil), + (*ExpiresAt_Height)(nil), + } +} + // FeeAllowanceGrant is stored in the KVStore to record a grant with full context type FeeAllowanceGrant struct { Granter string `protobuf:"bytes,1,opt,name=granter,proto3" json:"granter,omitempty"` @@ -345,43 +416,45 @@ func init() { } var fileDescriptor_5dd8ff02de9d10f0 = []byte{ - // 576 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x6e, 0xd3, 0x30, - 0x1c, 0x6f, 0xe8, 0x07, 0xab, 0x0b, 0x88, 0x5a, 0x15, 0xca, 0x7a, 0x48, 0xa7, 0x72, 0xa9, 0x84, - 0xe6, 0xb0, 0x71, 0x41, 0x3b, 0xd1, 0x8c, 0x31, 0x26, 0xed, 0x80, 0x02, 0x27, 0x04, 0xaa, 0x9c, - 0xd4, 0x4b, 0xad, 0xa5, 0x71, 0x14, 0xbb, 0xb0, 0xbe, 0x04, 0xda, 0x91, 0x67, 0xe0, 0xcc, 0x43, - 0x4c, 0x9c, 0x26, 0x4e, 0x9c, 0x28, 0x6a, 0x5f, 0x81, 0x07, 0x40, 0xfe, 0x48, 0x5b, 0x75, 0x14, - 0x31, 0x69, 0xa7, 0xc6, 0xfe, 0xff, 0x7f, 0x1f, 0xff, 0x9f, 0xed, 0x82, 0x4e, 0xc8, 0xf8, 0x90, - 0x71, 0xf7, 0x84, 0x90, 0x5e, 0x94, 0xe1, 0x44, 0xb8, 0x1f, 0x76, 0x02, 0x22, 0xf0, 0xce, 0x62, - 0x07, 0xa5, 0x19, 0x13, 0x0c, 0xda, 0xba, 0x13, 0x2d, 0xf6, 0x4d, 0x67, 0xb3, 0x11, 0xb1, 0x88, - 0xa9, 0x26, 0x57, 0x7e, 0xe9, 0xfe, 0xe6, 0x66, 0xc4, 0x58, 0x14, 0x13, 0x57, 0xad, 0x82, 0xd1, - 0x89, 0x8b, 0x93, 0x71, 0x5e, 0xd2, 0x54, 0x3d, 0x8d, 0x31, 0xbc, 0xba, 0xe4, 0x18, 0x3f, 0x01, - 0xe6, 0x64, 0x6e, 0x25, 0x64, 0x34, 0x31, 0xf5, 0xd6, 0x2a, 0xab, 0xa0, 0x43, 0xc2, 0x05, 0x1e, - 0xa6, 0xba, 0xa1, 0x3d, 0xb1, 0x40, 0xdd, 0xc3, 0x9c, 0x86, 0x2f, 0x08, 0xe9, 0xc6, 0x31, 0xfb, - 0x88, 0x93, 0x90, 0xc0, 0x18, 0xd4, 0x78, 0x4a, 0x92, 0x7e, 0x2f, 0xa6, 0x43, 0x2a, 0x6c, 0x6b, - 0xab, 0xd8, 0xa9, 0xed, 0x6e, 0x22, 0x23, 0x2d, 0xc5, 0xf2, 0x69, 0xd0, 0x3e, 0xa3, 0x89, 0xf7, - 0xf8, 0xe2, 0x67, 0xab, 0xf0, 0x65, 0xd2, 0xea, 0x44, 0x54, 0x0c, 0x46, 0x01, 0x0a, 0xd9, 0xd0, - 0xf8, 0x34, 0x3f, 0xdb, 0xbc, 0x7f, 0xea, 0x8a, 0x71, 0x4a, 0xb8, 0x02, 0x70, 0x1f, 0x28, 0xfe, - 0x63, 0x49, 0x0f, 0x8f, 0x00, 0x20, 0x67, 0x29, 0xcd, 0xb0, 0xa0, 0x2c, 0xb1, 0x6f, 0x6d, 0x59, - 0x9d, 0xda, 0xee, 0x43, 0xb4, 0x2e, 0x3f, 0x74, 0x20, 0x7b, 0x09, 0xef, 0x0a, 0xaf, 0x24, 0x65, - 0xfd, 0x25, 0xf0, 0x5e, 0xfd, 0xfb, 0xd7, 0xed, 0xbb, 0xcb, 0xa3, 0x1c, 0xb5, 0x7f, 0x17, 0x41, - 0xe3, 0x15, 0xc9, 0x28, 0xeb, 0xaf, 0x0c, 0x79, 0x08, 0xca, 0x81, 0x9c, 0xdc, 0xb6, 0x94, 0xe2, - 0xa3, 0xf5, 0x8a, 0x57, 0x02, 0x32, 0xca, 0x1a, 0x0f, 0x9f, 0x81, 0x4a, 0xaa, 0x04, 0x8c, 0xf7, - 0xf6, 0x7a, 0xa6, 0xe7, 0x23, 0x6d, 0xd4, 0x10, 0x18, 0x1c, 0x1c, 0x03, 0xa8, 0xbf, 0x7a, 0xcb, - 0xb1, 0x17, 0x6f, 0x3e, 0xf6, 0xfb, 0x5a, 0xe6, 0xf5, 0x22, 0xfc, 0x11, 0x30, 0x7b, 0xbd, 0x10, - 0x27, 0x5a, 0xde, 0x2e, 0xdd, 0xbc, 0xf0, 0x3d, 0x2d, 0xb2, 0x8f, 0x13, 0xa5, 0x0d, 0x8f, 0xc1, - 0x1d, 0x23, 0x9b, 0x11, 0x4e, 0x84, 0x5d, 0xbe, 0xee, 0xa9, 0xd7, 0x34, 0xdc, 0x97, 0xe8, 0xbf, - 0x1d, 0xfb, 0x3b, 0xb0, 0x91, 0x87, 0x0d, 0xf7, 0x40, 0x39, 0x8c, 0x59, 0x78, 0x6a, 0x4e, 0xba, - 0x89, 0xf4, 0xab, 0x40, 0xf9, 0xab, 0x40, 0x6f, 0xf2, 0x57, 0xe1, 0x6d, 0x48, 0xf2, 0xcf, 0x93, - 0x96, 0xe5, 0x6b, 0x08, 0x6c, 0x80, 0x72, 0xa0, 0xb0, 0xf2, 0x6c, 0x8b, 0xbe, 0x5e, 0xb4, 0xdf, - 0x83, 0xea, 0xdc, 0x10, 0x7c, 0x0a, 0x4a, 0xf2, 0x59, 0xfd, 0x2f, 0xfb, 0xb9, 0x64, 0x57, 0x08, - 0xf8, 0x00, 0x54, 0x06, 0x84, 0x46, 0x03, 0x61, 0xd8, 0xcd, 0xaa, 0xfd, 0xc9, 0x02, 0xf5, 0xe5, - 0x71, 0x0e, 0x65, 0x14, 0xd0, 0x06, 0xb7, 0x55, 0x26, 0x24, 0x53, 0x52, 0x55, 0x3f, 0x5f, 0x2e, - 0x2a, 0x44, 0x11, 0xcd, 0x2b, 0x04, 0x1e, 0x80, 0x2a, 0xce, 0x59, 0xec, 0xa2, 0x32, 0xd8, 0xb8, - 0x62, 0xb0, 0x9b, 0x8c, 0xbd, 0xfa, 0xb7, 0xd5, 0x08, 0xfd, 0x05, 0xd2, 0x7b, 0x79, 0x31, 0x75, - 0xac, 0xcb, 0xa9, 0x63, 0xfd, 0x9a, 0x3a, 0xd6, 0xf9, 0xcc, 0x29, 0x5c, 0xce, 0x9c, 0xc2, 0x8f, - 0x99, 0x53, 0x78, 0x8b, 0xfe, 0x79, 0x05, 0xce, 0x96, 0xfe, 0x29, 0xd5, 0x75, 0x08, 0x2a, 0x4a, - 0xf5, 0xc9, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x93, 0x69, 0x7d, 0x9a, 0x4a, 0x05, 0x00, 0x00, + // 597 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0x86, 0x63, 0x9c, 0x84, 0x66, 0x02, 0x88, 0xac, 0x22, 0xe4, 0xe4, 0xe0, 0x54, 0xe1, 0x12, + 0x09, 0xd5, 0xa6, 0x45, 0xe2, 0x80, 0x84, 0x44, 0x5c, 0x4a, 0x53, 0xa9, 0x07, 0x64, 0x38, 0x71, + 0x89, 0x6c, 0x67, 0xeb, 0x58, 0xb5, 0xbd, 0x96, 0x77, 0x03, 0xcd, 0x4b, 0xa0, 0x1e, 0x79, 0x06, + 0xce, 0x3c, 0x44, 0xc5, 0xa9, 0xe2, 0xc4, 0x89, 0xa0, 0xe4, 0x15, 0x78, 0x00, 0xe4, 0xdd, 0x75, + 0x62, 0x25, 0x04, 0xa9, 0x52, 0x4f, 0xf1, 0xee, 0xce, 0xfc, 0xdf, 0xcc, 0x3f, 0xbb, 0x81, 0x9e, + 0x47, 0x68, 0x44, 0xa8, 0x79, 0x86, 0xf1, 0xd0, 0x4f, 0x9d, 0x98, 0x99, 0x1f, 0xf7, 0x5d, 0xcc, + 0x9c, 0xfd, 0xd5, 0x8e, 0x91, 0xa4, 0x84, 0x11, 0xa4, 0x89, 0x48, 0x63, 0xb5, 0x2f, 0x23, 0xdb, + 0x4d, 0x9f, 0xf8, 0x84, 0x07, 0x99, 0xd9, 0x97, 0x88, 0x6f, 0xb7, 0x7c, 0x42, 0xfc, 0x10, 0x9b, + 0x7c, 0xe5, 0x4e, 0xce, 0x4c, 0x27, 0x9e, 0xe6, 0x47, 0x42, 0x6a, 0x28, 0x72, 0xa4, 0xae, 0x38, + 0xd2, 0x65, 0x3d, 0xae, 0x43, 0xf1, 0xb2, 0x14, 0x8f, 0x04, 0xb1, 0x3c, 0xef, 0xac, 0xab, 0xb2, + 0x20, 0xc2, 0x94, 0x39, 0x51, 0x92, 0x0b, 0xac, 0x07, 0x8c, 0x26, 0xa9, 0xc3, 0x02, 0x22, 0x05, + 0xba, 0x33, 0x05, 0x1a, 0x96, 0x43, 0x03, 0xef, 0x0d, 0xc6, 0xfd, 0x30, 0x24, 0x9f, 0x9c, 0xd8, + 0xc3, 0x28, 0x84, 0x3a, 0x4d, 0x70, 0x3c, 0x1a, 0x86, 0x41, 0x14, 0x30, 0x4d, 0xd9, 0x55, 0x7b, + 0xf5, 0x83, 0x96, 0x21, 0x4b, 0xcb, 0x8a, 0xc9, 0xbb, 0x35, 0x0e, 0x49, 0x10, 0x5b, 0x4f, 0xaf, + 0x7e, 0x75, 0x4a, 0x5f, 0x67, 0x9d, 0x9e, 0x1f, 0xb0, 0xf1, 0xc4, 0x35, 0x3c, 0x12, 0xc9, 0x3e, + 0xe4, 0xcf, 0x1e, 0x1d, 0x9d, 0x9b, 0x6c, 0x9a, 0x60, 0xca, 0x13, 0xa8, 0x0d, 0x5c, 0xff, 0x34, + 0x93, 0x47, 0x27, 0x00, 0xf8, 0x22, 0x09, 0x44, 0x5d, 0xda, 0x9d, 0x5d, 0xa5, 0x57, 0x3f, 0x78, + 0x6c, 0x6c, 0xf3, 0xd7, 0x38, 0xca, 0x62, 0x31, 0xed, 0x33, 0xab, 0x9c, 0x61, 0xed, 0x42, 0xf2, + 0x8b, 0xc6, 0x8f, 0x6f, 0x7b, 0xf7, 0x8b, 0xad, 0x9c, 0x74, 0xff, 0xa8, 0xd0, 0x7c, 0x8b, 0xd3, + 0x80, 0x8c, 0xd6, 0x9a, 0x3c, 0x86, 0x8a, 0x9b, 0x75, 0xae, 0x29, 0x9c, 0xf8, 0x64, 0x3b, 0x71, + 0xc3, 0x20, 0x49, 0x16, 0xf9, 0xe8, 0x15, 0x54, 0x13, 0x0e, 0x90, 0xb5, 0x77, 0xb7, 0x2b, 0xbd, + 0x96, 0xee, 0x4b, 0x01, 0x99, 0x87, 0xa6, 0x80, 0xc4, 0xd7, 0xb0, 0x68, 0xbb, 0x7a, 0xfb, 0xb6, + 0x3f, 0x14, 0x98, 0x77, 0x2b, 0xf3, 0x27, 0x20, 0xf7, 0x86, 0x9e, 0x13, 0x0b, 0xbc, 0x56, 0xbe, + 0x7d, 0xf0, 0x03, 0x01, 0x39, 0x74, 0x62, 0xce, 0x46, 0xa7, 0x70, 0x4f, 0x62, 0x53, 0x4c, 0x31, + 0xd3, 0x2a, 0x37, 0x9d, 0x7a, 0x5d, 0xa4, 0xdb, 0x59, 0xf6, 0xbf, 0xc6, 0x3e, 0x86, 0x9d, 0xdc, + 0x6c, 0xf4, 0x12, 0x76, 0xf2, 0x6b, 0x2f, 0x87, 0xdd, 0x32, 0xc4, 0xbb, 0x30, 0xf2, 0x77, 0x51, + 0x98, 0xcc, 0x97, 0x59, 0x47, 0x19, 0x94, 0xec, 0x65, 0x0a, 0x7a, 0x04, 0x15, 0x37, 0x24, 0xde, + 0x39, 0x1f, 0xaf, 0x3a, 0xc8, 0xe6, 0x9e, 0x2d, 0xad, 0x0a, 0xa8, 0x74, 0x12, 0x75, 0x47, 0x50, + 0x5b, 0x16, 0x87, 0x9e, 0x43, 0x39, 0x7b, 0x82, 0x12, 0xd3, 0xde, 0xc0, 0xbc, 0xcf, 0xdf, 0xa7, + 0x55, 0xbe, 0x14, 0x1c, 0x1e, 0x8f, 0x34, 0xa8, 0x8e, 0x71, 0xe0, 0x8f, 0xd9, 0x12, 0x22, 0xd7, + 0x39, 0xe5, 0xb3, 0x02, 0x8d, 0x62, 0x87, 0xc7, 0x99, 0x3b, 0x48, 0x83, 0xbb, 0xdc, 0x26, 0x9c, + 0x72, 0x62, 0xcd, 0xce, 0x97, 0xab, 0x13, 0xcc, 0x15, 0x97, 0x27, 0x18, 0x1d, 0x41, 0xcd, 0xc9, + 0x55, 0x34, 0x95, 0xd7, 0xd9, 0xdc, 0xa8, 0xb3, 0x1f, 0x4f, 0xad, 0xc6, 0xf7, 0x75, 0x57, 0xed, + 0x55, 0xa6, 0x35, 0xb8, 0x9a, 0xeb, 0xca, 0xf5, 0x5c, 0x57, 0x7e, 0xcf, 0x75, 0xe5, 0x72, 0xa1, + 0x97, 0xae, 0x17, 0x7a, 0xe9, 0xe7, 0x42, 0x2f, 0x7d, 0x30, 0xfe, 0x7b, 0x2b, 0x2e, 0x0a, 0x7f, + 0xae, 0xfc, 0x86, 0xb8, 0x55, 0x4e, 0x7d, 0xf6, 0x37, 0x00, 0x00, 0xff, 0xff, 0x44, 0x7f, 0x07, + 0x7e, 0x7d, 0x05, 0x00, 0x00, } func (m *BasicFeeAllowance) Marshal() (dAtA []byte, err error) { @@ -532,22 +605,49 @@ func (m *Duration) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Block != 0 { - i = encodeVarintFeeGrant(dAtA, i, uint64(m.Block)) - i-- - dAtA[i] = 0x10 + if m.Sum != nil { + { + size := m.Sum.Size() + i -= size + if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } } - n5, err5 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.Clock, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.Clock):]) - if err5 != nil { - return 0, err5 + return len(dAtA) - i, nil +} + +func (m *Duration_Duration) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Duration_Duration) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Duration != nil { + n5, err5 := github_com_gogo_protobuf_types.StdDurationMarshalTo(*m.Duration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(*m.Duration):]) + if err5 != nil { + return 0, err5 + } + i -= n5 + i = encodeVarintFeeGrant(dAtA, i, uint64(n5)) + i-- + dAtA[i] = 0xa } - i -= n5 - i = encodeVarintFeeGrant(dAtA, i, uint64(n5)) - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } +func (m *Duration_Block) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} +func (m *Duration_Block) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + i = encodeVarintFeeGrant(dAtA, i, uint64(m.Block)) + i-- + dAtA[i] = 0x10 + return len(dAtA) - i, nil +} func (m *ExpiresAt) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -568,22 +668,49 @@ func (m *ExpiresAt) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Height != 0 { - i = encodeVarintFeeGrant(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x10 + if m.Sum != nil { + { + size := m.Sum.Size() + i -= size + if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } } - n6, err6 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Time):]) - if err6 != nil { - return 0, err6 + return len(dAtA) - i, nil +} + +func (m *ExpiresAt_Time) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ExpiresAt_Time) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Time != nil { + n6, err6 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.Time, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.Time):]) + if err6 != nil { + return 0, err6 + } + i -= n6 + i = encodeVarintFeeGrant(dAtA, i, uint64(n6)) + i-- + dAtA[i] = 0xa } - i -= n6 - i = encodeVarintFeeGrant(dAtA, i, uint64(n6)) - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } +func (m *ExpiresAt_Height) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} +func (m *ExpiresAt_Height) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + i = encodeVarintFeeGrant(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x10 + return len(dAtA) - i, nil +} func (m *FeeAllowanceGrant) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -694,28 +821,66 @@ func (m *Duration) Size() (n int) { } var l int _ = l - l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.Clock) - n += 1 + l + sovFeeGrant(uint64(l)) - if m.Block != 0 { - n += 1 + sovFeeGrant(uint64(m.Block)) + if m.Sum != nil { + n += m.Sum.Size() } return n } +func (m *Duration_Duration) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Duration != nil { + l = github_com_gogo_protobuf_types.SizeOfStdDuration(*m.Duration) + n += 1 + l + sovFeeGrant(uint64(l)) + } + return n +} +func (m *Duration_Block) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += 1 + sovFeeGrant(uint64(m.Block)) + return n +} func (m *ExpiresAt) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Time) - n += 1 + l + sovFeeGrant(uint64(l)) - if m.Height != 0 { - n += 1 + sovFeeGrant(uint64(m.Height)) + if m.Sum != nil { + n += m.Sum.Size() } return n } +func (m *ExpiresAt_Time) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Time != nil { + l = github_com_gogo_protobuf_types.SizeOfStdTime(*m.Time) + n += 1 + l + sovFeeGrant(uint64(l)) + } + return n +} +func (m *ExpiresAt_Height) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += 1 + sovFeeGrant(uint64(m.Height)) + return n +} func (m *FeeAllowanceGrant) Size() (n int) { if m == nil { return 0 @@ -1114,7 +1279,7 @@ func (m *Duration) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Clock", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1141,15 +1306,17 @@ func (m *Duration) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.Clock, dAtA[iNdEx:postIndex]); err != nil { + v := new(time.Duration) + if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(v, dAtA[iNdEx:postIndex]); err != nil { return err } + m.Sum = &Duration_Duration{v} iNdEx = postIndex case 2: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) } - m.Block = 0 + var v int64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowFeeGrant @@ -1159,11 +1326,12 @@ func (m *Duration) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Block |= int64(b&0x7F) << shift + v |= int64(b&0x7F) << shift if b < 0x80 { break } } + m.Sum = &Duration_Block{v} default: iNdEx = preIndex skippy, err := skipFeeGrant(dAtA[iNdEx:]) @@ -1246,15 +1414,17 @@ func (m *ExpiresAt) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.Time, dAtA[iNdEx:postIndex]); err != nil { + v := new(time.Time) + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(v, dAtA[iNdEx:postIndex]); err != nil { return err } + m.Sum = &ExpiresAt_Time{v} iNdEx = postIndex case 2: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) } - m.Height = 0 + var v int64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowFeeGrant @@ -1264,11 +1434,12 @@ func (m *ExpiresAt) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= int64(b&0x7F) << shift + v |= int64(b&0x7F) << shift if b < 0x80 { break } } + m.Sum = &ExpiresAt_Height{v} default: iNdEx = preIndex skippy, err := skipFeeGrant(dAtA[iNdEx:]) diff --git a/x/fee_grant/types/periodic_fee.go b/x/fee_grant/types/periodic_fee.go index 8108a70f4402..6548a4ea7c64 100644 --- a/x/fee_grant/types/periodic_fee.go +++ b/x/fee_grant/types/periodic_fee.go @@ -20,7 +20,7 @@ var _ FeeAllowanceI = (*PeriodicFeeAllowance)(nil) // If remove is true (regardless of the error), the FeeAllowance will be deleted from storage // (eg. when it is used up). (See call to RevokeFeeAllowance in Keeper.UseGrantedFees) func (a *PeriodicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockHeight int64) (bool, error) { - if a.Basic.Expiration.IsExpired(blockTime, blockHeight) { + if a.Basic.Expiration.IsExpired(&blockTime, blockHeight) { return true, sdkerrors.Wrap(ErrFeeLimitExpired, "absolute limit") } @@ -47,7 +47,7 @@ func (a *PeriodicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockH // last PeriodReset (eg. if you always do one tx per day, it will always reset the same time) // If we are more then one period out (eg. no activity in a week), reset is one Period from the execution of this method func (a *PeriodicFeeAllowance) TryResetPeriod(blockTime time.Time, blockHeight int64) { - if !a.PeriodReset.IsZero() && !a.PeriodReset.IsExpired(blockTime, blockHeight) { + if !a.PeriodReset.IsZero() && !a.PeriodReset.IsExpired(&blockTime, blockHeight) { return } // set CanSpend to the lesser of PeriodSpendLimit and the TotalLimit @@ -60,7 +60,7 @@ func (a *PeriodicFeeAllowance) TryResetPeriod(blockTime time.Time, blockHeight i // If we are within the period, step from expiration (eg. if you always do one tx per day, it will always reset the same time) // If we are more then one period out (eg. no activity in a week), reset is one period from this time a.PeriodReset = a.PeriodReset.MustStep(a.Period) - if a.PeriodReset.IsExpired(blockTime, blockHeight) { + if a.PeriodReset.IsExpired(&blockTime, blockHeight) { a.PeriodReset = a.PeriodReset.FastForward(blockTime, blockHeight).MustStep(a.Period) } } From 35bd132a1aea68d2a815527b5c91fba4aea1d04f Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 18 Jan 2021 16:14:39 +0530 Subject: [PATCH 152/184] fix test --- go.mod | 1 - go.sum | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 91297e54c149..10577caa095a 100644 --- a/go.mod +++ b/go.mod @@ -49,7 +49,6 @@ require ( github.com/tendermint/tendermint v0.34.2 github.com/tendermint/tm-db v0.6.3 golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad - golang.org/x/net v0.0.0-20200930145003-4acb6c075d10 // indirect google.golang.org/genproto v0.0.0-20210114201628-6edceaf6022f google.golang.org/grpc v1.33.2 google.golang.org/protobuf v1.25.0 diff --git a/go.sum b/go.sum index 85003747156b..066d94520d06 100644 --- a/go.sum +++ b/go.sum @@ -480,8 +480,8 @@ github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 h1:MkV+77GLUNo github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/regen-network/cosmos-proto v0.3.1 h1:rV7iM4SSFAagvy8RiyhiACbWEGotmqzywPxOvwMdxcg= github.com/regen-network/cosmos-proto v0.3.1/go.mod h1:jO0sVX6a1B36nmE8C9xBFXpNwWejXC7QqCOnH3O0+YM= -github.com/regen-network/protobuf v1.3.2-alpha.regen.4 h1:c9jEnU+xm6vqyrQe3M94UFWqiXxRIKKnqBOh2EACmBE= -github.com/regen-network/protobuf v1.3.2-alpha.regen.4/go.mod h1:/J8/bR1T/NXyIdQDLUaq15LjNE83nRzkyrLAMcPewig= +github.com/regen-network/protobuf v1.3.3-alpha.regen.1 h1:OHEc+q5iIAXpqiqFKeLpu5NwTIkVXUs48vFMwzqpqY4= +github.com/regen-network/protobuf v1.3.3-alpha.regen.1/go.mod h1:2DjTFR1HhMQhiWC5sZ4OhQ3+NtdbZ6oBDKQwq5Ou+FI= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= From b0299a4a7537a46638bb0984224a27a5032cc8f1 Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 18 Jan 2021 16:21:41 +0530 Subject: [PATCH 153/184] fix lint --- x/fee_grant/types/expiration.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x/fee_grant/types/expiration.go b/x/fee_grant/types/expiration.go index 429695d12905..e7483b6e945d 100644 --- a/x/fee_grant/types/expiration.go +++ b/x/fee_grant/types/expiration.go @@ -75,9 +75,9 @@ func (e ExpiresAt) IsCompatible(d Duration) bool { // Step will increase the expiration point by one Duration // It returns an error if the Duration is incompatible func (e ExpiresAt) Step(d Duration) (ExpiresAt, error) { - exp := ExpiresAt{} + var exp ExpiresAt if !e.IsCompatible(d) { - return ExpiresAt{}, sdkerrors.Wrap(ErrInvalidDuration, "expiration time and provided duration have different units") + return exp, sdkerrors.Wrap(ErrInvalidDuration, "expiration time and provided duration have different units") } if e.GetTime() != nil && !e.GetTime().IsZero() { exp = ExpiresAtTime(e.GetTime().Add(*d.GetDuration())) @@ -99,7 +99,7 @@ func (e ExpiresAt) MustStep(d Duration) ExpiresAt { // PrepareForExport will deduct the dumpHeight from the expiration, so when this is // reloaded after a hard fork, the actual number of allowed blocks is constant func (e ExpiresAt) PrepareForExport(dumpTime time.Time, dumpHeight int64) ExpiresAt { - exp := ExpiresAt{} + var exp ExpiresAt if e.GetHeight() != 0 { exp = ExpiresAtHeight(e.GetHeight() - dumpHeight) } From 67014336712514d56ea481beca21bac31f46a109 Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 19 Jan 2021 12:09:24 +0530 Subject: [PATCH 154/184] changed package name `feegrant` to `fee_grant` --- .../v1beta1/feegrant.proto} | 4 +- .../v1beta1/genesis.proto | 6 +- .../v1beta1/query.proto | 10 +- .../{fee_grant => feegrant}/v1beta1/tx.proto | 4 +- simapp/ante.go | 6 +- simapp/app.go | 6 +- x/{fee_grant => feegrant}/ante/fee.go | 4 +- x/{fee_grant => feegrant}/ante/fee_test.go | 4 +- .../client/cli/cli_test.go | 4 +- x/{fee_grant => feegrant}/client/cli/query.go | 2 +- .../client/cli/service_msg_client.go | 0 x/{fee_grant => feegrant}/client/cli/tx.go | 2 +- .../client/rest/grpc_query_test.go | 4 +- x/{fee_grant => feegrant}/doc.go | 0 x/{fee_grant => feegrant}/genesis.go | 4 +- x/{fee_grant => feegrant}/genesis_test.go | 6 +- .../keeper/grpc_query.go | 2 +- x/{fee_grant => feegrant}/keeper/keeper.go | 2 +- .../keeper/keeper_test.go | 2 +- .../keeper/msg_server.go | 2 +- x/{fee_grant => feegrant}/module.go | 8 +- .../simulation/decoder.go | 2 +- .../simulation/decoder_test.go | 4 +- .../simulation/genesis.go | 2 +- .../simulation/genesis_test.go | 4 +- .../simulation/operations.go | 8 +- .../simulation/operations_test.go | 4 +- x/{fee_grant => feegrant}/types/basic_fee.go | 0 .../types/basic_fee_test.go | 2 +- x/{fee_grant => feegrant}/types/codec.go | 0 x/{fee_grant => feegrant}/types/errors.go | 0 x/{fee_grant => feegrant}/types/events.go | 0 .../types/expected_keepers.go | 0 x/{fee_grant => feegrant}/types/expiration.go | 0 .../types/expiration_test.go | 2 +- .../types/feegrant.pb.go} | 325 +++++++++--------- x/{fee_grant => feegrant}/types/fees.go | 0 x/{fee_grant => feegrant}/types/genesis.go | 0 x/{fee_grant => feegrant}/types/genesis.pb.go | 45 ++- x/{fee_grant => feegrant}/types/grant.go | 0 x/{fee_grant => feegrant}/types/grant_test.go | 2 +- x/{fee_grant => feegrant}/types/key.go | 0 x/{fee_grant => feegrant}/types/msgs.go | 0 .../types/periodic_fee.go | 0 .../types/periodic_fee_test.go | 2 +- x/{fee_grant => feegrant}/types/query.pb.go | 114 +++--- .../types/query.pb.gw.go | 2 +- x/{fee_grant => feegrant}/types/tx.pb.go | 100 +++--- 48 files changed, 329 insertions(+), 371 deletions(-) rename proto/cosmos/{fee_grant/v1beta1/fee_grant.proto => feegrant/v1beta1/feegrant.proto} (95%) rename proto/cosmos/{fee_grant => feegrant}/v1beta1/genesis.proto (59%) rename proto/cosmos/{fee_grant => feegrant}/v1beta1/query.proto (84%) rename proto/cosmos/{fee_grant => feegrant}/v1beta1/tx.proto (92%) rename x/{fee_grant => feegrant}/ante/fee.go (96%) rename x/{fee_grant => feegrant}/ante/fee_test.go (99%) rename x/{fee_grant => feegrant}/client/cli/cli_test.go (98%) rename x/{fee_grant => feegrant}/client/cli/query.go (98%) rename x/{fee_grant => feegrant}/client/cli/service_msg_client.go (100%) rename x/{fee_grant => feegrant}/client/cli/tx.go (99%) rename x/{fee_grant => feegrant}/client/rest/grpc_query_test.go (98%) rename x/{fee_grant => feegrant}/doc.go (100%) rename x/{fee_grant => feegrant}/genesis.go (94%) rename x/{fee_grant => feegrant}/genesis_test.go (91%) rename x/{fee_grant => feegrant}/keeper/grpc_query.go (98%) rename x/{fee_grant => feegrant}/keeper/keeper.go (99%) rename x/{fee_grant => feegrant}/keeper/keeper_test.go (99%) rename x/{fee_grant => feegrant}/keeper/msg_server.go (97%) rename x/{fee_grant => feegrant}/module.go (97%) rename x/{fee_grant => feegrant}/simulation/decoder.go (93%) rename x/{fee_grant => feegrant}/simulation/decoder_test.go (93%) rename x/{fee_grant => feegrant}/simulation/genesis.go (95%) rename x/{fee_grant => feegrant}/simulation/genesis_test.go (90%) rename x/{fee_grant => feegrant}/simulation/operations.go (96%) rename x/{fee_grant => feegrant}/simulation/operations_test.go (97%) rename x/{fee_grant => feegrant}/types/basic_fee.go (100%) rename x/{fee_grant => feegrant}/types/basic_fee_test.go (97%) rename x/{fee_grant => feegrant}/types/codec.go (100%) rename x/{fee_grant => feegrant}/types/errors.go (100%) rename x/{fee_grant => feegrant}/types/events.go (100%) rename x/{fee_grant => feegrant}/types/expected_keepers.go (100%) rename x/{fee_grant => feegrant}/types/expiration.go (100%) rename x/{fee_grant => feegrant}/types/expiration_test.go (98%) rename x/{fee_grant/types/fee_grant.pb.go => feegrant/types/feegrant.pb.go} (79%) rename x/{fee_grant => feegrant}/types/fees.go (100%) rename x/{fee_grant => feegrant}/types/genesis.go (100%) rename x/{fee_grant => feegrant}/types/genesis.pb.go (80%) rename x/{fee_grant => feegrant}/types/grant.go (100%) rename x/{fee_grant => feegrant}/types/grant_test.go (97%) rename x/{fee_grant => feegrant}/types/key.go (100%) rename x/{fee_grant => feegrant}/types/msgs.go (100%) rename x/{fee_grant => feegrant}/types/periodic_fee.go (100%) rename x/{fee_grant => feegrant}/types/periodic_fee_test.go (99%) rename x/{fee_grant => feegrant}/types/query.pb.go (87%) rename x/{fee_grant => feegrant}/types/query.pb.gw.go (99%) rename x/{fee_grant => feegrant}/types/tx.pb.go (87%) diff --git a/proto/cosmos/fee_grant/v1beta1/fee_grant.proto b/proto/cosmos/feegrant/v1beta1/feegrant.proto similarity index 95% rename from proto/cosmos/fee_grant/v1beta1/fee_grant.proto rename to proto/cosmos/feegrant/v1beta1/feegrant.proto index b44f89a12757..a3b74b6f257d 100755 --- a/proto/cosmos/fee_grant/v1beta1/fee_grant.proto +++ b/proto/cosmos/feegrant/v1beta1/feegrant.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package cosmos.fee_grant.v1beta1; +package cosmos.feegrant.v1beta1; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; @@ -8,7 +8,7 @@ import "cosmos/base/v1beta1/coin.proto"; import "google/protobuf/timestamp.proto"; import "google/protobuf/duration.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/x/fee_grant/types"; +option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; // BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens // that optionally expires. The delegatee can use up to SpendLimit to cover fees. diff --git a/proto/cosmos/fee_grant/v1beta1/genesis.proto b/proto/cosmos/feegrant/v1beta1/genesis.proto similarity index 59% rename from proto/cosmos/fee_grant/v1beta1/genesis.proto rename to proto/cosmos/feegrant/v1beta1/genesis.proto index 6c0b5e3b91b5..9460a27d42cc 100644 --- a/proto/cosmos/fee_grant/v1beta1/genesis.proto +++ b/proto/cosmos/feegrant/v1beta1/genesis.proto @@ -1,10 +1,10 @@ syntax = "proto3"; -package cosmos.fee_grant.v1beta1; +package cosmos.feegrant.v1beta1; import "gogoproto/gogo.proto"; -import "cosmos/fee_grant/v1beta1/fee_grant.proto"; +import "cosmos/feegrant/v1beta1/feegrant.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/x/fee_grant/types"; +option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; // GenesisState contains a set of fee allowances, persisted from the store message GenesisState { diff --git a/proto/cosmos/fee_grant/v1beta1/query.proto b/proto/cosmos/feegrant/v1beta1/query.proto similarity index 84% rename from proto/cosmos/fee_grant/v1beta1/query.proto rename to proto/cosmos/feegrant/v1beta1/query.proto index d22002d6348b..d0b5622c6fea 100644 --- a/proto/cosmos/fee_grant/v1beta1/query.proto +++ b/proto/cosmos/feegrant/v1beta1/query.proto @@ -1,12 +1,12 @@ syntax = "proto3"; -package cosmos.fee_grant.v1beta1; +package cosmos.feegrant.v1beta1; import "gogoproto/gogo.proto"; -import "cosmos/fee_grant/v1beta1/fee_grant.proto"; +import "cosmos/feegrant/v1beta1/feegrant.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "google/api/annotations.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/x/fee_grant/types"; +option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; // Query defines the gRPC querier service. service Query { @@ -30,7 +30,7 @@ message QueryFeeAllowanceRequest { // QueryFeeAllowanceResponse is the response type for the Query/FeeAllowance RPC method. message QueryFeeAllowanceResponse { // fee_allowance is a fee_allowance granted for grantee by granter. - cosmos.fee_grant.v1beta1.FeeAllowanceGrant fee_allowance = 1; + cosmos.feegrant.v1beta1.FeeAllowanceGrant fee_allowance = 1; } // QueryFeeAllowancesRequest is the request type for the Query/FeeAllowances RPC method. @@ -44,7 +44,7 @@ message QueryFeeAllowancesRequest { // QueryFeeAllowancesResponse is the response type for the Query/FeeAllowances RPC method. message QueryFeeAllowancesResponse { // fee_allowance is a fee_allowance granted for grantee by granter. - repeated cosmos.fee_grant.v1beta1.FeeAllowanceGrant fee_allowances = 1; + repeated cosmos.feegrant.v1beta1.FeeAllowanceGrant fee_allowances = 1; // pagination defines an pagination for the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; diff --git a/proto/cosmos/fee_grant/v1beta1/tx.proto b/proto/cosmos/feegrant/v1beta1/tx.proto similarity index 92% rename from proto/cosmos/fee_grant/v1beta1/tx.proto rename to proto/cosmos/feegrant/v1beta1/tx.proto index 6becf92434d3..114ebc14a377 100644 --- a/proto/cosmos/fee_grant/v1beta1/tx.proto +++ b/proto/cosmos/feegrant/v1beta1/tx.proto @@ -1,11 +1,11 @@ syntax = "proto3"; -package cosmos.fee_grant.v1beta1; +package cosmos.feegrant.v1beta1; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; import "cosmos_proto/cosmos.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/x/fee_grant/types"; +option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; // Msg defines the feegrant msg service. service Msg { diff --git a/simapp/ante.go b/simapp/ante.go index 889efd8d3099..0af65940ced4 100644 --- a/simapp/ante.go +++ b/simapp/ante.go @@ -5,9 +5,9 @@ import ( authante "github.com/cosmos/cosmos-sdk/x/auth/ante" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/signing" - feegrantante "github.com/cosmos/cosmos-sdk/x/fee_grant/ante" - feegrantkeeper "github.com/cosmos/cosmos-sdk/x/fee_grant/keeper" - feegranttypes "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + feegrantante "github.com/cosmos/cosmos-sdk/x/feegrant/ante" + feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" + feegranttypes "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) // NewAnteHandler returns an AnteHandler that checks and increments sequence diff --git a/simapp/app.go b/simapp/app.go index 979877b92b02..07e15b31d7d8 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -54,9 +54,9 @@ import ( "github.com/cosmos/cosmos-sdk/x/evidence" evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - feegrant "github.com/cosmos/cosmos-sdk/x/fee_grant" - feegrantkeeper "github.com/cosmos/cosmos-sdk/x/fee_grant/keeper" - feegranttypes "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + feegrant "github.com/cosmos/cosmos-sdk/x/feegrant" + feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" + feegranttypes "github.com/cosmos/cosmos-sdk/x/feegrant/types" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/cosmos/cosmos-sdk/x/gov" diff --git a/x/fee_grant/ante/fee.go b/x/feegrant/ante/fee.go similarity index 96% rename from x/fee_grant/ante/fee.go rename to x/feegrant/ante/fee.go index 405434406f0e..bfb046da0a0d 100644 --- a/x/fee_grant/ante/fee.go +++ b/x/feegrant/ante/fee.go @@ -7,8 +7,8 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/fee_grant/keeper" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) // DeductGrantedFeeDecorator deducts fees from the first signer of the tx diff --git a/x/fee_grant/ante/fee_test.go b/x/feegrant/ante/fee_test.go similarity index 99% rename from x/fee_grant/ante/fee_test.go rename to x/feegrant/ante/fee_test.go index b134e0b44995..bf23f1e3bcff 100644 --- a/x/fee_grant/ante/fee_test.go +++ b/x/feegrant/ante/fee_test.go @@ -22,8 +22,8 @@ import ( authsign "github.com/cosmos/cosmos-sdk/x/auth/signing" "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/fee_grant/ante" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/ante" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) // AnteTestSuite is a test suite to be used with ante handler tests. diff --git a/x/fee_grant/client/cli/cli_test.go b/x/feegrant/client/cli/cli_test.go similarity index 98% rename from x/fee_grant/client/cli/cli_test.go rename to x/feegrant/client/cli/cli_test.go index 71c048ace7f7..fcf85ab164b0 100644 --- a/x/fee_grant/client/cli/cli_test.go +++ b/x/feegrant/client/cli/cli_test.go @@ -8,8 +8,8 @@ import ( clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/fee_grant/client/cli" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/client/cli" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/suite" tmcli "github.com/tendermint/tendermint/libs/cli" diff --git a/x/fee_grant/client/cli/query.go b/x/feegrant/client/cli/query.go similarity index 98% rename from x/fee_grant/client/cli/query.go rename to x/feegrant/client/cli/query.go index 10fc029883dc..bf2da17d7e5d 100644 --- a/x/fee_grant/client/cli/query.go +++ b/x/feegrant/client/cli/query.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" "github.com/spf13/cobra" ) diff --git a/x/fee_grant/client/cli/service_msg_client.go b/x/feegrant/client/cli/service_msg_client.go similarity index 100% rename from x/fee_grant/client/cli/service_msg_client.go rename to x/feegrant/client/cli/service_msg_client.go diff --git a/x/fee_grant/client/cli/tx.go b/x/feegrant/client/cli/tx.go similarity index 99% rename from x/fee_grant/client/cli/tx.go rename to x/feegrant/client/cli/tx.go index 9449ac42f2af..9b8328710904 100644 --- a/x/fee_grant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -14,7 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/tx" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) // flag for feegrant module diff --git a/x/fee_grant/client/rest/grpc_query_test.go b/x/feegrant/client/rest/grpc_query_test.go similarity index 98% rename from x/fee_grant/client/rest/grpc_query_test.go rename to x/feegrant/client/rest/grpc_query_test.go index a573bcdf21e7..99626923aafd 100644 --- a/x/fee_grant/client/rest/grpc_query_test.go +++ b/x/feegrant/client/rest/grpc_query_test.go @@ -12,8 +12,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil" - "github.com/cosmos/cosmos-sdk/x/fee_grant/client/cli" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/client/cli" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" "github.com/stretchr/testify/suite" ) diff --git a/x/fee_grant/doc.go b/x/feegrant/doc.go similarity index 100% rename from x/fee_grant/doc.go rename to x/feegrant/doc.go diff --git a/x/fee_grant/genesis.go b/x/feegrant/genesis.go similarity index 94% rename from x/fee_grant/genesis.go rename to x/feegrant/genesis.go index 0f7214f6ec6d..a5c05b7fecc1 100644 --- a/x/fee_grant/genesis.go +++ b/x/feegrant/genesis.go @@ -2,8 +2,8 @@ package feegrant import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/fee_grant/keeper" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) // GenesisState contains a set of fee allowances, persisted from the store diff --git a/x/fee_grant/genesis_test.go b/x/feegrant/genesis_test.go similarity index 91% rename from x/fee_grant/genesis_test.go rename to x/feegrant/genesis_test.go index 24a7b7a378b7..9ba458148609 100644 --- a/x/fee_grant/genesis_test.go +++ b/x/feegrant/genesis_test.go @@ -6,9 +6,9 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - feegrant "github.com/cosmos/cosmos-sdk/x/fee_grant" - "github.com/cosmos/cosmos-sdk/x/fee_grant/keeper" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + feegrant "github.com/cosmos/cosmos-sdk/x/feegrant" + "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) diff --git a/x/fee_grant/keeper/grpc_query.go b/x/feegrant/keeper/grpc_query.go similarity index 98% rename from x/fee_grant/keeper/grpc_query.go rename to x/feegrant/keeper/grpc_query.go index ccffc6a6a8d9..9f2abdd50e56 100644 --- a/x/fee_grant/keeper/grpc_query.go +++ b/x/feegrant/keeper/grpc_query.go @@ -11,7 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) var _ types.QueryServer = Keeper{} diff --git a/x/fee_grant/keeper/keeper.go b/x/feegrant/keeper/keeper.go similarity index 99% rename from x/fee_grant/keeper/keeper.go rename to x/feegrant/keeper/keeper.go index d4d4b54a5982..c9c07ca6b7bc 100644 --- a/x/fee_grant/keeper/keeper.go +++ b/x/feegrant/keeper/keeper.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) // Keeper manages state of all fee grants, as well as calculating approval. diff --git a/x/fee_grant/keeper/keeper_test.go b/x/feegrant/keeper/keeper_test.go similarity index 99% rename from x/fee_grant/keeper/keeper_test.go rename to x/feegrant/keeper/keeper_test.go index 62bea9be9761..0f7fdfeedd91 100644 --- a/x/fee_grant/keeper/keeper_test.go +++ b/x/feegrant/keeper/keeper_test.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) type KeeperTestSuite struct { diff --git a/x/fee_grant/keeper/msg_server.go b/x/feegrant/keeper/msg_server.go similarity index 97% rename from x/fee_grant/keeper/msg_server.go rename to x/feegrant/keeper/msg_server.go index ba529192fb07..0f8ff20642f8 100644 --- a/x/fee_grant/keeper/msg_server.go +++ b/x/feegrant/keeper/msg_server.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) type msgServer struct { diff --git a/x/fee_grant/module.go b/x/feegrant/module.go similarity index 97% rename from x/fee_grant/module.go rename to x/feegrant/module.go index 9b47d83602be..6e43077e80a3 100644 --- a/x/fee_grant/module.go +++ b/x/feegrant/module.go @@ -18,10 +18,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/fee_grant/client/cli" - "github.com/cosmos/cosmos-sdk/x/fee_grant/keeper" - "github.com/cosmos/cosmos-sdk/x/fee_grant/simulation" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/client/cli" + "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" + "github.com/cosmos/cosmos-sdk/x/feegrant/simulation" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) var ( diff --git a/x/fee_grant/simulation/decoder.go b/x/feegrant/simulation/decoder.go similarity index 93% rename from x/fee_grant/simulation/decoder.go rename to x/feegrant/simulation/decoder.go index 0f98b4b4856f..c7f783c2b6d5 100644 --- a/x/fee_grant/simulation/decoder.go +++ b/x/feegrant/simulation/decoder.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types/kv" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) // NewDecodeStore returns a decoder function closure that umarshals the KVPair's diff --git a/x/fee_grant/simulation/decoder_test.go b/x/feegrant/simulation/decoder_test.go similarity index 93% rename from x/fee_grant/simulation/decoder_test.go rename to x/feegrant/simulation/decoder_test.go index 561de05a3a40..3607c94cf581 100644 --- a/x/fee_grant/simulation/decoder_test.go +++ b/x/feegrant/simulation/decoder_test.go @@ -8,8 +8,8 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" - "github.com/cosmos/cosmos-sdk/x/fee_grant/simulation" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/simulation" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" "github.com/stretchr/testify/require" ) diff --git a/x/fee_grant/simulation/genesis.go b/x/feegrant/simulation/genesis.go similarity index 95% rename from x/fee_grant/simulation/genesis.go rename to x/feegrant/simulation/genesis.go index e3701e33db1f..f9f4c7e12748 100644 --- a/x/fee_grant/simulation/genesis.go +++ b/x/feegrant/simulation/genesis.go @@ -7,7 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) // Simulation parameter constants diff --git a/x/fee_grant/simulation/genesis_test.go b/x/feegrant/simulation/genesis_test.go similarity index 90% rename from x/fee_grant/simulation/genesis_test.go rename to x/feegrant/simulation/genesis_test.go index c507ac7e6dc3..4f3ae74b56be 100644 --- a/x/fee_grant/simulation/genesis_test.go +++ b/x/feegrant/simulation/genesis_test.go @@ -9,8 +9,8 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/fee_grant/simulation" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/simulation" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" "github.com/stretchr/testify/require" ) diff --git a/x/fee_grant/simulation/operations.go b/x/feegrant/simulation/operations.go similarity index 96% rename from x/fee_grant/simulation/operations.go rename to x/feegrant/simulation/operations.go index 5d85d501829a..e0bf8b289ebe 100644 --- a/x/fee_grant/simulation/operations.go +++ b/x/feegrant/simulation/operations.go @@ -11,8 +11,8 @@ import ( simappparams "github.com/cosmos/cosmos-sdk/simapp/params" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/fee_grant/keeper" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" "github.com/cosmos/cosmos-sdk/x/simulation" ) @@ -20,8 +20,8 @@ import ( const ( OpWeightMsgGrantFeeAllowance = "op_weight_msg_grant_fee_allowance" OpWeightMsgRevokeFeeAllowance = "op_weight_msg_grant_revoke_allowance" - TypeMsgGrantFeeAllowance = "/cosmos.fee_grant.v1beta1.Msg/GrantFeeAllowance" - TypeMsgRevokeFeeAllowance = "/cosmos.fee_grant.v1beta1.Msg/RevokeFeeAllowance" + TypeMsgGrantFeeAllowance = "/cosmos.feegrant.v1beta1.Msg/GrantFeeAllowance" + TypeMsgRevokeFeeAllowance = "/cosmos.feegrant.v1beta1.Msg/RevokeFeeAllowance" ) func WeightedOperations( diff --git a/x/fee_grant/simulation/operations_test.go b/x/feegrant/simulation/operations_test.go similarity index 97% rename from x/fee_grant/simulation/operations_test.go rename to x/feegrant/simulation/operations_test.go index 73b821e8889a..173e3772e581 100644 --- a/x/fee_grant/simulation/operations_test.go +++ b/x/feegrant/simulation/operations_test.go @@ -15,8 +15,8 @@ import ( simappparams "github.com/cosmos/cosmos-sdk/simapp/params" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/fee_grant/simulation" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/simulation" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) type SimTestSuite struct { diff --git a/x/fee_grant/types/basic_fee.go b/x/feegrant/types/basic_fee.go similarity index 100% rename from x/fee_grant/types/basic_fee.go rename to x/feegrant/types/basic_fee.go diff --git a/x/fee_grant/types/basic_fee_test.go b/x/feegrant/types/basic_fee_test.go similarity index 97% rename from x/fee_grant/types/basic_fee_test.go rename to x/feegrant/types/basic_fee_test.go index 1d032708f043..440aaeaf49da 100644 --- a/x/fee_grant/types/basic_fee_test.go +++ b/x/feegrant/types/basic_fee_test.go @@ -5,7 +5,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/x/fee_grant/types/codec.go b/x/feegrant/types/codec.go similarity index 100% rename from x/fee_grant/types/codec.go rename to x/feegrant/types/codec.go diff --git a/x/fee_grant/types/errors.go b/x/feegrant/types/errors.go similarity index 100% rename from x/fee_grant/types/errors.go rename to x/feegrant/types/errors.go diff --git a/x/fee_grant/types/events.go b/x/feegrant/types/events.go similarity index 100% rename from x/fee_grant/types/events.go rename to x/feegrant/types/events.go diff --git a/x/fee_grant/types/expected_keepers.go b/x/feegrant/types/expected_keepers.go similarity index 100% rename from x/fee_grant/types/expected_keepers.go rename to x/feegrant/types/expected_keepers.go diff --git a/x/fee_grant/types/expiration.go b/x/feegrant/types/expiration.go similarity index 100% rename from x/fee_grant/types/expiration.go rename to x/feegrant/types/expiration.go diff --git a/x/fee_grant/types/expiration_test.go b/x/feegrant/types/expiration_test.go similarity index 98% rename from x/fee_grant/types/expiration_test.go rename to x/feegrant/types/expiration_test.go index 95d3e1cbc842..fb8c749d43eb 100644 --- a/x/fee_grant/types/expiration_test.go +++ b/x/feegrant/types/expiration_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/x/fee_grant/types/fee_grant.pb.go b/x/feegrant/types/feegrant.pb.go similarity index 79% rename from x/fee_grant/types/fee_grant.pb.go rename to x/feegrant/types/feegrant.pb.go index 79c98c7a25bb..ced71cb7aa1c 100644 --- a/x/fee_grant/types/fee_grant.pb.go +++ b/x/feegrant/types/feegrant.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmos/fee_grant/v1beta1/fee_grant.proto +// source: cosmos/feegrant/v1beta1/feegrant.proto package types @@ -43,7 +43,7 @@ func (m *BasicFeeAllowance) Reset() { *m = BasicFeeAllowance{} } func (m *BasicFeeAllowance) String() string { return proto.CompactTextString(m) } func (*BasicFeeAllowance) ProtoMessage() {} func (*BasicFeeAllowance) Descriptor() ([]byte, []int) { - return fileDescriptor_5dd8ff02de9d10f0, []int{0} + return fileDescriptor_7279582900c30aea, []int{0} } func (m *BasicFeeAllowance) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -100,7 +100,7 @@ func (m *PeriodicFeeAllowance) Reset() { *m = PeriodicFeeAllowance{} } func (m *PeriodicFeeAllowance) String() string { return proto.CompactTextString(m) } func (*PeriodicFeeAllowance) ProtoMessage() {} func (*PeriodicFeeAllowance) Descriptor() ([]byte, []int) { - return fileDescriptor_5dd8ff02de9d10f0, []int{1} + return fileDescriptor_7279582900c30aea, []int{1} } func (m *PeriodicFeeAllowance) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -179,7 +179,7 @@ func (m *Duration) Reset() { *m = Duration{} } func (m *Duration) String() string { return proto.CompactTextString(m) } func (*Duration) ProtoMessage() {} func (*Duration) Descriptor() ([]byte, []int) { - return fileDescriptor_5dd8ff02de9d10f0, []int{2} + return fileDescriptor_7279582900c30aea, []int{2} } func (m *Duration) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -268,7 +268,7 @@ func (m *ExpiresAt) Reset() { *m = ExpiresAt{} } func (m *ExpiresAt) String() string { return proto.CompactTextString(m) } func (*ExpiresAt) ProtoMessage() {} func (*ExpiresAt) Descriptor() ([]byte, []int) { - return fileDescriptor_5dd8ff02de9d10f0, []int{3} + return fileDescriptor_7279582900c30aea, []int{3} } func (m *ExpiresAt) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -353,7 +353,7 @@ func (m *FeeAllowanceGrant) Reset() { *m = FeeAllowanceGrant{} } func (m *FeeAllowanceGrant) String() string { return proto.CompactTextString(m) } func (*FeeAllowanceGrant) ProtoMessage() {} func (*FeeAllowanceGrant) Descriptor() ([]byte, []int) { - return fileDescriptor_5dd8ff02de9d10f0, []int{4} + return fileDescriptor_7279582900c30aea, []int{4} } func (m *FeeAllowanceGrant) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -404,57 +404,57 @@ func (m *FeeAllowanceGrant) GetAllowance() *types1.Any { } func init() { - proto.RegisterType((*BasicFeeAllowance)(nil), "cosmos.fee_grant.v1beta1.BasicFeeAllowance") - proto.RegisterType((*PeriodicFeeAllowance)(nil), "cosmos.fee_grant.v1beta1.PeriodicFeeAllowance") - proto.RegisterType((*Duration)(nil), "cosmos.fee_grant.v1beta1.Duration") - proto.RegisterType((*ExpiresAt)(nil), "cosmos.fee_grant.v1beta1.ExpiresAt") - proto.RegisterType((*FeeAllowanceGrant)(nil), "cosmos.fee_grant.v1beta1.FeeAllowanceGrant") + proto.RegisterType((*BasicFeeAllowance)(nil), "cosmos.feegrant.v1beta1.BasicFeeAllowance") + proto.RegisterType((*PeriodicFeeAllowance)(nil), "cosmos.feegrant.v1beta1.PeriodicFeeAllowance") + proto.RegisterType((*Duration)(nil), "cosmos.feegrant.v1beta1.Duration") + proto.RegisterType((*ExpiresAt)(nil), "cosmos.feegrant.v1beta1.ExpiresAt") + proto.RegisterType((*FeeAllowanceGrant)(nil), "cosmos.feegrant.v1beta1.FeeAllowanceGrant") } func init() { - proto.RegisterFile("cosmos/fee_grant/v1beta1/fee_grant.proto", fileDescriptor_5dd8ff02de9d10f0) -} - -var fileDescriptor_5dd8ff02de9d10f0 = []byte{ - // 597 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xc1, 0x6e, 0xd3, 0x40, - 0x10, 0x86, 0x63, 0x9c, 0x84, 0x66, 0x02, 0x88, 0xac, 0x22, 0xe4, 0xe4, 0xe0, 0x54, 0xe1, 0x12, - 0x09, 0xd5, 0xa6, 0x45, 0xe2, 0x80, 0x84, 0x44, 0x5c, 0x4a, 0x53, 0xa9, 0x07, 0x64, 0x38, 0x71, - 0x89, 0x6c, 0x67, 0xeb, 0x58, 0xb5, 0xbd, 0x96, 0x77, 0x03, 0xcd, 0x4b, 0xa0, 0x1e, 0x79, 0x06, - 0xce, 0x3c, 0x44, 0xc5, 0xa9, 0xe2, 0xc4, 0x89, 0xa0, 0xe4, 0x15, 0x78, 0x00, 0xe4, 0xdd, 0x75, - 0x62, 0x25, 0x04, 0xa9, 0x52, 0x4f, 0xf1, 0xee, 0xce, 0xfc, 0xdf, 0xcc, 0x3f, 0xbb, 0x81, 0x9e, - 0x47, 0x68, 0x44, 0xa8, 0x79, 0x86, 0xf1, 0xd0, 0x4f, 0x9d, 0x98, 0x99, 0x1f, 0xf7, 0x5d, 0xcc, - 0x9c, 0xfd, 0xd5, 0x8e, 0x91, 0xa4, 0x84, 0x11, 0xa4, 0x89, 0x48, 0x63, 0xb5, 0x2f, 0x23, 0xdb, - 0x4d, 0x9f, 0xf8, 0x84, 0x07, 0x99, 0xd9, 0x97, 0x88, 0x6f, 0xb7, 0x7c, 0x42, 0xfc, 0x10, 0x9b, - 0x7c, 0xe5, 0x4e, 0xce, 0x4c, 0x27, 0x9e, 0xe6, 0x47, 0x42, 0x6a, 0x28, 0x72, 0xa4, 0xae, 0x38, - 0xd2, 0x65, 0x3d, 0xae, 0x43, 0xf1, 0xb2, 0x14, 0x8f, 0x04, 0xb1, 0x3c, 0xef, 0xac, 0xab, 0xb2, - 0x20, 0xc2, 0x94, 0x39, 0x51, 0x92, 0x0b, 0xac, 0x07, 0x8c, 0x26, 0xa9, 0xc3, 0x02, 0x22, 0x05, - 0xba, 0x33, 0x05, 0x1a, 0x96, 0x43, 0x03, 0xef, 0x0d, 0xc6, 0xfd, 0x30, 0x24, 0x9f, 0x9c, 0xd8, - 0xc3, 0x28, 0x84, 0x3a, 0x4d, 0x70, 0x3c, 0x1a, 0x86, 0x41, 0x14, 0x30, 0x4d, 0xd9, 0x55, 0x7b, - 0xf5, 0x83, 0x96, 0x21, 0x4b, 0xcb, 0x8a, 0xc9, 0xbb, 0x35, 0x0e, 0x49, 0x10, 0x5b, 0x4f, 0xaf, - 0x7e, 0x75, 0x4a, 0x5f, 0x67, 0x9d, 0x9e, 0x1f, 0xb0, 0xf1, 0xc4, 0x35, 0x3c, 0x12, 0xc9, 0x3e, - 0xe4, 0xcf, 0x1e, 0x1d, 0x9d, 0x9b, 0x6c, 0x9a, 0x60, 0xca, 0x13, 0xa8, 0x0d, 0x5c, 0xff, 0x34, - 0x93, 0x47, 0x27, 0x00, 0xf8, 0x22, 0x09, 0x44, 0x5d, 0xda, 0x9d, 0x5d, 0xa5, 0x57, 0x3f, 0x78, - 0x6c, 0x6c, 0xf3, 0xd7, 0x38, 0xca, 0x62, 0x31, 0xed, 0x33, 0xab, 0x9c, 0x61, 0xed, 0x42, 0xf2, - 0x8b, 0xc6, 0x8f, 0x6f, 0x7b, 0xf7, 0x8b, 0xad, 0x9c, 0x74, 0xff, 0xa8, 0xd0, 0x7c, 0x8b, 0xd3, - 0x80, 0x8c, 0xd6, 0x9a, 0x3c, 0x86, 0x8a, 0x9b, 0x75, 0xae, 0x29, 0x9c, 0xf8, 0x64, 0x3b, 0x71, - 0xc3, 0x20, 0x49, 0x16, 0xf9, 0xe8, 0x15, 0x54, 0x13, 0x0e, 0x90, 0xb5, 0x77, 0xb7, 0x2b, 0xbd, - 0x96, 0xee, 0x4b, 0x01, 0x99, 0x87, 0xa6, 0x80, 0xc4, 0xd7, 0xb0, 0x68, 0xbb, 0x7a, 0xfb, 0xb6, - 0x3f, 0x14, 0x98, 0x77, 0x2b, 0xf3, 0x27, 0x20, 0xf7, 0x86, 0x9e, 0x13, 0x0b, 0xbc, 0x56, 0xbe, - 0x7d, 0xf0, 0x03, 0x01, 0x39, 0x74, 0x62, 0xce, 0x46, 0xa7, 0x70, 0x4f, 0x62, 0x53, 0x4c, 0x31, - 0xd3, 0x2a, 0x37, 0x9d, 0x7a, 0x5d, 0xa4, 0xdb, 0x59, 0xf6, 0xbf, 0xc6, 0x3e, 0x86, 0x9d, 0xdc, - 0x6c, 0xf4, 0x12, 0x76, 0xf2, 0x6b, 0x2f, 0x87, 0xdd, 0x32, 0xc4, 0xbb, 0x30, 0xf2, 0x77, 0x51, - 0x98, 0xcc, 0x97, 0x59, 0x47, 0x19, 0x94, 0xec, 0x65, 0x0a, 0x7a, 0x04, 0x15, 0x37, 0x24, 0xde, - 0x39, 0x1f, 0xaf, 0x3a, 0xc8, 0xe6, 0x9e, 0x2d, 0xad, 0x0a, 0xa8, 0x74, 0x12, 0x75, 0x47, 0x50, - 0x5b, 0x16, 0x87, 0x9e, 0x43, 0x39, 0x7b, 0x82, 0x12, 0xd3, 0xde, 0xc0, 0xbc, 0xcf, 0xdf, 0xa7, - 0x55, 0xbe, 0x14, 0x1c, 0x1e, 0x8f, 0x34, 0xa8, 0x8e, 0x71, 0xe0, 0x8f, 0xd9, 0x12, 0x22, 0xd7, - 0x39, 0xe5, 0xb3, 0x02, 0x8d, 0x62, 0x87, 0xc7, 0x99, 0x3b, 0x48, 0x83, 0xbb, 0xdc, 0x26, 0x9c, - 0x72, 0x62, 0xcd, 0xce, 0x97, 0xab, 0x13, 0xcc, 0x15, 0x97, 0x27, 0x18, 0x1d, 0x41, 0xcd, 0xc9, - 0x55, 0x34, 0x95, 0xd7, 0xd9, 0xdc, 0xa8, 0xb3, 0x1f, 0x4f, 0xad, 0xc6, 0xf7, 0x75, 0x57, 0xed, - 0x55, 0xa6, 0x35, 0xb8, 0x9a, 0xeb, 0xca, 0xf5, 0x5c, 0x57, 0x7e, 0xcf, 0x75, 0xe5, 0x72, 0xa1, - 0x97, 0xae, 0x17, 0x7a, 0xe9, 0xe7, 0x42, 0x2f, 0x7d, 0x30, 0xfe, 0x7b, 0x2b, 0x2e, 0x0a, 0x7f, - 0xae, 0xfc, 0x86, 0xb8, 0x55, 0x4e, 0x7d, 0xf6, 0x37, 0x00, 0x00, 0xff, 0xff, 0x44, 0x7f, 0x07, - 0x7e, 0x7d, 0x05, 0x00, 0x00, + proto.RegisterFile("cosmos/feegrant/v1beta1/feegrant.proto", fileDescriptor_7279582900c30aea) +} + +var fileDescriptor_7279582900c30aea = []byte{ + // 596 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcf, 0x6e, 0xd3, 0x30, + 0x18, 0x6f, 0x48, 0x3b, 0xd6, 0xaf, 0x80, 0xa8, 0x55, 0x41, 0xda, 0x43, 0x3a, 0x7a, 0x40, 0x15, + 0x52, 0x13, 0x36, 0x24, 0x0e, 0x48, 0x08, 0x35, 0x63, 0x5b, 0x11, 0x1c, 0x50, 0xe0, 0xc4, 0xa5, + 0x4a, 0x52, 0x2f, 0x8d, 0x96, 0xc4, 0x51, 0xec, 0xc2, 0xfa, 0x12, 0x68, 0x47, 0x9e, 0x81, 0x33, + 0x0f, 0x31, 0x71, 0x9a, 0x38, 0x71, 0xda, 0x50, 0xfb, 0x04, 0xbc, 0x01, 0x8a, 0xed, 0xa4, 0x55, + 0x4b, 0x91, 0x90, 0x76, 0x6a, 0x6c, 0x7f, 0xbf, 0x3f, 0xdf, 0xef, 0xb3, 0x0b, 0x0f, 0x3d, 0x42, + 0x23, 0x42, 0xcd, 0x63, 0x8c, 0xfd, 0xd4, 0x89, 0x99, 0xf9, 0x71, 0xd7, 0xc5, 0xcc, 0xd9, 0x2d, + 0x36, 0x8c, 0x24, 0x25, 0x8c, 0xa0, 0xfb, 0xa2, 0xce, 0x28, 0xb6, 0x65, 0x5d, 0xab, 0xe1, 0x13, + 0x9f, 0xf0, 0x1a, 0x33, 0xfb, 0x12, 0xe5, 0xad, 0xa6, 0x4f, 0x88, 0x1f, 0x62, 0x93, 0xaf, 0xdc, + 0xc9, 0xb1, 0xe9, 0xc4, 0xd3, 0xfc, 0x48, 0x30, 0x0d, 0x05, 0x46, 0xd2, 0x8a, 0x23, 0x5d, 0x9a, + 0x71, 0x1d, 0x8a, 0x0b, 0x23, 0x1e, 0x09, 0x62, 0x79, 0xde, 0x5e, 0x65, 0x65, 0x41, 0x84, 0x29, + 0x73, 0xa2, 0x24, 0x27, 0x58, 0x2d, 0x18, 0x4d, 0x52, 0x87, 0x05, 0x44, 0x12, 0x74, 0x2e, 0x15, + 0xa8, 0x5b, 0x0e, 0x0d, 0xbc, 0x43, 0x8c, 0xfb, 0x61, 0x48, 0x3e, 0x39, 0xb1, 0x87, 0x51, 0x08, + 0x35, 0x9a, 0xe0, 0x78, 0x34, 0x0c, 0x83, 0x28, 0x60, 0x9a, 0xb2, 0xa3, 0x76, 0x6b, 0x7b, 0x4d, + 0x43, 0x5a, 0xcb, 0xcc, 0xe4, 0xdd, 0x1a, 0xfb, 0x24, 0x88, 0xad, 0xc7, 0xe7, 0x97, 0xed, 0xd2, + 0xd7, 0xab, 0x76, 0xd7, 0x0f, 0xd8, 0x78, 0xe2, 0x1a, 0x1e, 0x89, 0x64, 0x1f, 0xf2, 0xa7, 0x47, + 0x47, 0x27, 0x26, 0x9b, 0x26, 0x98, 0x72, 0x00, 0xb5, 0x81, 0xf3, 0xbf, 0xc9, 0xe8, 0xd1, 0x00, + 0x00, 0x9f, 0x26, 0x81, 0xf0, 0xa5, 0xdd, 0xd8, 0x51, 0xba, 0xb5, 0xbd, 0x8e, 0xb1, 0x21, 0x5e, + 0xe3, 0x20, 0x2b, 0xc5, 0xb4, 0xcf, 0xac, 0x72, 0xa6, 0x6a, 0x2f, 0x61, 0x9f, 0xd5, 0x7f, 0x7c, + 0xeb, 0xdd, 0x5e, 0xee, 0xe4, 0x55, 0xe7, 0xb7, 0x0a, 0x8d, 0xb7, 0x38, 0x0d, 0xc8, 0x68, 0xa5, + 0xc7, 0x43, 0xa8, 0xb8, 0x59, 0xe3, 0x9a, 0xc2, 0x05, 0x1f, 0x6d, 0x14, 0x5c, 0x8b, 0x47, 0x0a, + 0x0b, 0x38, 0x7a, 0x01, 0x5b, 0x09, 0xe7, 0x97, 0xce, 0x1f, 0x6c, 0x24, 0x7a, 0x29, 0xa3, 0x97, + 0x78, 0x09, 0x43, 0x53, 0x40, 0xe2, 0x6b, 0xb8, 0x9c, 0xb9, 0x7a, 0xfd, 0x99, 0xdf, 0x15, 0x32, + 0xef, 0x16, 0xc9, 0x4f, 0x40, 0xee, 0x0d, 0x3d, 0x27, 0x16, 0xf2, 0x5a, 0xf9, 0xfa, 0x85, 0xef, + 0x08, 0x91, 0x7d, 0x27, 0xe6, 0xda, 0xe8, 0x35, 0xdc, 0x92, 0xb2, 0x29, 0xa6, 0x98, 0x69, 0x95, + 0xff, 0x1c, 0x79, 0x4d, 0xa0, 0xed, 0x0c, 0xfc, 0xb7, 0x99, 0x8f, 0x61, 0x3b, 0xcf, 0x1a, 0x3d, + 0x87, 0xed, 0xfc, 0xca, 0xcb, 0x49, 0x37, 0x0d, 0xf1, 0x26, 0x8c, 0xfc, 0x4d, 0x2c, 0x0d, 0xe6, + 0xcb, 0x55, 0x5b, 0x19, 0x94, 0xec, 0x02, 0x82, 0xee, 0x41, 0xc5, 0x0d, 0x89, 0x77, 0xc2, 0x87, + 0xab, 0x0e, 0xb2, 0xa9, 0x67, 0x4b, 0xab, 0x02, 0x2a, 0x9d, 0x44, 0x9d, 0x11, 0x54, 0x0b, 0x73, + 0xe8, 0x29, 0x94, 0xb3, 0xe7, 0x27, 0x65, 0x5a, 0x6b, 0x32, 0xef, 0xf3, 0xb7, 0x69, 0x95, 0xcf, + 0x84, 0x0e, 0xaf, 0x47, 0x1a, 0x6c, 0x8d, 0x71, 0xe0, 0x8f, 0x59, 0x21, 0x22, 0xd7, 0xb9, 0xca, + 0x67, 0x05, 0xea, 0xcb, 0x1d, 0x1e, 0x65, 0xe9, 0x20, 0x0d, 0x6e, 0xf2, 0x98, 0x70, 0xca, 0x15, + 0xab, 0x76, 0xbe, 0x5c, 0x9c, 0x60, 0xce, 0x58, 0x9c, 0x60, 0x74, 0x00, 0x55, 0x27, 0x67, 0xd1, + 0x54, 0xee, 0xb3, 0xb1, 0xe6, 0xb3, 0x1f, 0x4f, 0xad, 0xfa, 0xf7, 0xd5, 0x54, 0xed, 0x05, 0xd2, + 0x3a, 0x3a, 0x9f, 0xe9, 0xca, 0xc5, 0x4c, 0x57, 0x7e, 0xcd, 0x74, 0xe5, 0x6c, 0xae, 0x97, 0x2e, + 0xe6, 0x7a, 0xe9, 0xe7, 0x5c, 0x2f, 0x7d, 0xe8, 0xfd, 0xf3, 0x52, 0x9c, 0x2e, 0xfe, 0x55, 0xf9, + 0xfd, 0x70, 0xb7, 0xb8, 0xe8, 0x93, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x2e, 0xb1, 0xe6, 0x7e, + 0x75, 0x05, 0x00, 0x00, } func (m *BasicFeeAllowance) Marshal() (dAtA []byte, err error) { @@ -483,7 +483,7 @@ func (m *BasicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintFeeGrant(dAtA, i, uint64(size)) + i = encodeVarintFeegrant(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x12 @@ -495,7 +495,7 @@ func (m *BasicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintFeeGrant(dAtA, i, uint64(size)) + i = encodeVarintFeegrant(dAtA, i, uint64(size)) } i-- dAtA[i] = 0xa @@ -530,7 +530,7 @@ func (m *PeriodicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintFeeGrant(dAtA, i, uint64(size)) + i = encodeVarintFeegrant(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x2a @@ -542,7 +542,7 @@ func (m *PeriodicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintFeeGrant(dAtA, i, uint64(size)) + i = encodeVarintFeegrant(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x22 @@ -556,7 +556,7 @@ func (m *PeriodicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintFeeGrant(dAtA, i, uint64(size)) + i = encodeVarintFeegrant(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x1a @@ -568,7 +568,7 @@ func (m *PeriodicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintFeeGrant(dAtA, i, uint64(size)) + i = encodeVarintFeegrant(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x12 @@ -578,7 +578,7 @@ func (m *PeriodicFeeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintFeeGrant(dAtA, i, uint64(size)) + i = encodeVarintFeegrant(dAtA, i, uint64(size)) } i-- dAtA[i] = 0xa @@ -630,7 +630,7 @@ func (m *Duration_Duration) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err5 } i -= n5 - i = encodeVarintFeeGrant(dAtA, i, uint64(n5)) + i = encodeVarintFeegrant(dAtA, i, uint64(n5)) i-- dAtA[i] = 0xa } @@ -643,7 +643,7 @@ func (m *Duration_Block) MarshalTo(dAtA []byte) (int, error) { func (m *Duration_Block) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) - i = encodeVarintFeeGrant(dAtA, i, uint64(m.Block)) + i = encodeVarintFeegrant(dAtA, i, uint64(m.Block)) i-- dAtA[i] = 0x10 return len(dAtA) - i, nil @@ -693,7 +693,7 @@ func (m *ExpiresAt_Time) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err6 } i -= n6 - i = encodeVarintFeeGrant(dAtA, i, uint64(n6)) + i = encodeVarintFeegrant(dAtA, i, uint64(n6)) i-- dAtA[i] = 0xa } @@ -706,7 +706,7 @@ func (m *ExpiresAt_Height) MarshalTo(dAtA []byte) (int, error) { func (m *ExpiresAt_Height) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) - i = encodeVarintFeeGrant(dAtA, i, uint64(m.Height)) + i = encodeVarintFeegrant(dAtA, i, uint64(m.Height)) i-- dAtA[i] = 0x10 return len(dAtA) - i, nil @@ -738,7 +738,7 @@ func (m *FeeAllowanceGrant) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintFeeGrant(dAtA, i, uint64(size)) + i = encodeVarintFeegrant(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x1a @@ -746,22 +746,22 @@ func (m *FeeAllowanceGrant) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.Grantee) > 0 { i -= len(m.Grantee) copy(dAtA[i:], m.Grantee) - i = encodeVarintFeeGrant(dAtA, i, uint64(len(m.Grantee))) + i = encodeVarintFeegrant(dAtA, i, uint64(len(m.Grantee))) i-- dAtA[i] = 0x12 } if len(m.Granter) > 0 { i -= len(m.Granter) copy(dAtA[i:], m.Granter) - i = encodeVarintFeeGrant(dAtA, i, uint64(len(m.Granter))) + i = encodeVarintFeegrant(dAtA, i, uint64(len(m.Granter))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func encodeVarintFeeGrant(dAtA []byte, offset int, v uint64) int { - offset -= sovFeeGrant(v) +func encodeVarintFeegrant(dAtA []byte, offset int, v uint64) int { + offset -= sovFeegrant(v) base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -780,11 +780,11 @@ func (m *BasicFeeAllowance) Size() (n int) { if len(m.SpendLimit) > 0 { for _, e := range m.SpendLimit { l = e.Size() - n += 1 + l + sovFeeGrant(uint64(l)) + n += 1 + l + sovFeegrant(uint64(l)) } } l = m.Expiration.Size() - n += 1 + l + sovFeeGrant(uint64(l)) + n += 1 + l + sovFeegrant(uint64(l)) return n } @@ -795,23 +795,23 @@ func (m *PeriodicFeeAllowance) Size() (n int) { var l int _ = l l = m.Basic.Size() - n += 1 + l + sovFeeGrant(uint64(l)) + n += 1 + l + sovFeegrant(uint64(l)) l = m.Period.Size() - n += 1 + l + sovFeeGrant(uint64(l)) + n += 1 + l + sovFeegrant(uint64(l)) if len(m.PeriodSpendLimit) > 0 { for _, e := range m.PeriodSpendLimit { l = e.Size() - n += 1 + l + sovFeeGrant(uint64(l)) + n += 1 + l + sovFeegrant(uint64(l)) } } if len(m.PeriodCanSpend) > 0 { for _, e := range m.PeriodCanSpend { l = e.Size() - n += 1 + l + sovFeeGrant(uint64(l)) + n += 1 + l + sovFeegrant(uint64(l)) } } l = m.PeriodReset.Size() - n += 1 + l + sovFeeGrant(uint64(l)) + n += 1 + l + sovFeegrant(uint64(l)) return n } @@ -835,7 +835,7 @@ func (m *Duration_Duration) Size() (n int) { _ = l if m.Duration != nil { l = github_com_gogo_protobuf_types.SizeOfStdDuration(*m.Duration) - n += 1 + l + sovFeeGrant(uint64(l)) + n += 1 + l + sovFeegrant(uint64(l)) } return n } @@ -845,7 +845,7 @@ func (m *Duration_Block) Size() (n int) { } var l int _ = l - n += 1 + sovFeeGrant(uint64(m.Block)) + n += 1 + sovFeegrant(uint64(m.Block)) return n } func (m *ExpiresAt) Size() (n int) { @@ -868,7 +868,7 @@ func (m *ExpiresAt_Time) Size() (n int) { _ = l if m.Time != nil { l = github_com_gogo_protobuf_types.SizeOfStdTime(*m.Time) - n += 1 + l + sovFeeGrant(uint64(l)) + n += 1 + l + sovFeegrant(uint64(l)) } return n } @@ -878,7 +878,7 @@ func (m *ExpiresAt_Height) Size() (n int) { } var l int _ = l - n += 1 + sovFeeGrant(uint64(m.Height)) + n += 1 + sovFeegrant(uint64(m.Height)) return n } func (m *FeeAllowanceGrant) Size() (n int) { @@ -889,24 +889,24 @@ func (m *FeeAllowanceGrant) Size() (n int) { _ = l l = len(m.Granter) if l > 0 { - n += 1 + l + sovFeeGrant(uint64(l)) + n += 1 + l + sovFeegrant(uint64(l)) } l = len(m.Grantee) if l > 0 { - n += 1 + l + sovFeeGrant(uint64(l)) + n += 1 + l + sovFeegrant(uint64(l)) } if m.Allowance != nil { l = m.Allowance.Size() - n += 1 + l + sovFeeGrant(uint64(l)) + n += 1 + l + sovFeegrant(uint64(l)) } return n } -func sovFeeGrant(x uint64) (n int) { +func sovFeegrant(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } -func sozFeeGrant(x uint64) (n int) { - return sovFeeGrant(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func sozFeegrant(x uint64) (n int) { + return sovFeegrant(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } func (m *BasicFeeAllowance) Unmarshal(dAtA []byte) error { l := len(dAtA) @@ -916,7 +916,7 @@ func (m *BasicFeeAllowance) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeeGrant + return ErrIntOverflowFeegrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -944,7 +944,7 @@ func (m *BasicFeeAllowance) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeeGrant + return ErrIntOverflowFeegrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -957,11 +957,11 @@ func (m *BasicFeeAllowance) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -978,7 +978,7 @@ func (m *BasicFeeAllowance) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeeGrant + return ErrIntOverflowFeegrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -991,11 +991,11 @@ func (m *BasicFeeAllowance) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -1006,15 +1006,12 @@ func (m *BasicFeeAllowance) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipFeeGrant(dAtA[iNdEx:]) + skippy, err := skipFeegrant(dAtA[iNdEx:]) if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthFeeGrant - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthFeeGrant + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFeegrant } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1036,7 +1033,7 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeeGrant + return ErrIntOverflowFeegrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1064,7 +1061,7 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeeGrant + return ErrIntOverflowFeegrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1077,11 +1074,11 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -1097,7 +1094,7 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeeGrant + return ErrIntOverflowFeegrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1110,11 +1107,11 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -1130,7 +1127,7 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeeGrant + return ErrIntOverflowFeegrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1143,11 +1140,11 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -1164,7 +1161,7 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeeGrant + return ErrIntOverflowFeegrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1177,11 +1174,11 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -1198,7 +1195,7 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeeGrant + return ErrIntOverflowFeegrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1211,11 +1208,11 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -1226,15 +1223,12 @@ func (m *PeriodicFeeAllowance) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipFeeGrant(dAtA[iNdEx:]) + skippy, err := skipFeegrant(dAtA[iNdEx:]) if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthFeeGrant - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthFeeGrant + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFeegrant } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1256,7 +1250,7 @@ func (m *Duration) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeeGrant + return ErrIntOverflowFeegrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1284,7 +1278,7 @@ func (m *Duration) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeeGrant + return ErrIntOverflowFeegrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1297,11 +1291,11 @@ func (m *Duration) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -1319,7 +1313,7 @@ func (m *Duration) Unmarshal(dAtA []byte) error { var v int64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeeGrant + return ErrIntOverflowFeegrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1334,15 +1328,12 @@ func (m *Duration) Unmarshal(dAtA []byte) error { m.Sum = &Duration_Block{v} default: iNdEx = preIndex - skippy, err := skipFeeGrant(dAtA[iNdEx:]) + skippy, err := skipFeegrant(dAtA[iNdEx:]) if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthFeeGrant - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthFeeGrant + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFeegrant } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1364,7 +1355,7 @@ func (m *ExpiresAt) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeeGrant + return ErrIntOverflowFeegrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1392,7 +1383,7 @@ func (m *ExpiresAt) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeeGrant + return ErrIntOverflowFeegrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1405,11 +1396,11 @@ func (m *ExpiresAt) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -1427,7 +1418,7 @@ func (m *ExpiresAt) Unmarshal(dAtA []byte) error { var v int64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeeGrant + return ErrIntOverflowFeegrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1442,15 +1433,12 @@ func (m *ExpiresAt) Unmarshal(dAtA []byte) error { m.Sum = &ExpiresAt_Height{v} default: iNdEx = preIndex - skippy, err := skipFeeGrant(dAtA[iNdEx:]) + skippy, err := skipFeegrant(dAtA[iNdEx:]) if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthFeeGrant - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthFeeGrant + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFeegrant } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1472,7 +1460,7 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeeGrant + return ErrIntOverflowFeegrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1500,7 +1488,7 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeeGrant + return ErrIntOverflowFeegrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1514,11 +1502,11 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -1532,7 +1520,7 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeeGrant + return ErrIntOverflowFeegrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1546,11 +1534,11 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -1564,7 +1552,7 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeeGrant + return ErrIntOverflowFeegrant } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1577,11 +1565,11 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthFeeGrant + return ErrInvalidLengthFeegrant } if postIndex > l { return io.ErrUnexpectedEOF @@ -1595,15 +1583,12 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipFeeGrant(dAtA[iNdEx:]) + skippy, err := skipFeegrant(dAtA[iNdEx:]) if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthFeeGrant - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthFeeGrant + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFeegrant } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1617,7 +1602,7 @@ func (m *FeeAllowanceGrant) Unmarshal(dAtA []byte) error { } return nil } -func skipFeeGrant(dAtA []byte) (n int, err error) { +func skipFeegrant(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 depth := 0 @@ -1625,7 +1610,7 @@ func skipFeeGrant(dAtA []byte) (n int, err error) { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowFeeGrant + return 0, ErrIntOverflowFeegrant } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -1642,7 +1627,7 @@ func skipFeeGrant(dAtA []byte) (n int, err error) { case 0: for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowFeeGrant + return 0, ErrIntOverflowFeegrant } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -1658,7 +1643,7 @@ func skipFeeGrant(dAtA []byte) (n int, err error) { var length int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowFeeGrant + return 0, ErrIntOverflowFeegrant } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -1671,14 +1656,14 @@ func skipFeeGrant(dAtA []byte) (n int, err error) { } } if length < 0 { - return 0, ErrInvalidLengthFeeGrant + return 0, ErrInvalidLengthFeegrant } iNdEx += length case 3: depth++ case 4: if depth == 0 { - return 0, ErrUnexpectedEndOfGroupFeeGrant + return 0, ErrUnexpectedEndOfGroupFeegrant } depth-- case 5: @@ -1687,7 +1672,7 @@ func skipFeeGrant(dAtA []byte) (n int, err error) { return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } if iNdEx < 0 { - return 0, ErrInvalidLengthFeeGrant + return 0, ErrInvalidLengthFeegrant } if depth == 0 { return iNdEx, nil @@ -1697,7 +1682,7 @@ func skipFeeGrant(dAtA []byte) (n int, err error) { } var ( - ErrInvalidLengthFeeGrant = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowFeeGrant = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupFeeGrant = fmt.Errorf("proto: unexpected end of group") + ErrInvalidLengthFeegrant = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowFeegrant = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupFeegrant = fmt.Errorf("proto: unexpected end of group") ) diff --git a/x/fee_grant/types/fees.go b/x/feegrant/types/fees.go similarity index 100% rename from x/fee_grant/types/fees.go rename to x/feegrant/types/fees.go diff --git a/x/fee_grant/types/genesis.go b/x/feegrant/types/genesis.go similarity index 100% rename from x/fee_grant/types/genesis.go rename to x/feegrant/types/genesis.go diff --git a/x/fee_grant/types/genesis.pb.go b/x/feegrant/types/genesis.pb.go similarity index 80% rename from x/fee_grant/types/genesis.pb.go rename to x/feegrant/types/genesis.pb.go index 00961b3bb9b8..499f57d626d6 100644 --- a/x/fee_grant/types/genesis.pb.go +++ b/x/feegrant/types/genesis.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmos/fee_grant/v1beta1/genesis.proto +// source: cosmos/feegrant/v1beta1/genesis.proto package types @@ -32,7 +32,7 @@ func (m *GenesisState) Reset() { *m = GenesisState{} } func (m *GenesisState) String() string { return proto.CompactTextString(m) } func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_2ab54f02a586cbd9, []int{0} + return fileDescriptor_ac719d2d0954d1bf, []int{0} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -69,29 +69,29 @@ func (m *GenesisState) GetFeeAllowances() []FeeAllowanceGrant { } func init() { - proto.RegisterType((*GenesisState)(nil), "cosmos.fee_grant.v1beta1.GenesisState") + proto.RegisterType((*GenesisState)(nil), "cosmos.feegrant.v1beta1.GenesisState") } func init() { - proto.RegisterFile("cosmos/fee_grant/v1beta1/genesis.proto", fileDescriptor_2ab54f02a586cbd9) + proto.RegisterFile("cosmos/feegrant/v1beta1/genesis.proto", fileDescriptor_ac719d2d0954d1bf) } -var fileDescriptor_2ab54f02a586cbd9 = []byte{ - // 220 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4b, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0x8d, 0x4f, 0x2f, 0x4a, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, - 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, - 0x2f, 0xc9, 0x17, 0x92, 0x80, 0xa8, 0xd3, 0x83, 0xab, 0xd3, 0x83, 0xaa, 0x93, 0x12, 0x49, 0xcf, - 0x4f, 0xcf, 0x07, 0x2b, 0xd2, 0x07, 0xb1, 0x20, 0xea, 0xa5, 0x34, 0x70, 0x9a, 0x8b, 0x30, 0x01, - 0xac, 0x52, 0x29, 0x83, 0x8b, 0xc7, 0x1d, 0x62, 0x55, 0x70, 0x49, 0x62, 0x49, 0xaa, 0x50, 0x04, - 0x17, 0x1f, 0x48, 0x49, 0x62, 0x4e, 0x4e, 0x7e, 0x79, 0x62, 0x5e, 0x72, 0x6a, 0xb1, 0x04, 0xa3, - 0x02, 0xb3, 0x06, 0xb7, 0x91, 0xb6, 0x1e, 0x2e, 0x27, 0xe8, 0xb9, 0xa5, 0xa6, 0x3a, 0xc2, 0x94, - 0xbb, 0x83, 0x64, 0x9c, 0x58, 0x4e, 0xdc, 0x93, 0x67, 0x08, 0xe2, 0x4d, 0x43, 0x92, 0x28, 0x76, - 0xf2, 0x38, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, - 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xbd, 0xf4, 0xcc, 0x92, - 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0xa8, 0xc3, 0x21, 0x94, 0x6e, 0x71, 0x4a, 0xb6, - 0x7e, 0x05, 0x92, 0x2f, 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x4e, 0x37, 0x06, 0x04, - 0x00, 0x00, 0xff, 0xff, 0x27, 0x5c, 0xbd, 0x8c, 0x3e, 0x01, 0x00, 0x00, +var fileDescriptor_ac719d2d0954d1bf = []byte{ + // 221 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4d, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0x4d, 0x2f, 0x4a, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, + 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, + 0xc9, 0x17, 0x12, 0x87, 0x28, 0xd3, 0x83, 0x29, 0xd3, 0x83, 0x2a, 0x93, 0x12, 0x49, 0xcf, 0x4f, + 0xcf, 0x07, 0xab, 0xd1, 0x07, 0xb1, 0x20, 0xca, 0xa5, 0xd4, 0x70, 0x99, 0x0a, 0xd7, 0x0f, 0x56, + 0xa7, 0x94, 0xce, 0xc5, 0xe3, 0x0e, 0xb1, 0x27, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0x28, 0x9c, 0x8b, + 0x2f, 0x2d, 0x35, 0x35, 0x3e, 0x31, 0x27, 0x27, 0xbf, 0x3c, 0x31, 0x2f, 0x39, 0xb5, 0x58, 0x82, + 0x51, 0x81, 0x59, 0x83, 0xdb, 0x48, 0x4b, 0x0f, 0x87, 0xfd, 0x7a, 0x6e, 0xa9, 0xa9, 0x8e, 0x30, + 0xd5, 0xee, 0x20, 0x19, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0x78, 0xd3, 0x90, 0x24, 0x8a, + 0x9d, 0xdc, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, + 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x37, 0x3d, 0xb3, + 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xea, 0x6a, 0x08, 0xa5, 0x5b, 0x9c, 0x92, + 0xad, 0x5f, 0x81, 0xf0, 0x42, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0xe1, 0xc6, 0x80, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xaf, 0x53, 0x6e, 0xc5, 0x38, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -232,10 +232,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthGenesis } if (iNdEx + skippy) > l { diff --git a/x/fee_grant/types/grant.go b/x/feegrant/types/grant.go similarity index 100% rename from x/fee_grant/types/grant.go rename to x/feegrant/types/grant.go diff --git a/x/fee_grant/types/grant_test.go b/x/feegrant/types/grant_test.go similarity index 97% rename from x/fee_grant/types/grant_test.go rename to x/feegrant/types/grant_test.go index 716aa61c919a..c826889c7bf5 100644 --- a/x/fee_grant/types/grant_test.go +++ b/x/feegrant/types/grant_test.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/x/fee_grant/types/key.go b/x/feegrant/types/key.go similarity index 100% rename from x/fee_grant/types/key.go rename to x/feegrant/types/key.go diff --git a/x/fee_grant/types/msgs.go b/x/feegrant/types/msgs.go similarity index 100% rename from x/fee_grant/types/msgs.go rename to x/feegrant/types/msgs.go diff --git a/x/fee_grant/types/periodic_fee.go b/x/feegrant/types/periodic_fee.go similarity index 100% rename from x/fee_grant/types/periodic_fee.go rename to x/feegrant/types/periodic_fee.go diff --git a/x/fee_grant/types/periodic_fee_test.go b/x/feegrant/types/periodic_fee_test.go similarity index 99% rename from x/fee_grant/types/periodic_fee_test.go rename to x/feegrant/types/periodic_fee_test.go index 9a92fc19a492..0f853da28a60 100644 --- a/x/fee_grant/types/periodic_fee_test.go +++ b/x/feegrant/types/periodic_fee_test.go @@ -5,7 +5,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/fee_grant/types" + "github.com/cosmos/cosmos-sdk/x/feegrant/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/x/fee_grant/types/query.pb.go b/x/feegrant/types/query.pb.go similarity index 87% rename from x/fee_grant/types/query.pb.go rename to x/feegrant/types/query.pb.go index dd30ff171bce..31450c64bbb2 100644 --- a/x/fee_grant/types/query.pb.go +++ b/x/feegrant/types/query.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmos/fee_grant/v1beta1/query.proto +// source: cosmos/feegrant/v1beta1/query.proto package types @@ -40,7 +40,7 @@ func (m *QueryFeeAllowanceRequest) Reset() { *m = QueryFeeAllowanceReque func (m *QueryFeeAllowanceRequest) String() string { return proto.CompactTextString(m) } func (*QueryFeeAllowanceRequest) ProtoMessage() {} func (*QueryFeeAllowanceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2264e3bbfc7b20e4, []int{0} + return fileDescriptor_59efc303945de53f, []int{0} } func (m *QueryFeeAllowanceRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -93,7 +93,7 @@ func (m *QueryFeeAllowanceResponse) Reset() { *m = QueryFeeAllowanceResp func (m *QueryFeeAllowanceResponse) String() string { return proto.CompactTextString(m) } func (*QueryFeeAllowanceResponse) ProtoMessage() {} func (*QueryFeeAllowanceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2264e3bbfc7b20e4, []int{1} + return fileDescriptor_59efc303945de53f, []int{1} } func (m *QueryFeeAllowanceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -140,7 +140,7 @@ func (m *QueryFeeAllowancesRequest) Reset() { *m = QueryFeeAllowancesReq func (m *QueryFeeAllowancesRequest) String() string { return proto.CompactTextString(m) } func (*QueryFeeAllowancesRequest) ProtoMessage() {} func (*QueryFeeAllowancesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2264e3bbfc7b20e4, []int{2} + return fileDescriptor_59efc303945de53f, []int{2} } func (m *QueryFeeAllowancesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -195,7 +195,7 @@ func (m *QueryFeeAllowancesResponse) Reset() { *m = QueryFeeAllowancesRe func (m *QueryFeeAllowancesResponse) String() string { return proto.CompactTextString(m) } func (*QueryFeeAllowancesResponse) ProtoMessage() {} func (*QueryFeeAllowancesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2264e3bbfc7b20e4, []int{3} + return fileDescriptor_59efc303945de53f, []int{3} } func (m *QueryFeeAllowancesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -239,47 +239,47 @@ func (m *QueryFeeAllowancesResponse) GetPagination() *query.PageResponse { } func init() { - proto.RegisterType((*QueryFeeAllowanceRequest)(nil), "cosmos.fee_grant.v1beta1.QueryFeeAllowanceRequest") - proto.RegisterType((*QueryFeeAllowanceResponse)(nil), "cosmos.fee_grant.v1beta1.QueryFeeAllowanceResponse") - proto.RegisterType((*QueryFeeAllowancesRequest)(nil), "cosmos.fee_grant.v1beta1.QueryFeeAllowancesRequest") - proto.RegisterType((*QueryFeeAllowancesResponse)(nil), "cosmos.fee_grant.v1beta1.QueryFeeAllowancesResponse") + proto.RegisterType((*QueryFeeAllowanceRequest)(nil), "cosmos.feegrant.v1beta1.QueryFeeAllowanceRequest") + proto.RegisterType((*QueryFeeAllowanceResponse)(nil), "cosmos.feegrant.v1beta1.QueryFeeAllowanceResponse") + proto.RegisterType((*QueryFeeAllowancesRequest)(nil), "cosmos.feegrant.v1beta1.QueryFeeAllowancesRequest") + proto.RegisterType((*QueryFeeAllowancesResponse)(nil), "cosmos.feegrant.v1beta1.QueryFeeAllowancesResponse") } func init() { - proto.RegisterFile("cosmos/fee_grant/v1beta1/query.proto", fileDescriptor_2264e3bbfc7b20e4) + proto.RegisterFile("cosmos/feegrant/v1beta1/query.proto", fileDescriptor_59efc303945de53f) } -var fileDescriptor_2264e3bbfc7b20e4 = []byte{ - // 460 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x41, 0x8b, 0xd3, 0x40, - 0x14, 0xc7, 0x3b, 0x15, 0x15, 0x67, 0xb7, 0x1e, 0x06, 0x0f, 0x31, 0x48, 0x58, 0x82, 0xe8, 0xa2, - 0x38, 0x43, 0x5b, 0x2f, 0x8a, 0x17, 0xf7, 0xb0, 0xeb, 0x49, 0xd6, 0x1c, 0xbd, 0xc8, 0xb4, 0xbe, - 0x1d, 0x8b, 0x6d, 0x26, 0x9b, 0x99, 0xaa, 0x8b, 0xf4, 0xe2, 0x27, 0x10, 0xfc, 0x2c, 0x1e, 0xc4, - 0x2f, 0xe0, 0x71, 0xc1, 0x8b, 0x47, 0x69, 0xfd, 0x1a, 0x82, 0x64, 0x26, 0xd3, 0x4c, 0x69, 0x82, - 0x9b, 0x53, 0x26, 0x79, 0xff, 0xf7, 0xde, 0xef, 0xff, 0xf2, 0x12, 0x7c, 0x7b, 0x2c, 0xd5, 0x4c, - 0x2a, 0x76, 0x02, 0xf0, 0x4a, 0xe4, 0x3c, 0xd5, 0xec, 0x5d, 0x7f, 0x04, 0x9a, 0xf7, 0xd9, 0xe9, - 0x1c, 0xf2, 0x33, 0x9a, 0xe5, 0x52, 0x4b, 0x12, 0x58, 0x15, 0x5d, 0xab, 0x68, 0xa9, 0x0a, 0x6f, - 0x08, 0x29, 0xa4, 0x11, 0xb1, 0xe2, 0x64, 0xf5, 0xe1, 0x7e, 0x63, 0xd5, 0xaa, 0x82, 0x55, 0xde, - 0x2b, 0x95, 0x23, 0xae, 0xc0, 0xb6, 0x5c, 0x4b, 0x33, 0x2e, 0x26, 0x29, 0xd7, 0x13, 0x99, 0x96, - 0xda, 0x5b, 0x42, 0x4a, 0x31, 0x05, 0xc6, 0xb3, 0x09, 0xe3, 0x69, 0x2a, 0xb5, 0x09, 0x2a, 0x1b, - 0x8d, 0x9f, 0xe3, 0xe0, 0x45, 0x91, 0x7f, 0x08, 0xf0, 0x74, 0x3a, 0x95, 0xef, 0x79, 0x3a, 0x86, - 0x04, 0x4e, 0xe7, 0xa0, 0x34, 0x09, 0xf0, 0x55, 0xd3, 0x14, 0xf2, 0x00, 0xed, 0xa1, 0xfd, 0x6b, - 0x89, 0xbb, 0xad, 0x22, 0x10, 0x74, 0xfd, 0x08, 0xc4, 0x33, 0x7c, 0xb3, 0xa6, 0x9e, 0xca, 0x64, - 0xaa, 0x80, 0x1c, 0xe3, 0x5e, 0xe1, 0x84, 0xbb, 0x80, 0x29, 0xbb, 0x33, 0xb8, 0x4f, 0x9b, 0x06, - 0x45, 0xfd, 0x32, 0x47, 0x45, 0x24, 0xd9, 0x3d, 0xf1, 0x1e, 0xc5, 0x8b, 0x9a, 0x76, 0x6a, 0x8b, - 0x1f, 0x36, 0xf9, 0x81, 0x1c, 0x62, 0x5c, 0xcd, 0xc9, 0x58, 0xd8, 0x19, 0xdc, 0x71, 0x14, 0xc5, - 0x50, 0xa9, 0x7d, 0x8f, 0x0e, 0xe3, 0x98, 0x0b, 0x37, 0x95, 0xc4, 0xcb, 0x8c, 0xbf, 0x21, 0x1c, - 0xd6, 0xf5, 0x2f, 0xfd, 0x26, 0xf8, 0xfa, 0x86, 0x5f, 0x15, 0xa0, 0xbd, 0x4b, 0x6d, 0x0d, 0xf7, - 0x7c, 0xc3, 0x8a, 0x1c, 0xd5, 0xa0, 0xdf, 0xfd, 0x2f, 0xba, 0x05, 0xf2, 0xd9, 0x07, 0x7f, 0xbb, - 0xf8, 0xb2, 0x61, 0x27, 0xdf, 0x11, 0xde, 0xf5, 0xfb, 0x92, 0x41, 0x33, 0x5f, 0xd3, 0xb2, 0x84, - 0xc3, 0x56, 0x39, 0x96, 0x27, 0x3e, 0xf8, 0xf4, 0xf3, 0xcf, 0x97, 0xee, 0x13, 0xf2, 0x98, 0x55, - 0xab, 0xbf, 0xbd, 0xf9, 0xeb, 0xf9, 0xb1, 0x8f, 0xe5, 0x02, 0x2e, 0xdc, 0x09, 0x16, 0xe4, 0x2b, - 0xc2, 0xbd, 0x8d, 0xf1, 0x93, 0x36, 0x28, 0x6e, 0x59, 0xc2, 0x87, 0xed, 0x92, 0x4a, 0x03, 0x8f, - 0x8c, 0x81, 0x21, 0xe9, 0x5f, 0xcc, 0x80, 0xaa, 0xb8, 0x0f, 0x9e, 0xfd, 0x58, 0x46, 0xe8, 0x7c, - 0x19, 0xa1, 0xdf, 0xcb, 0x08, 0x7d, 0x5e, 0x45, 0x9d, 0xf3, 0x55, 0xd4, 0xf9, 0xb5, 0x8a, 0x3a, - 0x2f, 0xa9, 0x98, 0xe8, 0x37, 0xf3, 0x11, 0x1d, 0xcb, 0x99, 0x2b, 0x6b, 0x2f, 0x0f, 0xd4, 0xeb, - 0xb7, 0xec, 0x83, 0xf7, 0x7f, 0xd0, 0x67, 0x19, 0xa8, 0xd1, 0x15, 0xf3, 0x29, 0x0f, 0xff, 0x05, - 0x00, 0x00, 0xff, 0xff, 0x38, 0x5c, 0xd5, 0x1e, 0x96, 0x04, 0x00, 0x00, +var fileDescriptor_59efc303945de53f = []byte{ + // 455 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x31, 0x8f, 0xd3, 0x30, + 0x14, 0xc7, 0xeb, 0x22, 0x40, 0xf8, 0xae, 0x0c, 0x16, 0x12, 0x21, 0x42, 0xd1, 0x29, 0x48, 0x07, + 0x3a, 0xe9, 0x62, 0x35, 0x9d, 0x40, 0x2c, 0xdc, 0x70, 0xdd, 0x80, 0xcb, 0xc8, 0x82, 0x9c, 0xf2, + 0x6a, 0x22, 0x72, 0x71, 0x2e, 0x76, 0x81, 0x13, 0xea, 0xc2, 0x27, 0x40, 0xe2, 0xa3, 0xb0, 0xc0, + 0x37, 0x60, 0x3c, 0x89, 0x85, 0x11, 0xb5, 0x7c, 0x09, 0x36, 0x14, 0x3b, 0x6e, 0x52, 0x91, 0x00, + 0x99, 0xe2, 0xe4, 0xfd, 0xdf, 0x7b, 0xbf, 0xf7, 0xcf, 0x33, 0xbe, 0x33, 0x13, 0xf2, 0x54, 0x48, + 0x3a, 0x07, 0xe0, 0x05, 0xcb, 0x14, 0x7d, 0x3d, 0x8e, 0x41, 0xb1, 0x31, 0x3d, 0x5b, 0x40, 0x71, + 0x1e, 0xe4, 0x85, 0x50, 0x82, 0xdc, 0x34, 0xa2, 0xc0, 0x8a, 0x82, 0x4a, 0xe4, 0xde, 0xe0, 0x82, + 0x0b, 0xad, 0xa1, 0xe5, 0xc9, 0xc8, 0xdd, 0xfd, 0xae, 0x9a, 0x9b, 0x7c, 0xa3, 0x3b, 0xa8, 0x74, + 0x31, 0x93, 0x60, 0xfa, 0x6d, 0x94, 0x39, 0xe3, 0x49, 0xc6, 0x54, 0x22, 0xb2, 0x4a, 0x7b, 0x9b, + 0x0b, 0xc1, 0x53, 0xa0, 0x2c, 0x4f, 0x28, 0xcb, 0x32, 0xa1, 0x74, 0x50, 0x9a, 0xa8, 0xff, 0x18, + 0x3b, 0x27, 0x65, 0xfe, 0x31, 0xc0, 0xa3, 0x34, 0x15, 0x6f, 0x58, 0x36, 0x83, 0x08, 0xce, 0x16, + 0x20, 0x15, 0x71, 0xf0, 0x55, 0xdd, 0x14, 0x0a, 0x07, 0xed, 0xa1, 0x7b, 0xd7, 0x22, 0xfb, 0x5a, + 0x47, 0xc0, 0x19, 0x36, 0x23, 0xe0, 0xa7, 0xf8, 0x56, 0x4b, 0x3d, 0x99, 0x8b, 0x4c, 0x02, 0x79, + 0x82, 0x47, 0x73, 0x80, 0xe7, 0xcc, 0x06, 0x74, 0xd9, 0x9d, 0xf0, 0x20, 0xe8, 0x70, 0x29, 0x68, + 0x56, 0x99, 0x96, 0x91, 0x68, 0x77, 0xde, 0xf8, 0xe4, 0x2f, 0x5b, 0xba, 0xc9, 0x3f, 0xf0, 0x61, + 0x1b, 0x1f, 0xc8, 0x31, 0xc6, 0xb5, 0x4d, 0x7a, 0x82, 0x9d, 0x70, 0xdf, 0x42, 0x94, 0x9e, 0x06, + 0xe6, 0x1f, 0x5a, 0x8c, 0xa7, 0x8c, 0x5b, 0x53, 0xa2, 0x46, 0xa6, 0xff, 0x19, 0x61, 0xb7, 0xad, + 0x7f, 0x35, 0xee, 0x09, 0xbe, 0xbe, 0x35, 0xae, 0x74, 0xd0, 0xde, 0xa5, 0x9e, 0xf3, 0x8e, 0x9a, + 0xf3, 0x4a, 0x32, 0x6d, 0x21, 0xbf, 0xfb, 0x4f, 0x72, 0xc3, 0xd3, 0x44, 0x0f, 0x7f, 0x0d, 0xf1, + 0x65, 0x8d, 0x4e, 0xbe, 0x20, 0xbc, 0xdb, 0xec, 0x4b, 0xc6, 0x9d, 0x78, 0x5d, 0x9b, 0xe2, 0x86, + 0x7d, 0x52, 0x0c, 0x8d, 0x7f, 0xf4, 0xfe, 0xdb, 0xcf, 0x8f, 0xc3, 0x87, 0xe4, 0x01, 0xfd, 0xcb, + 0xd2, 0xd7, 0xe6, 0xd1, 0x77, 0xd5, 0xf2, 0x2d, 0xed, 0x09, 0x96, 0xe4, 0x13, 0xc2, 0xa3, 0x2d, + 0xef, 0x49, 0x0f, 0x12, 0xbb, 0x28, 0xee, 0xa4, 0x57, 0x4e, 0x85, 0x7f, 0x5f, 0xe3, 0x4f, 0xc8, + 0xf8, 0xff, 0xf0, 0x65, 0x4d, 0x7d, 0x34, 0xfd, 0xba, 0xf2, 0xd0, 0xc5, 0xca, 0x43, 0x3f, 0x56, + 0x1e, 0xfa, 0xb0, 0xf6, 0x06, 0x17, 0x6b, 0x6f, 0xf0, 0x7d, 0xed, 0x0d, 0x9e, 0x1d, 0xf2, 0x44, + 0xbd, 0x5c, 0xc4, 0xc1, 0x4c, 0x9c, 0xda, 0xb2, 0xe6, 0x71, 0x28, 0x5f, 0xbc, 0xa2, 0x6f, 0xeb, + 0x1e, 0xea, 0x3c, 0x07, 0x19, 0x5f, 0xd1, 0x77, 0x78, 0xf2, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xb8, + 0x46, 0x4c, 0xba, 0x8b, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -310,7 +310,7 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { func (c *queryClient) FeeAllowance(ctx context.Context, in *QueryFeeAllowanceRequest, opts ...grpc.CallOption) (*QueryFeeAllowanceResponse, error) { out := new(QueryFeeAllowanceResponse) - err := c.cc.Invoke(ctx, "/cosmos.fee_grant.v1beta1.Query/FeeAllowance", in, out, opts...) + err := c.cc.Invoke(ctx, "/cosmos.feegrant.v1beta1.Query/FeeAllowance", in, out, opts...) if err != nil { return nil, err } @@ -319,7 +319,7 @@ func (c *queryClient) FeeAllowance(ctx context.Context, in *QueryFeeAllowanceReq func (c *queryClient) FeeAllowances(ctx context.Context, in *QueryFeeAllowancesRequest, opts ...grpc.CallOption) (*QueryFeeAllowancesResponse, error) { out := new(QueryFeeAllowancesResponse) - err := c.cc.Invoke(ctx, "/cosmos.fee_grant.v1beta1.Query/FeeAllowances", in, out, opts...) + err := c.cc.Invoke(ctx, "/cosmos.feegrant.v1beta1.Query/FeeAllowances", in, out, opts...) if err != nil { return nil, err } @@ -359,7 +359,7 @@ func _Query_FeeAllowance_Handler(srv interface{}, ctx context.Context, dec func( } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/cosmos.fee_grant.v1beta1.Query/FeeAllowance", + FullMethod: "/cosmos.feegrant.v1beta1.Query/FeeAllowance", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).FeeAllowance(ctx, req.(*QueryFeeAllowanceRequest)) @@ -377,7 +377,7 @@ func _Query_FeeAllowances_Handler(srv interface{}, ctx context.Context, dec func } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/cosmos.fee_grant.v1beta1.Query/FeeAllowances", + FullMethod: "/cosmos.feegrant.v1beta1.Query/FeeAllowances", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).FeeAllowances(ctx, req.(*QueryFeeAllowancesRequest)) @@ -386,7 +386,7 @@ func _Query_FeeAllowances_Handler(srv interface{}, ctx context.Context, dec func } var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "cosmos.fee_grant.v1beta1.Query", + ServiceName: "cosmos.feegrant.v1beta1.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { @@ -399,7 +399,7 @@ var _Query_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "cosmos/fee_grant/v1beta1/query.proto", + Metadata: "cosmos/feegrant/v1beta1/query.proto", } func (m *QueryFeeAllowanceRequest) Marshal() (dAtA []byte, err error) { @@ -747,10 +747,7 @@ func (m *QueryFeeAllowanceRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -836,10 +833,7 @@ func (m *QueryFeeAllowanceResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -957,10 +951,7 @@ func (m *QueryFeeAllowancesRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -1080,10 +1071,7 @@ func (m *QueryFeeAllowancesResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { diff --git a/x/fee_grant/types/query.pb.gw.go b/x/feegrant/types/query.pb.gw.go similarity index 99% rename from x/fee_grant/types/query.pb.gw.go rename to x/feegrant/types/query.pb.gw.go index 0a86d05e44bb..499e4a441d18 100644 --- a/x/fee_grant/types/query.pb.gw.go +++ b/x/feegrant/types/query.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: cosmos/fee_grant/v1beta1/query.proto +// source: cosmos/feegrant/v1beta1/query.proto /* Package types is a reverse proxy. diff --git a/x/fee_grant/types/tx.pb.go b/x/feegrant/types/tx.pb.go similarity index 87% rename from x/fee_grant/types/tx.pb.go rename to x/feegrant/types/tx.pb.go index 8bda6ce8f975..d3080f10e3df 100644 --- a/x/fee_grant/types/tx.pb.go +++ b/x/feegrant/types/tx.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmos/fee_grant/v1beta1/tx.proto +// source: cosmos/feegrant/v1beta1/tx.proto package types @@ -42,7 +42,7 @@ func (m *MsgGrantFeeAllowance) Reset() { *m = MsgGrantFeeAllowance{} } func (m *MsgGrantFeeAllowance) String() string { return proto.CompactTextString(m) } func (*MsgGrantFeeAllowance) ProtoMessage() {} func (*MsgGrantFeeAllowance) Descriptor() ([]byte, []int) { - return fileDescriptor_12c787f073d65b9c, []int{0} + return fileDescriptor_dd44ad7946dad783, []int{0} } func (m *MsgGrantFeeAllowance) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -100,7 +100,7 @@ func (m *MsgGrantFeeAllowanceResponse) Reset() { *m = MsgGrantFeeAllowan func (m *MsgGrantFeeAllowanceResponse) String() string { return proto.CompactTextString(m) } func (*MsgGrantFeeAllowanceResponse) ProtoMessage() {} func (*MsgGrantFeeAllowanceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_12c787f073d65b9c, []int{1} + return fileDescriptor_dd44ad7946dad783, []int{1} } func (m *MsgGrantFeeAllowanceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -139,7 +139,7 @@ func (m *MsgRevokeFeeAllowance) Reset() { *m = MsgRevokeFeeAllowance{} } func (m *MsgRevokeFeeAllowance) String() string { return proto.CompactTextString(m) } func (*MsgRevokeFeeAllowance) ProtoMessage() {} func (*MsgRevokeFeeAllowance) Descriptor() ([]byte, []int) { - return fileDescriptor_12c787f073d65b9c, []int{2} + return fileDescriptor_dd44ad7946dad783, []int{2} } func (m *MsgRevokeFeeAllowance) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -190,7 +190,7 @@ func (m *MsgRevokeFeeAllowanceResponse) Reset() { *m = MsgRevokeFeeAllow func (m *MsgRevokeFeeAllowanceResponse) String() string { return proto.CompactTextString(m) } func (*MsgRevokeFeeAllowanceResponse) ProtoMessage() {} func (*MsgRevokeFeeAllowanceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_12c787f073d65b9c, []int{3} + return fileDescriptor_dd44ad7946dad783, []int{3} } func (m *MsgRevokeFeeAllowanceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -220,38 +220,38 @@ func (m *MsgRevokeFeeAllowanceResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRevokeFeeAllowanceResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgGrantFeeAllowance)(nil), "cosmos.fee_grant.v1beta1.MsgGrantFeeAllowance") - proto.RegisterType((*MsgGrantFeeAllowanceResponse)(nil), "cosmos.fee_grant.v1beta1.MsgGrantFeeAllowanceResponse") - proto.RegisterType((*MsgRevokeFeeAllowance)(nil), "cosmos.fee_grant.v1beta1.MsgRevokeFeeAllowance") - proto.RegisterType((*MsgRevokeFeeAllowanceResponse)(nil), "cosmos.fee_grant.v1beta1.MsgRevokeFeeAllowanceResponse") + proto.RegisterType((*MsgGrantFeeAllowance)(nil), "cosmos.feegrant.v1beta1.MsgGrantFeeAllowance") + proto.RegisterType((*MsgGrantFeeAllowanceResponse)(nil), "cosmos.feegrant.v1beta1.MsgGrantFeeAllowanceResponse") + proto.RegisterType((*MsgRevokeFeeAllowance)(nil), "cosmos.feegrant.v1beta1.MsgRevokeFeeAllowance") + proto.RegisterType((*MsgRevokeFeeAllowanceResponse)(nil), "cosmos.feegrant.v1beta1.MsgRevokeFeeAllowanceResponse") } -func init() { proto.RegisterFile("cosmos/fee_grant/v1beta1/tx.proto", fileDescriptor_12c787f073d65b9c) } +func init() { proto.RegisterFile("cosmos/feegrant/v1beta1/tx.proto", fileDescriptor_dd44ad7946dad783) } -var fileDescriptor_12c787f073d65b9c = []byte{ - // 346 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0x8d, 0x4f, 0x2f, 0x4a, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, - 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x80, - 0x28, 0xd1, 0x83, 0x2b, 0xd1, 0x83, 0x2a, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, 0xd2, - 0x07, 0xb1, 0x20, 0xea, 0xa5, 0x24, 0xd3, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0xc1, 0xbc, 0xa4, - 0xd2, 0x34, 0xfd, 0xc4, 0xbc, 0x4a, 0x98, 0x14, 0xc4, 0xa8, 0x78, 0x88, 0x1e, 0xa8, 0xb9, 0x60, - 0x8e, 0xd2, 0x44, 0x46, 0x2e, 0x11, 0xdf, 0xe2, 0x74, 0x77, 0x90, 0x05, 0x6e, 0xa9, 0xa9, 0x8e, - 0x39, 0x39, 0xf9, 0xe5, 0x89, 0x79, 0xc9, 0xa9, 0x42, 0x12, 0x5c, 0xec, 0x60, 0x5b, 0x53, 0x8b, - 0x24, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x60, 0x5c, 0x84, 0x4c, 0xaa, 0x04, 0x13, 0xb2, 0x4c, - 0xaa, 0x90, 0x2b, 0x17, 0x67, 0x22, 0xcc, 0x00, 0x09, 0x66, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x11, - 0x3d, 0x88, 0xb3, 0xf4, 0x60, 0xce, 0xd2, 0x73, 0xcc, 0xab, 0x74, 0x12, 0x3c, 0xb5, 0x45, 0x97, - 0x17, 0xd9, 0x3a, 0xcf, 0x20, 0x84, 0x4e, 0x25, 0x39, 0x2e, 0x19, 0x6c, 0x4e, 0x0a, 0x4a, 0x2d, - 0x2e, 0xc8, 0xcf, 0x2b, 0x4e, 0x55, 0xf2, 0xe6, 0x12, 0xf5, 0x2d, 0x4e, 0x0f, 0x4a, 0x2d, 0xcb, - 0xcf, 0x4e, 0xa5, 0xd4, 0xcd, 0x4a, 0xf2, 0x5c, 0xb2, 0x58, 0x0d, 0x83, 0xd9, 0x66, 0xd4, 0xc4, - 0xc4, 0xc5, 0xec, 0x5b, 0x9c, 0x2e, 0x54, 0xcd, 0x25, 0x88, 0x19, 0x4a, 0x7a, 0x7a, 0xb8, 0x62, - 0x49, 0x0f, 0x9b, 0x17, 0xa4, 0xcc, 0x48, 0x53, 0x0f, 0x73, 0x84, 0x50, 0x1d, 0x97, 0x10, 0x16, - 0xff, 0xea, 0xe3, 0x35, 0x0d, 0x53, 0x83, 0x94, 0x39, 0x89, 0x1a, 0x60, 0xf6, 0x3b, 0x79, 0x9c, - 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, - 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x5e, 0x7a, 0x66, 0x49, 0x46, 0x69, - 0x92, 0x5e, 0x72, 0x7e, 0x2e, 0x34, 0x65, 0x41, 0x29, 0xdd, 0xe2, 0x94, 0x6c, 0xfd, 0x0a, 0xa4, - 0x14, 0x5e, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x4e, 0x08, 0xc6, 0x80, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x04, 0xa2, 0x6d, 0xe9, 0x02, 0x03, 0x00, 0x00, +var fileDescriptor_dd44ad7946dad783 = []byte{ + // 345 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0x4d, 0x2f, 0x4a, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, + 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x87, 0xa8, + 0xd0, 0x83, 0xa9, 0xd0, 0x83, 0xaa, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xab, 0xd1, 0x07, + 0xb1, 0x20, 0xca, 0xa5, 0x24, 0xd3, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0xc1, 0xbc, 0xa4, 0xd2, + 0x34, 0xfd, 0xc4, 0xbc, 0x4a, 0x98, 0x14, 0xc4, 0xa4, 0x78, 0x88, 0x1e, 0xa8, 0xb1, 0x60, 0x8e, + 0xd2, 0x44, 0x46, 0x2e, 0x11, 0xdf, 0xe2, 0x74, 0x77, 0x90, 0x05, 0x6e, 0xa9, 0xa9, 0x8e, 0x39, + 0x39, 0xf9, 0xe5, 0x89, 0x79, 0xc9, 0xa9, 0x42, 0x12, 0x5c, 0xec, 0x60, 0x5b, 0x53, 0x8b, 0x24, + 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x60, 0x5c, 0x84, 0x4c, 0xaa, 0x04, 0x13, 0xb2, 0x4c, 0xaa, + 0x90, 0x2b, 0x17, 0x67, 0x22, 0xcc, 0x00, 0x09, 0x66, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x11, 0x3d, + 0x88, 0xb3, 0xf4, 0x60, 0xce, 0xd2, 0x73, 0xcc, 0xab, 0x74, 0x12, 0x3c, 0xb5, 0x45, 0x97, 0x17, + 0xd9, 0x3a, 0xcf, 0x20, 0x84, 0x4e, 0x25, 0x39, 0x2e, 0x19, 0x6c, 0x4e, 0x0a, 0x4a, 0x2d, 0x2e, + 0xc8, 0xcf, 0x2b, 0x4e, 0x55, 0xf2, 0xe6, 0x12, 0xf5, 0x2d, 0x4e, 0x0f, 0x4a, 0x2d, 0xcb, 0xcf, + 0x4e, 0xa5, 0xd4, 0xcd, 0x4a, 0xf2, 0x5c, 0xb2, 0x58, 0x0d, 0x83, 0xd9, 0x66, 0xf4, 0x8f, 0x91, + 0x8b, 0xd9, 0xb7, 0x38, 0x5d, 0xa8, 0x92, 0x4b, 0x10, 0x33, 0x94, 0x74, 0xf5, 0x70, 0x44, 0x92, + 0x1e, 0x36, 0x1f, 0x48, 0x99, 0x92, 0xa4, 0x1c, 0xe6, 0x04, 0xa1, 0x1a, 0x2e, 0x21, 0x2c, 0xbe, + 0xd5, 0xc3, 0x67, 0x18, 0xa6, 0x7a, 0x29, 0x33, 0xd2, 0xd4, 0xc3, 0x6c, 0x77, 0x72, 0x3f, 0xf1, + 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, + 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xdd, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, + 0xbd, 0xe4, 0xfc, 0x5c, 0x68, 0xaa, 0x82, 0x52, 0xba, 0xc5, 0x29, 0xd9, 0xfa, 0x15, 0x88, 0xb4, + 0x5d, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x4e, 0x03, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x7b, 0xbe, 0x24, 0x15, 0xfb, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -284,7 +284,7 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { func (c *msgClient) GrantFeeAllowance(ctx context.Context, in *MsgGrantFeeAllowance, opts ...grpc.CallOption) (*MsgGrantFeeAllowanceResponse, error) { out := new(MsgGrantFeeAllowanceResponse) - err := c.cc.Invoke(ctx, "/cosmos.fee_grant.v1beta1.Msg/GrantFeeAllowance", in, out, opts...) + err := c.cc.Invoke(ctx, "/cosmos.feegrant.v1beta1.Msg/GrantFeeAllowance", in, out, opts...) if err != nil { return nil, err } @@ -293,7 +293,7 @@ func (c *msgClient) GrantFeeAllowance(ctx context.Context, in *MsgGrantFeeAllowa func (c *msgClient) RevokeFeeAllowance(ctx context.Context, in *MsgRevokeFeeAllowance, opts ...grpc.CallOption) (*MsgRevokeFeeAllowanceResponse, error) { out := new(MsgRevokeFeeAllowanceResponse) - err := c.cc.Invoke(ctx, "/cosmos.fee_grant.v1beta1.Msg/RevokeFeeAllowance", in, out, opts...) + err := c.cc.Invoke(ctx, "/cosmos.feegrant.v1beta1.Msg/RevokeFeeAllowance", in, out, opts...) if err != nil { return nil, err } @@ -335,7 +335,7 @@ func _Msg_GrantFeeAllowance_Handler(srv interface{}, ctx context.Context, dec fu } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/cosmos.fee_grant.v1beta1.Msg/GrantFeeAllowance", + FullMethod: "/cosmos.feegrant.v1beta1.Msg/GrantFeeAllowance", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).GrantFeeAllowance(ctx, req.(*MsgGrantFeeAllowance)) @@ -353,7 +353,7 @@ func _Msg_RevokeFeeAllowance_Handler(srv interface{}, ctx context.Context, dec f } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/cosmos.fee_grant.v1beta1.Msg/RevokeFeeAllowance", + FullMethod: "/cosmos.feegrant.v1beta1.Msg/RevokeFeeAllowance", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).RevokeFeeAllowance(ctx, req.(*MsgRevokeFeeAllowance)) @@ -362,7 +362,7 @@ func _Msg_RevokeFeeAllowance_Handler(srv interface{}, ctx context.Context, dec f } var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "cosmos.fee_grant.v1beta1.Msg", + ServiceName: "cosmos.feegrant.v1beta1.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { @@ -375,7 +375,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "cosmos/fee_grant/v1beta1/tx.proto", + Metadata: "cosmos/feegrant/v1beta1/tx.proto", } func (m *MsgGrantFeeAllowance) Marshal() (dAtA []byte, err error) { @@ -718,10 +718,7 @@ func (m *MsgGrantFeeAllowance) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -771,10 +768,7 @@ func (m *MsgGrantFeeAllowanceResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -888,10 +882,7 @@ func (m *MsgRevokeFeeAllowance) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -941,10 +932,7 @@ func (m *MsgRevokeFeeAllowanceResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { From f484c58fe4224e9a5d2483284a95568f1bbfd737 Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 19 Jan 2021 16:44:06 +0530 Subject: [PATCH 155/184] review comments --- x/feegrant/client/rest/grpc_query_test.go | 40 +++++++++++------------ x/feegrant/types/expiration.go | 16 ++++++--- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/x/feegrant/client/rest/grpc_query_test.go b/x/feegrant/client/rest/grpc_query_test.go index 99626923aafd..271f2b6cda09 100644 --- a/x/feegrant/client/rest/grpc_query_test.go +++ b/x/feegrant/client/rest/grpc_query_test.go @@ -60,7 +60,7 @@ func (s *IntegrationTestSuite) TearDownSuite() { s.network.Cleanup() } -func (s *IntegrationTestSuite) TestQueryFeeAllowence() { +func (s *IntegrationTestSuite) TestQueryFeeAllowance() { val := s.network.Validators[0] baseURL := val.APIAddress testCases := []struct { @@ -101,11 +101,11 @@ func (s *IntegrationTestSuite) TestQueryFeeAllowence() { false, "", func() { - execFeeAllowence(val, s) + execFeeAllowance(val, s) }, - func(allowence types.QueryFeeAllowanceResponse) { - s.Require().Equal(allowence.FeeAllowance.Granter, val.Address.String()) - s.Require().Equal(allowence.FeeAllowance.Grantee, s.grantee.String()) + func(allowance types.QueryFeeAllowanceResponse) { + s.Require().Equal(allowance.FeeAllowance.Granter, val.Address.String()) + s.Require().Equal(allowance.FeeAllowance.Grantee, s.grantee.String()) }, }, } @@ -116,16 +116,16 @@ func (s *IntegrationTestSuite) TestQueryFeeAllowence() { if tc.expectErr { s.Require().Contains(string(resp), tc.errorMsg) } else { - var allowence types.QueryFeeAllowanceResponse - err := val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &allowence) + var allowance types.QueryFeeAllowanceResponse + err := val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &allowance) s.Require().NoError(err) - tc.postRun(allowence) + tc.postRun(allowance) } }) } } -func (s *IntegrationTestSuite) TestQueryGranteeAllowences() { +func (s *IntegrationTestSuite) TestQueryGranteeAllowances() { val := s.network.Validators[0] baseURL := val.APIAddress testCases := []struct { @@ -150,8 +150,8 @@ func (s *IntegrationTestSuite) TestQueryGranteeAllowences() { false, "", func() {}, - func(allowences types.QueryFeeAllowancesResponse) { - s.Require().Equal(len(allowences.FeeAllowances), 0) + func(allowances types.QueryFeeAllowancesResponse) { + s.Require().Equal(len(allowances.FeeAllowances), 0) }, }, { @@ -160,12 +160,12 @@ func (s *IntegrationTestSuite) TestQueryGranteeAllowences() { false, "", func() { - execFeeAllowence(val, s) + execFeeAllowance(val, s) }, - func(allowences types.QueryFeeAllowancesResponse) { - s.Require().Equal(len(allowences.FeeAllowances), 1) - s.Require().Equal(allowences.FeeAllowances[0].Granter, val.Address.String()) - s.Require().Equal(allowences.FeeAllowances[0].Grantee, s.grantee.String()) + func(allowances types.QueryFeeAllowancesResponse) { + s.Require().Equal(len(allowances.FeeAllowances), 1) + s.Require().Equal(allowances.FeeAllowances[0].Granter, val.Address.String()) + s.Require().Equal(allowances.FeeAllowances[0].Grantee, s.grantee.String()) }, }, } @@ -176,16 +176,16 @@ func (s *IntegrationTestSuite) TestQueryGranteeAllowences() { if tc.expectErr { s.Require().Contains(string(resp), tc.errorMsg) } else { - var allowence types.QueryFeeAllowancesResponse - err := val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &allowence) + var allowance types.QueryFeeAllowancesResponse + err := val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &allowance) s.Require().NoError(err) - tc.postRun(allowence) + tc.postRun(allowance) } }) } } -func execFeeAllowence(val *network.Validator, s *IntegrationTestSuite) { +func execFeeAllowance(val *network.Validator, s *IntegrationTestSuite) { fee := sdk.NewCoin("steak", sdk.NewInt(100)) duration := 365 * 24 * 60 * 60 args := []string{ diff --git a/x/feegrant/types/expiration.go b/x/feegrant/types/expiration.go index e7483b6e945d..182990e00ee3 100644 --- a/x/feegrant/types/expiration.go +++ b/x/feegrant/types/expiration.go @@ -27,7 +27,7 @@ func ExpiresAtHeight(h int64) ExpiresAt { // ValidateBasic performs basic sanity checks. // Note that empty expiration is allowed func (e ExpiresAt) ValidateBasic() error { - if e.GetTime() != nil && !e.GetTime().IsZero() && e.GetHeight() != 0 { + if e.HasDefinedTime() && e.GetHeight() != 0 { return sdkerrors.Wrap(ErrInvalidDuration, "both time and height are set") } if e.GetHeight() < 0 { @@ -41,10 +41,16 @@ func (e ExpiresAt) IsZero() bool { return e.GetTime() == nil && e.GetHeight() == 0 } +// HasDefinedTime returns true if `ExpiresAt` has valid time +func (e ExpiresAt) HasDefinedTime() bool { + t := e.GetTime() + return t != nil && t.Unix() > 0 +} + // FastForward produces a new Expiration with the time or height set to the // new value, depending on what was set on the original expiration func (e ExpiresAt) FastForward(t time.Time, h int64) ExpiresAt { - if e.GetTime() != nil && !e.GetTime().IsZero() { + if e.HasDefinedTime() { return ExpiresAtTime(t) } return ExpiresAtHeight(h) @@ -56,7 +62,7 @@ func (e ExpiresAt) FastForward(t time.Time, h int64) ExpiresAt { // // Note a "zero" ExpiresAt is never expired func (e ExpiresAt) IsExpired(t *time.Time, h int64) bool { - if e.GetTime() != nil && !e.GetTime().IsZero() && !t.Before(*e.GetTime()) { + if e.HasDefinedTime() && !t.Before(*e.GetTime()) { return true } @@ -66,7 +72,7 @@ func (e ExpiresAt) IsExpired(t *time.Time, h int64) bool { // IsCompatible returns true iff the two use the same units. // If false, they cannot be added. func (e ExpiresAt) IsCompatible(d Duration) bool { - if e.GetTime() != nil && !e.GetTime().IsZero() { + if e.HasDefinedTime() { return d.GetDuration() != nil && d.GetDuration().Seconds() > float64(0) } return d.GetBlock() > 0 @@ -79,7 +85,7 @@ func (e ExpiresAt) Step(d Duration) (ExpiresAt, error) { if !e.IsCompatible(d) { return exp, sdkerrors.Wrap(ErrInvalidDuration, "expiration time and provided duration have different units") } - if e.GetTime() != nil && !e.GetTime().IsZero() { + if e.HasDefinedTime() { exp = ExpiresAtTime(e.GetTime().Add(*d.GetDuration())) } else { exp = ExpiresAtHeight(e.GetHeight() + d.GetBlock()) From a05a4c6aee0b2180cb778ba88b041e33e0704e2e Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 19 Jan 2021 17:30:46 +0530 Subject: [PATCH 156/184] review changes --- proto/cosmos/feegrant/v1beta1/feegrant.proto | 2 +- x/feegrant/module.go | 17 ----------------- x/feegrant/types/expiration.go | 13 +++++-------- 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/proto/cosmos/feegrant/v1beta1/feegrant.proto b/proto/cosmos/feegrant/v1beta1/feegrant.proto index a3b74b6f257d..733ef99e6a0c 100755 --- a/proto/cosmos/feegrant/v1beta1/feegrant.proto +++ b/proto/cosmos/feegrant/v1beta1/feegrant.proto @@ -35,7 +35,7 @@ message PeriodicFeeAllowance { ExpiresAt period_reset = 5 [(gogoproto.nullable) = false]; } -// Duration is a repeating unit of either clock time or number of blocks. +// Duration is a span of a clock time or number of blocks. // This is designed to be added to an ExpiresAt struct. message Duration { // sum is the oneof that represents either duration or block diff --git a/x/feegrant/module.go b/x/feegrant/module.go index 6e43077e80a3..1723b5950a36 100644 --- a/x/feegrant/module.go +++ b/x/feegrant/module.go @@ -81,18 +81,6 @@ func (a AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, config sdkclien return types.ValidateGenesis(data) } -// func (a AppModuleBasic) getValidatedGenesis(cdc codec.JSONMarshaler, bz json.RawMessage) (GenesisState, error) { -// var data GenesisState - -// // TODO migrate genesis types to proto -// // err := cdc.UnmarshalJSON(bz, &data) -// // if err != nil { -// // return nil, err -// // } - -// return data, data.ValidateBasic() -// } - // RegisterRESTRoutes registers the REST routes for the feegrant module. func (AppModuleBasic) RegisterRESTRoutes(ctx sdkclient.Context, rtr *mux.Router) {} @@ -158,11 +146,6 @@ func (AppModule) QuerierRoute() string { return "" } -// // NewQuerierHandler returns the feegrant module sdk.Querier. -// func (am AppModule) NewQuerierHandler() sdk.Querier { -// return NewQuerier(am.keeper) -// } - // InitGenesis performs genesis initialization for the feegrant module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, bz json.RawMessage) []abci.ValidatorUpdate { diff --git a/x/feegrant/types/expiration.go b/x/feegrant/types/expiration.go index 182990e00ee3..fe707026f0c8 100644 --- a/x/feegrant/types/expiration.go +++ b/x/feegrant/types/expiration.go @@ -81,16 +81,14 @@ func (e ExpiresAt) IsCompatible(d Duration) bool { // Step will increase the expiration point by one Duration // It returns an error if the Duration is incompatible func (e ExpiresAt) Step(d Duration) (ExpiresAt, error) { - var exp ExpiresAt if !e.IsCompatible(d) { - return exp, sdkerrors.Wrap(ErrInvalidDuration, "expiration time and provided duration have different units") + return ExpiresAt{}, sdkerrors.Wrap(ErrInvalidDuration, "expiration time and provided duration have different units") } if e.HasDefinedTime() { - exp = ExpiresAtTime(e.GetTime().Add(*d.GetDuration())) + return ExpiresAtTime(e.GetTime().Add(*d.GetDuration())), nil } else { - exp = ExpiresAtHeight(e.GetHeight() + d.GetBlock()) + return ExpiresAtHeight(e.GetHeight() + d.GetBlock()), nil } - return exp, nil } // MustStep is like Step, but panics on error @@ -105,11 +103,10 @@ func (e ExpiresAt) MustStep(d Duration) ExpiresAt { // PrepareForExport will deduct the dumpHeight from the expiration, so when this is // reloaded after a hard fork, the actual number of allowed blocks is constant func (e ExpiresAt) PrepareForExport(dumpTime time.Time, dumpHeight int64) ExpiresAt { - var exp ExpiresAt if e.GetHeight() != 0 { - exp = ExpiresAtHeight(e.GetHeight() - dumpHeight) + return ExpiresAtHeight(e.GetHeight() - dumpHeight) } - return exp + return ExpiresAt{} } // ClockDuration creates an Duration by clock time From 25f18d8dafca0cdcf5c5af834246bb4bf34a1c1f Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 19 Jan 2021 17:39:34 +0530 Subject: [PATCH 157/184] review change --- x/feegrant/types/expiration.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x/feegrant/types/expiration.go b/x/feegrant/types/expiration.go index fe707026f0c8..6d1827ebadf5 100644 --- a/x/feegrant/types/expiration.go +++ b/x/feegrant/types/expiration.go @@ -86,9 +86,8 @@ func (e ExpiresAt) Step(d Duration) (ExpiresAt, error) { } if e.HasDefinedTime() { return ExpiresAtTime(e.GetTime().Add(*d.GetDuration())), nil - } else { - return ExpiresAtHeight(e.GetHeight() + d.GetBlock()), nil } + return ExpiresAtHeight(e.GetHeight() + d.GetBlock()), nil } // MustStep is like Step, but panics on error From b283eb706dbff42e26547c0cf1869028ffbe58c7 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 20 Jan 2021 18:08:03 +0530 Subject: [PATCH 158/184] review changes --- x/feegrant/types/expiration.go | 4 ++-- x/feegrant/types/expiration_test.go | 6 +++--- x/feegrant/types/periodic_fee.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/x/feegrant/types/expiration.go b/x/feegrant/types/expiration.go index 6d1827ebadf5..2528667519ec 100644 --- a/x/feegrant/types/expiration.go +++ b/x/feegrant/types/expiration.go @@ -37,8 +37,8 @@ func (e ExpiresAt) ValidateBasic() error { } // IsZero returns true for an uninitialized struct -func (e ExpiresAt) IsZero() bool { - return e.GetTime() == nil && e.GetHeight() == 0 +func (e ExpiresAt) Undefined() bool { + return (e.GetTime() == nil || e.GetTime().Unix() <= 0) && e.GetHeight() == 0 } // HasDefinedTime returns true if `ExpiresAt` has valid time diff --git a/x/feegrant/types/expiration_test.go b/x/feegrant/types/expiration_test.go index fb8c749d43eb..95a64f973e54 100644 --- a/x/feegrant/types/expiration_test.go +++ b/x/feegrant/types/expiration_test.go @@ -49,17 +49,17 @@ func TestExpiresAt(t *testing.T) { tc := stc // to make scopelint happy t.Run(name, func(t *testing.T) { err := tc.example.ValidateBasic() - assert.Equal(t, tc.zero, tc.example.IsZero()) + assert.Equal(t, tc.zero, tc.example.Undefined()) if !tc.valid { require.Error(t, err) return } require.NoError(t, err) - if !tc.before.IsZero() { + if !tc.before.Undefined() { assert.Equal(t, false, tc.example.IsExpired(tc.before.GetTime(), tc.before.GetHeight())) } - if !tc.after.IsZero() { + if !tc.after.Undefined() { assert.Equal(t, true, tc.example.IsExpired(tc.after.GetTime(), tc.after.GetHeight())) } }) diff --git a/x/feegrant/types/periodic_fee.go b/x/feegrant/types/periodic_fee.go index 6548a4ea7c64..dfd57477e333 100644 --- a/x/feegrant/types/periodic_fee.go +++ b/x/feegrant/types/periodic_fee.go @@ -47,7 +47,7 @@ func (a *PeriodicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockH // last PeriodReset (eg. if you always do one tx per day, it will always reset the same time) // If we are more then one period out (eg. no activity in a week), reset is one Period from the execution of this method func (a *PeriodicFeeAllowance) TryResetPeriod(blockTime time.Time, blockHeight int64) { - if !a.PeriodReset.IsZero() && !a.PeriodReset.IsExpired(&blockTime, blockHeight) { + if !a.PeriodReset.Undefined() && !a.PeriodReset.IsExpired(&blockTime, blockHeight) { return } // set CanSpend to the lesser of PeriodSpendLimit and the TotalLimit From 96bc2ae1f3a69e4ef6fd243cc84f9ff771f1e3eb Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 21 Jan 2021 18:02:27 +0530 Subject: [PATCH 159/184] added fee-account in flags --- client/cmd.go | 14 +++++++++ client/context.go | 8 +++++ client/flags/flags.go | 1 + client/query.go | 5 +++ client/tx/tx.go | 1 + x/feegrant/client/cli/cli_test.go | 51 ++++++++++++++++++++++++------- 6 files changed, 69 insertions(+), 11 deletions(-) diff --git a/client/cmd.go b/client/cmd.go index eccf59c3515c..d1113c5090d0 100644 --- a/client/cmd.go +++ b/client/cmd.go @@ -239,6 +239,20 @@ func readTxCommandFlags(clientCtx Context, flagSet *pflag.FlagSet) (Context, err } } + if clientCtx.FeeGranter == nil || flagSet.Changed(flags.FlagFeeAccount) { + granter, err := flagSet.GetString(flags.FlagFeeAccount) + fmt.Println("granter", granter, err) + + if granter != "" { + granterAcc, err := sdk.AccAddressFromBech32(granter) + if err != nil { + return clientCtx, err + } + + clientCtx = clientCtx.WithFeeGranterAddress(granterAcc) + } + } + return clientCtx, nil } diff --git a/client/context.go b/client/context.go index 0e3d1181af6e..f7f555339c2c 100644 --- a/client/context.go +++ b/client/context.go @@ -44,6 +44,7 @@ type Context struct { TxConfig TxConfig AccountRetriever AccountRetriever NodeURI string + FeeGranter sdk.AccAddress // TODO: Deprecated (remove). LegacyAmino *codec.LegacyAmino @@ -166,6 +167,13 @@ func (ctx Context) WithFromAddress(addr sdk.AccAddress) Context { return ctx } +// WithFeeGranterAddress returns a copy of the context with an updated fee granter account +// address. +func (ctx Context) WithFeeGranterAddress(addr sdk.AccAddress) Context { + ctx.FeeGranter = addr + return ctx +} + // WithBroadcastMode returns a copy of the context with an updated broadcast // mode. func (ctx Context) WithBroadcastMode(mode string) Context { diff --git a/client/flags/flags.go b/client/flags/flags.go index 6e5547892834..1afb55b46733 100644 --- a/client/flags/flags.go +++ b/client/flags/flags.go @@ -113,6 +113,7 @@ func AddTxFlagsToCmd(cmd *cobra.Command) { cmd.Flags().String(FlagKeyringBackend, DefaultKeyringBackend, "Select keyring's backend (os|file|kwallet|pass|test)") cmd.Flags().String(FlagSignMode, "", "Choose sign mode (direct|amino-json), this is an advanced feature") cmd.Flags().Uint64(FlagTimeoutHeight, 0, "Set a block timeout height to prevent the tx from being committed past a certain height") + cmd.Flags().String(FlagFeeAccount, "", "Fee account pays fees for the transaction instead of deducting from the signer") // --gas can accept integers and "auto" cmd.Flags().String(FlagGas, "", fmt.Sprintf("gas limit to set per-transaction; set to %q to calculate sufficient gas automatically (default %d)", GasFlagAuto, DefaultGasLimit)) diff --git a/client/query.go b/client/query.go index 18a5c3c2f4ee..bb65d9bf3833 100644 --- a/client/query.go +++ b/client/query.go @@ -57,6 +57,11 @@ func (ctx Context) GetFromAddress() sdk.AccAddress { return ctx.FromAddress } +// GetFeeGranterAddress returns the fee granter address from the context +func (ctx Context) GetFeeGranterAddress() sdk.AccAddress { + return ctx.FeeGranter +} + // GetFromName returns the key name for the current context. func (ctx Context) GetFromName() string { return ctx.FromName diff --git a/client/tx/tx.go b/client/tx/tx.go index 594293732bc8..62e3e9098eea 100644 --- a/client/tx/tx.go +++ b/client/tx/tx.go @@ -117,6 +117,7 @@ func BroadcastTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error { } } + tx.SetFeeGranter(clientCtx.GetFeeGranterAddress()) err = Sign(txf, clientCtx.GetFromName(), tx, true) if err != nil { return err diff --git a/x/feegrant/client/cli/cli_test.go b/x/feegrant/client/cli/cli_test.go index fcf85ab164b0..bdedb9670fc9 100644 --- a/x/feegrant/client/cli/cli_test.go +++ b/x/feegrant/client/cli/cli_test.go @@ -7,9 +7,12 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" + "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/feegrant/client/cli" "github.com/cosmos/cosmos-sdk/x/feegrant/types" + govtestutil "github.com/cosmos/cosmos-sdk/x/gov/client/testutil" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/suite" tmcli "github.com/tendermint/tendermint/libs/cli" @@ -43,7 +46,9 @@ func (s *IntegrationTestSuite) SetupSuite() { val := s.network.Validators[0] granter := val.Address - grantee := s.network.Validators[1].Address + + // creating a account manually (This won't existed in accounts store) + _, _, grantee := testdata.KeyTestPubAddr() clientCtx := val.ClientCtx commonFlags := []string{ @@ -86,7 +91,7 @@ func (s *IntegrationTestSuite) TearDownSuite() { func (s *IntegrationTestSuite) TestCmdGetFeeGrant() { val := s.network.Validators[0] granter := val.Address - grantee := s.network.Validators[1].Address + grantee := s.addedGrantee clientCtx := val.ClientCtx testCases := []struct { @@ -167,9 +172,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrant() { func (s *IntegrationTestSuite) TestCmdGetFeeGrants() { val := s.network.Validators[0] - granter := val.Address - _ = granter - grantee := s.network.Validators[1].Address + grantee := s.addedGrantee clientCtx := val.ClientCtx testCases := []struct { @@ -226,7 +229,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrants() { func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { val := s.network.Validators[0] granter := val.Address - grantee := s.network.Validators[1].Address + alreadyExistedGrantee := s.addedGrantee clientCtx := val.ClientCtx commonFlags := []string{ @@ -247,7 +250,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { append( []string{ "wrong_granter", - grantee.String(), + "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", "100steak", fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), }, @@ -269,7 +272,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { true, nil, 0, }, { - "Valid basic fee grant", + "valid basic fee grant", append( []string{ granter.String(), @@ -281,12 +284,25 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { ), false, &sdk.TxResponse{}, 0, }, + { + "try to add existed grant", + append( + []string{ + granter.String(), + alreadyExistedGrantee.String(), + "100steak", + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + }, + commonFlags..., + ), + false, &sdk.TxResponse{}, 18, + }, { "invalid number of args(periodic fee grant)", append( []string{ granter.String(), - grantee.String(), + "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", "100steak", "10steak", fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), @@ -301,7 +317,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { append( []string{ granter.String(), - grantee.String(), + "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", "100steak", fmt.Sprintf("%d", 10*60*60), //period "10steak", @@ -313,7 +329,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { true, nil, 0, }, { - "Valid periodic fee grant", + "valid periodic fee grant", append( []string{ granter.String(), @@ -447,6 +463,19 @@ func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() { } } +func (s *IntegrationTestSuite) TestTxWithFeeGrant() { + val := s.network.Validators[0] + granter := s.addedGranter + grantee := s.addedGrantee + + out, err := govtestutil.MsgSubmitProposal(val.ClientCtx, grantee.String(), + "Text Proposal", "No title", govtypes.ProposalTypeText, + fmt.Sprintf("--%s=%s", flags.FlagFeeAccount, granter.String()), + ) + + fmt.Println("out, err", out, err) +} + func TestIntegrationTestSuite(t *testing.T) { suite.Run(t, new(IntegrationTestSuite)) } From b0d5f7d8c45f8c03b050cc8ee1dd0d04a0a75112 Mon Sep 17 00:00:00 2001 From: atheesh Date: Fri, 22 Jan 2021 15:16:54 +0530 Subject: [PATCH 160/184] address review changes --- proto/cosmos/feegrant/v1beta1/genesis.proto | 2 +- proto/cosmos/feegrant/v1beta1/query.proto | 1 + proto/cosmos/feegrant/v1beta1/tx.proto | 1 - simapp/ante.go | 4 ++-- x/feegrant/ante/fee_test.go | 2 +- x/feegrant/client/cli/cli_test.go | 4 ++-- x/feegrant/client/cli/tx.go | 2 +- x/feegrant/client/rest/grpc_query_test.go | 1 - x/feegrant/keeper/keeper_test.go | 1 - x/feegrant/simulation/decoder.go | 2 +- x/feegrant/types/errors.go | 2 +- x/feegrant/types/expiration.go | 2 +- x/feegrant/types/grant.go | 4 ++-- x/mint/simulation/decoder.go | 2 +- 14 files changed, 14 insertions(+), 16 deletions(-) diff --git a/proto/cosmos/feegrant/v1beta1/genesis.proto b/proto/cosmos/feegrant/v1beta1/genesis.proto index 9460a27d42cc..a021ea61dfc7 100644 --- a/proto/cosmos/feegrant/v1beta1/genesis.proto +++ b/proto/cosmos/feegrant/v1beta1/genesis.proto @@ -9,4 +9,4 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; // GenesisState contains a set of fee allowances, persisted from the store message GenesisState { repeated FeeAllowanceGrant fee_allowances = 1 [(gogoproto.nullable) = false]; -} \ No newline at end of file +} diff --git a/proto/cosmos/feegrant/v1beta1/query.proto b/proto/cosmos/feegrant/v1beta1/query.proto index d0b5622c6fea..d5494ff49674 100644 --- a/proto/cosmos/feegrant/v1beta1/query.proto +++ b/proto/cosmos/feegrant/v1beta1/query.proto @@ -10,6 +10,7 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; // Query defines the gRPC querier service. service Query { + // FeeAllowance returns fee granted to the grantee by the granter. rpc FeeAllowance(QueryFeeAllowanceRequest) returns (QueryFeeAllowanceResponse) { option (google.api.http).get = "/cosmos/feegrant/v1beta1/fee_allowance/{granter}/{grantee}"; diff --git a/proto/cosmos/feegrant/v1beta1/tx.proto b/proto/cosmos/feegrant/v1beta1/tx.proto index 114ebc14a377..a36f358f2503 100644 --- a/proto/cosmos/feegrant/v1beta1/tx.proto +++ b/proto/cosmos/feegrant/v1beta1/tx.proto @@ -22,7 +22,6 @@ service Msg { // MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance // of fees from the account of Granter. message MsgGrantFeeAllowance { - string granter = 1; string grantee = 2; google.protobuf.Any allowance = 3 [(cosmos_proto.accepts_interface) = "FeeAllowanceI"]; diff --git a/simapp/ante.go b/simapp/ante.go index 0af65940ced4..b49a2fbfd97b 100644 --- a/simapp/ante.go +++ b/simapp/ante.go @@ -11,8 +11,8 @@ import ( ) // NewAnteHandler returns an AnteHandler that checks and increments sequence -// numbers, checks signatures & account numbers, and deducts fees from the first -// signer. +// numbers, checks signatures & account numbers, and deducts fees from the +// fee_payer or from fee_granter (if valid grant exist). func NewAnteHandler( ak authkeeper.AccountKeeper, bankKeeper feegranttypes.BankKeeper, feeGrantKeeper feegrantkeeper.Keeper, sigGasConsumer authante.SignatureVerificationGasConsumer, signModeHandler signing.SignModeHandler, diff --git a/x/feegrant/ante/fee_test.go b/x/feegrant/ante/fee_test.go index bf23f1e3bcff..dc251747a765 100644 --- a/x/feegrant/ante/fee_test.go +++ b/x/feegrant/ante/fee_test.go @@ -289,7 +289,7 @@ func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { return app, ctx } -// don't cosume any gas +// don't consume any gas func SigGasNoConsumer(meter sdk.GasMeter, sig []byte, pubkey crypto.PubKey, params authtypes.Params) error { return nil } diff --git a/x/feegrant/client/cli/cli_test.go b/x/feegrant/client/cli/cli_test.go index bdedb9670fc9..ae3a936ae76a 100644 --- a/x/feegrant/client/cli/cli_test.go +++ b/x/feegrant/client/cli/cli_test.go @@ -47,7 +47,7 @@ func (s *IntegrationTestSuite) SetupSuite() { val := s.network.Validators[0] granter := val.Address - // creating a account manually (This won't existed in accounts store) + // creating an account manually (This won't exist in accounts store) _, _, grantee := testdata.KeyTestPubAddr() clientCtx := val.ClientCtx @@ -469,7 +469,7 @@ func (s *IntegrationTestSuite) TestTxWithFeeGrant() { grantee := s.addedGrantee out, err := govtestutil.MsgSubmitProposal(val.ClientCtx, grantee.String(), - "Text Proposal", "No title", govtypes.ProposalTypeText, + "Text Proposal", "No desc", govtypes.ProposalTypeText, fmt.Sprintf("--%s=%s", flags.FlagFeeAccount, granter.String()), ) diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index 9b8328710904..12c2b5f425be 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -48,7 +48,7 @@ func NewCmdFeeGrant() *cobra.Command { Short: "Grant Fee allowance to an address", Long: strings.TrimSpace( fmt.Sprintf( - `Grant authorization to use fee from your address. Note, the'--from' flag is + `Grant authorization to pay fees from your address. Note, the'--from' flag is ignored as it is implied from [granter]. Examples: diff --git a/x/feegrant/client/rest/grpc_query_test.go b/x/feegrant/client/rest/grpc_query_test.go index 271f2b6cda09..75f2d9cc90a3 100644 --- a/x/feegrant/client/rest/grpc_query_test.go +++ b/x/feegrant/client/rest/grpc_query_test.go @@ -202,7 +202,6 @@ func execFeeAllowance(val *network.Validator, s *IntegrationTestSuite) { cmd := cli.NewCmdFeeGrant() _, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args) s.Require().NoError(err) - } func TestIntegrationTestSuite(t *testing.T) { diff --git a/x/feegrant/keeper/keeper_test.go b/x/feegrant/keeper/keeper_test.go index 0f7fdfeedd91..a43393c39e1e 100644 --- a/x/feegrant/keeper/keeper_test.go +++ b/x/feegrant/keeper/keeper_test.go @@ -116,7 +116,6 @@ func (suite *KeeperTestSuite) TestKeeperCrud() { }, "addr has one": { grantee: suite.addrs[0], - // grants: []types.FeeAllowanceGrant{{Granter: suite.addrs[3], Grantee: suite.addrs[0], Allowance: basic2}}, grants: []types.FeeAllowanceGrant{ types.NewFeeAllowanceGrant(suite.addrs[3], suite.addrs[0], basic2), }, diff --git a/x/feegrant/simulation/decoder.go b/x/feegrant/simulation/decoder.go index c7f783c2b6d5..46e35594fdf8 100644 --- a/x/feegrant/simulation/decoder.go +++ b/x/feegrant/simulation/decoder.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) -// NewDecodeStore returns a decoder function closure that umarshals the KVPair's +// NewDecodeStore returns a decoder function closure that unmarshals the KVPair's // Value to the corresponding feegrant type. func NewDecodeStore(cdc codec.Marshaler) func(kvA, kvB kv.Pair) string { return func(kvA, kvB kv.Pair) string { diff --git a/x/feegrant/types/errors.go b/x/feegrant/types/errors.go index 9b824253ae9d..183f681ca5dc 100644 --- a/x/feegrant/types/errors.go +++ b/x/feegrant/types/errors.go @@ -13,7 +13,7 @@ var ( // ErrFeeLimitExceeded error if there are not enough allowance to cover the fees ErrFeeLimitExceeded = sdkerrors.Register(DefaultCodespace, 2, "fee limit exceeded") // ErrFeeLimitExpired error if the allowance has expired - ErrFeeLimitExpired = sdkerrors.Register(DefaultCodespace, 3, "fee limit expired") + ErrFeeLimitExpired = sdkerrors.Register(DefaultCodespace, 3, "fee allowance expired") // ErrInvalidDuration error if the Duration is invalid or doesn't match the expiration ErrInvalidDuration = sdkerrors.Register(DefaultCodespace, 4, "invalid duration") // ErrNoAllowance error if there is no allowance for that pair diff --git a/x/feegrant/types/expiration.go b/x/feegrant/types/expiration.go index 2528667519ec..df779aea757f 100644 --- a/x/feegrant/types/expiration.go +++ b/x/feegrant/types/expiration.go @@ -36,7 +36,7 @@ func (e ExpiresAt) ValidateBasic() error { return nil } -// IsZero returns true for an uninitialized struct +// Undefined returns true for an uninitialized struct func (e ExpiresAt) Undefined() bool { return (e.GetTime() == nil || e.GetTime().Unix() <= 0) && e.GetHeight() == 0 } diff --git a/x/feegrant/types/grant.go b/x/feegrant/types/grant.go index 73d785617c9b..e0d46028e576 100644 --- a/x/feegrant/types/grant.go +++ b/x/feegrant/types/grant.go @@ -49,6 +49,7 @@ func (a FeeAllowanceGrant) ValidateBasic() error { return a.GetFeeGrant().ValidateBasic() } +// GetFeeGrant unpacks allowance func (a FeeAllowanceGrant) GetFeeGrant() FeeAllowanceI { allowance, ok := a.Allowance.GetCachedValue().(FeeAllowanceI) if !ok { @@ -56,7 +57,6 @@ func (a FeeAllowanceGrant) GetFeeGrant() FeeAllowanceI { } return allowance - // return a.Allowance.GetFeeAllowanceI() } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces @@ -65,7 +65,7 @@ func (a FeeAllowanceGrant) UnpackInterfaces(unpacker types.AnyUnpacker) error { return unpacker.UnpackAny(a.Allowance, &allowance) } -// PrepareForExport will m ake all needed changes to the allowance to prepare to be +// PrepareForExport will make all needed changes to the allowance to prepare to be // re-imported at height 0, and return a copy of this grant. func (a FeeAllowanceGrant) PrepareForExport(dumpTime time.Time, dumpHeight int64) FeeAllowanceGrant { feegrant := a.GetFeeGrant().PrepareForExport(dumpTime, dumpHeight) diff --git a/x/mint/simulation/decoder.go b/x/mint/simulation/decoder.go index 37d9930f7da5..f0a89be43965 100644 --- a/x/mint/simulation/decoder.go +++ b/x/mint/simulation/decoder.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/mint/types" ) -// NewDecodeStore returns a decoder function closure that umarshals the KVPair's +// NewDecodeStore returns a decoder function closure that unmarshals the KVPair's // Value to the corresponding mint type. func NewDecodeStore(cdc codec.Marshaler) func(kvA, kvB kv.Pair) string { return func(kvA, kvB kv.Pair) string { From c234b1a04eff23eee9e91d541719e1d9ab5c1a35 Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 25 Jan 2021 11:04:33 +0530 Subject: [PATCH 161/184] read fee granter from cli --- client/cmd.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/client/cmd.go b/client/cmd.go index d1113c5090d0..1495b80fc8e4 100644 --- a/client/cmd.go +++ b/client/cmd.go @@ -221,6 +221,20 @@ func readTxCommandFlags(clientCtx Context, flagSet *pflag.FlagSet) (Context, err clientCtx = clientCtx.WithSignModeStr(signModeStr) } + if clientCtx.FeeGranter == nil || flagSet.Changed(flags.FlagFeeAccount) { + granter, err := flagSet.GetString(flags.FlagFeeAccount) + fmt.Println("granter", granter, err) + + if granter != "" { + granterAcc, err := sdk.AccAddressFromBech32(granter) + if err != nil { + return clientCtx, err + } + + clientCtx = clientCtx.WithFeeGranterAddress(granterAcc) + } + } + if clientCtx.From == "" || flagSet.Changed(flags.FlagFrom) { from, _ := flagSet.GetString(flags.FlagFrom) fromAddr, fromName, keyType, err := GetFromFields(clientCtx.Keyring, from, clientCtx.GenerateOnly) @@ -239,20 +253,6 @@ func readTxCommandFlags(clientCtx Context, flagSet *pflag.FlagSet) (Context, err } } - if clientCtx.FeeGranter == nil || flagSet.Changed(flags.FlagFeeAccount) { - granter, err := flagSet.GetString(flags.FlagFeeAccount) - fmt.Println("granter", granter, err) - - if granter != "" { - granterAcc, err := sdk.AccAddressFromBech32(granter) - if err != nil { - return clientCtx, err - } - - clientCtx = clientCtx.WithFeeGranterAddress(granterAcc) - } - } - return clientCtx, nil } From 35d9fb19e502b6c63993ec73a4e653f4bf76fe00 Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 25 Jan 2021 15:05:53 +0530 Subject: [PATCH 162/184] updated create account with mnemonic --- x/feegrant/client/cli/cli_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/x/feegrant/client/cli/cli_test.go b/x/feegrant/client/cli/cli_test.go index ae3a936ae76a..dc78bc307964 100644 --- a/x/feegrant/client/cli/cli_test.go +++ b/x/feegrant/client/cli/cli_test.go @@ -5,9 +5,10 @@ import ( "testing" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/crypto/keyring" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" - "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/feegrant/client/cli" "github.com/cosmos/cosmos-sdk/x/feegrant/types" @@ -48,7 +49,9 @@ func (s *IntegrationTestSuite) SetupSuite() { granter := val.Address // creating an account manually (This won't exist in accounts store) - _, _, grantee := testdata.KeyTestPubAddr() + info, _, err := val.ClientCtx.Keyring.NewMnemonic("grantee", keyring.English, sdk.FullFundraiserPath, hd.Secp256k1) + s.Require().NoError(err) + grantee := sdk.AccAddress(info.GetPubKey().Address()) clientCtx := val.ClientCtx commonFlags := []string{ From f5fae0f742691bf023a7fdc05c2601e1388e2fb0 Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 25 Jan 2021 15:43:09 +0530 Subject: [PATCH 163/184] Address review comments --- client/cmd.go | 3 +-- proto/cosmos/feegrant/v1beta1/query.proto | 2 +- x/feegrant/ante/fee.go | 4 ++-- x/feegrant/ante/fee_test.go | 13 ++----------- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/client/cmd.go b/client/cmd.go index 1495b80fc8e4..437022695d47 100644 --- a/client/cmd.go +++ b/client/cmd.go @@ -222,8 +222,7 @@ func readTxCommandFlags(clientCtx Context, flagSet *pflag.FlagSet) (Context, err } if clientCtx.FeeGranter == nil || flagSet.Changed(flags.FlagFeeAccount) { - granter, err := flagSet.GetString(flags.FlagFeeAccount) - fmt.Println("granter", granter, err) + granter, _ := flagSet.GetString(flags.FlagFeeAccount) if granter != "" { granterAcc, err := sdk.AccAddressFromBech32(granter) diff --git a/proto/cosmos/feegrant/v1beta1/query.proto b/proto/cosmos/feegrant/v1beta1/query.proto index d5494ff49674..2889921f22de 100644 --- a/proto/cosmos/feegrant/v1beta1/query.proto +++ b/proto/cosmos/feegrant/v1beta1/query.proto @@ -44,7 +44,7 @@ message QueryFeeAllowancesRequest { // QueryFeeAllowancesResponse is the response type for the Query/FeeAllowances RPC method. message QueryFeeAllowancesResponse { - // fee_allowance is a fee_allowance granted for grantee by granter. + //fee_allowances are fee_allowance's granted for grantee by granter. repeated cosmos.feegrant.v1beta1.FeeAllowanceGrant fee_allowances = 1; // pagination defines an pagination for the response. diff --git a/x/feegrant/ante/fee.go b/x/feegrant/ante/fee.go index bfb046da0a0d..cb6c015156b4 100644 --- a/x/feegrant/ante/fee.go +++ b/x/feegrant/ante/fee.go @@ -11,8 +11,8 @@ import ( "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) -// DeductGrantedFeeDecorator deducts fees from the first signer of the tx -// If the first signer does not have the funds to pay for the fees, return with InsufficientFunds error +// DeductGrantedFeeDecorator deducts fees from fee_payer or fee_granter (if exists a valid fee allowance) of the tx +// If the fee_payer or fee_granter does not have the funds to pay for the fees, return with InsufficientFunds error // Call next AnteHandler if fees successfully deducted // CONTRACT: Tx must implement GrantedFeeTx interface to use DeductGrantedFeeDecorator type DeductGrantedFeeDecorator struct { diff --git a/x/feegrant/ante/fee_test.go b/x/feegrant/ante/fee_test.go index dc251747a765..0c8f70871433 100644 --- a/x/feegrant/ante/fee_test.go +++ b/x/feegrant/ante/fee_test.go @@ -90,25 +90,16 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { app.AccountKeeper.SetAccount(ctx, acc2) app.BankKeeper.SetBalances(ctx, addr2, []sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(99999))}) - // Set grant from addr2 to addr3 (plenty to pay) + // grant fee allowance from `addr2` to `addr3` (plenty to pay) app.FeeGrantKeeper.GrantFeeAllowance(ctx, addr2, addr3, &types.BasicFeeAllowance{ SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 500)), }) - // Set low grant from addr2 to addr4 (keeper will reject) + // grant low fee allowance (20atom), to check the tx requesting more than allowed. app.FeeGrantKeeper.GrantFeeAllowance(ctx, addr2, addr4, &types.BasicFeeAllowance{ SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 20)), }) - // Set grant from addr1 to addr4 (cannot cover this ) - app.FeeGrantKeeper.GrantFeeAllowance(ctx, addr2, addr3, &types.BasicFeeAllowance{ - SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 500)), - }) - - // app.FeeGrantKeeper.GrantFeeAllowance(ctx, addr1, addr4, &types.BasicFeeAllowance{ - // SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 500)), - // }) - cases := map[string]struct { signerKey cryptotypes.PrivKey signer sdk.AccAddress From f2998e715bfda69ab6a1a1eac18cb85a027a446c Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 25 Jan 2021 15:58:06 +0530 Subject: [PATCH 164/184] move `simapp/ante` file to `feegrant/ante` --- simapp/app.go | 3 ++- {simapp => x/feegrant/ante}/ante.go | 5 ++--- x/feegrant/ante/fee_test.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename {simapp => x/feegrant/ante}/ante.go (92%) diff --git a/simapp/app.go b/simapp/app.go index 07e15b31d7d8..a8ef3905bdff 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -55,6 +55,7 @@ import ( evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" feegrant "github.com/cosmos/cosmos-sdk/x/feegrant" + feegrantante "github.com/cosmos/cosmos-sdk/x/feegrant/ante" feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" feegranttypes "github.com/cosmos/cosmos-sdk/x/feegrant/types" "github.com/cosmos/cosmos-sdk/x/genutil" @@ -416,7 +417,7 @@ func NewSimApp( app.SetInitChainer(app.InitChainer) app.SetBeginBlocker(app.BeginBlocker) app.SetAnteHandler( - NewAnteHandler( + feegrantante.NewAnteHandler( app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, ante.DefaultSigVerificationGasConsumer, encodingConfig.TxConfig.SignModeHandler(), ), diff --git a/simapp/ante.go b/x/feegrant/ante/ante.go similarity index 92% rename from simapp/ante.go rename to x/feegrant/ante/ante.go index b49a2fbfd97b..661de0bf2518 100644 --- a/simapp/ante.go +++ b/x/feegrant/ante/ante.go @@ -1,11 +1,10 @@ -package simapp +package ante import ( sdk "github.com/cosmos/cosmos-sdk/types" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/signing" - feegrantante "github.com/cosmos/cosmos-sdk/x/feegrant/ante" feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" feegranttypes "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) @@ -29,7 +28,7 @@ func NewAnteHandler( // DeductGrantedFeeDecorator will create an empty account if we sign with no // tokens but valid validation. This must be before SetPubKey, ValidateSigCount, // SigVerification, which error if account doesn't exist yet. - feegrantante.NewDeductGrantedFeeDecorator(ak, bankKeeper, feeGrantKeeper), + NewDeductGrantedFeeDecorator(ak, bankKeeper, feeGrantKeeper), authante.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators authante.NewValidateSigCountDecorator(ak), authante.NewSigGasConsumeDecorator(ak, sigGasConsumer), diff --git a/x/feegrant/ante/fee_test.go b/x/feegrant/ante/fee_test.go index 0c8f70871433..f8bc8fe5f86d 100644 --- a/x/feegrant/ante/fee_test.go +++ b/x/feegrant/ante/fee_test.go @@ -51,7 +51,7 @@ func (suite *AnteTestSuite) SetupTest(isCheckTx bool) { suite.clientCtx = client.Context{}. WithTxConfig(encodingConfig.TxConfig) - suite.anteHandler = simapp.NewAnteHandler(suite.app.AccountKeeper, suite.app.BankKeeper, suite.app.FeeGrantKeeper, authante.DefaultSigVerificationGasConsumer, encodingConfig.TxConfig.SignModeHandler()) + suite.anteHandler = ante.NewAnteHandler(suite.app.AccountKeeper, suite.app.BankKeeper, suite.app.FeeGrantKeeper, authante.DefaultSigVerificationGasConsumer, encodingConfig.TxConfig.SignModeHandler()) } func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { From a22c7363e6c4068628498357c094ff1cac407cf2 Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 25 Jan 2021 23:13:55 +0530 Subject: [PATCH 165/184] update keeper logic to create account --- simapp/app.go | 2 +- x/feegrant/ante/fee.go | 7 ------- x/feegrant/ante/fee_test.go | 17 ++++++----------- x/feegrant/client/cli/cli_test.go | 30 ++++++++++++++++++------------ x/feegrant/keeper/keeper.go | 21 +++++++++++++++++---- 5 files changed, 42 insertions(+), 35 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index a8ef3905bdff..3580d32f9f02 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -276,7 +276,7 @@ func NewSimApp( app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, ) - app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegranttypes.StoreKey]) + app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegranttypes.StoreKey], app.AccountKeeper) app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath) // register the staking hooks diff --git a/x/feegrant/ante/fee.go b/x/feegrant/ante/fee.go index cb6c015156b4..52cbda7210eb 100644 --- a/x/feegrant/ante/fee.go +++ b/x/feegrant/ante/fee.go @@ -58,13 +58,6 @@ func (d DeductGrantedFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula return ctx, sdkerrors.Wrapf(err, "%s not allowed to pay fees from %s", feeGranter, feePayer) } - // if there was a valid grant, ensure that the feeGranter account exists (we create it if needed) - signerAcc := d.ak.GetAccount(ctx, feePayer) - if signerAcc == nil { - signerAcc = d.ak.NewAccountWithAddress(ctx, feePayer) - d.ak.SetAccount(ctx, signerAcc) - } - deductFeesFrom = feeGranter } diff --git a/x/feegrant/ante/fee_test.go b/x/feegrant/ante/fee_test.go index f8bc8fe5f86d..63a693311d33 100644 --- a/x/feegrant/ante/fee_test.go +++ b/x/feegrant/ante/fee_test.go @@ -73,12 +73,7 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { priv2, _, addr2 := testdata.KeyTestPubAddr() priv3, _, addr3 := testdata.KeyTestPubAddr() priv4, _, addr4 := testdata.KeyTestPubAddr() - - nonExistedAccNums := make(map[string]uint64) - nonExistedAccNums[addr1.String()] = 0 - nonExistedAccNums[addr2.String()] = 1 - nonExistedAccNums[addr3.String()] = 2 - nonExistedAccNums[addr4.String()] = 3 + priv5, _, addr5 := testdata.KeyTestPubAddr() // Set addr1 with insufficient funds acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1) @@ -138,8 +133,8 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { valid: true, }, "no fee with no account (only ours)": { - signerKey: priv4, - signer: addr4, + signerKey: priv5, + signer: addr5, fee: 0, handler: ourAnteHandler, valid: false, @@ -205,8 +200,8 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { valid: true, }, "no fee with no account (whole stack)": { - signerKey: priv4, - signer: addr4, + signerKey: priv5, + signer: addr5, fee: 0, handler: anteHandlerStack, valid: false, @@ -253,7 +248,7 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { msgs := []sdk.Msg{testdata.NewTestMsg(tc.signer)} acc := app.AccountKeeper.GetAccount(ctx, tc.signer) - privs, accNums, seqs := []cryptotypes.PrivKey{tc.signerKey}, []uint64{nonExistedAccNums[tc.signer.String()]}, []uint64{0} + privs, accNums, seqs := []cryptotypes.PrivKey{tc.signerKey}, []uint64{0}, []uint64{0} if acc != nil { accNums, seqs = []uint64{acc.GetAccountNumber()}, []uint64{acc.GetSequence()} } diff --git a/x/feegrant/client/cli/cli_test.go b/x/feegrant/client/cli/cli_test.go index dc78bc307964..41b55424252e 100644 --- a/x/feegrant/client/cli/cli_test.go +++ b/x/feegrant/client/cli/cli_test.go @@ -60,7 +60,7 @@ func (s *IntegrationTestSuite) SetupSuite() { fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } - fee := sdk.NewCoin("steak", sdk.NewInt(100)) + fee := sdk.NewCoin("stake", sdk.NewInt(100)) duration := 365 * 24 * 60 * 60 args := append( @@ -254,7 +254,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { []string{ "wrong_granter", "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", - "100steak", + "100stake", fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), }, commonFlags..., @@ -267,7 +267,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { []string{ granter.String(), "wrong_grantee", - "100steak", + "100stake", fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), }, commonFlags..., @@ -280,7 +280,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { []string{ granter.String(), "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", - "100steak", + "100stake", fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), }, commonFlags..., @@ -293,7 +293,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { []string{ granter.String(), alreadyExistedGrantee.String(), - "100steak", + "100stake", fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), }, commonFlags..., @@ -306,8 +306,8 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { []string{ granter.String(), "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", - "100steak", - "10steak", + "100stake", + "10stake", fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), fmt.Sprintf("--%s=%d", cli.FlagExpiration, 10*60*60), }, @@ -321,9 +321,9 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { []string{ granter.String(), "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", - "100steak", + "100stake", fmt.Sprintf("%d", 10*60*60), //period - "10steak", + "10stake", fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), fmt.Sprintf("--%s=%d", cli.FlagExpiration, 60*60), }, @@ -337,9 +337,9 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { []string{ granter.String(), "cosmos1w55kgcf3ltaqdy4ww49nge3klxmrdavrr6frmp", - "100steak", + "100stake", fmt.Sprintf("%d", 60*60), - "10steak", + "10stake", fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), fmt.Sprintf("--%s=%d", cli.FlagExpiration, 10*60*60), }, @@ -468,15 +468,21 @@ func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() { func (s *IntegrationTestSuite) TestTxWithFeeGrant() { val := s.network.Validators[0] + clientCtx := val.ClientCtx granter := s.addedGranter grantee := s.addedGrantee + // granted fee allowance for an account which is not in state and creating + // any tx with it by using --fee-account shouldn't fail out, err := govtestutil.MsgSubmitProposal(val.ClientCtx, grantee.String(), "Text Proposal", "No desc", govtypes.ProposalTypeText, fmt.Sprintf("--%s=%s", flags.FlagFeeAccount, granter.String()), ) - fmt.Println("out, err", out, err) + s.Require().NoError(err) + var resp sdk.TxResponse + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &resp), out.String()) + s.Require().Equal(uint32(0), resp.Code) } func TestIntegrationTestSuite(t *testing.T) { diff --git a/x/feegrant/keeper/keeper.go b/x/feegrant/keeper/keeper.go index c9c07ca6b7bc..78cda94e47e7 100644 --- a/x/feegrant/keeper/keeper.go +++ b/x/feegrant/keeper/keeper.go @@ -14,13 +14,18 @@ import ( // Keeper manages state of all fee grants, as well as calculating approval. // It must have a codec with all available allowances registered. type Keeper struct { - cdc codec.BinaryMarshaler - storeKey sdk.StoreKey + cdc codec.BinaryMarshaler + storeKey sdk.StoreKey + authKeeper types.AccountKeeper } // NewKeeper creates a fee grant Keeper -func NewKeeper(cdc codec.BinaryMarshaler, storeKey sdk.StoreKey) Keeper { - return Keeper{cdc: cdc, storeKey: storeKey} +func NewKeeper(cdc codec.BinaryMarshaler, storeKey sdk.StoreKey, ak types.AccountKeeper) Keeper { + return Keeper{ + cdc: cdc, + storeKey: storeKey, + authKeeper: ak, + } } // Logger returns a module-specific logger. @@ -30,6 +35,14 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { // GrantFeeAllowance creates a new grant func (k Keeper) GrantFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddress, feeAllowance types.FeeAllowanceI) { + + // create the account if it is not in account state + granteeAcc := k.authKeeper.GetAccount(ctx, grantee) + if granteeAcc == nil { + granteeAcc = k.authKeeper.NewAccountWithAddress(ctx, grantee) + k.authKeeper.SetAccount(ctx, granteeAcc) + } + store := ctx.KVStore(k.storeKey) key := types.FeeAllowanceKey(granter, grantee) grant := types.NewFeeAllowanceGrant(granter, grantee, feeAllowance) From 27c918269f5d1b680d0a2e7e78228bea14520a90 Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 25 Jan 2021 23:26:17 +0530 Subject: [PATCH 166/184] update docs --- x/feegrant/ante/ante.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/x/feegrant/ante/ante.go b/x/feegrant/ante/ante.go index 661de0bf2518..483868c23e16 100644 --- a/x/feegrant/ante/ante.go +++ b/x/feegrant/ante/ante.go @@ -25,9 +25,6 @@ func NewAnteHandler( authante.TxTimeoutHeightDecorator{}, authante.NewValidateMemoDecorator(ak), authante.NewConsumeGasForTxSizeDecorator(ak), - // DeductGrantedFeeDecorator will create an empty account if we sign with no - // tokens but valid validation. This must be before SetPubKey, ValidateSigCount, - // SigVerification, which error if account doesn't exist yet. NewDeductGrantedFeeDecorator(ak, bankKeeper, feeGrantKeeper), authante.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators authante.NewValidateSigCountDecorator(ak), From d3423bf6fd8e9a58d4ea4df62ec8f9a4357a8c95 Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 26 Jan 2021 00:14:11 +0530 Subject: [PATCH 167/184] fix tests --- x/feegrant/client/cli/cli_test.go | 43 ++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/x/feegrant/client/cli/cli_test.go b/x/feegrant/client/cli/cli_test.go index 41b55424252e..b7948de73d80 100644 --- a/x/feegrant/client/cli/cli_test.go +++ b/x/feegrant/client/cli/cli_test.go @@ -47,11 +47,7 @@ func (s *IntegrationTestSuite) SetupSuite() { val := s.network.Validators[0] granter := val.Address - - // creating an account manually (This won't exist in accounts store) - info, _, err := val.ClientCtx.Keyring.NewMnemonic("grantee", keyring.English, sdk.FullFundraiserPath, hd.Secp256k1) - s.Require().NoError(err) - grantee := sdk.AccAddress(info.GetPubKey().Address()) + grantee := s.network.Validators[1].Address clientCtx := val.ClientCtx commonFlags := []string{ @@ -78,6 +74,8 @@ func (s *IntegrationTestSuite) SetupSuite() { _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, args) s.Require().NoError(err) + _, err = s.network.WaitForHeight(1) + s.Require().NoError(err) s.addedGranter = granter s.addedGrantee = grantee @@ -469,8 +467,39 @@ func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() { func (s *IntegrationTestSuite) TestTxWithFeeGrant() { val := s.network.Validators[0] clientCtx := val.ClientCtx - granter := s.addedGranter - grantee := s.addedGrantee + granter := val.Address + + // creating an account manually (This account won't be exist in state) + info, _, err := val.ClientCtx.Keyring.NewMnemonic("grantee", keyring.English, sdk.FullFundraiserPath, hd.Secp256k1) + s.Require().NoError(err) + grantee := sdk.AccAddress(info.GetPubKey().Address()) + + commonFlags := []string{ + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + fee := sdk.NewCoin("stake", sdk.NewInt(100)) + duration := 365 * 24 * 60 * 60 + + args := append( + []string{ + granter.String(), + grantee.String(), + fee.String(), + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + fmt.Sprintf("--%s=%v", cli.FlagExpiration, duration), + }, + commonFlags..., + ) + + cmd := cli.NewCmdFeeGrant() + + _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, args) + s.Require().NoError(err) + _, err = s.network.WaitForHeight(1) + s.Require().NoError(err) // granted fee allowance for an account which is not in state and creating // any tx with it by using --fee-account shouldn't fail From 0ff9adeb84786116540a54f3d7cf208c9e52e98a Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 26 Jan 2021 00:34:28 +0530 Subject: [PATCH 168/184] update `serviceMsgClientConn` from `msgservice` --- simapp/helpers/service_msg_client.go | 50 --------------------- x/feegrant/client/cli/service_msg_client.go | 43 ------------------ x/feegrant/client/cli/tx.go | 9 ++-- x/feegrant/simulation/operations.go | 5 ++- 4 files changed, 8 insertions(+), 99 deletions(-) delete mode 100644 simapp/helpers/service_msg_client.go delete mode 100644 x/feegrant/client/cli/service_msg_client.go diff --git a/simapp/helpers/service_msg_client.go b/simapp/helpers/service_msg_client.go deleted file mode 100644 index 2c8a273ce68e..000000000000 --- a/simapp/helpers/service_msg_client.go +++ /dev/null @@ -1,50 +0,0 @@ -package helpers - -import ( - "context" - "fmt" - - gogogrpc "github.com/gogo/protobuf/grpc" - grpc "google.golang.org/grpc" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -var _ gogogrpc.ClientConn = &ServiceMsgClientConn{} - -// ServiceMsgClientConn is an instance of grpc.ClientConn that is used to test building -// transactions with MsgClient's. It is intended to be replaced by the work in -// https://github.com/cosmos/cosmos-sdk/issues/7541 when that is ready. -type ServiceMsgClientConn struct { - msgs []sdk.Msg -} - -// Invoke implements the grpc ClientConn.Invoke method -func (t *ServiceMsgClientConn) Invoke(_ context.Context, method string, args, _ interface{}, _ ...grpc.CallOption) error { - req, ok := args.(sdk.MsgRequest) - if !ok { - return fmt.Errorf("%T should implement %T", args, (*sdk.MsgRequest)(nil)) - } - - err := req.ValidateBasic() - if err != nil { - return err - } - - t.msgs = append(t.msgs, sdk.ServiceMsg{ - MethodName: method, - Request: req, - }) - - return nil -} - -// NewStream implements the grpc ClientConn.NewStream method -func (t *ServiceMsgClientConn) NewStream(context.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error) { - return nil, fmt.Errorf("not supported") -} - -// GetMsgs returns ServiceMsgClientConn.msgs -func (t *ServiceMsgClientConn) GetMsgs() []sdk.Msg { - return t.msgs -} diff --git a/x/feegrant/client/cli/service_msg_client.go b/x/feegrant/client/cli/service_msg_client.go deleted file mode 100644 index 001b37fa4d38..000000000000 --- a/x/feegrant/client/cli/service_msg_client.go +++ /dev/null @@ -1,43 +0,0 @@ -package cli - -import ( - "context" - "fmt" - - gogogrpc "github.com/gogo/protobuf/grpc" - grpc "google.golang.org/grpc" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -var _ gogogrpc.ClientConn = &serviceMsgClientConn{} - -// serviceMsgClientConn is an instance of grpc.ClientConn that is used to test building -// transactions with MsgClient's. It is intended to be replaced by the work in -// https://github.com/cosmos/cosmos-sdk/issues/7541 when that is ready. -type serviceMsgClientConn struct { - msgs []sdk.Msg -} - -func (t *serviceMsgClientConn) Invoke(_ context.Context, method string, args, _ interface{}, _ ...grpc.CallOption) error { - req, ok := args.(sdk.MsgRequest) - if !ok { - return fmt.Errorf("%T should implement %T", args, (*sdk.MsgRequest)(nil)) - } - - err := req.ValidateBasic() - if err != nil { - return err - } - - t.msgs = append(t.msgs, sdk.ServiceMsg{ - MethodName: method, - Request: req, - }) - - return nil -} - -func (t *serviceMsgClientConn) NewStream(context.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error) { - return nil, fmt.Errorf("not supported") -} diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index 12c2b5f425be..c90ae7a65a09 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -13,6 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/feegrant/types" ) @@ -134,14 +135,14 @@ Examples: return err } - svcMsgClientConn := &serviceMsgClientConn{} + svcMsgClientConn := &msgservice.ServiceMsgClientConn{} feeGrantMsgClient := types.NewMsgClient(svcMsgClientConn) _, err = feeGrantMsgClient.GrantFeeAllowance(context.Background(), msg) if err != nil { return err } - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), svcMsgClientConn.msgs...) + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), svcMsgClientConn.GetMsgs()...) }, } @@ -177,14 +178,14 @@ Example: } msg := types.NewMsgRevokeFeeAllowance(clientCtx.GetFromAddress(), grantee) - svcMsgClientConn := &serviceMsgClientConn{} + svcMsgClientConn := &msgservice.ServiceMsgClientConn{} feeGrantMsgClient := types.NewMsgClient(svcMsgClientConn) _, err = feeGrantMsgClient.RevokeFeeAllowance(context.Background(), &msg) if err != nil { return err } - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), svcMsgClientConn.msgs...) + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), svcMsgClientConn.GetMsgs()...) }, } diff --git a/x/feegrant/simulation/operations.go b/x/feegrant/simulation/operations.go index e0bf8b289ebe..54821873b6b6 100644 --- a/x/feegrant/simulation/operations.go +++ b/x/feegrant/simulation/operations.go @@ -10,6 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp/helpers" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" "github.com/cosmos/cosmos-sdk/x/feegrant/types" @@ -97,7 +98,7 @@ func SimulateMsgGrantFeeAllowance(ak types.AccountKeeper, bk types.BankKeeper, k return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgGrantFeeAllowance, err.Error()), nil, err } txGen := simappparams.MakeTestEncodingConfig().TxConfig - svcMsgClientConn := &helpers.ServiceMsgClientConn{} + svcMsgClientConn := &msgservice.ServiceMsgClientConn{} feegrantMsgClient := types.NewMsgClient(svcMsgClientConn) _, err = feegrantMsgClient.GrantFeeAllowance(context.Background(), msg) if err != nil { @@ -171,7 +172,7 @@ func SimulateMsgRevokeFeeAllowance(ak types.AccountKeeper, bk types.BankKeeper, msg := types.NewMsgRevokeFeeAllowance(granterAddr, granteeAddr) txGen := simappparams.MakeTestEncodingConfig().TxConfig - svcMsgClientConn := &helpers.ServiceMsgClientConn{} + svcMsgClientConn := &msgservice.ServiceMsgClientConn{} feegrantMsgClient := types.NewMsgClient(svcMsgClientConn) _, err = feegrantMsgClient.RevokeFeeAllowance(context.Background(), &msg) if err != nil { From a0d67bd32ae98e77651a42689b3e8865b5246aec Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 27 Jan 2021 15:40:40 +0530 Subject: [PATCH 169/184] review changes --- proto/cosmos/feegrant/v1beta1/feegrant.proto | 2 +- proto/cosmos/feegrant/v1beta1/query.proto | 4 +- x/feegrant/client/cli/query.go | 5 +- x/feegrant/client/cli/tx.go | 5 +- x/feegrant/keeper/msg_server.go | 2 +- x/feegrant/module.go | 5 +- x/feegrant/types/codec.go | 2 +- x/feegrant/types/expiration.go | 18 +-- x/feegrant/types/expiration_test.go | 6 +- x/feegrant/types/feegrant.pb.go | 114 +++++++++---------- x/feegrant/types/grant_test.go | 4 - x/feegrant/types/msgs.go | 4 +- x/feegrant/types/query.pb.go | 2 +- 13 files changed, 81 insertions(+), 92 deletions(-) mode change 100755 => 100644 proto/cosmos/feegrant/v1beta1/feegrant.proto diff --git a/proto/cosmos/feegrant/v1beta1/feegrant.proto b/proto/cosmos/feegrant/v1beta1/feegrant.proto old mode 100755 new mode 100644 index 733ef99e6a0c..9879e488886e --- a/proto/cosmos/feegrant/v1beta1/feegrant.proto +++ b/proto/cosmos/feegrant/v1beta1/feegrant.proto @@ -41,7 +41,7 @@ message Duration { // sum is the oneof that represents either duration or block oneof sum { google.protobuf.Duration duration = 1 [(gogoproto.stdduration) = true]; - int64 block = 2; + uint64 blocks = 2; } } diff --git a/proto/cosmos/feegrant/v1beta1/query.proto b/proto/cosmos/feegrant/v1beta1/query.proto index 2889921f22de..42d5f302005f 100644 --- a/proto/cosmos/feegrant/v1beta1/query.proto +++ b/proto/cosmos/feegrant/v1beta1/query.proto @@ -10,7 +10,7 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; // Query defines the gRPC querier service. service Query { - + // FeeAllowance returns fee granted to the grantee by the granter. rpc FeeAllowance(QueryFeeAllowanceRequest) returns (QueryFeeAllowanceResponse) { option (google.api.http).get = "/cosmos/feegrant/v1beta1/fee_allowance/{granter}/{grantee}"; @@ -44,7 +44,7 @@ message QueryFeeAllowancesRequest { // QueryFeeAllowancesResponse is the response type for the Query/FeeAllowances RPC method. message QueryFeeAllowancesResponse { - //fee_allowances are fee_allowance's granted for grantee by granter. + // fee_allowances are fee_allowance's granted for grantee by granter. repeated cosmos.feegrant.v1beta1.FeeAllowanceGrant fee_allowances = 1; // pagination defines an pagination for the response. diff --git a/x/feegrant/client/cli/query.go b/x/feegrant/client/cli/query.go index bf2da17d7e5d..c3a488ab5536 100644 --- a/x/feegrant/client/cli/query.go +++ b/x/feegrant/client/cli/query.go @@ -1,7 +1,6 @@ package cli import ( - "context" "fmt" "strings" @@ -60,7 +59,7 @@ $ %s query feegrant grant [granter] [grantee] } res, err := queryClient.FeeAllowance( - context.Background(), + cmd.Context(), &types.QueryFeeAllowanceRequest{ Granter: granterAddr.String(), Grantee: granteeAddr.String(), @@ -108,7 +107,7 @@ $ %s query feegrant grants [grantee] } res, err := queryClient.FeeAllowances( - context.Background(), + cmd.Context(), &types.QueryFeeAllowancesRequest{ Grantee: granteeAddr.String(), Pagination: pageReq, diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index c90ae7a65a09..200a255627df 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -1,7 +1,6 @@ package cli import ( - "context" "fmt" "strconv" "strings" @@ -137,7 +136,7 @@ Examples: svcMsgClientConn := &msgservice.ServiceMsgClientConn{} feeGrantMsgClient := types.NewMsgClient(svcMsgClientConn) - _, err = feeGrantMsgClient.GrantFeeAllowance(context.Background(), msg) + _, err = feeGrantMsgClient.GrantFeeAllowance(cmd.Context(), msg) if err != nil { return err } @@ -180,7 +179,7 @@ Example: msg := types.NewMsgRevokeFeeAllowance(clientCtx.GetFromAddress(), grantee) svcMsgClientConn := &msgservice.ServiceMsgClientConn{} feeGrantMsgClient := types.NewMsgClient(svcMsgClientConn) - _, err = feeGrantMsgClient.RevokeFeeAllowance(context.Background(), &msg) + _, err = feeGrantMsgClient.RevokeFeeAllowance(cmd.Context(), &msg) if err != nil { return err } diff --git a/x/feegrant/keeper/msg_server.go b/x/feegrant/keeper/msg_server.go index 0f8ff20642f8..94d1eb926b17 100644 --- a/x/feegrant/keeper/msg_server.go +++ b/x/feegrant/keeper/msg_server.go @@ -39,7 +39,7 @@ func (k msgServer) GrantFeeAllowance(goCtx context.Context, msg *types.MsgGrantF // Checking for duplicate entry f := k.Keeper.GetFeeAllowance(ctx, granter, grantee) if f != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "fee allowance already exist") + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "fee allowance already exists") } k.Keeper.GrantFeeAllowance(ctx, granter, grantee, msg.GetFeeAllowanceI()) diff --git a/x/feegrant/module.go b/x/feegrant/module.go index 1723b5950a36..9f539040fdb8 100644 --- a/x/feegrant/module.go +++ b/x/feegrant/module.go @@ -3,7 +3,6 @@ package feegrant import ( "context" "encoding/json" - "fmt" "math/rand" "github.com/gorilla/mux" @@ -16,6 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/feegrant/client/cli" @@ -75,7 +75,8 @@ func (AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage { func (a AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, config sdkclient.TxEncodingConfig, bz json.RawMessage) error { var data types.GenesisState if err := cdc.UnmarshalJSON(bz, &data); err != nil { - return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + // return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + sdkerrors.Wrapf(err, "failed to unmarshal %s genesis state: %w", types.ModuleName, err) } return types.ValidateGenesis(data) diff --git a/x/feegrant/types/codec.go b/x/feegrant/types/codec.go index 37c3b1f04037..686187cd7510 100644 --- a/x/feegrant/types/codec.go +++ b/x/feegrant/types/codec.go @@ -14,7 +14,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { ) registry.RegisterInterface( - "cosmos.authz.v1beta1.FeeAllowance", + "cosmos.feegrant.v1beta1.FeeAllowanceI", (*FeeAllowanceI)(nil), &BasicFeeAllowance{}, &PeriodicFeeAllowance{}, diff --git a/x/feegrant/types/expiration.go b/x/feegrant/types/expiration.go index df779aea757f..5bbd46f94015 100644 --- a/x/feegrant/types/expiration.go +++ b/x/feegrant/types/expiration.go @@ -62,7 +62,7 @@ func (e ExpiresAt) FastForward(t time.Time, h int64) ExpiresAt { // // Note a "zero" ExpiresAt is never expired func (e ExpiresAt) IsExpired(t *time.Time, h int64) bool { - if e.HasDefinedTime() && !t.Before(*e.GetTime()) { + if e.HasDefinedTime() && t.After(*e.GetTime()) { return true } @@ -75,7 +75,7 @@ func (e ExpiresAt) IsCompatible(d Duration) bool { if e.HasDefinedTime() { return d.GetDuration() != nil && d.GetDuration().Seconds() > float64(0) } - return d.GetBlock() > 0 + return d.GetBlocks() > 0 } // Step will increase the expiration point by one Duration @@ -87,7 +87,7 @@ func (e ExpiresAt) Step(d Duration) (ExpiresAt, error) { if e.HasDefinedTime() { return ExpiresAtTime(e.GetTime().Add(*d.GetDuration())), nil } - return ExpiresAtHeight(e.GetHeight() + d.GetBlock()), nil + return ExpiresAtHeight(e.GetHeight() + int64(d.GetBlocks())), nil } // MustStep is like Step, but panics on error @@ -116,22 +116,22 @@ func ClockDuration(d time.Duration) Duration { } // BlockDuration creates an Duration by block height -func BlockDuration(h int64) Duration { - return Duration{Sum: &Duration_Block{ - Block: h, +func BlockDuration(h uint64) Duration { + return Duration{Sum: &Duration_Blocks{ + Blocks: h, }} } // ValidateBasic performs basic sanity checks // Note that exactly one must be set and it must be positive func (d Duration) ValidateBasic() error { - if d.GetBlock() == 0 && d.GetDuration() == nil { + if d.GetBlocks() == 0 && d.GetDuration() == nil { return sdkerrors.Wrap(ErrInvalidDuration, "neither time and height are set") } - if d.GetBlock() != 0 && d.GetDuration() != nil && d.GetDuration().Seconds() != float64(0) { + if d.GetBlocks() != 0 && d.GetDuration() != nil && d.GetDuration().Seconds() != float64(0) { return sdkerrors.Wrap(ErrInvalidDuration, "both time and height are set") } - if d.GetBlock() < 0 { + if d.GetBlocks() < 0 { return sdkerrors.Wrap(ErrInvalidDuration, "negative block step") } if d.GetDuration() != nil && d.GetDuration().Seconds() < 0 { diff --git a/x/feegrant/types/expiration_test.go b/x/feegrant/types/expiration_test.go index 95a64f973e54..60b1753bcbc1 100644 --- a/x/feegrant/types/expiration_test.go +++ b/x/feegrant/types/expiration_test.go @@ -41,7 +41,7 @@ func TestExpiresAt(t *testing.T) { example: types.ExpiresAtTime(now), valid: true, before: types.ExpiresAtTime(now.Add(-1 * time.Second)), - after: types.ExpiresAtTime(now), + after: types.ExpiresAtTime(now.Add(1 * time.Second)), }, } @@ -95,10 +95,6 @@ func TestDurationValid(t *testing.T) { period: types.ClockDuration(-1 * time.Hour), valid: false, }, - "negative block": { - period: types.BlockDuration(-5), - valid: false, - }, } for name, stc := range cases { diff --git a/x/feegrant/types/feegrant.pb.go b/x/feegrant/types/feegrant.pb.go index ced71cb7aa1c..d60cf72a177e 100644 --- a/x/feegrant/types/feegrant.pb.go +++ b/x/feegrant/types/feegrant.pb.go @@ -164,14 +164,14 @@ func (m *PeriodicFeeAllowance) GetPeriodReset() ExpiresAt { return ExpiresAt{} } -// Duration is a repeating unit of either clock time or number of blocks. +// Duration is a span of a clock time or number of blocks. // This is designed to be added to an ExpiresAt struct. type Duration struct { // sum is the oneof that represents either duration or block // // Types that are valid to be assigned to Sum: // *Duration_Duration - // *Duration_Block + // *Duration_Blocks Sum isDuration_Sum `protobuf_oneof:"sum"` } @@ -217,12 +217,12 @@ type isDuration_Sum interface { type Duration_Duration struct { Duration *time.Duration `protobuf:"bytes,1,opt,name=duration,proto3,oneof,stdduration" json:"duration,omitempty"` } -type Duration_Block struct { - Block int64 `protobuf:"varint,2,opt,name=block,proto3,oneof" json:"block,omitempty"` +type Duration_Blocks struct { + Blocks uint64 `protobuf:"varint,2,opt,name=blocks,proto3,oneof" json:"blocks,omitempty"` } func (*Duration_Duration) isDuration_Sum() {} -func (*Duration_Block) isDuration_Sum() {} +func (*Duration_Blocks) isDuration_Sum() {} func (m *Duration) GetSum() isDuration_Sum { if m != nil { @@ -238,9 +238,9 @@ func (m *Duration) GetDuration() *time.Duration { return nil } -func (m *Duration) GetBlock() int64 { - if x, ok := m.GetSum().(*Duration_Block); ok { - return x.Block +func (m *Duration) GetBlocks() uint64 { + if x, ok := m.GetSum().(*Duration_Blocks); ok { + return x.Blocks } return 0 } @@ -249,7 +249,7 @@ func (m *Duration) GetBlock() int64 { func (*Duration) XXX_OneofWrappers() []interface{} { return []interface{}{ (*Duration_Duration)(nil), - (*Duration_Block)(nil), + (*Duration_Blocks)(nil), } } @@ -416,45 +416,45 @@ func init() { } var fileDescriptor_7279582900c30aea = []byte{ - // 596 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcf, 0x6e, 0xd3, 0x30, - 0x18, 0x6f, 0x48, 0x3b, 0xd6, 0xaf, 0x80, 0xa8, 0x55, 0x41, 0xda, 0x43, 0x3a, 0x7a, 0x40, 0x15, - 0x52, 0x13, 0x36, 0x24, 0x0e, 0x48, 0x08, 0x35, 0x63, 0x5b, 0x11, 0x1c, 0x50, 0xe0, 0xc4, 0xa5, - 0x4a, 0x52, 0x2f, 0x8d, 0x96, 0xc4, 0x51, 0xec, 0xc2, 0xfa, 0x12, 0x68, 0x47, 0x9e, 0x81, 0x33, - 0x0f, 0x31, 0x71, 0x9a, 0x38, 0x71, 0xda, 0x50, 0xfb, 0x04, 0xbc, 0x01, 0x8a, 0xed, 0xa4, 0x55, - 0x4b, 0x91, 0x90, 0x76, 0x6a, 0x6c, 0x7f, 0xbf, 0x3f, 0xdf, 0xef, 0xb3, 0x0b, 0x0f, 0x3d, 0x42, - 0x23, 0x42, 0xcd, 0x63, 0x8c, 0xfd, 0xd4, 0x89, 0x99, 0xf9, 0x71, 0xd7, 0xc5, 0xcc, 0xd9, 0x2d, - 0x36, 0x8c, 0x24, 0x25, 0x8c, 0xa0, 0xfb, 0xa2, 0xce, 0x28, 0xb6, 0x65, 0x5d, 0xab, 0xe1, 0x13, - 0x9f, 0xf0, 0x1a, 0x33, 0xfb, 0x12, 0xe5, 0xad, 0xa6, 0x4f, 0x88, 0x1f, 0x62, 0x93, 0xaf, 0xdc, - 0xc9, 0xb1, 0xe9, 0xc4, 0xd3, 0xfc, 0x48, 0x30, 0x0d, 0x05, 0x46, 0xd2, 0x8a, 0x23, 0x5d, 0x9a, - 0x71, 0x1d, 0x8a, 0x0b, 0x23, 0x1e, 0x09, 0x62, 0x79, 0xde, 0x5e, 0x65, 0x65, 0x41, 0x84, 0x29, - 0x73, 0xa2, 0x24, 0x27, 0x58, 0x2d, 0x18, 0x4d, 0x52, 0x87, 0x05, 0x44, 0x12, 0x74, 0x2e, 0x15, - 0xa8, 0x5b, 0x0e, 0x0d, 0xbc, 0x43, 0x8c, 0xfb, 0x61, 0x48, 0x3e, 0x39, 0xb1, 0x87, 0x51, 0x08, - 0x35, 0x9a, 0xe0, 0x78, 0x34, 0x0c, 0x83, 0x28, 0x60, 0x9a, 0xb2, 0xa3, 0x76, 0x6b, 0x7b, 0x4d, - 0x43, 0x5a, 0xcb, 0xcc, 0xe4, 0xdd, 0x1a, 0xfb, 0x24, 0x88, 0xad, 0xc7, 0xe7, 0x97, 0xed, 0xd2, - 0xd7, 0xab, 0x76, 0xd7, 0x0f, 0xd8, 0x78, 0xe2, 0x1a, 0x1e, 0x89, 0x64, 0x1f, 0xf2, 0xa7, 0x47, - 0x47, 0x27, 0x26, 0x9b, 0x26, 0x98, 0x72, 0x00, 0xb5, 0x81, 0xf3, 0xbf, 0xc9, 0xe8, 0xd1, 0x00, - 0x00, 0x9f, 0x26, 0x81, 0xf0, 0xa5, 0xdd, 0xd8, 0x51, 0xba, 0xb5, 0xbd, 0x8e, 0xb1, 0x21, 0x5e, - 0xe3, 0x20, 0x2b, 0xc5, 0xb4, 0xcf, 0xac, 0x72, 0xa6, 0x6a, 0x2f, 0x61, 0x9f, 0xd5, 0x7f, 0x7c, - 0xeb, 0xdd, 0x5e, 0xee, 0xe4, 0x55, 0xe7, 0xb7, 0x0a, 0x8d, 0xb7, 0x38, 0x0d, 0xc8, 0x68, 0xa5, - 0xc7, 0x43, 0xa8, 0xb8, 0x59, 0xe3, 0x9a, 0xc2, 0x05, 0x1f, 0x6d, 0x14, 0x5c, 0x8b, 0x47, 0x0a, - 0x0b, 0x38, 0x7a, 0x01, 0x5b, 0x09, 0xe7, 0x97, 0xce, 0x1f, 0x6c, 0x24, 0x7a, 0x29, 0xa3, 0x97, - 0x78, 0x09, 0x43, 0x53, 0x40, 0xe2, 0x6b, 0xb8, 0x9c, 0xb9, 0x7a, 0xfd, 0x99, 0xdf, 0x15, 0x32, - 0xef, 0x16, 0xc9, 0x4f, 0x40, 0xee, 0x0d, 0x3d, 0x27, 0x16, 0xf2, 0x5a, 0xf9, 0xfa, 0x85, 0xef, - 0x08, 0x91, 0x7d, 0x27, 0xe6, 0xda, 0xe8, 0x35, 0xdc, 0x92, 0xb2, 0x29, 0xa6, 0x98, 0x69, 0x95, - 0xff, 0x1c, 0x79, 0x4d, 0xa0, 0xed, 0x0c, 0xfc, 0xb7, 0x99, 0x8f, 0x61, 0x3b, 0xcf, 0x1a, 0x3d, - 0x87, 0xed, 0xfc, 0xca, 0xcb, 0x49, 0x37, 0x0d, 0xf1, 0x26, 0x8c, 0xfc, 0x4d, 0x2c, 0x0d, 0xe6, - 0xcb, 0x55, 0x5b, 0x19, 0x94, 0xec, 0x02, 0x82, 0xee, 0x41, 0xc5, 0x0d, 0x89, 0x77, 0xc2, 0x87, - 0xab, 0x0e, 0xb2, 0xa9, 0x67, 0x4b, 0xab, 0x02, 0x2a, 0x9d, 0x44, 0x9d, 0x11, 0x54, 0x0b, 0x73, - 0xe8, 0x29, 0x94, 0xb3, 0xe7, 0x27, 0x65, 0x5a, 0x6b, 0x32, 0xef, 0xf3, 0xb7, 0x69, 0x95, 0xcf, - 0x84, 0x0e, 0xaf, 0x47, 0x1a, 0x6c, 0x8d, 0x71, 0xe0, 0x8f, 0x59, 0x21, 0x22, 0xd7, 0xb9, 0xca, - 0x67, 0x05, 0xea, 0xcb, 0x1d, 0x1e, 0x65, 0xe9, 0x20, 0x0d, 0x6e, 0xf2, 0x98, 0x70, 0xca, 0x15, - 0xab, 0x76, 0xbe, 0x5c, 0x9c, 0x60, 0xce, 0x58, 0x9c, 0x60, 0x74, 0x00, 0x55, 0x27, 0x67, 0xd1, - 0x54, 0xee, 0xb3, 0xb1, 0xe6, 0xb3, 0x1f, 0x4f, 0xad, 0xfa, 0xf7, 0xd5, 0x54, 0xed, 0x05, 0xd2, - 0x3a, 0x3a, 0x9f, 0xe9, 0xca, 0xc5, 0x4c, 0x57, 0x7e, 0xcd, 0x74, 0xe5, 0x6c, 0xae, 0x97, 0x2e, - 0xe6, 0x7a, 0xe9, 0xe7, 0x5c, 0x2f, 0x7d, 0xe8, 0xfd, 0xf3, 0x52, 0x9c, 0x2e, 0xfe, 0x55, 0xf9, - 0xfd, 0x70, 0xb7, 0xb8, 0xe8, 0x93, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x2e, 0xb1, 0xe6, 0x7e, - 0x75, 0x05, 0x00, 0x00, + // 599 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x4f, 0x6e, 0xd3, 0x40, + 0x14, 0xc6, 0x6d, 0x9c, 0x96, 0x76, 0x02, 0x88, 0x8c, 0x22, 0xe1, 0x64, 0xe1, 0x94, 0x2c, 0x50, + 0x84, 0x14, 0x9b, 0x16, 0x89, 0x05, 0x12, 0x42, 0x71, 0x69, 0x1b, 0x04, 0x0b, 0x64, 0x58, 0xb1, + 0x89, 0x6c, 0x67, 0xea, 0x0c, 0xb5, 0x3d, 0x96, 0x67, 0x02, 0xcd, 0x25, 0x50, 0x97, 0x9c, 0x81, + 0x35, 0x87, 0xa8, 0x58, 0x55, 0xac, 0x58, 0xb5, 0x28, 0x39, 0x01, 0x37, 0x40, 0xf3, 0xc7, 0x4e, + 0x94, 0x10, 0x24, 0xa4, 0xae, 0xe2, 0x99, 0x79, 0xef, 0xfb, 0xbd, 0xf7, 0xbd, 0x99, 0x80, 0x07, + 0x21, 0xa1, 0x09, 0xa1, 0xce, 0x31, 0x42, 0x51, 0xee, 0xa7, 0xcc, 0xf9, 0xb8, 0x1b, 0x20, 0xe6, + 0xef, 0x96, 0x1b, 0x76, 0x96, 0x13, 0x46, 0xe0, 0x3d, 0x19, 0x67, 0x97, 0xdb, 0x2a, 0xae, 0x59, + 0x8f, 0x48, 0x44, 0x44, 0x8c, 0xc3, 0xbf, 0x64, 0x78, 0xb3, 0x11, 0x11, 0x12, 0xc5, 0xc8, 0x11, + 0xab, 0x60, 0x7c, 0xec, 0xf8, 0xe9, 0xa4, 0x38, 0x92, 0x4a, 0x03, 0x99, 0xa3, 0x64, 0xe5, 0x91, + 0xa5, 0x8a, 0x09, 0x7c, 0x8a, 0xca, 0x42, 0x42, 0x82, 0x53, 0x75, 0xde, 0x5a, 0x56, 0x65, 0x38, + 0x41, 0x94, 0xf9, 0x49, 0x56, 0x08, 0x2c, 0x07, 0x0c, 0xc7, 0xb9, 0xcf, 0x30, 0x51, 0x02, 0xed, + 0x4b, 0x1d, 0xd4, 0x5c, 0x9f, 0xe2, 0xf0, 0x10, 0xa1, 0x5e, 0x1c, 0x93, 0x4f, 0x7e, 0x1a, 0x22, + 0x18, 0x83, 0x2a, 0xcd, 0x50, 0x3a, 0x1c, 0xc4, 0x38, 0xc1, 0xcc, 0xd4, 0x77, 0x8c, 0x4e, 0x75, + 0xaf, 0x61, 0xab, 0xd2, 0x78, 0x31, 0x45, 0xb7, 0xf6, 0x3e, 0xc1, 0xa9, 0xfb, 0xe8, 0xfc, 0xb2, + 0xa5, 0x7d, 0xbd, 0x6a, 0x75, 0x22, 0xcc, 0x46, 0xe3, 0xc0, 0x0e, 0x49, 0xa2, 0xfa, 0x50, 0x3f, + 0x5d, 0x3a, 0x3c, 0x71, 0xd8, 0x24, 0x43, 0x54, 0x24, 0x50, 0x0f, 0x08, 0xfd, 0xd7, 0x5c, 0x1e, + 0xf6, 0x01, 0x40, 0xa7, 0x19, 0x96, 0x75, 0x99, 0x37, 0x76, 0xf4, 0x4e, 0x75, 0xaf, 0x6d, 0xaf, + 0xb1, 0xd7, 0x3e, 0xe0, 0xa1, 0x88, 0xf6, 0x98, 0x5b, 0xe1, 0x54, 0x6f, 0x21, 0xf7, 0x69, 0xed, + 0xc7, 0xb7, 0xee, 0xed, 0xc5, 0x4e, 0x5e, 0xb6, 0x7f, 0x1b, 0xa0, 0xfe, 0x06, 0xe5, 0x98, 0x0c, + 0x97, 0x7a, 0x3c, 0x04, 0x1b, 0x01, 0x6f, 0xdc, 0xd4, 0x05, 0xf0, 0xe1, 0x5a, 0xe0, 0x8a, 0x3d, + 0x0a, 0x2c, 0xd3, 0xe1, 0x73, 0xb0, 0x99, 0x09, 0x7d, 0x55, 0xf9, 0xfd, 0xb5, 0x42, 0x2f, 0x94, + 0xf5, 0x2a, 0x5f, 0xa5, 0xc1, 0x09, 0x80, 0xf2, 0x6b, 0xb0, 0xe8, 0xb9, 0x71, 0xfd, 0x9e, 0xdf, + 0x95, 0x98, 0xb7, 0x73, 0xe7, 0xc7, 0x40, 0xed, 0x0d, 0x42, 0x3f, 0x95, 0x78, 0xb3, 0x72, 0xfd, + 0xe0, 0x3b, 0x12, 0xb2, 0xef, 0xa7, 0x82, 0x0d, 0x5f, 0x81, 0x5b, 0x0a, 0x9b, 0x23, 0x8a, 0x98, + 0xb9, 0xf1, 0x9f, 0x23, 0xaf, 0xca, 0x6c, 0x8f, 0x27, 0xff, 0x6d, 0xe6, 0x1f, 0xc0, 0x56, 0xe1, + 0x35, 0x7c, 0x06, 0xb6, 0x8a, 0x2b, 0xaf, 0x26, 0xdd, 0xb0, 0xe5, 0x9b, 0xb0, 0x8b, 0x37, 0xb1, + 0x30, 0x98, 0x2f, 0x57, 0x2d, 0xbd, 0xaf, 0x79, 0x65, 0x0a, 0x34, 0xc1, 0x66, 0x10, 0x93, 0xf0, + 0x84, 0x8a, 0xe9, 0x56, 0xfa, 0x9a, 0xa7, 0xd6, 0xee, 0x06, 0x30, 0xe8, 0x38, 0x69, 0x0f, 0xc1, + 0x76, 0x59, 0x1e, 0x7c, 0x02, 0x2a, 0xfc, 0x01, 0x2a, 0x50, 0x73, 0x05, 0xf4, 0xae, 0x78, 0x9d, + 0x6e, 0xe5, 0x4c, 0x92, 0x44, 0x3c, 0xa7, 0x8c, 0x10, 0x8e, 0x46, 0x4c, 0x50, 0x0c, 0x4e, 0x91, + 0xeb, 0x82, 0xf2, 0x59, 0x07, 0xb5, 0xc5, 0x1e, 0x8f, 0xb8, 0x3f, 0xd0, 0x04, 0x37, 0x85, 0x51, + 0x28, 0x17, 0xc4, 0x6d, 0xaf, 0x58, 0xce, 0x4f, 0x90, 0x50, 0x2c, 0x4f, 0x10, 0x3c, 0x00, 0xdb, + 0x7e, 0xa1, 0x62, 0x1a, 0xa2, 0xce, 0xfa, 0x4a, 0x9d, 0xbd, 0x74, 0xe2, 0xd6, 0xbe, 0x2f, 0xfb, + 0xea, 0xcd, 0x33, 0xdd, 0xa3, 0xf3, 0xa9, 0xa5, 0x5f, 0x4c, 0x2d, 0xfd, 0xd7, 0xd4, 0xd2, 0xcf, + 0x66, 0x96, 0x76, 0x31, 0xb3, 0xb4, 0x9f, 0x33, 0x4b, 0x7b, 0xdf, 0xfd, 0xe7, 0xb5, 0x38, 0x9d, + 0xff, 0xaf, 0x8a, 0x1b, 0x12, 0x6c, 0x0a, 0xe8, 0xe3, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x74, + 0x27, 0xe6, 0x00, 0x77, 0x05, 0x00, 0x00, } func (m *BasicFeeAllowance) Marshal() (dAtA []byte, err error) { @@ -636,14 +636,14 @@ func (m *Duration_Duration) MarshalToSizedBuffer(dAtA []byte) (int, error) { } return len(dAtA) - i, nil } -func (m *Duration_Block) MarshalTo(dAtA []byte) (int, error) { +func (m *Duration_Blocks) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *Duration_Block) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Duration_Blocks) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) - i = encodeVarintFeegrant(dAtA, i, uint64(m.Block)) + i = encodeVarintFeegrant(dAtA, i, uint64(m.Blocks)) i-- dAtA[i] = 0x10 return len(dAtA) - i, nil @@ -839,13 +839,13 @@ func (m *Duration_Duration) Size() (n int) { } return n } -func (m *Duration_Block) Size() (n int) { +func (m *Duration_Blocks) Size() (n int) { if m == nil { return 0 } var l int _ = l - n += 1 + sovFeegrant(uint64(m.Block)) + n += 1 + sovFeegrant(uint64(m.Blocks)) return n } func (m *ExpiresAt) Size() (n int) { @@ -1308,9 +1308,9 @@ func (m *Duration) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Blocks", wireType) } - var v int64 + var v uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowFeegrant @@ -1320,12 +1320,12 @@ func (m *Duration) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= int64(b&0x7F) << shift + v |= uint64(b&0x7F) << shift if b < 0x80 { break } } - m.Sum = &Duration_Block{v} + m.Sum = &Duration_Blocks{v} default: iNdEx = preIndex skippy, err := skipFeegrant(dAtA[iNdEx:]) diff --git a/x/feegrant/types/grant_test.go b/x/feegrant/types/grant_test.go index c826889c7bf5..c2ea144cdaf9 100644 --- a/x/feegrant/types/grant_test.go +++ b/x/feegrant/types/grant_test.go @@ -1,7 +1,6 @@ package types_test import ( - "fmt" "testing" "github.com/cosmos/cosmos-sdk/simapp" @@ -78,11 +77,8 @@ func TestGrant(t *testing.T) { err = loaded.ValidateBasic() require.NoError(t, err) - fmt.Println("tc", tc.grant) - fmt.Println("tc", loaded) assert.Equal(t, tc.grant, loaded) }) } - } diff --git a/x/feegrant/types/msgs.go b/x/feegrant/types/msgs.go index 22438e08d6b1..5a25016f87e0 100644 --- a/x/feegrant/types/msgs.go +++ b/x/feegrant/types/msgs.go @@ -1,8 +1,6 @@ package types import ( - "fmt" - "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -25,7 +23,7 @@ const ( func NewMsgGrantFeeAllowance(feeAllowance FeeAllowanceI, granter, grantee sdk.AccAddress) (*MsgGrantFeeAllowance, error) { msg, ok := feeAllowance.(proto.Message) if !ok { - return nil, fmt.Errorf("cannot proto marshal %T", msg) + return nil, sdkerrors.Wrapf(sdkerrors.ErrPackAny, "cannot proto marshal %T", msg) } any, err := types.NewAnyWithValue(msg) if err != nil { diff --git a/x/feegrant/types/query.pb.go b/x/feegrant/types/query.pb.go index 31450c64bbb2..e2597c3bc833 100644 --- a/x/feegrant/types/query.pb.go +++ b/x/feegrant/types/query.pb.go @@ -185,7 +185,7 @@ func (m *QueryFeeAllowancesRequest) GetPagination() *query.PageRequest { // QueryFeeAllowancesResponse is the response type for the Query/FeeAllowances RPC method. type QueryFeeAllowancesResponse struct { - // fee_allowance is a fee_allowance granted for grantee by granter. + // fee_allowances are fee_allowance's granted for grantee by granter. FeeAllowances []*FeeAllowanceGrant `protobuf:"bytes,1,rep,name=fee_allowances,json=feeAllowances,proto3" json:"fee_allowances,omitempty"` // pagination defines an pagination for the response. Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` From 65547e7ad83e7fc6c0b6ac14d15cf18dcc8ae93c Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 27 Jan 2021 16:24:17 +0530 Subject: [PATCH 170/184] add test case for using more fees than allowed --- x/feegrant/module.go | 3 +-- x/feegrant/types/basic_fee_test.go | 11 +++++++++++ x/feegrant/types/expiration.go | 3 --- x/feegrant/types/periodic_fee.go | 6 +++--- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/x/feegrant/module.go b/x/feegrant/module.go index 9f539040fdb8..902e8c7c31bd 100644 --- a/x/feegrant/module.go +++ b/x/feegrant/module.go @@ -75,8 +75,7 @@ func (AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage { func (a AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, config sdkclient.TxEncodingConfig, bz json.RawMessage) error { var data types.GenesisState if err := cdc.UnmarshalJSON(bz, &data); err != nil { - // return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) - sdkerrors.Wrapf(err, "failed to unmarshal %s genesis state: %w", types.ModuleName, err) + sdkerrors.Wrapf(err, "failed to unmarshal %s genesis state: %w", types.ModuleName) } return types.ValidateGenesis(data) diff --git a/x/feegrant/types/basic_fee_test.go b/x/feegrant/types/basic_fee_test.go index 440aaeaf49da..d6247db00e51 100644 --- a/x/feegrant/types/basic_fee_test.go +++ b/x/feegrant/types/basic_fee_test.go @@ -14,6 +14,7 @@ func TestBasicFeeValidAllow(t *testing.T) { eth := sdk.NewCoins(sdk.NewInt64Coin("eth", 10)) atom := sdk.NewCoins(sdk.NewInt64Coin("atom", 555)) smallAtom := sdk.NewCoins(sdk.NewInt64Coin("atom", 43)) + bigAtom := sdk.NewCoins(sdk.NewInt64Coin("atom", 1000)) leftAtom := sdk.NewCoins(sdk.NewInt64Coin("atom", 512)) cases := map[string]struct { @@ -81,6 +82,16 @@ func TestBasicFeeValidAllow(t *testing.T) { accept: false, remove: true, }, + "fee more than allowed": { + allow: &types.BasicFeeAllowance{ + SpendLimit: atom, + Expiration: types.ExpiresAtHeight(100), + }, + valid: true, + fee: bigAtom, + blockHeight: 85, + accept: false, + }, } for name, stc := range cases { diff --git a/x/feegrant/types/expiration.go b/x/feegrant/types/expiration.go index 5bbd46f94015..4922b6d481d0 100644 --- a/x/feegrant/types/expiration.go +++ b/x/feegrant/types/expiration.go @@ -131,9 +131,6 @@ func (d Duration) ValidateBasic() error { if d.GetBlocks() != 0 && d.GetDuration() != nil && d.GetDuration().Seconds() != float64(0) { return sdkerrors.Wrap(ErrInvalidDuration, "both time and height are set") } - if d.GetBlocks() < 0 { - return sdkerrors.Wrap(ErrInvalidDuration, "negative block step") - } if d.GetDuration() != nil && d.GetDuration().Seconds() < 0 { return sdkerrors.Wrap(ErrInvalidDuration, "negative clock step") } diff --git a/x/feegrant/types/periodic_fee.go b/x/feegrant/types/periodic_fee.go index dfd57477e333..f13c740d2e2e 100644 --- a/x/feegrant/types/periodic_fee.go +++ b/x/feegrant/types/periodic_fee.go @@ -24,7 +24,7 @@ func (a *PeriodicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockH return true, sdkerrors.Wrap(ErrFeeLimitExpired, "absolute limit") } - a.TryResetPeriod(blockTime, blockHeight) + a.tryResetPeriod(blockTime, blockHeight) // deduct from both the current period and the max amount var isNeg bool @@ -40,13 +40,13 @@ func (a *PeriodicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockH return a.Basic.SpendLimit.IsZero(), nil } -// TryResetPeriod will check if the PeriodReset has been hit. If not, it is a no-op. +// tryResetPeriod will check if the PeriodReset has been hit. If not, it is a no-op. // If we hit the reset period, it will top up the PeriodCanSpend amount to // min(PeriodicSpendLimit, a.Basic.SpendLimit) so it is never more than the maximum allowed. // It will also update the PeriodReset. If we are within one Period, it will update from the // last PeriodReset (eg. if you always do one tx per day, it will always reset the same time) // If we are more then one period out (eg. no activity in a week), reset is one Period from the execution of this method -func (a *PeriodicFeeAllowance) TryResetPeriod(blockTime time.Time, blockHeight int64) { +func (a *PeriodicFeeAllowance) tryResetPeriod(blockTime time.Time, blockHeight int64) { if !a.PeriodReset.Undefined() && !a.PeriodReset.IsExpired(&blockTime, blockHeight) { return } From fa01503747eee3e55256027255df34deaa1be09f Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 27 Jan 2021 17:14:44 +0530 Subject: [PATCH 171/184] eliminate panic checks from keeper --- x/feegrant/ante/fee_test.go | 6 ++- x/feegrant/client/cli/cli_test.go | 6 ++- x/feegrant/genesis.go | 3 +- x/feegrant/genesis_test.go | 4 +- x/feegrant/keeper/keeper.go | 19 +++++--- x/feegrant/keeper/keeper_test.go | 50 +++++++++++++++------ x/feegrant/keeper/msg_server.go | 5 ++- x/feegrant/simulation/decoder_test.go | 4 +- x/feegrant/simulation/operations_test.go | 3 +- x/feegrant/types/grant.go | 17 +++++--- x/feegrant/types/grant_test.go | 55 +++++++++++++++--------- 11 files changed, 120 insertions(+), 52 deletions(-) diff --git a/x/feegrant/ante/fee_test.go b/x/feegrant/ante/fee_test.go index 63a693311d33..98866b0589ed 100644 --- a/x/feegrant/ante/fee_test.go +++ b/x/feegrant/ante/fee_test.go @@ -86,14 +86,16 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { app.BankKeeper.SetBalances(ctx, addr2, []sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(99999))}) // grant fee allowance from `addr2` to `addr3` (plenty to pay) - app.FeeGrantKeeper.GrantFeeAllowance(ctx, addr2, addr3, &types.BasicFeeAllowance{ + err := app.FeeGrantKeeper.GrantFeeAllowance(ctx, addr2, addr3, &types.BasicFeeAllowance{ SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 500)), }) + suite.Require().NoError(err) // grant low fee allowance (20atom), to check the tx requesting more than allowed. - app.FeeGrantKeeper.GrantFeeAllowance(ctx, addr2, addr4, &types.BasicFeeAllowance{ + err = app.FeeGrantKeeper.GrantFeeAllowance(ctx, addr2, addr4, &types.BasicFeeAllowance{ SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 20)), }) + suite.Require().NoError(err) cases := map[string]struct { signerKey cryptotypes.PrivKey diff --git a/x/feegrant/client/cli/cli_test.go b/x/feegrant/client/cli/cli_test.go index b7948de73d80..25e5b045d55b 100644 --- a/x/feegrant/client/cli/cli_test.go +++ b/x/feegrant/client/cli/cli_test.go @@ -79,9 +79,13 @@ func (s *IntegrationTestSuite) SetupSuite() { s.addedGranter = granter s.addedGrantee = grantee - s.addedGrant = types.NewFeeAllowanceGrant(granter, grantee, &types.BasicFeeAllowance{ + + grant, err := types.NewFeeAllowanceGrant(granter, grantee, &types.BasicFeeAllowance{ SpendLimit: sdk.NewCoins(fee), }) + s.Require().NoError(err) + + s.addedGrant = grant } func (s *IntegrationTestSuite) TearDownSuite() { diff --git a/x/feegrant/genesis.go b/x/feegrant/genesis.go index a5c05b7fecc1..34a36a20831c 100644 --- a/x/feegrant/genesis.go +++ b/x/feegrant/genesis.go @@ -32,7 +32,8 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, data *types.GenesisState) { panic(err) } - k.GrantFeeAllowance(ctx, granter, grantee, f.GetFeeGrant()) + err = k.GrantFeeAllowance(ctx, granter, grantee, f.GetFeeGrant()) + panic(err) } } diff --git a/x/feegrant/genesis_test.go b/x/feegrant/genesis_test.go index 9ba458148609..d086daac077f 100644 --- a/x/feegrant/genesis_test.go +++ b/x/feegrant/genesis_test.go @@ -38,7 +38,9 @@ func (suite *GenesisTestSuite) TestImportExportGenesis() { now := suite.ctx.BlockHeader().Time allowance := &types.BasicFeeAllowance{SpendLimit: coins, Expiration: types.ExpiresAtTime(now.AddDate(1, 0, 0))} - suite.keeper.GrantFeeAllowance(suite.ctx, granterAddr, granteeAddr, allowance) + err := suite.keeper.GrantFeeAllowance(suite.ctx, granterAddr, granteeAddr, allowance) + suite.Require().NoError(err) + genesis, err := feegrant.ExportGenesis(suite.ctx, suite.keeper) suite.Require().NoError(err) // Clear keeper diff --git a/x/feegrant/keeper/keeper.go b/x/feegrant/keeper/keeper.go index 78cda94e47e7..e6606bf0ca55 100644 --- a/x/feegrant/keeper/keeper.go +++ b/x/feegrant/keeper/keeper.go @@ -34,7 +34,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { } // GrantFeeAllowance creates a new grant -func (k Keeper) GrantFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddress, feeAllowance types.FeeAllowanceI) { +func (k Keeper) GrantFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddress, feeAllowance types.FeeAllowanceI) error { // create the account if it is not in account state granteeAcc := k.authKeeper.GetAccount(ctx, grantee) @@ -45,8 +45,16 @@ func (k Keeper) GrantFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddre store := ctx.KVStore(k.storeKey) key := types.FeeAllowanceKey(granter, grantee) - grant := types.NewFeeAllowanceGrant(granter, grantee, feeAllowance) - bz := k.cdc.MustMarshalBinaryBare(&grant) + grant, err := types.NewFeeAllowanceGrant(granter, grantee, feeAllowance) + if err != nil { + return err + } + + bz, err := k.cdc.MarshalBinaryBare(&grant) + if err != nil { + return err + } + store.Set(key, bz) ctx.EventManager().EmitEvent( @@ -56,6 +64,8 @@ func (k Keeper) GrantFeeAllowance(ctx sdk.Context, granter, grantee sdk.AccAddre sdk.NewAttribute(types.AttributeKeyGrantee, grant.Grantee), ), ) + + return nil } // RevokeFeeAllowance removes an existing grant @@ -176,6 +186,5 @@ func (k Keeper) UseGrantedFees(ctx sdk.Context, granter, grantee sdk.AccAddress, } // if we accepted, store the updated state of the allowance - k.GrantFeeAllowance(ctx, granter, grantee, grant.GetFeeGrant()) - return nil + return k.GrantFeeAllowance(ctx, granter, grantee, grant.GetFeeGrant()) } diff --git a/x/feegrant/keeper/keeper_test.go b/x/feegrant/keeper/keeper_test.go index a43393c39e1e..8562b6f79c93 100644 --- a/x/feegrant/keeper/keeper_test.go +++ b/x/feegrant/keeper/keeper_test.go @@ -50,18 +50,30 @@ func (suite *KeeperTestSuite) TestKeeperCrud() { } // let's set up some initial state here - k.GrantFeeAllowance(ctx, suite.addrs[0], suite.addrs[1], basic) - k.GrantFeeAllowance(ctx, suite.addrs[0], suite.addrs[2], basic2) - k.GrantFeeAllowance(ctx, suite.addrs[1], suite.addrs[2], basic) - k.GrantFeeAllowance(ctx, suite.addrs[1], suite.addrs[3], basic) - k.GrantFeeAllowance(ctx, suite.addrs[3], suite.addrs[0], basic2) + err := k.GrantFeeAllowance(ctx, suite.addrs[0], suite.addrs[1], basic) + suite.Require().NoError(err) + + err = k.GrantFeeAllowance(ctx, suite.addrs[0], suite.addrs[2], basic2) + suite.Require().NoError(err) + + err = k.GrantFeeAllowance(ctx, suite.addrs[1], suite.addrs[2], basic) + suite.Require().NoError(err) + + err = k.GrantFeeAllowance(ctx, suite.addrs[1], suite.addrs[3], basic) + suite.Require().NoError(err) + + err = k.GrantFeeAllowance(ctx, suite.addrs[3], suite.addrs[0], basic2) + suite.Require().NoError(err) // remove some, overwrite other k.RevokeFeeAllowance(ctx, suite.addrs[0], suite.addrs[1]) k.RevokeFeeAllowance(ctx, suite.addrs[0], suite.addrs[2]) - k.GrantFeeAllowance(ctx, suite.addrs[0], suite.addrs[2], basic) - k.GrantFeeAllowance(ctx, suite.addrs[1], suite.addrs[2], basic2) + err = k.GrantFeeAllowance(ctx, suite.addrs[0], suite.addrs[2], basic) + suite.Require().NoError(err) + + err = k.GrantFeeAllowance(ctx, suite.addrs[1], suite.addrs[2], basic2) + suite.Require().NoError(err) // end state: // addr -> addr3 (basic) @@ -107,6 +119,15 @@ func (suite *KeeperTestSuite) TestKeeperCrud() { }) } + grant1, err := types.NewFeeAllowanceGrant(suite.addrs[3], suite.addrs[0], basic2) + suite.NoError(err) + + grant2, err := types.NewFeeAllowanceGrant(suite.addrs[1], suite.addrs[2], basic2) + suite.NoError(err) + + grant3, err := types.NewFeeAllowanceGrant(suite.addrs[0], suite.addrs[2], basic) + suite.NoError(err) + allCases := map[string]struct { grantee sdk.AccAddress grants []types.FeeAllowanceGrant @@ -117,14 +138,14 @@ func (suite *KeeperTestSuite) TestKeeperCrud() { "addr has one": { grantee: suite.addrs[0], grants: []types.FeeAllowanceGrant{ - types.NewFeeAllowanceGrant(suite.addrs[3], suite.addrs[0], basic2), + grant1, }, }, "addr3 has two": { grantee: suite.addrs[2], grants: []types.FeeAllowanceGrant{ - types.NewFeeAllowanceGrant(suite.addrs[1], suite.addrs[2], basic2), - types.NewFeeAllowanceGrant(suite.addrs[0], suite.addrs[2], basic), + grant2, + grant3, }, }, } @@ -215,10 +236,13 @@ func (suite *KeeperTestSuite) TestUseGrantedFee() { // addr -> addr2 (future) // addr -> addr3 (expired) - k.GrantFeeAllowance(ctx, suite.addrs[0], suite.addrs[1], future) - k.GrantFeeAllowance(ctx, suite.addrs[0], suite.addrs[3], expired) + err := k.GrantFeeAllowance(ctx, suite.addrs[0], suite.addrs[1], future) + suite.Require().NoError(err) + + err = k.GrantFeeAllowance(ctx, suite.addrs[0], suite.addrs[3], expired) + suite.Require().NoError(err) - err := k.UseGrantedFees(ctx, tc.granter, tc.grantee, tc.fee) + err = k.UseGrantedFees(ctx, tc.granter, tc.grantee, tc.fee) if tc.allowed { suite.NoError(err) } else { diff --git a/x/feegrant/keeper/msg_server.go b/x/feegrant/keeper/msg_server.go index 94d1eb926b17..3cd96e79ba88 100644 --- a/x/feegrant/keeper/msg_server.go +++ b/x/feegrant/keeper/msg_server.go @@ -42,7 +42,10 @@ func (k msgServer) GrantFeeAllowance(goCtx context.Context, msg *types.MsgGrantF return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "fee allowance already exists") } - k.Keeper.GrantFeeAllowance(ctx, granter, grantee, msg.GetFeeAllowanceI()) + err = k.Keeper.GrantFeeAllowance(ctx, granter, grantee, msg.GetFeeAllowanceI()) + if err != nil { + return nil, err + } return &types.MsgGrantFeeAllowanceResponse{}, nil } diff --git a/x/feegrant/simulation/decoder_test.go b/x/feegrant/simulation/decoder_test.go index 3607c94cf581..0087e5eba117 100644 --- a/x/feegrant/simulation/decoder_test.go +++ b/x/feegrant/simulation/decoder_test.go @@ -24,10 +24,12 @@ func TestDecodeStore(t *testing.T) { cdc := simapp.MakeTestEncodingConfig().Marshaler dec := simulation.NewDecodeStore(cdc) - grant := types.NewFeeAllowanceGrant(granterAddr, granteeAddr, &types.BasicFeeAllowance{ + grant, err := types.NewFeeAllowanceGrant(granterAddr, granteeAddr, &types.BasicFeeAllowance{ SpendLimit: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100))), }) + require.NoError(t, err) + grantBz, err := cdc.MarshalBinaryBare(&grant) require.NoError(t, err) diff --git a/x/feegrant/simulation/operations_test.go b/x/feegrant/simulation/operations_test.go index 173e3772e581..7c2593a5302a 100644 --- a/x/feegrant/simulation/operations_test.go +++ b/x/feegrant/simulation/operations_test.go @@ -143,7 +143,7 @@ func (suite *SimTestSuite) TestSimulateMsgRevokeFeeAllowance() { granter, grantee := accounts[0], accounts[1] - app.FeeGrantKeeper.GrantFeeAllowance( + err := app.FeeGrantKeeper.GrantFeeAllowance( ctx, granter.Address, grantee.Address, @@ -152,6 +152,7 @@ func (suite *SimTestSuite) TestSimulateMsgRevokeFeeAllowance() { Expiration: types.ExpiresAtTime(ctx.BlockTime().Add(30 * time.Hour)), }, ) + require.NoError(err) // execute operation op := simulation.SimulateMsgRevokeFeeAllowance(app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, suite.protoCdc) diff --git a/x/feegrant/types/grant.go b/x/feegrant/types/grant.go index e0d46028e576..ca2c93d9efb2 100644 --- a/x/feegrant/types/grant.go +++ b/x/feegrant/types/grant.go @@ -1,7 +1,6 @@ package types import ( - fmt "fmt" "time" "github.com/cosmos/cosmos-sdk/codec/types" @@ -16,21 +15,22 @@ var ( // NewFeeAllowanceGrant creates a new FeeAllowanceGrant. //nolint:interfacer -func NewFeeAllowanceGrant(granter, grantee sdk.AccAddress, feeAllowance FeeAllowanceI) FeeAllowanceGrant { +func NewFeeAllowanceGrant(granter, grantee sdk.AccAddress, feeAllowance FeeAllowanceI) (FeeAllowanceGrant, error) { msg, ok := feeAllowance.(proto.Message) if !ok { - panic(fmt.Errorf("cannot proto marshal %T", msg)) + return FeeAllowanceGrant{}, sdkerrors.Wrapf(sdkerrors.ErrPackAny, "cannot proto marshal %T", feeAllowance) } + any, err := types.NewAnyWithValue(msg) if err != nil { - panic(err) + return FeeAllowanceGrant{}, err } return FeeAllowanceGrant{ Granter: granter.String(), Grantee: grantee.String(), Allowance: any, - } + }, nil } // ValidateBasic performs basic validation on @@ -83,5 +83,10 @@ func (a FeeAllowanceGrant) PrepareForExport(dumpTime time.Time, dumpHeight int64 return FeeAllowanceGrant{} } - return NewFeeAllowanceGrant(granter, grantee, feegrant) + grant, err := NewFeeAllowanceGrant(granter, grantee, feegrant) + if err != nil { + return FeeAllowanceGrant{} + } + + return grant } diff --git a/x/feegrant/types/grant_test.go b/x/feegrant/types/grant_test.go index c2ea144cdaf9..a4819b102cb2 100644 --- a/x/feegrant/types/grant_test.go +++ b/x/feegrant/types/grant_test.go @@ -18,6 +18,36 @@ func TestGrant(t *testing.T) { require.NoError(t, err) atom := sdk.NewCoins(sdk.NewInt64Coin("atom", 555)) + goodGrant, err := types.NewFeeAllowanceGrant(addr2, addr, &types.BasicFeeAllowance{ + SpendLimit: atom, + Expiration: types.ExpiresAtHeight(100), + }) + require.NoError(t, err) + + noGranteeGrant, err := types.NewFeeAllowanceGrant(addr2, nil, &types.BasicFeeAllowance{ + SpendLimit: atom, + Expiration: types.ExpiresAtHeight(100), + }) + require.NoError(t, err) + + noGranterGrant, err := types.NewFeeAllowanceGrant(nil, addr, &types.BasicFeeAllowance{ + SpendLimit: atom, + Expiration: types.ExpiresAtHeight(100), + }) + require.NoError(t, err) + + selfGrant, err := types.NewFeeAllowanceGrant(addr2, addr2, &types.BasicFeeAllowance{ + SpendLimit: atom, + Expiration: types.ExpiresAtHeight(100), + }) + require.NoError(t, err) + + badAllowanceGrant, err := types.NewFeeAllowanceGrant(addr2, addr, &types.BasicFeeAllowance{ + SpendLimit: atom, + Expiration: types.ExpiresAtHeight(-1), + }) + require.NoError(t, err) + cdc := app.AppCodec() // RegisterLegacyAminoCodec(cdc) @@ -26,35 +56,20 @@ func TestGrant(t *testing.T) { valid bool }{ "good": { - grant: types.NewFeeAllowanceGrant(addr2, addr, &types.BasicFeeAllowance{ - SpendLimit: atom, - Expiration: types.ExpiresAtHeight(100), - }), + grant: goodGrant, valid: true, }, "no grantee": { - grant: types.NewFeeAllowanceGrant(addr2, nil, &types.BasicFeeAllowance{ - SpendLimit: atom, - Expiration: types.ExpiresAtHeight(100), - }), + grant: noGranteeGrant, }, "no granter": { - grant: types.NewFeeAllowanceGrant(nil, addr, &types.BasicFeeAllowance{ - SpendLimit: atom, - Expiration: types.ExpiresAtHeight(100), - }), + grant: noGranterGrant, }, "self-grant": { - grant: types.NewFeeAllowanceGrant(addr2, addr2, &types.BasicFeeAllowance{ - SpendLimit: atom, - Expiration: types.ExpiresAtHeight(100), - }), + grant: selfGrant, }, "bad allowance": { - grant: types.NewFeeAllowanceGrant(addr2, addr, &types.BasicFeeAllowance{ - SpendLimit: atom, - Expiration: types.ExpiresAtHeight(-1), - }), + grant: badAllowanceGrant, }, } From 86714f1e1271222a8577dec6208f7e9e8876e298 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 27 Jan 2021 17:18:42 +0530 Subject: [PATCH 172/184] fix lint --- x/feegrant/module.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/feegrant/module.go b/x/feegrant/module.go index 902e8c7c31bd..c558ba8300ad 100644 --- a/x/feegrant/module.go +++ b/x/feegrant/module.go @@ -75,7 +75,7 @@ func (AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage { func (a AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, config sdkclient.TxEncodingConfig, bz json.RawMessage) error { var data types.GenesisState if err := cdc.UnmarshalJSON(bz, &data); err != nil { - sdkerrors.Wrapf(err, "failed to unmarshal %s genesis state: %w", types.ModuleName) + sdkerrors.Wrapf(err, "failed to unmarshal %s genesis state", types.ModuleName) } return types.ValidateGenesis(data) From 1d6f9cfe062b6ea86ff47af9eb892f117dc9ad93 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 27 Jan 2021 17:54:18 +0530 Subject: [PATCH 173/184] change store keys string to bytes --- x/feegrant/types/key.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/x/feegrant/types/key.go b/x/feegrant/types/key.go index 675cb41097eb..36934075b463 100644 --- a/x/feegrant/types/key.go +++ b/x/feegrant/types/key.go @@ -1,8 +1,6 @@ package types import ( - "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -28,10 +26,11 @@ var ( // FeeAllowanceKey is the canonical key to store a grant from granter to grantee // We store by grantee first to allow searching by everyone who granted to you func FeeAllowanceKey(granter sdk.AccAddress, grantee sdk.AccAddress) []byte { - return append(FeeAllowanceKeyPrefix, []byte(fmt.Sprintf("%s/%s", grantee, granter))...) + // return append(FeeAllowanceKeyPrefix, []byte(fmt.Sprintf("%s/%s", grantee, granter))...) + return append(append(FeeAllowanceKeyPrefix, grantee.Bytes()...), granter.Bytes()...) } // FeeAllowancePrefixByGrantee returns a prefix to scan for all grants to this given address. func FeeAllowancePrefixByGrantee(grantee sdk.AccAddress) []byte { - return append(FeeAllowanceKeyPrefix, []byte(fmt.Sprintf("%s/", grantee))...) + return append(FeeAllowanceKeyPrefix, grantee.Bytes()...) } From e9086520063fe94ae3066cb06b4172d75e46e167 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 27 Jan 2021 18:11:55 +0530 Subject: [PATCH 174/184] fix tests --- x/feegrant/genesis.go | 4 +++- x/feegrant/keeper/keeper_test.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/x/feegrant/genesis.go b/x/feegrant/genesis.go index 34a36a20831c..f65cfdb57825 100644 --- a/x/feegrant/genesis.go +++ b/x/feegrant/genesis.go @@ -33,7 +33,9 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, data *types.GenesisState) { } err = k.GrantFeeAllowance(ctx, granter, grantee, f.GetFeeGrant()) - panic(err) + if err != nil { + panic(err) + } } } diff --git a/x/feegrant/keeper/keeper_test.go b/x/feegrant/keeper/keeper_test.go index 8562b6f79c93..c14e141d31f0 100644 --- a/x/feegrant/keeper/keeper_test.go +++ b/x/feegrant/keeper/keeper_test.go @@ -144,8 +144,8 @@ func (suite *KeeperTestSuite) TestKeeperCrud() { "addr3 has two": { grantee: suite.addrs[2], grants: []types.FeeAllowanceGrant{ - grant2, grant3, + grant2, }, }, } From e5d26109855f2934eb0858f113b93a45812b4c11 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 27 Jan 2021 20:43:52 +0530 Subject: [PATCH 175/184] review changes --- x/feegrant/module.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/feegrant/module.go b/x/feegrant/module.go index c558ba8300ad..5f4ba807d895 100644 --- a/x/feegrant/module.go +++ b/x/feegrant/module.go @@ -196,12 +196,12 @@ func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { return nil } -// RegisterStoreDecoder registers a decoder for staking module's types +// RegisterStoreDecoder registers a decoder for feegrant module's types func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc) } -// WeightedOperations returns the all the staking module operations with their respective weights. +// WeightedOperations returns all the feegrant module operations with their respective weights. func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { protoCdc := codec.NewProtoCodec(am.registry) return simulation.WeightedOperations( From 0ffebce6f2288e2fc7ca56d570d2d36248a25bcb Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 27 Jan 2021 20:56:29 +0530 Subject: [PATCH 176/184] review changes --- x/feegrant/client/cli/cli_test.go | 23 ++++++++++++++--- x/feegrant/client/cli/tx.go | 42 +++++++++++++++++++------------ x/feegrant/keeper/grpc_query.go | 12 --------- 3 files changed, 45 insertions(+), 32 deletions(-) diff --git a/x/feegrant/client/cli/cli_test.go b/x/feegrant/client/cli/cli_test.go index 25e5b045d55b..59a2488bf764 100644 --- a/x/feegrant/client/cli/cli_test.go +++ b/x/feegrant/client/cli/cli_test.go @@ -317,6 +317,21 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { ), true, nil, 0, }, + { + "period mentioned and period limit omitted, invalid periodic grant", + append( + []string{ + granter.String(), + "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", + "100stake", + fmt.Sprintf("--%s=%d", cli.FlagPeriod, 10*60*60), + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + fmt.Sprintf("--%s=%d", cli.FlagExpiration, 60*60), + }, + commonFlags..., + ), + true, nil, 0, + }, { "period cannot be greater than the actual expiration(periodic fee grant)", append( @@ -324,8 +339,8 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { granter.String(), "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", "100stake", - fmt.Sprintf("%d", 10*60*60), //period - "10stake", + fmt.Sprintf("--%s=%d", cli.FlagPeriod, 10*60*60), + fmt.Sprintf("--%s=%s", cli.FlagPeriodLimit, "10stake"), fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), fmt.Sprintf("--%s=%d", cli.FlagExpiration, 60*60), }, @@ -340,8 +355,8 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { granter.String(), "cosmos1w55kgcf3ltaqdy4ww49nge3klxmrdavrr6frmp", "100stake", - fmt.Sprintf("%d", 60*60), - "10stake", + fmt.Sprintf("--%s=%d", cli.FlagPeriod, 60*60), + fmt.Sprintf("--%s=%s", cli.FlagPeriodLimit, "10stake"), fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), fmt.Sprintf("--%s=%d", cli.FlagExpiration, 10*60*60), }, diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index 200a255627df..fd3e97e1f6f2 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -2,7 +2,6 @@ package cli import ( "fmt" - "strconv" "strings" "time" @@ -19,7 +18,9 @@ import ( // flag for feegrant module const ( - FlagExpiration = "expiration" + FlagExpiration = "expiration" + FlagPeriod = "period" + FlagPeriodLimit = "period-limit" ) // GetTxCmd returns the transaction commands for this module @@ -53,11 +54,11 @@ func NewCmdFeeGrant() *cobra.Command { Examples: %s tx %s grant cosmos1skjw... cosmos1skjw... 100stake --expiration 36000 or -%s tx %s grant cosmos1skjw... cosmos1skjw... 100stake 3600 10stake --expiration 36000 +%s tx %s grant cosmos1skjw... cosmos1skjw... 100stake --period 3600 --periodlimit 10stake --expiration 36000 `, version.AppName, types.ModuleName, version.AppName, types.ModuleName, ), ), - Args: cobra.RangeArgs(3, 5), + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { _, err := sdk.AccAddressFromBech32(args[0]) if err != nil { @@ -87,28 +88,34 @@ Examples: return err } - period := time.Duration(exp) * time.Second + expDuration := time.Duration(exp) * time.Second basic := types.BasicFeeAllowance{ SpendLimit: limit, - Expiration: types.ExpiresAtTime(time.Now().Add(period)), + Expiration: types.ExpiresAtTime(time.Now().Add(expDuration)), } var grant types.FeeAllowanceI grant = &basic - if len(args) > 3 { // if period mentioned it can be treated as periodic fee allowance - if len(args) >= 5 { + periodClock, err := cmd.Flags().GetInt64(FlagPeriod) + if err != nil { + return err + } - periodClock, err := strconv.ParseInt(args[3], 10, 64) - if err != nil { - return err - } + periodLimitVal, err := cmd.Flags().GetString(FlagPeriodLimit) + if err != nil { + return err + } - periodLimit, err := sdk.ParseCoinsNormalized(args[4]) - if err != nil { - return err - } + // Check any of period or periodLimit flags set, If set consider it as periodic fee allowance. + if periodClock > 0 || periodLimitVal != "" { + periodLimit, err := sdk.ParseCoinsNormalized(periodLimitVal) + if err != nil { + return err + } + + if periodClock > 0 && periodLimit != nil { if periodClock > exp { return fmt.Errorf("period(%d) cannot be greater than the expiration(%d)", periodClock, exp) @@ -147,6 +154,9 @@ Examples: flags.AddTxFlagsToCmd(cmd) cmd.Flags().Int64(FlagExpiration, int64(365*24*60*60), "The second unit of time duration which the grant is active for the user; Default is a year") + cmd.Flags().Int64(FlagPeriod, 0, "period specifies the time duration in which period_spend_limit coins can be spent before that allowance is reset") + cmd.Flags().String(FlagPeriodLimit, "", "// period limit specifies the maximum number of coins that can be spent in the period") + return cmd } diff --git a/x/feegrant/keeper/grpc_query.go b/x/feegrant/keeper/grpc_query.go index 9f2abdd50e56..0fce084f90ba 100644 --- a/x/feegrant/keeper/grpc_query.go +++ b/x/feegrant/keeper/grpc_query.go @@ -22,14 +22,6 @@ func (q Keeper) FeeAllowance(c context.Context, req *types.QueryFeeAllowanceRequ return nil, status.Error(codes.InvalidArgument, "invalid request") } - if req.Granter == "" { - return nil, status.Errorf(codes.InvalidArgument, "invalid granter addr") - } - - if req.Grantee == "" { - return nil, status.Errorf(codes.InvalidArgument, "invalid grantee addr") - } - granterAddr, err := sdk.AccAddressFromBech32(req.Granter) if err != nil { return nil, err @@ -71,10 +63,6 @@ func (q Keeper) FeeAllowances(c context.Context, req *types.QueryFeeAllowancesRe return nil, status.Error(codes.InvalidArgument, "invalid request") } - if req.Grantee == "" { - return nil, status.Errorf(codes.InvalidArgument, "invalid grantee addr") - } - granteeAddr, err := sdk.AccAddressFromBech32(req.Grantee) if err != nil { return nil, err From fa378254b1af4457ed3244195cfe91dc34ee84aa Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 27 Jan 2021 21:00:01 +0530 Subject: [PATCH 177/184] udpate docs --- x/feegrant/client/cli/tx.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index fd3e97e1f6f2..bacfa460f2b9 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -45,7 +45,7 @@ func GetTxCmd() *cobra.Command { // NewCmdFeeGrant returns a CLI command handler for creating a MsgGrantFeeAllowance transaction. func NewCmdFeeGrant() *cobra.Command { cmd := &cobra.Command{ - Use: "grant [granter] [grantee] [limit] or grant [granter] [grantee] [limit] [period] [periodLimit]", + Use: "grant [granter] [grantee] [limit]", Short: "Grant Fee allowance to an address", Long: strings.TrimSpace( fmt.Sprintf( @@ -54,7 +54,7 @@ func NewCmdFeeGrant() *cobra.Command { Examples: %s tx %s grant cosmos1skjw... cosmos1skjw... 100stake --expiration 36000 or -%s tx %s grant cosmos1skjw... cosmos1skjw... 100stake --period 3600 --periodlimit 10stake --expiration 36000 +%s tx %s grant cosmos1skjw... cosmos1skjw... 100stake --period 3600 --period-limit 10stake --expiration 36000 `, version.AppName, types.ModuleName, version.AppName, types.ModuleName, ), ), From f2b616f41477aad13943de7b2c131a19e4976323 Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 28 Jan 2021 15:04:05 +0530 Subject: [PATCH 178/184] make spend limit optional --- x/feegrant/client/cli/cli_test.go | 101 +++++++++++++++++++++++--- x/feegrant/client/cli/tx.go | 30 +++++--- x/feegrant/types/basic_fee.go | 26 ++++--- x/feegrant/types/basic_fee_test.go | 27 ++++++- x/feegrant/types/periodic_fee.go | 15 ++-- x/feegrant/types/periodic_fee_test.go | 9 ++- 6 files changed, 166 insertions(+), 42 deletions(-) diff --git a/x/feegrant/client/cli/cli_test.go b/x/feegrant/client/cli/cli_test.go index 59a2488bf764..c2c4c9d426b9 100644 --- a/x/feegrant/client/cli/cli_test.go +++ b/x/feegrant/client/cli/cli_test.go @@ -63,7 +63,7 @@ func (s *IntegrationTestSuite) SetupSuite() { []string{ granter.String(), grantee.String(), - fee.String(), + fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, fee.String()), fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), fmt.Sprintf("--%s=%v", cli.FlagExpiration, duration), }, @@ -256,7 +256,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { []string{ "wrong_granter", "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", - "100stake", + fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, "100stake"), fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), }, commonFlags..., @@ -269,7 +269,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { []string{ granter.String(), "wrong_grantee", - "100stake", + fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, "100stake"), fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), }, commonFlags..., @@ -282,7 +282,44 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { []string{ granter.String(), "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", - "100stake", + fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, "100stake"), + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + }, + commonFlags..., + ), + false, &sdk.TxResponse{}, 0, + }, + { + "valid basic fee grant without spend limit", + append( + []string{ + granter.String(), + "cosmos17h5lzptx3ghvsuhk7wx4c4hnl7rsswxjer97em", + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + }, + commonFlags..., + ), + false, &sdk.TxResponse{}, 0, + }, + { + "valid basic fee grant without expiration", + append( + []string{ + granter.String(), + "cosmos16dlc38dcqt0uralyd8hksxyrny6kaeqfjvjwp5", + fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, "100stake"), + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + }, + commonFlags..., + ), + false, &sdk.TxResponse{}, 0, + }, + { + "valid basic fee grant without spend-limit and expiration", + append( + []string{ + granter.String(), + "cosmos1ku40qup9vwag4wtf8cls9mkszxfthaklxkp3c8", fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), }, commonFlags..., @@ -295,7 +332,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { []string{ granter.String(), alreadyExistedGrantee.String(), - "100stake", + fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, "100stake"), fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), }, commonFlags..., @@ -308,8 +345,8 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { []string{ granter.String(), "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", - "100stake", - "10stake", + fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, "100stake"), + fmt.Sprintf("--%s=%s", cli.FlagPeriodLimit, "10stake"), fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), fmt.Sprintf("--%s=%d", cli.FlagExpiration, 10*60*60), }, @@ -323,7 +360,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { []string{ granter.String(), "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", - "100stake", + fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, "100stake"), fmt.Sprintf("--%s=%d", cli.FlagPeriod, 10*60*60), fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), fmt.Sprintf("--%s=%d", cli.FlagExpiration, 60*60), @@ -338,7 +375,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { []string{ granter.String(), "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", - "100stake", + fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, "100stake"), fmt.Sprintf("--%s=%d", cli.FlagPeriod, 10*60*60), fmt.Sprintf("--%s=%s", cli.FlagPeriodLimit, "10stake"), fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), @@ -354,7 +391,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { []string{ granter.String(), "cosmos1w55kgcf3ltaqdy4ww49nge3klxmrdavrr6frmp", - "100stake", + fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, "100stake"), fmt.Sprintf("--%s=%d", cli.FlagPeriod, 60*60), fmt.Sprintf("--%s=%s", cli.FlagPeriodLimit, "10stake"), fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), @@ -364,6 +401,50 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { ), false, &sdk.TxResponse{}, 0, }, + { + "valid periodic fee grant without spend-limit", + append( + []string{ + granter.String(), + "cosmos1vevyks8pthkscvgazc97qyfjt40m6g9xe85ry8", + fmt.Sprintf("--%s=%d", cli.FlagPeriod, 60*60), + fmt.Sprintf("--%s=%s", cli.FlagPeriodLimit, "10stake"), + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + fmt.Sprintf("--%s=%d", cli.FlagExpiration, 10*60*60), + }, + commonFlags..., + ), + false, &sdk.TxResponse{}, 0, + }, + { + "valid periodic fee grant without expiration", + append( + []string{ + granter.String(), + "cosmos14cm33pvnrv2497tyt8sp9yavhmw83nwej3m0e8", + fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, "100stake"), + fmt.Sprintf("--%s=%d", cli.FlagPeriod, 60*60), + fmt.Sprintf("--%s=%s", cli.FlagPeriodLimit, "10stake"), + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + }, + commonFlags..., + ), + false, &sdk.TxResponse{}, 0, + }, + { + "valid periodic fee grant without spend-limit and expiration", + append( + []string{ + granter.String(), + "cosmos12nyk4pcf4arshznkpz882e4l4ts0lt0ap8ce54", + fmt.Sprintf("--%s=%d", cli.FlagPeriod, 60*60), + fmt.Sprintf("--%s=%s", cli.FlagPeriodLimit, "10stake"), + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + }, + commonFlags..., + ), + false, &sdk.TxResponse{}, 0, + }, } for _, tc := range testCases { diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index bacfa460f2b9..a28ddb976cc1 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -21,6 +21,7 @@ const ( FlagExpiration = "expiration" FlagPeriod = "period" FlagPeriodLimit = "period-limit" + FlagSpendLimit = "spend-limit" ) // GetTxCmd returns the transaction commands for this module @@ -45,7 +46,7 @@ func GetTxCmd() *cobra.Command { // NewCmdFeeGrant returns a CLI command handler for creating a MsgGrantFeeAllowance transaction. func NewCmdFeeGrant() *cobra.Command { cmd := &cobra.Command{ - Use: "grant [granter] [grantee] [limit]", + Use: "grant [granter] [grantee]", Short: "Grant Fee allowance to an address", Long: strings.TrimSpace( fmt.Sprintf( @@ -53,12 +54,12 @@ func NewCmdFeeGrant() *cobra.Command { ignored as it is implied from [granter]. Examples: -%s tx %s grant cosmos1skjw... cosmos1skjw... 100stake --expiration 36000 or -%s tx %s grant cosmos1skjw... cosmos1skjw... 100stake --period 3600 --period-limit 10stake --expiration 36000 +%s tx %s grant cosmos1skjw... cosmos1skjw... --spend-limit 100stake --expiration 36000 or +%s tx %s grant cosmos1skjw... cosmos1skjw... --spend-limit 100stake --period 3600 --period-limit 10stake --expiration 36000 `, version.AppName, types.ModuleName, version.AppName, types.ModuleName, ), ), - Args: cobra.ExactArgs(3), + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { _, err := sdk.AccAddressFromBech32(args[0]) if err != nil { @@ -77,8 +78,13 @@ Examples: } granter := clientCtx.GetFromAddress() + sl, err := cmd.Flags().GetString(FlagSpendLimit) + if err != nil { + return err + } - limit, err := sdk.ParseCoinsNormalized(args[2]) + // if `FlagSpendLimit` isn't set, limit will be nil + limit, err := sdk.ParseCoinsNormalized(sl) if err != nil { return err } @@ -88,11 +94,13 @@ Examples: return err } - expDuration := time.Duration(exp) * time.Second - basic := types.BasicFeeAllowance{ SpendLimit: limit, - Expiration: types.ExpiresAtTime(time.Now().Add(expDuration)), + } + + if exp != 0 { + expDuration := time.Duration(exp) * time.Second + basic.Expiration = types.ExpiresAtTime(time.Now().Add(expDuration)) } var grant types.FeeAllowanceI @@ -116,8 +124,7 @@ Examples: } if periodClock > 0 && periodLimit != nil { - - if periodClock > exp { + if exp > 0 && periodClock > exp { return fmt.Errorf("period(%d) cannot be greater than the expiration(%d)", periodClock, exp) } @@ -153,7 +160,8 @@ Examples: } flags.AddTxFlagsToCmd(cmd) - cmd.Flags().Int64(FlagExpiration, int64(365*24*60*60), "The second unit of time duration which the grant is active for the user; Default is a year") + cmd.Flags().Int64(FlagExpiration, 0, "The second unit of time duration which the grant is active for the user") + cmd.Flags().String(FlagSpendLimit, "", "Spend limit specifies the max limit can be used, if not mentioned there is no limit") cmd.Flags().Int64(FlagPeriod, 0, "period specifies the time duration in which period_spend_limit coins can be spent before that allowance is reset") cmd.Flags().String(FlagPeriodLimit, "", "// period limit specifies the maximum number of coins that can be spent in the period") diff --git a/x/feegrant/types/basic_fee.go b/x/feegrant/types/basic_fee.go index 173ff7b9260d..6d970680510f 100644 --- a/x/feegrant/types/basic_fee.go +++ b/x/feegrant/types/basic_fee.go @@ -24,13 +24,17 @@ func (a *BasicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockHeig return true, sdkerrors.Wrap(ErrFeeLimitExpired, "basic allowance") } - left, invalid := a.SpendLimit.SafeSub(fee) - if invalid { - return false, sdkerrors.Wrap(ErrFeeLimitExceeded, "basic allowance") + if a.SpendLimit != nil { + left, invalid := a.SpendLimit.SafeSub(fee) + if invalid { + return false, sdkerrors.Wrap(ErrFeeLimitExceeded, "basic allowance") + } + + a.SpendLimit = left + return left.IsZero(), nil } - a.SpendLimit = left - return left.IsZero(), nil + return false, nil } // PrepareForExport will adjust the expiration based on export time. In particular, @@ -45,11 +49,13 @@ func (a *BasicFeeAllowance) PrepareForExport(dumpTime time.Time, dumpHeight int6 // ValidateBasic implements FeeAllowance and enforces basic sanity checks func (a BasicFeeAllowance) ValidateBasic() error { - if !a.SpendLimit.IsValid() { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidCoins, "send amount is invalid: %s", a.SpendLimit) - } - if !a.SpendLimit.IsAllPositive() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "spend limit must be positive") + if a.SpendLimit != nil { + if !a.SpendLimit.IsValid() { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidCoins, "send amount is invalid: %s", a.SpendLimit) + } + if !a.SpendLimit.IsAllPositive() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "spend limit must be positive") + } } return a.Expiration.ValidateBasic() } diff --git a/x/feegrant/types/basic_fee_test.go b/x/feegrant/types/basic_fee_test.go index d6247db00e51..a5669e99ada4 100644 --- a/x/feegrant/types/basic_fee_test.go +++ b/x/feegrant/types/basic_fee_test.go @@ -29,10 +29,11 @@ func TestBasicFeeValidAllow(t *testing.T) { remains sdk.Coins }{ "empty": { - allow: &types.BasicFeeAllowance{}, - valid: false, + allow: &types.BasicFeeAllowance{}, + valid: true, + accept: true, }, - "small fee": { + "small fee without expire": { allow: &types.BasicFeeAllowance{ SpendLimit: atom, }, @@ -42,7 +43,7 @@ func TestBasicFeeValidAllow(t *testing.T) { remove: false, remains: leftAtom, }, - "all fee": { + "all fee without expire": { allow: &types.BasicFeeAllowance{ SpendLimit: smallAtom, }, @@ -92,6 +93,24 @@ func TestBasicFeeValidAllow(t *testing.T) { blockHeight: 85, accept: false, }, + "with out spend limit": { + allow: &types.BasicFeeAllowance{ + Expiration: types.ExpiresAtHeight(100), + }, + valid: true, + fee: bigAtom, + blockHeight: 85, + accept: true, + }, + "expired no spend limit": { + allow: &types.BasicFeeAllowance{ + Expiration: types.ExpiresAtHeight(100), + }, + valid: true, + fee: bigAtom, + blockHeight: 120, + accept: false, + }, } for name, stc := range cases { diff --git a/x/feegrant/types/periodic_fee.go b/x/feegrant/types/periodic_fee.go index f13c740d2e2e..61c9ba2ffe2d 100644 --- a/x/feegrant/types/periodic_fee.go +++ b/x/feegrant/types/periodic_fee.go @@ -32,12 +32,17 @@ func (a *PeriodicFeeAllowance) Accept(fee sdk.Coins, blockTime time.Time, blockH if isNeg { return false, sdkerrors.Wrap(ErrFeeLimitExceeded, "period limit") } - a.Basic.SpendLimit, isNeg = a.Basic.SpendLimit.SafeSub(fee) - if isNeg { - return false, sdkerrors.Wrap(ErrFeeLimitExceeded, "absolute limit") + + if a.Basic.SpendLimit != nil { + a.Basic.SpendLimit, isNeg = a.Basic.SpendLimit.SafeSub(fee) + if isNeg { + return false, sdkerrors.Wrap(ErrFeeLimitExceeded, "absolute limit") + } + + return a.Basic.SpendLimit.IsZero(), nil } - return a.Basic.SpendLimit.IsZero(), nil + return false, nil } // tryResetPeriod will check if the PeriodReset has been hit. If not, it is a no-op. @@ -103,7 +108,7 @@ func (a PeriodicFeeAllowance) ValidateBasic() error { } // ensure PeriodSpendLimit can be subtracted from total (same coin types) - if !a.PeriodSpendLimit.DenomsSubsetOf(a.Basic.SpendLimit) { + if a.Basic.SpendLimit != nil && !a.PeriodSpendLimit.DenomsSubsetOf(a.Basic.SpendLimit) { return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "period spend limit has different currency than basic spend limit") } diff --git a/x/feegrant/types/periodic_fee_test.go b/x/feegrant/types/periodic_fee_test.go index 0f853da28a60..cc54f4080878 100644 --- a/x/feegrant/types/periodic_fee_test.go +++ b/x/feegrant/types/periodic_fee_test.go @@ -45,10 +45,15 @@ func TestPeriodicFeeValidAllow(t *testing.T) { }, "empty basic": { allow: types.PeriodicFeeAllowance{ - Period: types.BlockDuration(50), + Period: types.BlockDuration(10), PeriodSpendLimit: smallAtom, + PeriodReset: types.ExpiresAtHeight(70), }, - valid: false, + blockHeight: 75, + valid: true, + accept: true, + remove: false, + periodReset: types.ExpiresAtHeight(80), }, "mismatched currencies": { allow: types.PeriodicFeeAllowance{ From c172ccaeabb04da855e1656054beeb2e1c46ef92 Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 28 Jan 2021 15:18:46 +0530 Subject: [PATCH 179/184] fix tests --- x/feegrant/client/rest/grpc_query_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/feegrant/client/rest/grpc_query_test.go b/x/feegrant/client/rest/grpc_query_test.go index 75f2d9cc90a3..10d77a1e4c1f 100644 --- a/x/feegrant/client/rest/grpc_query_test.go +++ b/x/feegrant/client/rest/grpc_query_test.go @@ -191,7 +191,7 @@ func execFeeAllowance(val *network.Validator, s *IntegrationTestSuite) { args := []string{ val.Address.String(), s.grantee.String(), - fee.String(), + fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, fee.String()), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%v", cli.FlagExpiration, duration), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), From 8d8f1378399ca8a627e62ff86ee604cdb9bcba09 Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 28 Jan 2021 15:28:24 +0530 Subject: [PATCH 180/184] fix tests --- x/feegrant/client/cli/cli_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/feegrant/client/cli/cli_test.go b/x/feegrant/client/cli/cli_test.go index c2c4c9d426b9..ed9d6794f229 100644 --- a/x/feegrant/client/cli/cli_test.go +++ b/x/feegrant/client/cli/cli_test.go @@ -587,7 +587,7 @@ func (s *IntegrationTestSuite) TestTxWithFeeGrant() { []string{ granter.String(), grantee.String(), - fee.String(), + fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, fee.String()), fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), fmt.Sprintf("--%s=%v", cli.FlagExpiration, duration), }, From 3dfb3abd0b56b36889232bef4761c390fd6f5ea3 Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 28 Jan 2021 16:16:30 +0530 Subject: [PATCH 181/184] review changes --- x/feegrant/ante/fee_test.go | 76 ++++--------------------------------- x/feegrant/types/key.go | 1 - 2 files changed, 7 insertions(+), 70 deletions(-) diff --git a/x/feegrant/ante/fee_test.go b/x/feegrant/ante/fee_test.go index 98866b0589ed..293f448d73f8 100644 --- a/x/feegrant/ante/fee_test.go +++ b/x/feegrant/ante/fee_test.go @@ -173,74 +173,6 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { handler: ourAnteHandler, valid: false, }, - "paying with low funds (whole stack)": { - signerKey: priv1, - signer: addr1, - fee: 50, - handler: anteHandlerStack, - valid: false, - }, - "paying with good funds (whole stack)": { - signerKey: priv2, - signer: addr2, - fee: 50, - handler: anteHandlerStack, - valid: true, - }, - "paying with no account (whole stack)": { - signerKey: priv3, - signer: addr3, - fee: 1, - handler: anteHandlerStack, - valid: false, - }, - "no fee with real account (whole stack)": { - signerKey: priv1, - signer: addr1, - fee: 0, - handler: anteHandlerStack, - valid: true, - }, - "no fee with no account (whole stack)": { - signerKey: priv5, - signer: addr5, - fee: 0, - handler: anteHandlerStack, - valid: false, - }, - "valid fee grant without account (whole stack)": { - signerKey: priv3, - signer: addr3, - feeAccountKey: priv2, - feeAccount: addr2, - fee: 50, - handler: anteHandlerStack, - valid: true, - }, - "no fee grant (whole stack)": { - signerKey: priv3, - signer: addr3, - feeAccount: addr1, - fee: 2, - handler: anteHandlerStack, - valid: false, - }, - "allowance smaller than requested fee (whole stack)": { - signerKey: priv4, - signer: addr4, - feeAccount: addr2, - fee: 50, - handler: anteHandlerStack, - valid: false, - }, - "granter cannot cover allowed fee grant (whole stack)": { - signerKey: priv4, - signer: addr4, - feeAccount: addr1, - fee: 50, - handler: anteHandlerStack, - valid: false, - }, } for name, stc := range cases { @@ -257,8 +189,14 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { tx, err := genTxWithFeeGranter(protoTxCfg, msgs, fee, helpers.DefaultGenTxGas, ctx.ChainID(), accNums, seqs, tc.feeAccount, privs...) suite.Require().NoError(err) - _, err = tc.handler(ctx, tx, false) + _, err = ourAnteHandler(ctx, tx, false) + if tc.valid { + suite.Require().NoError(err) + } else { + suite.Require().Error(err) + } + _, err = anteHandlerStack(ctx, tx, false) if tc.valid { suite.Require().NoError(err) } else { diff --git a/x/feegrant/types/key.go b/x/feegrant/types/key.go index 36934075b463..e30427b136b4 100644 --- a/x/feegrant/types/key.go +++ b/x/feegrant/types/key.go @@ -26,7 +26,6 @@ var ( // FeeAllowanceKey is the canonical key to store a grant from granter to grantee // We store by grantee first to allow searching by everyone who granted to you func FeeAllowanceKey(granter sdk.AccAddress, grantee sdk.AccAddress) []byte { - // return append(FeeAllowanceKeyPrefix, []byte(fmt.Sprintf("%s/%s", grantee, granter))...) return append(append(FeeAllowanceKeyPrefix, grantee.Bytes()...), granter.Bytes()...) } From 3398c46ff68aa536786effe24221507fbc964efb Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 28 Jan 2021 16:44:29 +0530 Subject: [PATCH 182/184] add norace tag --- x/feegrant/client/cli/cli_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x/feegrant/client/cli/cli_test.go b/x/feegrant/client/cli/cli_test.go index ed9d6794f229..224e7282a80a 100644 --- a/x/feegrant/client/cli/cli_test.go +++ b/x/feegrant/client/cli/cli_test.go @@ -1,3 +1,5 @@ +// +build norace + package cli_test import ( From a344c785f79233dd4eb46fb2ed3a47ef18289241 Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 28 Jan 2021 17:08:13 +0530 Subject: [PATCH 183/184] proto-docs --- docs/core/proto-docs.md | 7606 +++++++++++++++++++-------------------- 1 file changed, 3803 insertions(+), 3803 deletions(-) diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 81127e1110a4..6b5909a3dbc3 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -4,70 +4,116 @@ ## Table of Contents -- [cosmos/auth/v1beta1/auth.proto](#cosmos/auth/v1beta1/auth.proto) - - [BaseAccount](#cosmos.auth.v1beta1.BaseAccount) - - [ModuleAccount](#cosmos.auth.v1beta1.ModuleAccount) - - [Params](#cosmos.auth.v1beta1.Params) +- [cosmos/tx/v1beta1/tx.proto](#cosmos/tx/v1beta1/tx.proto) + - [AuthInfo](#cosmos.tx.v1beta1.AuthInfo) + - [Fee](#cosmos.tx.v1beta1.Fee) + - [ModeInfo](#cosmos.tx.v1beta1.ModeInfo) + - [ModeInfo.Multi](#cosmos.tx.v1beta1.ModeInfo.Multi) + - [ModeInfo.Single](#cosmos.tx.v1beta1.ModeInfo.Single) + - [SignDoc](#cosmos.tx.v1beta1.SignDoc) + - [SignerInfo](#cosmos.tx.v1beta1.SignerInfo) + - [Tx](#cosmos.tx.v1beta1.Tx) + - [TxBody](#cosmos.tx.v1beta1.TxBody) + - [TxRaw](#cosmos.tx.v1beta1.TxRaw) -- [cosmos/auth/v1beta1/genesis.proto](#cosmos/auth/v1beta1/genesis.proto) - - [GenesisState](#cosmos.auth.v1beta1.GenesisState) +- [cosmos/tx/v1beta1/service.proto](#cosmos/tx/v1beta1/service.proto) + - [BroadcastTxRequest](#cosmos.tx.v1beta1.BroadcastTxRequest) + - [BroadcastTxResponse](#cosmos.tx.v1beta1.BroadcastTxResponse) + - [GetTxRequest](#cosmos.tx.v1beta1.GetTxRequest) + - [GetTxResponse](#cosmos.tx.v1beta1.GetTxResponse) + - [GetTxsEventRequest](#cosmos.tx.v1beta1.GetTxsEventRequest) + - [GetTxsEventResponse](#cosmos.tx.v1beta1.GetTxsEventResponse) + - [SimulateRequest](#cosmos.tx.v1beta1.SimulateRequest) + - [SimulateResponse](#cosmos.tx.v1beta1.SimulateResponse) -- [cosmos/auth/v1beta1/query.proto](#cosmos/auth/v1beta1/query.proto) - - [QueryAccountRequest](#cosmos.auth.v1beta1.QueryAccountRequest) - - [QueryAccountResponse](#cosmos.auth.v1beta1.QueryAccountResponse) - - [QueryParamsRequest](#cosmos.auth.v1beta1.QueryParamsRequest) - - [QueryParamsResponse](#cosmos.auth.v1beta1.QueryParamsResponse) + - [BroadcastMode](#cosmos.tx.v1beta1.BroadcastMode) - - [Query](#cosmos.auth.v1beta1.Query) + - [Service](#cosmos.tx.v1beta1.Service) -- [cosmos/base/v1beta1/coin.proto](#cosmos/base/v1beta1/coin.proto) - - [Coin](#cosmos.base.v1beta1.Coin) - - [DecCoin](#cosmos.base.v1beta1.DecCoin) - - [DecProto](#cosmos.base.v1beta1.DecProto) - - [IntProto](#cosmos.base.v1beta1.IntProto) +- [cosmos/tx/signing/v1beta1/signing.proto](#cosmos/tx/signing/v1beta1/signing.proto) + - [SignatureDescriptor](#cosmos.tx.signing.v1beta1.SignatureDescriptor) + - [SignatureDescriptor.Data](#cosmos.tx.signing.v1beta1.SignatureDescriptor.Data) + - [SignatureDescriptor.Data.Multi](#cosmos.tx.signing.v1beta1.SignatureDescriptor.Data.Multi) + - [SignatureDescriptor.Data.Single](#cosmos.tx.signing.v1beta1.SignatureDescriptor.Data.Single) + - [SignatureDescriptors](#cosmos.tx.signing.v1beta1.SignatureDescriptors) -- [cosmos/authz/v1beta1/authz.proto](#cosmos/authz/v1beta1/authz.proto) - - [AuthorizationGrant](#cosmos.authz.v1beta1.AuthorizationGrant) - - [GenericAuthorization](#cosmos.authz.v1beta1.GenericAuthorization) - - [SendAuthorization](#cosmos.authz.v1beta1.SendAuthorization) + - [SignMode](#cosmos.tx.signing.v1beta1.SignMode) -- [cosmos/base/abci/v1beta1/abci.proto](#cosmos/base/abci/v1beta1/abci.proto) - - [ABCIMessageLog](#cosmos.base.abci.v1beta1.ABCIMessageLog) - - [Attribute](#cosmos.base.abci.v1beta1.Attribute) - - [GasInfo](#cosmos.base.abci.v1beta1.GasInfo) - - [MsgData](#cosmos.base.abci.v1beta1.MsgData) - - [Result](#cosmos.base.abci.v1beta1.Result) - - [SearchTxsResult](#cosmos.base.abci.v1beta1.SearchTxsResult) - - [SimulationResponse](#cosmos.base.abci.v1beta1.SimulationResponse) - - [StringEvent](#cosmos.base.abci.v1beta1.StringEvent) - - [TxMsgData](#cosmos.base.abci.v1beta1.TxMsgData) - - [TxResponse](#cosmos.base.abci.v1beta1.TxResponse) +- [cosmos/crisis/v1beta1/tx.proto](#cosmos/crisis/v1beta1/tx.proto) + - [MsgVerifyInvariant](#cosmos.crisis.v1beta1.MsgVerifyInvariant) + - [MsgVerifyInvariantResponse](#cosmos.crisis.v1beta1.MsgVerifyInvariantResponse) -- [cosmos/authz/v1beta1/tx.proto](#cosmos/authz/v1beta1/tx.proto) - - [MsgExecAuthorizedRequest](#cosmos.authz.v1beta1.MsgExecAuthorizedRequest) - - [MsgExecAuthorizedResponse](#cosmos.authz.v1beta1.MsgExecAuthorizedResponse) - - [MsgGrantAuthorizationRequest](#cosmos.authz.v1beta1.MsgGrantAuthorizationRequest) - - [MsgGrantAuthorizationResponse](#cosmos.authz.v1beta1.MsgGrantAuthorizationResponse) - - [MsgRevokeAuthorizationRequest](#cosmos.authz.v1beta1.MsgRevokeAuthorizationRequest) - - [MsgRevokeAuthorizationResponse](#cosmos.authz.v1beta1.MsgRevokeAuthorizationResponse) + - [Msg](#cosmos.crisis.v1beta1.Msg) - - [Msg](#cosmos.authz.v1beta1.Msg) +- [cosmos/crisis/v1beta1/genesis.proto](#cosmos/crisis/v1beta1/genesis.proto) + - [GenesisState](#cosmos.crisis.v1beta1.GenesisState) -- [cosmos/authz/v1beta1/genesis.proto](#cosmos/authz/v1beta1/genesis.proto) - - [GenesisState](#cosmos.authz.v1beta1.GenesisState) - - [GrantAuthorization](#cosmos.authz.v1beta1.GrantAuthorization) +- [cosmos/crypto/multisig/keys.proto](#cosmos/crypto/multisig/keys.proto) + - [LegacyAminoPubKey](#cosmos.crypto.multisig.LegacyAminoPubKey) -- [cosmos/base/query/v1beta1/pagination.proto](#cosmos/base/query/v1beta1/pagination.proto) - - [PageRequest](#cosmos.base.query.v1beta1.PageRequest) - - [PageResponse](#cosmos.base.query.v1beta1.PageResponse) +- [cosmos/crypto/multisig/v1beta1/multisig.proto](#cosmos/crypto/multisig/v1beta1/multisig.proto) + - [CompactBitArray](#cosmos.crypto.multisig.v1beta1.CompactBitArray) + - [MultiSignature](#cosmos.crypto.multisig.v1beta1.MultiSignature) -- [cosmos/authz/v1beta1/query.proto](#cosmos/authz/v1beta1/query.proto) - - [QueryAuthorizationRequest](#cosmos.authz.v1beta1.QueryAuthorizationRequest) - - [QueryAuthorizationResponse](#cosmos.authz.v1beta1.QueryAuthorizationResponse) - - [QueryAuthorizationsRequest](#cosmos.authz.v1beta1.QueryAuthorizationsRequest) - - [QueryAuthorizationsResponse](#cosmos.authz.v1beta1.QueryAuthorizationsResponse) +- [cosmos/crypto/secp256k1/keys.proto](#cosmos/crypto/secp256k1/keys.proto) + - [PrivKey](#cosmos.crypto.secp256k1.PrivKey) + - [PubKey](#cosmos.crypto.secp256k1.PubKey) - - [Query](#cosmos.authz.v1beta1.Query) +- [cosmos/crypto/ed25519/keys.proto](#cosmos/crypto/ed25519/keys.proto) + - [PrivKey](#cosmos.crypto.ed25519.PrivKey) + - [PubKey](#cosmos.crypto.ed25519.PubKey) + +- [cosmos/mint/v1beta1/query.proto](#cosmos/mint/v1beta1/query.proto) + - [QueryAnnualProvisionsRequest](#cosmos.mint.v1beta1.QueryAnnualProvisionsRequest) + - [QueryAnnualProvisionsResponse](#cosmos.mint.v1beta1.QueryAnnualProvisionsResponse) + - [QueryInflationRequest](#cosmos.mint.v1beta1.QueryInflationRequest) + - [QueryInflationResponse](#cosmos.mint.v1beta1.QueryInflationResponse) + - [QueryParamsRequest](#cosmos.mint.v1beta1.QueryParamsRequest) + - [QueryParamsResponse](#cosmos.mint.v1beta1.QueryParamsResponse) + + - [Query](#cosmos.mint.v1beta1.Query) + +- [cosmos/mint/v1beta1/genesis.proto](#cosmos/mint/v1beta1/genesis.proto) + - [GenesisState](#cosmos.mint.v1beta1.GenesisState) + +- [cosmos/mint/v1beta1/mint.proto](#cosmos/mint/v1beta1/mint.proto) + - [Minter](#cosmos.mint.v1beta1.Minter) + - [Params](#cosmos.mint.v1beta1.Params) + +- [cosmos/feegrant/v1beta1/feegrant.proto](#cosmos/feegrant/v1beta1/feegrant.proto) + - [BasicFeeAllowance](#cosmos.feegrant.v1beta1.BasicFeeAllowance) + - [Duration](#cosmos.feegrant.v1beta1.Duration) + - [ExpiresAt](#cosmos.feegrant.v1beta1.ExpiresAt) + - [FeeAllowanceGrant](#cosmos.feegrant.v1beta1.FeeAllowanceGrant) + - [PeriodicFeeAllowance](#cosmos.feegrant.v1beta1.PeriodicFeeAllowance) + +- [cosmos/feegrant/v1beta1/query.proto](#cosmos/feegrant/v1beta1/query.proto) + - [QueryFeeAllowanceRequest](#cosmos.feegrant.v1beta1.QueryFeeAllowanceRequest) + - [QueryFeeAllowanceResponse](#cosmos.feegrant.v1beta1.QueryFeeAllowanceResponse) + - [QueryFeeAllowancesRequest](#cosmos.feegrant.v1beta1.QueryFeeAllowancesRequest) + - [QueryFeeAllowancesResponse](#cosmos.feegrant.v1beta1.QueryFeeAllowancesResponse) + + - [Query](#cosmos.feegrant.v1beta1.Query) + +- [cosmos/feegrant/v1beta1/tx.proto](#cosmos/feegrant/v1beta1/tx.proto) + - [MsgGrantFeeAllowance](#cosmos.feegrant.v1beta1.MsgGrantFeeAllowance) + - [MsgGrantFeeAllowanceResponse](#cosmos.feegrant.v1beta1.MsgGrantFeeAllowanceResponse) + - [MsgRevokeFeeAllowance](#cosmos.feegrant.v1beta1.MsgRevokeFeeAllowance) + - [MsgRevokeFeeAllowanceResponse](#cosmos.feegrant.v1beta1.MsgRevokeFeeAllowanceResponse) + + - [Msg](#cosmos.feegrant.v1beta1.Msg) + +- [cosmos/feegrant/v1beta1/genesis.proto](#cosmos/feegrant/v1beta1/genesis.proto) + - [GenesisState](#cosmos.feegrant.v1beta1.GenesisState) + +- [cosmos/capability/v1beta1/capability.proto](#cosmos/capability/v1beta1/capability.proto) + - [Capability](#cosmos.capability.v1beta1.Capability) + - [CapabilityOwners](#cosmos.capability.v1beta1.CapabilityOwners) + - [Owner](#cosmos.capability.v1beta1.Owner) + +- [cosmos/capability/v1beta1/genesis.proto](#cosmos/capability/v1beta1/genesis.proto) + - [GenesisOwners](#cosmos.capability.v1beta1.GenesisOwners) + - [GenesisState](#cosmos.capability.v1beta1.GenesisState) - [cosmos/bank/v1beta1/bank.proto](#cosmos/bank/v1beta1/bank.proto) - [DenomUnit](#cosmos.bank.v1beta1.DenomUnit) @@ -78,10 +124,6 @@ - [SendEnabled](#cosmos.bank.v1beta1.SendEnabled) - [Supply](#cosmos.bank.v1beta1.Supply) -- [cosmos/bank/v1beta1/genesis.proto](#cosmos/bank/v1beta1/genesis.proto) - - [Balance](#cosmos.bank.v1beta1.Balance) - - [GenesisState](#cosmos.bank.v1beta1.GenesisState) - - [cosmos/bank/v1beta1/query.proto](#cosmos/bank/v1beta1/query.proto) - [QueryAllBalancesRequest](#cosmos.bank.v1beta1.QueryAllBalancesRequest) - [QueryAllBalancesResponse](#cosmos.bank.v1beta1.QueryAllBalancesResponse) @@ -108,107 +150,85 @@ - [Msg](#cosmos.bank.v1beta1.Msg) -- [cosmos/base/kv/v1beta1/kv.proto](#cosmos/base/kv/v1beta1/kv.proto) - - [Pair](#cosmos.base.kv.v1beta1.Pair) - - [Pairs](#cosmos.base.kv.v1beta1.Pairs) - -- [cosmos/base/reflection/v1beta1/reflection.proto](#cosmos/base/reflection/v1beta1/reflection.proto) - - [ListAllInterfacesRequest](#cosmos.base.reflection.v1beta1.ListAllInterfacesRequest) - - [ListAllInterfacesResponse](#cosmos.base.reflection.v1beta1.ListAllInterfacesResponse) - - [ListImplementationsRequest](#cosmos.base.reflection.v1beta1.ListImplementationsRequest) - - [ListImplementationsResponse](#cosmos.base.reflection.v1beta1.ListImplementationsResponse) - - - [ReflectionService](#cosmos.base.reflection.v1beta1.ReflectionService) - -- [cosmos/base/snapshots/v1beta1/snapshot.proto](#cosmos/base/snapshots/v1beta1/snapshot.proto) - - [Metadata](#cosmos.base.snapshots.v1beta1.Metadata) - - [Snapshot](#cosmos.base.snapshots.v1beta1.Snapshot) - -- [cosmos/base/store/v1beta1/commit_info.proto](#cosmos/base/store/v1beta1/commit_info.proto) - - [CommitID](#cosmos.base.store.v1beta1.CommitID) - - [CommitInfo](#cosmos.base.store.v1beta1.CommitInfo) - - [StoreInfo](#cosmos.base.store.v1beta1.StoreInfo) +- [cosmos/bank/v1beta1/genesis.proto](#cosmos/bank/v1beta1/genesis.proto) + - [Balance](#cosmos.bank.v1beta1.Balance) + - [GenesisState](#cosmos.bank.v1beta1.GenesisState) -- [cosmos/base/store/v1beta1/snapshot.proto](#cosmos/base/store/v1beta1/snapshot.proto) - - [SnapshotIAVLItem](#cosmos.base.store.v1beta1.SnapshotIAVLItem) - - [SnapshotItem](#cosmos.base.store.v1beta1.SnapshotItem) - - [SnapshotStoreItem](#cosmos.base.store.v1beta1.SnapshotStoreItem) +- [cosmos/authz/v1beta1/authz.proto](#cosmos/authz/v1beta1/authz.proto) + - [AuthorizationGrant](#cosmos.authz.v1beta1.AuthorizationGrant) + - [GenericAuthorization](#cosmos.authz.v1beta1.GenericAuthorization) + - [SendAuthorization](#cosmos.authz.v1beta1.SendAuthorization) -- [cosmos/base/tendermint/v1beta1/query.proto](#cosmos/base/tendermint/v1beta1/query.proto) - - [GetBlockByHeightRequest](#cosmos.base.tendermint.v1beta1.GetBlockByHeightRequest) - - [GetBlockByHeightResponse](#cosmos.base.tendermint.v1beta1.GetBlockByHeightResponse) - - [GetLatestBlockRequest](#cosmos.base.tendermint.v1beta1.GetLatestBlockRequest) - - [GetLatestBlockResponse](#cosmos.base.tendermint.v1beta1.GetLatestBlockResponse) - - [GetLatestValidatorSetRequest](#cosmos.base.tendermint.v1beta1.GetLatestValidatorSetRequest) - - [GetLatestValidatorSetResponse](#cosmos.base.tendermint.v1beta1.GetLatestValidatorSetResponse) - - [GetNodeInfoRequest](#cosmos.base.tendermint.v1beta1.GetNodeInfoRequest) - - [GetNodeInfoResponse](#cosmos.base.tendermint.v1beta1.GetNodeInfoResponse) - - [GetSyncingRequest](#cosmos.base.tendermint.v1beta1.GetSyncingRequest) - - [GetSyncingResponse](#cosmos.base.tendermint.v1beta1.GetSyncingResponse) - - [GetValidatorSetByHeightRequest](#cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightRequest) - - [GetValidatorSetByHeightResponse](#cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightResponse) - - [Module](#cosmos.base.tendermint.v1beta1.Module) - - [Validator](#cosmos.base.tendermint.v1beta1.Validator) - - [VersionInfo](#cosmos.base.tendermint.v1beta1.VersionInfo) +- [cosmos/authz/v1beta1/query.proto](#cosmos/authz/v1beta1/query.proto) + - [QueryAuthorizationRequest](#cosmos.authz.v1beta1.QueryAuthorizationRequest) + - [QueryAuthorizationResponse](#cosmos.authz.v1beta1.QueryAuthorizationResponse) + - [QueryAuthorizationsRequest](#cosmos.authz.v1beta1.QueryAuthorizationsRequest) + - [QueryAuthorizationsResponse](#cosmos.authz.v1beta1.QueryAuthorizationsResponse) - - [Service](#cosmos.base.tendermint.v1beta1.Service) + - [Query](#cosmos.authz.v1beta1.Query) -- [cosmos/capability/v1beta1/capability.proto](#cosmos/capability/v1beta1/capability.proto) - - [Capability](#cosmos.capability.v1beta1.Capability) - - [CapabilityOwners](#cosmos.capability.v1beta1.CapabilityOwners) - - [Owner](#cosmos.capability.v1beta1.Owner) +- [cosmos/authz/v1beta1/tx.proto](#cosmos/authz/v1beta1/tx.proto) + - [MsgExecAuthorizedRequest](#cosmos.authz.v1beta1.MsgExecAuthorizedRequest) + - [MsgExecAuthorizedResponse](#cosmos.authz.v1beta1.MsgExecAuthorizedResponse) + - [MsgGrantAuthorizationRequest](#cosmos.authz.v1beta1.MsgGrantAuthorizationRequest) + - [MsgGrantAuthorizationResponse](#cosmos.authz.v1beta1.MsgGrantAuthorizationResponse) + - [MsgRevokeAuthorizationRequest](#cosmos.authz.v1beta1.MsgRevokeAuthorizationRequest) + - [MsgRevokeAuthorizationResponse](#cosmos.authz.v1beta1.MsgRevokeAuthorizationResponse) -- [cosmos/capability/v1beta1/genesis.proto](#cosmos/capability/v1beta1/genesis.proto) - - [GenesisOwners](#cosmos.capability.v1beta1.GenesisOwners) - - [GenesisState](#cosmos.capability.v1beta1.GenesisState) + - [Msg](#cosmos.authz.v1beta1.Msg) -- [cosmos/crisis/v1beta1/genesis.proto](#cosmos/crisis/v1beta1/genesis.proto) - - [GenesisState](#cosmos.crisis.v1beta1.GenesisState) +- [cosmos/authz/v1beta1/genesis.proto](#cosmos/authz/v1beta1/genesis.proto) + - [GenesisState](#cosmos.authz.v1beta1.GenesisState) + - [GrantAuthorization](#cosmos.authz.v1beta1.GrantAuthorization) -- [cosmos/crisis/v1beta1/tx.proto](#cosmos/crisis/v1beta1/tx.proto) - - [MsgVerifyInvariant](#cosmos.crisis.v1beta1.MsgVerifyInvariant) - - [MsgVerifyInvariantResponse](#cosmos.crisis.v1beta1.MsgVerifyInvariantResponse) +- [cosmos/gov/v1beta1/gov.proto](#cosmos/gov/v1beta1/gov.proto) + - [Deposit](#cosmos.gov.v1beta1.Deposit) + - [DepositParams](#cosmos.gov.v1beta1.DepositParams) + - [Proposal](#cosmos.gov.v1beta1.Proposal) + - [TallyParams](#cosmos.gov.v1beta1.TallyParams) + - [TallyResult](#cosmos.gov.v1beta1.TallyResult) + - [TextProposal](#cosmos.gov.v1beta1.TextProposal) + - [Vote](#cosmos.gov.v1beta1.Vote) + - [VotingParams](#cosmos.gov.v1beta1.VotingParams) - - [Msg](#cosmos.crisis.v1beta1.Msg) + - [ProposalStatus](#cosmos.gov.v1beta1.ProposalStatus) + - [VoteOption](#cosmos.gov.v1beta1.VoteOption) -- [cosmos/crypto/ed25519/keys.proto](#cosmos/crypto/ed25519/keys.proto) - - [PrivKey](#cosmos.crypto.ed25519.PrivKey) - - [PubKey](#cosmos.crypto.ed25519.PubKey) +- [cosmos/gov/v1beta1/query.proto](#cosmos/gov/v1beta1/query.proto) + - [QueryDepositRequest](#cosmos.gov.v1beta1.QueryDepositRequest) + - [QueryDepositResponse](#cosmos.gov.v1beta1.QueryDepositResponse) + - [QueryDepositsRequest](#cosmos.gov.v1beta1.QueryDepositsRequest) + - [QueryDepositsResponse](#cosmos.gov.v1beta1.QueryDepositsResponse) + - [QueryParamsRequest](#cosmos.gov.v1beta1.QueryParamsRequest) + - [QueryParamsResponse](#cosmos.gov.v1beta1.QueryParamsResponse) + - [QueryProposalRequest](#cosmos.gov.v1beta1.QueryProposalRequest) + - [QueryProposalResponse](#cosmos.gov.v1beta1.QueryProposalResponse) + - [QueryProposalsRequest](#cosmos.gov.v1beta1.QueryProposalsRequest) + - [QueryProposalsResponse](#cosmos.gov.v1beta1.QueryProposalsResponse) + - [QueryTallyResultRequest](#cosmos.gov.v1beta1.QueryTallyResultRequest) + - [QueryTallyResultResponse](#cosmos.gov.v1beta1.QueryTallyResultResponse) + - [QueryVoteRequest](#cosmos.gov.v1beta1.QueryVoteRequest) + - [QueryVoteResponse](#cosmos.gov.v1beta1.QueryVoteResponse) + - [QueryVotesRequest](#cosmos.gov.v1beta1.QueryVotesRequest) + - [QueryVotesResponse](#cosmos.gov.v1beta1.QueryVotesResponse) -- [cosmos/crypto/multisig/keys.proto](#cosmos/crypto/multisig/keys.proto) - - [LegacyAminoPubKey](#cosmos.crypto.multisig.LegacyAminoPubKey) + - [Query](#cosmos.gov.v1beta1.Query) -- [cosmos/crypto/multisig/v1beta1/multisig.proto](#cosmos/crypto/multisig/v1beta1/multisig.proto) - - [CompactBitArray](#cosmos.crypto.multisig.v1beta1.CompactBitArray) - - [MultiSignature](#cosmos.crypto.multisig.v1beta1.MultiSignature) +- [cosmos/gov/v1beta1/tx.proto](#cosmos/gov/v1beta1/tx.proto) + - [MsgDeposit](#cosmos.gov.v1beta1.MsgDeposit) + - [MsgDepositResponse](#cosmos.gov.v1beta1.MsgDepositResponse) + - [MsgSubmitProposal](#cosmos.gov.v1beta1.MsgSubmitProposal) + - [MsgSubmitProposalResponse](#cosmos.gov.v1beta1.MsgSubmitProposalResponse) + - [MsgVote](#cosmos.gov.v1beta1.MsgVote) + - [MsgVoteResponse](#cosmos.gov.v1beta1.MsgVoteResponse) -- [cosmos/crypto/secp256k1/keys.proto](#cosmos/crypto/secp256k1/keys.proto) - - [PrivKey](#cosmos.crypto.secp256k1.PrivKey) - - [PubKey](#cosmos.crypto.secp256k1.PubKey) + - [Msg](#cosmos.gov.v1beta1.Msg) -- [cosmos/distribution/v1beta1/distribution.proto](#cosmos/distribution/v1beta1/distribution.proto) - - [CommunityPoolSpendProposal](#cosmos.distribution.v1beta1.CommunityPoolSpendProposal) - - [CommunityPoolSpendProposalWithDeposit](#cosmos.distribution.v1beta1.CommunityPoolSpendProposalWithDeposit) - - [DelegationDelegatorReward](#cosmos.distribution.v1beta1.DelegationDelegatorReward) - - [DelegatorStartingInfo](#cosmos.distribution.v1beta1.DelegatorStartingInfo) - - [FeePool](#cosmos.distribution.v1beta1.FeePool) - - [Params](#cosmos.distribution.v1beta1.Params) - - [ValidatorAccumulatedCommission](#cosmos.distribution.v1beta1.ValidatorAccumulatedCommission) - - [ValidatorCurrentRewards](#cosmos.distribution.v1beta1.ValidatorCurrentRewards) - - [ValidatorHistoricalRewards](#cosmos.distribution.v1beta1.ValidatorHistoricalRewards) - - [ValidatorOutstandingRewards](#cosmos.distribution.v1beta1.ValidatorOutstandingRewards) - - [ValidatorSlashEvent](#cosmos.distribution.v1beta1.ValidatorSlashEvent) - - [ValidatorSlashEvents](#cosmos.distribution.v1beta1.ValidatorSlashEvents) +- [cosmos/gov/v1beta1/genesis.proto](#cosmos/gov/v1beta1/genesis.proto) + - [GenesisState](#cosmos.gov.v1beta1.GenesisState) -- [cosmos/distribution/v1beta1/genesis.proto](#cosmos/distribution/v1beta1/genesis.proto) - - [DelegatorStartingInfoRecord](#cosmos.distribution.v1beta1.DelegatorStartingInfoRecord) - - [DelegatorWithdrawInfo](#cosmos.distribution.v1beta1.DelegatorWithdrawInfo) - - [GenesisState](#cosmos.distribution.v1beta1.GenesisState) - - [ValidatorAccumulatedCommissionRecord](#cosmos.distribution.v1beta1.ValidatorAccumulatedCommissionRecord) - - [ValidatorCurrentRewardsRecord](#cosmos.distribution.v1beta1.ValidatorCurrentRewardsRecord) - - [ValidatorHistoricalRewardsRecord](#cosmos.distribution.v1beta1.ValidatorHistoricalRewardsRecord) - - [ValidatorOutstandingRewardsRecord](#cosmos.distribution.v1beta1.ValidatorOutstandingRewardsRecord) - - [ValidatorSlashEventRecord](#cosmos.distribution.v1beta1.ValidatorSlashEventRecord) +- [cosmos/genutil/v1beta1/genesis.proto](#cosmos/genutil/v1beta1/genesis.proto) + - [GenesisState](#cosmos.genutil.v1beta1.GenesisState) - [cosmos/distribution/v1beta1/query.proto](#cosmos/distribution/v1beta1/query.proto) - [QueryCommunityPoolRequest](#cosmos.distribution.v1beta1.QueryCommunityPoolRequest) @@ -244,138 +264,116 @@ - [Msg](#cosmos.distribution.v1beta1.Msg) -- [cosmos/evidence/v1beta1/evidence.proto](#cosmos/evidence/v1beta1/evidence.proto) - - [Equivocation](#cosmos.evidence.v1beta1.Equivocation) - -- [cosmos/evidence/v1beta1/genesis.proto](#cosmos/evidence/v1beta1/genesis.proto) - - [GenesisState](#cosmos.evidence.v1beta1.GenesisState) - -- [cosmos/evidence/v1beta1/query.proto](#cosmos/evidence/v1beta1/query.proto) - - [QueryAllEvidenceRequest](#cosmos.evidence.v1beta1.QueryAllEvidenceRequest) - - [QueryAllEvidenceResponse](#cosmos.evidence.v1beta1.QueryAllEvidenceResponse) - - [QueryEvidenceRequest](#cosmos.evidence.v1beta1.QueryEvidenceRequest) - - [QueryEvidenceResponse](#cosmos.evidence.v1beta1.QueryEvidenceResponse) - - - [Query](#cosmos.evidence.v1beta1.Query) - -- [cosmos/evidence/v1beta1/tx.proto](#cosmos/evidence/v1beta1/tx.proto) - - [MsgSubmitEvidence](#cosmos.evidence.v1beta1.MsgSubmitEvidence) - - [MsgSubmitEvidenceResponse](#cosmos.evidence.v1beta1.MsgSubmitEvidenceResponse) - - - [Msg](#cosmos.evidence.v1beta1.Msg) - -- [cosmos/fee_grant/v1beta1/fee_grant.proto](#cosmos/fee_grant/v1beta1/fee_grant.proto) - - [BasicFeeAllowance](#cosmos.fee_grant.v1beta1.BasicFeeAllowance) - - [Duration](#cosmos.fee_grant.v1beta1.Duration) - - [ExpiresAt](#cosmos.fee_grant.v1beta1.ExpiresAt) - - [FeeAllowanceGrant](#cosmos.fee_grant.v1beta1.FeeAllowanceGrant) - - [PeriodicFeeAllowance](#cosmos.fee_grant.v1beta1.PeriodicFeeAllowance) - -- [cosmos/fee_grant/v1beta1/genesis.proto](#cosmos/fee_grant/v1beta1/genesis.proto) - - [GenesisState](#cosmos.fee_grant.v1beta1.GenesisState) - -- [cosmos/fee_grant/v1beta1/query.proto](#cosmos/fee_grant/v1beta1/query.proto) - - [QueryFeeAllowanceRequest](#cosmos.fee_grant.v1beta1.QueryFeeAllowanceRequest) - - [QueryFeeAllowanceResponse](#cosmos.fee_grant.v1beta1.QueryFeeAllowanceResponse) - - [QueryFeeAllowancesRequest](#cosmos.fee_grant.v1beta1.QueryFeeAllowancesRequest) - - [QueryFeeAllowancesResponse](#cosmos.fee_grant.v1beta1.QueryFeeAllowancesResponse) - - - [Query](#cosmos.fee_grant.v1beta1.Query) - -- [cosmos/fee_grant/v1beta1/tx.proto](#cosmos/fee_grant/v1beta1/tx.proto) - - [MsgGrantFeeAllowance](#cosmos.fee_grant.v1beta1.MsgGrantFeeAllowance) - - [MsgGrantFeeAllowanceResponse](#cosmos.fee_grant.v1beta1.MsgGrantFeeAllowanceResponse) - - [MsgRevokeFeeAllowance](#cosmos.fee_grant.v1beta1.MsgRevokeFeeAllowance) - - [MsgRevokeFeeAllowanceResponse](#cosmos.fee_grant.v1beta1.MsgRevokeFeeAllowanceResponse) - - - [Msg](#cosmos.fee_grant.v1beta1.Msg) +- [cosmos/distribution/v1beta1/genesis.proto](#cosmos/distribution/v1beta1/genesis.proto) + - [DelegatorStartingInfoRecord](#cosmos.distribution.v1beta1.DelegatorStartingInfoRecord) + - [DelegatorWithdrawInfo](#cosmos.distribution.v1beta1.DelegatorWithdrawInfo) + - [GenesisState](#cosmos.distribution.v1beta1.GenesisState) + - [ValidatorAccumulatedCommissionRecord](#cosmos.distribution.v1beta1.ValidatorAccumulatedCommissionRecord) + - [ValidatorCurrentRewardsRecord](#cosmos.distribution.v1beta1.ValidatorCurrentRewardsRecord) + - [ValidatorHistoricalRewardsRecord](#cosmos.distribution.v1beta1.ValidatorHistoricalRewardsRecord) + - [ValidatorOutstandingRewardsRecord](#cosmos.distribution.v1beta1.ValidatorOutstandingRewardsRecord) + - [ValidatorSlashEventRecord](#cosmos.distribution.v1beta1.ValidatorSlashEventRecord) -- [cosmos/genutil/v1beta1/genesis.proto](#cosmos/genutil/v1beta1/genesis.proto) - - [GenesisState](#cosmos.genutil.v1beta1.GenesisState) +- [cosmos/distribution/v1beta1/distribution.proto](#cosmos/distribution/v1beta1/distribution.proto) + - [CommunityPoolSpendProposal](#cosmos.distribution.v1beta1.CommunityPoolSpendProposal) + - [CommunityPoolSpendProposalWithDeposit](#cosmos.distribution.v1beta1.CommunityPoolSpendProposalWithDeposit) + - [DelegationDelegatorReward](#cosmos.distribution.v1beta1.DelegationDelegatorReward) + - [DelegatorStartingInfo](#cosmos.distribution.v1beta1.DelegatorStartingInfo) + - [FeePool](#cosmos.distribution.v1beta1.FeePool) + - [Params](#cosmos.distribution.v1beta1.Params) + - [ValidatorAccumulatedCommission](#cosmos.distribution.v1beta1.ValidatorAccumulatedCommission) + - [ValidatorCurrentRewards](#cosmos.distribution.v1beta1.ValidatorCurrentRewards) + - [ValidatorHistoricalRewards](#cosmos.distribution.v1beta1.ValidatorHistoricalRewards) + - [ValidatorOutstandingRewards](#cosmos.distribution.v1beta1.ValidatorOutstandingRewards) + - [ValidatorSlashEvent](#cosmos.distribution.v1beta1.ValidatorSlashEvent) + - [ValidatorSlashEvents](#cosmos.distribution.v1beta1.ValidatorSlashEvents) -- [cosmos/gov/v1beta1/gov.proto](#cosmos/gov/v1beta1/gov.proto) - - [Deposit](#cosmos.gov.v1beta1.Deposit) - - [DepositParams](#cosmos.gov.v1beta1.DepositParams) - - [Proposal](#cosmos.gov.v1beta1.Proposal) - - [TallyParams](#cosmos.gov.v1beta1.TallyParams) - - [TallyResult](#cosmos.gov.v1beta1.TallyResult) - - [TextProposal](#cosmos.gov.v1beta1.TextProposal) - - [Vote](#cosmos.gov.v1beta1.Vote) - - [VotingParams](#cosmos.gov.v1beta1.VotingParams) +- [cosmos/upgrade/v1beta1/query.proto](#cosmos/upgrade/v1beta1/query.proto) + - [QueryAppliedPlanRequest](#cosmos.upgrade.v1beta1.QueryAppliedPlanRequest) + - [QueryAppliedPlanResponse](#cosmos.upgrade.v1beta1.QueryAppliedPlanResponse) + - [QueryCurrentPlanRequest](#cosmos.upgrade.v1beta1.QueryCurrentPlanRequest) + - [QueryCurrentPlanResponse](#cosmos.upgrade.v1beta1.QueryCurrentPlanResponse) + - [QueryUpgradedConsensusStateRequest](#cosmos.upgrade.v1beta1.QueryUpgradedConsensusStateRequest) + - [QueryUpgradedConsensusStateResponse](#cosmos.upgrade.v1beta1.QueryUpgradedConsensusStateResponse) - - [ProposalStatus](#cosmos.gov.v1beta1.ProposalStatus) - - [VoteOption](#cosmos.gov.v1beta1.VoteOption) + - [Query](#cosmos.upgrade.v1beta1.Query) -- [cosmos/gov/v1beta1/genesis.proto](#cosmos/gov/v1beta1/genesis.proto) - - [GenesisState](#cosmos.gov.v1beta1.GenesisState) +- [cosmos/upgrade/v1beta1/upgrade.proto](#cosmos/upgrade/v1beta1/upgrade.proto) + - [CancelSoftwareUpgradeProposal](#cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal) + - [Plan](#cosmos.upgrade.v1beta1.Plan) + - [SoftwareUpgradeProposal](#cosmos.upgrade.v1beta1.SoftwareUpgradeProposal) -- [cosmos/gov/v1beta1/query.proto](#cosmos/gov/v1beta1/query.proto) - - [QueryDepositRequest](#cosmos.gov.v1beta1.QueryDepositRequest) - - [QueryDepositResponse](#cosmos.gov.v1beta1.QueryDepositResponse) - - [QueryDepositsRequest](#cosmos.gov.v1beta1.QueryDepositsRequest) - - [QueryDepositsResponse](#cosmos.gov.v1beta1.QueryDepositsResponse) - - [QueryParamsRequest](#cosmos.gov.v1beta1.QueryParamsRequest) - - [QueryParamsResponse](#cosmos.gov.v1beta1.QueryParamsResponse) - - [QueryProposalRequest](#cosmos.gov.v1beta1.QueryProposalRequest) - - [QueryProposalResponse](#cosmos.gov.v1beta1.QueryProposalResponse) - - [QueryProposalsRequest](#cosmos.gov.v1beta1.QueryProposalsRequest) - - [QueryProposalsResponse](#cosmos.gov.v1beta1.QueryProposalsResponse) - - [QueryTallyResultRequest](#cosmos.gov.v1beta1.QueryTallyResultRequest) - - [QueryTallyResultResponse](#cosmos.gov.v1beta1.QueryTallyResultResponse) - - [QueryVoteRequest](#cosmos.gov.v1beta1.QueryVoteRequest) - - [QueryVoteResponse](#cosmos.gov.v1beta1.QueryVoteResponse) - - [QueryVotesRequest](#cosmos.gov.v1beta1.QueryVotesRequest) - - [QueryVotesResponse](#cosmos.gov.v1beta1.QueryVotesResponse) +- [cosmos/base/kv/v1beta1/kv.proto](#cosmos/base/kv/v1beta1/kv.proto) + - [Pair](#cosmos.base.kv.v1beta1.Pair) + - [Pairs](#cosmos.base.kv.v1beta1.Pairs) - - [Query](#cosmos.gov.v1beta1.Query) +- [cosmos/base/abci/v1beta1/abci.proto](#cosmos/base/abci/v1beta1/abci.proto) + - [ABCIMessageLog](#cosmos.base.abci.v1beta1.ABCIMessageLog) + - [Attribute](#cosmos.base.abci.v1beta1.Attribute) + - [GasInfo](#cosmos.base.abci.v1beta1.GasInfo) + - [MsgData](#cosmos.base.abci.v1beta1.MsgData) + - [Result](#cosmos.base.abci.v1beta1.Result) + - [SearchTxsResult](#cosmos.base.abci.v1beta1.SearchTxsResult) + - [SimulationResponse](#cosmos.base.abci.v1beta1.SimulationResponse) + - [StringEvent](#cosmos.base.abci.v1beta1.StringEvent) + - [TxMsgData](#cosmos.base.abci.v1beta1.TxMsgData) + - [TxResponse](#cosmos.base.abci.v1beta1.TxResponse) -- [cosmos/gov/v1beta1/tx.proto](#cosmos/gov/v1beta1/tx.proto) - - [MsgDeposit](#cosmos.gov.v1beta1.MsgDeposit) - - [MsgDepositResponse](#cosmos.gov.v1beta1.MsgDepositResponse) - - [MsgSubmitProposal](#cosmos.gov.v1beta1.MsgSubmitProposal) - - [MsgSubmitProposalResponse](#cosmos.gov.v1beta1.MsgSubmitProposalResponse) - - [MsgVote](#cosmos.gov.v1beta1.MsgVote) - - [MsgVoteResponse](#cosmos.gov.v1beta1.MsgVoteResponse) +- [cosmos/base/query/v1beta1/pagination.proto](#cosmos/base/query/v1beta1/pagination.proto) + - [PageRequest](#cosmos.base.query.v1beta1.PageRequest) + - [PageResponse](#cosmos.base.query.v1beta1.PageResponse) - - [Msg](#cosmos.gov.v1beta1.Msg) +- [cosmos/base/store/v1beta1/snapshot.proto](#cosmos/base/store/v1beta1/snapshot.proto) + - [SnapshotIAVLItem](#cosmos.base.store.v1beta1.SnapshotIAVLItem) + - [SnapshotItem](#cosmos.base.store.v1beta1.SnapshotItem) + - [SnapshotStoreItem](#cosmos.base.store.v1beta1.SnapshotStoreItem) -- [cosmos/mint/v1beta1/mint.proto](#cosmos/mint/v1beta1/mint.proto) - - [Minter](#cosmos.mint.v1beta1.Minter) - - [Params](#cosmos.mint.v1beta1.Params) +- [cosmos/base/store/v1beta1/commit_info.proto](#cosmos/base/store/v1beta1/commit_info.proto) + - [CommitID](#cosmos.base.store.v1beta1.CommitID) + - [CommitInfo](#cosmos.base.store.v1beta1.CommitInfo) + - [StoreInfo](#cosmos.base.store.v1beta1.StoreInfo) -- [cosmos/mint/v1beta1/genesis.proto](#cosmos/mint/v1beta1/genesis.proto) - - [GenesisState](#cosmos.mint.v1beta1.GenesisState) +- [cosmos/base/v1beta1/coin.proto](#cosmos/base/v1beta1/coin.proto) + - [Coin](#cosmos.base.v1beta1.Coin) + - [DecCoin](#cosmos.base.v1beta1.DecCoin) + - [DecProto](#cosmos.base.v1beta1.DecProto) + - [IntProto](#cosmos.base.v1beta1.IntProto) -- [cosmos/mint/v1beta1/query.proto](#cosmos/mint/v1beta1/query.proto) - - [QueryAnnualProvisionsRequest](#cosmos.mint.v1beta1.QueryAnnualProvisionsRequest) - - [QueryAnnualProvisionsResponse](#cosmos.mint.v1beta1.QueryAnnualProvisionsResponse) - - [QueryInflationRequest](#cosmos.mint.v1beta1.QueryInflationRequest) - - [QueryInflationResponse](#cosmos.mint.v1beta1.QueryInflationResponse) - - [QueryParamsRequest](#cosmos.mint.v1beta1.QueryParamsRequest) - - [QueryParamsResponse](#cosmos.mint.v1beta1.QueryParamsResponse) +- [cosmos/base/tendermint/v1beta1/query.proto](#cosmos/base/tendermint/v1beta1/query.proto) + - [GetBlockByHeightRequest](#cosmos.base.tendermint.v1beta1.GetBlockByHeightRequest) + - [GetBlockByHeightResponse](#cosmos.base.tendermint.v1beta1.GetBlockByHeightResponse) + - [GetLatestBlockRequest](#cosmos.base.tendermint.v1beta1.GetLatestBlockRequest) + - [GetLatestBlockResponse](#cosmos.base.tendermint.v1beta1.GetLatestBlockResponse) + - [GetLatestValidatorSetRequest](#cosmos.base.tendermint.v1beta1.GetLatestValidatorSetRequest) + - [GetLatestValidatorSetResponse](#cosmos.base.tendermint.v1beta1.GetLatestValidatorSetResponse) + - [GetNodeInfoRequest](#cosmos.base.tendermint.v1beta1.GetNodeInfoRequest) + - [GetNodeInfoResponse](#cosmos.base.tendermint.v1beta1.GetNodeInfoResponse) + - [GetSyncingRequest](#cosmos.base.tendermint.v1beta1.GetSyncingRequest) + - [GetSyncingResponse](#cosmos.base.tendermint.v1beta1.GetSyncingResponse) + - [GetValidatorSetByHeightRequest](#cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightRequest) + - [GetValidatorSetByHeightResponse](#cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightResponse) + - [Module](#cosmos.base.tendermint.v1beta1.Module) + - [Validator](#cosmos.base.tendermint.v1beta1.Validator) + - [VersionInfo](#cosmos.base.tendermint.v1beta1.VersionInfo) - - [Query](#cosmos.mint.v1beta1.Query) + - [Service](#cosmos.base.tendermint.v1beta1.Service) -- [cosmos/params/v1beta1/params.proto](#cosmos/params/v1beta1/params.proto) - - [ParamChange](#cosmos.params.v1beta1.ParamChange) - - [ParameterChangeProposal](#cosmos.params.v1beta1.ParameterChangeProposal) +- [cosmos/base/snapshots/v1beta1/snapshot.proto](#cosmos/base/snapshots/v1beta1/snapshot.proto) + - [Metadata](#cosmos.base.snapshots.v1beta1.Metadata) + - [Snapshot](#cosmos.base.snapshots.v1beta1.Snapshot) -- [cosmos/params/v1beta1/query.proto](#cosmos/params/v1beta1/query.proto) - - [QueryParamsRequest](#cosmos.params.v1beta1.QueryParamsRequest) - - [QueryParamsResponse](#cosmos.params.v1beta1.QueryParamsResponse) +- [cosmos/base/reflection/v1beta1/reflection.proto](#cosmos/base/reflection/v1beta1/reflection.proto) + - [ListAllInterfacesRequest](#cosmos.base.reflection.v1beta1.ListAllInterfacesRequest) + - [ListAllInterfacesResponse](#cosmos.base.reflection.v1beta1.ListAllInterfacesResponse) + - [ListImplementationsRequest](#cosmos.base.reflection.v1beta1.ListImplementationsRequest) + - [ListImplementationsResponse](#cosmos.base.reflection.v1beta1.ListImplementationsResponse) - - [Query](#cosmos.params.v1beta1.Query) + - [ReflectionService](#cosmos.base.reflection.v1beta1.ReflectionService) - [cosmos/slashing/v1beta1/slashing.proto](#cosmos/slashing/v1beta1/slashing.proto) - [Params](#cosmos.slashing.v1beta1.Params) - [ValidatorSigningInfo](#cosmos.slashing.v1beta1.ValidatorSigningInfo) -- [cosmos/slashing/v1beta1/genesis.proto](#cosmos/slashing/v1beta1/genesis.proto) - - [GenesisState](#cosmos.slashing.v1beta1.GenesisState) - - [MissedBlock](#cosmos.slashing.v1beta1.MissedBlock) - - [SigningInfo](#cosmos.slashing.v1beta1.SigningInfo) - - [ValidatorMissedBlocks](#cosmos.slashing.v1beta1.ValidatorMissedBlocks) - - [cosmos/slashing/v1beta1/query.proto](#cosmos/slashing/v1beta1/query.proto) - [QueryParamsRequest](#cosmos.slashing.v1beta1.QueryParamsRequest) - [QueryParamsResponse](#cosmos.slashing.v1beta1.QueryParamsResponse) @@ -392,33 +390,47 @@ - [Msg](#cosmos.slashing.v1beta1.Msg) -- [cosmos/staking/v1beta1/staking.proto](#cosmos/staking/v1beta1/staking.proto) - - [Commission](#cosmos.staking.v1beta1.Commission) - - [CommissionRates](#cosmos.staking.v1beta1.CommissionRates) - - [DVPair](#cosmos.staking.v1beta1.DVPair) - - [DVPairs](#cosmos.staking.v1beta1.DVPairs) - - [DVVTriplet](#cosmos.staking.v1beta1.DVVTriplet) - - [DVVTriplets](#cosmos.staking.v1beta1.DVVTriplets) - - [Delegation](#cosmos.staking.v1beta1.Delegation) - - [DelegationResponse](#cosmos.staking.v1beta1.DelegationResponse) - - [Description](#cosmos.staking.v1beta1.Description) - - [HistoricalInfo](#cosmos.staking.v1beta1.HistoricalInfo) - - [Params](#cosmos.staking.v1beta1.Params) - - [Pool](#cosmos.staking.v1beta1.Pool) - - [Redelegation](#cosmos.staking.v1beta1.Redelegation) - - [RedelegationEntry](#cosmos.staking.v1beta1.RedelegationEntry) - - [RedelegationEntryResponse](#cosmos.staking.v1beta1.RedelegationEntryResponse) - - [RedelegationResponse](#cosmos.staking.v1beta1.RedelegationResponse) - - [UnbondingDelegation](#cosmos.staking.v1beta1.UnbondingDelegation) - - [UnbondingDelegationEntry](#cosmos.staking.v1beta1.UnbondingDelegationEntry) - - [ValAddresses](#cosmos.staking.v1beta1.ValAddresses) - - [Validator](#cosmos.staking.v1beta1.Validator) +- [cosmos/slashing/v1beta1/genesis.proto](#cosmos/slashing/v1beta1/genesis.proto) + - [GenesisState](#cosmos.slashing.v1beta1.GenesisState) + - [MissedBlock](#cosmos.slashing.v1beta1.MissedBlock) + - [SigningInfo](#cosmos.slashing.v1beta1.SigningInfo) + - [ValidatorMissedBlocks](#cosmos.slashing.v1beta1.ValidatorMissedBlocks) - - [BondStatus](#cosmos.staking.v1beta1.BondStatus) +- [cosmos/evidence/v1beta1/evidence.proto](#cosmos/evidence/v1beta1/evidence.proto) + - [Equivocation](#cosmos.evidence.v1beta1.Equivocation) -- [cosmos/staking/v1beta1/genesis.proto](#cosmos/staking/v1beta1/genesis.proto) - - [GenesisState](#cosmos.staking.v1beta1.GenesisState) - - [LastValidatorPower](#cosmos.staking.v1beta1.LastValidatorPower) +- [cosmos/evidence/v1beta1/query.proto](#cosmos/evidence/v1beta1/query.proto) + - [QueryAllEvidenceRequest](#cosmos.evidence.v1beta1.QueryAllEvidenceRequest) + - [QueryAllEvidenceResponse](#cosmos.evidence.v1beta1.QueryAllEvidenceResponse) + - [QueryEvidenceRequest](#cosmos.evidence.v1beta1.QueryEvidenceRequest) + - [QueryEvidenceResponse](#cosmos.evidence.v1beta1.QueryEvidenceResponse) + + - [Query](#cosmos.evidence.v1beta1.Query) + +- [cosmos/evidence/v1beta1/tx.proto](#cosmos/evidence/v1beta1/tx.proto) + - [MsgSubmitEvidence](#cosmos.evidence.v1beta1.MsgSubmitEvidence) + - [MsgSubmitEvidenceResponse](#cosmos.evidence.v1beta1.MsgSubmitEvidenceResponse) + + - [Msg](#cosmos.evidence.v1beta1.Msg) + +- [cosmos/evidence/v1beta1/genesis.proto](#cosmos/evidence/v1beta1/genesis.proto) + - [GenesisState](#cosmos.evidence.v1beta1.GenesisState) + +- [cosmos/auth/v1beta1/auth.proto](#cosmos/auth/v1beta1/auth.proto) + - [BaseAccount](#cosmos.auth.v1beta1.BaseAccount) + - [ModuleAccount](#cosmos.auth.v1beta1.ModuleAccount) + - [Params](#cosmos.auth.v1beta1.Params) + +- [cosmos/auth/v1beta1/query.proto](#cosmos/auth/v1beta1/query.proto) + - [QueryAccountRequest](#cosmos.auth.v1beta1.QueryAccountRequest) + - [QueryAccountResponse](#cosmos.auth.v1beta1.QueryAccountResponse) + - [QueryParamsRequest](#cosmos.auth.v1beta1.QueryParamsRequest) + - [QueryParamsResponse](#cosmos.auth.v1beta1.QueryParamsResponse) + + - [Query](#cosmos.auth.v1beta1.Query) + +- [cosmos/auth/v1beta1/genesis.proto](#cosmos/auth/v1beta1/genesis.proto) + - [GenesisState](#cosmos.auth.v1beta1.GenesisState) - [cosmos/staking/v1beta1/query.proto](#cosmos/staking/v1beta1/query.proto) - [QueryDelegationRequest](#cosmos.staking.v1beta1.QueryDelegationRequest) @@ -448,73 +460,51 @@ - [QueryValidatorUnbondingDelegationsRequest](#cosmos.staking.v1beta1.QueryValidatorUnbondingDelegationsRequest) - [QueryValidatorUnbondingDelegationsResponse](#cosmos.staking.v1beta1.QueryValidatorUnbondingDelegationsResponse) - [QueryValidatorsRequest](#cosmos.staking.v1beta1.QueryValidatorsRequest) - - [QueryValidatorsResponse](#cosmos.staking.v1beta1.QueryValidatorsResponse) - - - [Query](#cosmos.staking.v1beta1.Query) - -- [cosmos/staking/v1beta1/tx.proto](#cosmos/staking/v1beta1/tx.proto) - - [MsgBeginRedelegate](#cosmos.staking.v1beta1.MsgBeginRedelegate) - - [MsgBeginRedelegateResponse](#cosmos.staking.v1beta1.MsgBeginRedelegateResponse) - - [MsgCreateValidator](#cosmos.staking.v1beta1.MsgCreateValidator) - - [MsgCreateValidatorResponse](#cosmos.staking.v1beta1.MsgCreateValidatorResponse) - - [MsgDelegate](#cosmos.staking.v1beta1.MsgDelegate) - - [MsgDelegateResponse](#cosmos.staking.v1beta1.MsgDelegateResponse) - - [MsgEditValidator](#cosmos.staking.v1beta1.MsgEditValidator) - - [MsgEditValidatorResponse](#cosmos.staking.v1beta1.MsgEditValidatorResponse) - - [MsgUndelegate](#cosmos.staking.v1beta1.MsgUndelegate) - - [MsgUndelegateResponse](#cosmos.staking.v1beta1.MsgUndelegateResponse) - - - [Msg](#cosmos.staking.v1beta1.Msg) - -- [cosmos/tx/signing/v1beta1/signing.proto](#cosmos/tx/signing/v1beta1/signing.proto) - - [SignatureDescriptor](#cosmos.tx.signing.v1beta1.SignatureDescriptor) - - [SignatureDescriptor.Data](#cosmos.tx.signing.v1beta1.SignatureDescriptor.Data) - - [SignatureDescriptor.Data.Multi](#cosmos.tx.signing.v1beta1.SignatureDescriptor.Data.Multi) - - [SignatureDescriptor.Data.Single](#cosmos.tx.signing.v1beta1.SignatureDescriptor.Data.Single) - - [SignatureDescriptors](#cosmos.tx.signing.v1beta1.SignatureDescriptors) - - - [SignMode](#cosmos.tx.signing.v1beta1.SignMode) - -- [cosmos/tx/v1beta1/tx.proto](#cosmos/tx/v1beta1/tx.proto) - - [AuthInfo](#cosmos.tx.v1beta1.AuthInfo) - - [Fee](#cosmos.tx.v1beta1.Fee) - - [ModeInfo](#cosmos.tx.v1beta1.ModeInfo) - - [ModeInfo.Multi](#cosmos.tx.v1beta1.ModeInfo.Multi) - - [ModeInfo.Single](#cosmos.tx.v1beta1.ModeInfo.Single) - - [SignDoc](#cosmos.tx.v1beta1.SignDoc) - - [SignerInfo](#cosmos.tx.v1beta1.SignerInfo) - - [Tx](#cosmos.tx.v1beta1.Tx) - - [TxBody](#cosmos.tx.v1beta1.TxBody) - - [TxRaw](#cosmos.tx.v1beta1.TxRaw) - -- [cosmos/tx/v1beta1/service.proto](#cosmos/tx/v1beta1/service.proto) - - [BroadcastTxRequest](#cosmos.tx.v1beta1.BroadcastTxRequest) - - [BroadcastTxResponse](#cosmos.tx.v1beta1.BroadcastTxResponse) - - [GetTxRequest](#cosmos.tx.v1beta1.GetTxRequest) - - [GetTxResponse](#cosmos.tx.v1beta1.GetTxResponse) - - [GetTxsEventRequest](#cosmos.tx.v1beta1.GetTxsEventRequest) - - [GetTxsEventResponse](#cosmos.tx.v1beta1.GetTxsEventResponse) - - [SimulateRequest](#cosmos.tx.v1beta1.SimulateRequest) - - [SimulateResponse](#cosmos.tx.v1beta1.SimulateResponse) + - [QueryValidatorsResponse](#cosmos.staking.v1beta1.QueryValidatorsResponse) - - [BroadcastMode](#cosmos.tx.v1beta1.BroadcastMode) + - [Query](#cosmos.staking.v1beta1.Query) - - [Service](#cosmos.tx.v1beta1.Service) +- [cosmos/staking/v1beta1/tx.proto](#cosmos/staking/v1beta1/tx.proto) + - [MsgBeginRedelegate](#cosmos.staking.v1beta1.MsgBeginRedelegate) + - [MsgBeginRedelegateResponse](#cosmos.staking.v1beta1.MsgBeginRedelegateResponse) + - [MsgCreateValidator](#cosmos.staking.v1beta1.MsgCreateValidator) + - [MsgCreateValidatorResponse](#cosmos.staking.v1beta1.MsgCreateValidatorResponse) + - [MsgDelegate](#cosmos.staking.v1beta1.MsgDelegate) + - [MsgDelegateResponse](#cosmos.staking.v1beta1.MsgDelegateResponse) + - [MsgEditValidator](#cosmos.staking.v1beta1.MsgEditValidator) + - [MsgEditValidatorResponse](#cosmos.staking.v1beta1.MsgEditValidatorResponse) + - [MsgUndelegate](#cosmos.staking.v1beta1.MsgUndelegate) + - [MsgUndelegateResponse](#cosmos.staking.v1beta1.MsgUndelegateResponse) -- [cosmos/upgrade/v1beta1/upgrade.proto](#cosmos/upgrade/v1beta1/upgrade.proto) - - [CancelSoftwareUpgradeProposal](#cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal) - - [Plan](#cosmos.upgrade.v1beta1.Plan) - - [SoftwareUpgradeProposal](#cosmos.upgrade.v1beta1.SoftwareUpgradeProposal) + - [Msg](#cosmos.staking.v1beta1.Msg) -- [cosmos/upgrade/v1beta1/query.proto](#cosmos/upgrade/v1beta1/query.proto) - - [QueryAppliedPlanRequest](#cosmos.upgrade.v1beta1.QueryAppliedPlanRequest) - - [QueryAppliedPlanResponse](#cosmos.upgrade.v1beta1.QueryAppliedPlanResponse) - - [QueryCurrentPlanRequest](#cosmos.upgrade.v1beta1.QueryCurrentPlanRequest) - - [QueryCurrentPlanResponse](#cosmos.upgrade.v1beta1.QueryCurrentPlanResponse) - - [QueryUpgradedConsensusStateRequest](#cosmos.upgrade.v1beta1.QueryUpgradedConsensusStateRequest) - - [QueryUpgradedConsensusStateResponse](#cosmos.upgrade.v1beta1.QueryUpgradedConsensusStateResponse) +- [cosmos/staking/v1beta1/genesis.proto](#cosmos/staking/v1beta1/genesis.proto) + - [GenesisState](#cosmos.staking.v1beta1.GenesisState) + - [LastValidatorPower](#cosmos.staking.v1beta1.LastValidatorPower) - - [Query](#cosmos.upgrade.v1beta1.Query) +- [cosmos/staking/v1beta1/staking.proto](#cosmos/staking/v1beta1/staking.proto) + - [Commission](#cosmos.staking.v1beta1.Commission) + - [CommissionRates](#cosmos.staking.v1beta1.CommissionRates) + - [DVPair](#cosmos.staking.v1beta1.DVPair) + - [DVPairs](#cosmos.staking.v1beta1.DVPairs) + - [DVVTriplet](#cosmos.staking.v1beta1.DVVTriplet) + - [DVVTriplets](#cosmos.staking.v1beta1.DVVTriplets) + - [Delegation](#cosmos.staking.v1beta1.Delegation) + - [DelegationResponse](#cosmos.staking.v1beta1.DelegationResponse) + - [Description](#cosmos.staking.v1beta1.Description) + - [HistoricalInfo](#cosmos.staking.v1beta1.HistoricalInfo) + - [Params](#cosmos.staking.v1beta1.Params) + - [Pool](#cosmos.staking.v1beta1.Pool) + - [Redelegation](#cosmos.staking.v1beta1.Redelegation) + - [RedelegationEntry](#cosmos.staking.v1beta1.RedelegationEntry) + - [RedelegationEntryResponse](#cosmos.staking.v1beta1.RedelegationEntryResponse) + - [RedelegationResponse](#cosmos.staking.v1beta1.RedelegationResponse) + - [UnbondingDelegation](#cosmos.staking.v1beta1.UnbondingDelegation) + - [UnbondingDelegationEntry](#cosmos.staking.v1beta1.UnbondingDelegationEntry) + - [ValAddresses](#cosmos.staking.v1beta1.ValAddresses) + - [Validator](#cosmos.staking.v1beta1.Validator) + + - [BondStatus](#cosmos.staking.v1beta1.BondStatus) - [cosmos/vesting/v1beta1/tx.proto](#cosmos/vesting/v1beta1/tx.proto) - [MsgCreateVestingAccount](#cosmos.vesting.v1beta1.MsgCreateVestingAccount) @@ -529,13 +519,15 @@ - [Period](#cosmos.vesting.v1beta1.Period) - [PeriodicVestingAccount](#cosmos.vesting.v1beta1.PeriodicVestingAccount) -- [ibc/applications/transfer/v1/transfer.proto](#ibc/applications/transfer/v1/transfer.proto) - - [DenomTrace](#ibc.applications.transfer.v1.DenomTrace) - - [FungibleTokenPacketData](#ibc.applications.transfer.v1.FungibleTokenPacketData) - - [Params](#ibc.applications.transfer.v1.Params) +- [cosmos/params/v1beta1/query.proto](#cosmos/params/v1beta1/query.proto) + - [QueryParamsRequest](#cosmos.params.v1beta1.QueryParamsRequest) + - [QueryParamsResponse](#cosmos.params.v1beta1.QueryParamsResponse) -- [ibc/applications/transfer/v1/genesis.proto](#ibc/applications/transfer/v1/genesis.proto) - - [GenesisState](#ibc.applications.transfer.v1.GenesisState) + - [Query](#cosmos.params.v1beta1.Query) + +- [cosmos/params/v1beta1/params.proto](#cosmos/params/v1beta1/params.proto) + - [ParamChange](#cosmos.params.v1beta1.ParamChange) + - [ParameterChangeProposal](#cosmos.params.v1beta1.ParameterChangeProposal) - [ibc/applications/transfer/v1/query.proto](#ibc/applications/transfer/v1/query.proto) - [QueryDenomTraceRequest](#ibc.applications.transfer.v1.QueryDenomTraceRequest) @@ -547,6 +539,20 @@ - [Query](#ibc.applications.transfer.v1.Query) +- [ibc/applications/transfer/v1/tx.proto](#ibc/applications/transfer/v1/tx.proto) + - [MsgTransfer](#ibc.applications.transfer.v1.MsgTransfer) + - [MsgTransferResponse](#ibc.applications.transfer.v1.MsgTransferResponse) + + - [Msg](#ibc.applications.transfer.v1.Msg) + +- [ibc/applications/transfer/v1/transfer.proto](#ibc/applications/transfer/v1/transfer.proto) + - [DenomTrace](#ibc.applications.transfer.v1.DenomTrace) + - [FungibleTokenPacketData](#ibc.applications.transfer.v1.FungibleTokenPacketData) + - [Params](#ibc.applications.transfer.v1.Params) + +- [ibc/applications/transfer/v1/genesis.proto](#ibc/applications/transfer/v1/genesis.proto) + - [GenesisState](#ibc.applications.transfer.v1.GenesisState) + - [ibc/core/client/v1/client.proto](#ibc/core/client/v1/client.proto) - [ClientConsensusStates](#ibc.core.client.v1.ClientConsensusStates) - [ClientUpdateProposal](#ibc.core.client.v1.ClientUpdateProposal) @@ -555,11 +561,36 @@ - [IdentifiedClientState](#ibc.core.client.v1.IdentifiedClientState) - [Params](#ibc.core.client.v1.Params) -- [ibc/applications/transfer/v1/tx.proto](#ibc/applications/transfer/v1/tx.proto) - - [MsgTransfer](#ibc.applications.transfer.v1.MsgTransfer) - - [MsgTransferResponse](#ibc.applications.transfer.v1.MsgTransferResponse) +- [ibc/core/client/v1/query.proto](#ibc/core/client/v1/query.proto) + - [QueryClientParamsRequest](#ibc.core.client.v1.QueryClientParamsRequest) + - [QueryClientParamsResponse](#ibc.core.client.v1.QueryClientParamsResponse) + - [QueryClientStateRequest](#ibc.core.client.v1.QueryClientStateRequest) + - [QueryClientStateResponse](#ibc.core.client.v1.QueryClientStateResponse) + - [QueryClientStatesRequest](#ibc.core.client.v1.QueryClientStatesRequest) + - [QueryClientStatesResponse](#ibc.core.client.v1.QueryClientStatesResponse) + - [QueryConsensusStateRequest](#ibc.core.client.v1.QueryConsensusStateRequest) + - [QueryConsensusStateResponse](#ibc.core.client.v1.QueryConsensusStateResponse) + - [QueryConsensusStatesRequest](#ibc.core.client.v1.QueryConsensusStatesRequest) + - [QueryConsensusStatesResponse](#ibc.core.client.v1.QueryConsensusStatesResponse) - - [Msg](#ibc.applications.transfer.v1.Msg) + - [Query](#ibc.core.client.v1.Query) + +- [ibc/core/client/v1/tx.proto](#ibc/core/client/v1/tx.proto) + - [MsgCreateClient](#ibc.core.client.v1.MsgCreateClient) + - [MsgCreateClientResponse](#ibc.core.client.v1.MsgCreateClientResponse) + - [MsgSubmitMisbehaviour](#ibc.core.client.v1.MsgSubmitMisbehaviour) + - [MsgSubmitMisbehaviourResponse](#ibc.core.client.v1.MsgSubmitMisbehaviourResponse) + - [MsgUpdateClient](#ibc.core.client.v1.MsgUpdateClient) + - [MsgUpdateClientResponse](#ibc.core.client.v1.MsgUpdateClientResponse) + - [MsgUpgradeClient](#ibc.core.client.v1.MsgUpgradeClient) + - [MsgUpgradeClientResponse](#ibc.core.client.v1.MsgUpgradeClientResponse) + + - [Msg](#ibc.core.client.v1.Msg) + +- [ibc/core/client/v1/genesis.proto](#ibc/core/client/v1/genesis.proto) + - [GenesisMetadata](#ibc.core.client.v1.GenesisMetadata) + - [GenesisState](#ibc.core.client.v1.GenesisState) + - [IdentifiedGenesisMetadata](#ibc.core.client.v1.IdentifiedGenesisMetadata) - [ibc/core/channel/v1/channel.proto](#ibc/core/channel/v1/channel.proto) - [Acknowledgement](#ibc.core.channel.v1.Acknowledgement) @@ -572,10 +603,6 @@ - [Order](#ibc.core.channel.v1.Order) - [State](#ibc.core.channel.v1.State) -- [ibc/core/channel/v1/genesis.proto](#ibc/core/channel/v1/genesis.proto) - - [GenesisState](#ibc.core.channel.v1.GenesisState) - - [PacketSequence](#ibc.core.channel.v1.PacketSequence) - - [ibc/core/channel/v1/query.proto](#ibc/core/channel/v1/query.proto) - [QueryChannelClientStateRequest](#ibc.core.channel.v1.QueryChannelClientStateRequest) - [QueryChannelClientStateResponse](#ibc.core.channel.v1.QueryChannelClientStateResponse) @@ -630,36 +657,9 @@ - [Msg](#ibc.core.channel.v1.Msg) -- [ibc/core/client/v1/genesis.proto](#ibc/core/client/v1/genesis.proto) - - [GenesisMetadata](#ibc.core.client.v1.GenesisMetadata) - - [GenesisState](#ibc.core.client.v1.GenesisState) - - [IdentifiedGenesisMetadata](#ibc.core.client.v1.IdentifiedGenesisMetadata) - -- [ibc/core/client/v1/query.proto](#ibc/core/client/v1/query.proto) - - [QueryClientParamsRequest](#ibc.core.client.v1.QueryClientParamsRequest) - - [QueryClientParamsResponse](#ibc.core.client.v1.QueryClientParamsResponse) - - [QueryClientStateRequest](#ibc.core.client.v1.QueryClientStateRequest) - - [QueryClientStateResponse](#ibc.core.client.v1.QueryClientStateResponse) - - [QueryClientStatesRequest](#ibc.core.client.v1.QueryClientStatesRequest) - - [QueryClientStatesResponse](#ibc.core.client.v1.QueryClientStatesResponse) - - [QueryConsensusStateRequest](#ibc.core.client.v1.QueryConsensusStateRequest) - - [QueryConsensusStateResponse](#ibc.core.client.v1.QueryConsensusStateResponse) - - [QueryConsensusStatesRequest](#ibc.core.client.v1.QueryConsensusStatesRequest) - - [QueryConsensusStatesResponse](#ibc.core.client.v1.QueryConsensusStatesResponse) - - - [Query](#ibc.core.client.v1.Query) - -- [ibc/core/client/v1/tx.proto](#ibc/core/client/v1/tx.proto) - - [MsgCreateClient](#ibc.core.client.v1.MsgCreateClient) - - [MsgCreateClientResponse](#ibc.core.client.v1.MsgCreateClientResponse) - - [MsgSubmitMisbehaviour](#ibc.core.client.v1.MsgSubmitMisbehaviour) - - [MsgSubmitMisbehaviourResponse](#ibc.core.client.v1.MsgSubmitMisbehaviourResponse) - - [MsgUpdateClient](#ibc.core.client.v1.MsgUpdateClient) - - [MsgUpdateClientResponse](#ibc.core.client.v1.MsgUpdateClientResponse) - - [MsgUpgradeClient](#ibc.core.client.v1.MsgUpgradeClient) - - [MsgUpgradeClientResponse](#ibc.core.client.v1.MsgUpgradeClientResponse) - - - [Msg](#ibc.core.client.v1.Msg) +- [ibc/core/channel/v1/genesis.proto](#ibc/core/channel/v1/genesis.proto) + - [GenesisState](#ibc.core.channel.v1.GenesisState) + - [PacketSequence](#ibc.core.channel.v1.PacketSequence) - [ibc/core/commitment/v1/commitment.proto](#ibc/core/commitment/v1/commitment.proto) - [MerklePath](#ibc.core.commitment.v1.MerklePath) @@ -677,9 +677,6 @@ - [State](#ibc.core.connection.v1.State) -- [ibc/core/connection/v1/genesis.proto](#ibc/core/connection/v1/genesis.proto) - - [GenesisState](#ibc.core.connection.v1.GenesisState) - - [ibc/core/connection/v1/query.proto](#ibc/core/connection/v1/query.proto) - [QueryClientConnectionsRequest](#ibc.core.connection.v1.QueryClientConnectionsRequest) - [QueryClientConnectionsResponse](#ibc.core.connection.v1.QueryClientConnectionsResponse) @@ -706,12 +703,22 @@ - [Msg](#ibc.core.connection.v1.Msg) +- [ibc/core/connection/v1/genesis.proto](#ibc/core/connection/v1/genesis.proto) + - [GenesisState](#ibc.core.connection.v1.GenesisState) + - [ibc/core/types/v1/genesis.proto](#ibc/core/types/v1/genesis.proto) - [GenesisState](#ibc.core.types.v1.GenesisState) - [ibc/lightclients/localhost/v1/localhost.proto](#ibc/lightclients/localhost/v1/localhost.proto) - [ClientState](#ibc.lightclients.localhost.v1.ClientState) +- [ibc/lightclients/tendermint/v1/tendermint.proto](#ibc/lightclients/tendermint/v1/tendermint.proto) + - [ClientState](#ibc.lightclients.tendermint.v1.ClientState) + - [ConsensusState](#ibc.lightclients.tendermint.v1.ConsensusState) + - [Fraction](#ibc.lightclients.tendermint.v1.Fraction) + - [Header](#ibc.lightclients.tendermint.v1.Header) + - [Misbehaviour](#ibc.lightclients.tendermint.v1.Misbehaviour) + - [ibc/lightclients/solomachine/v1/solomachine.proto](#ibc/lightclients/solomachine/v1/solomachine.proto) - [ChannelStateData](#ibc.lightclients.solomachine.v1.ChannelStateData) - [ClientState](#ibc.lightclients.solomachine.v1.ClientState) @@ -732,106 +739,190 @@ - [DataType](#ibc.lightclients.solomachine.v1.DataType) -- [ibc/lightclients/tendermint/v1/tendermint.proto](#ibc/lightclients/tendermint/v1/tendermint.proto) - - [ClientState](#ibc.lightclients.tendermint.v1.ClientState) - - [ConsensusState](#ibc.lightclients.tendermint.v1.ConsensusState) - - [Fraction](#ibc.lightclients.tendermint.v1.Fraction) - - [Header](#ibc.lightclients.tendermint.v1.Header) - - [Misbehaviour](#ibc.lightclients.tendermint.v1.Misbehaviour) - - [Scalar Value Types](#scalar-value-types) - -

Top

+ +

Top

+ +## cosmos/tx/v1beta1/tx.proto + + + + + +### AuthInfo +AuthInfo describes the fee and signer modes that are used to sign a +transaction. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `signer_infos` | [SignerInfo](#cosmos.tx.v1beta1.SignerInfo) | repeated | signer_infos defines the signing modes for the required signers. The number and order of elements must match the required signers from TxBody's messages. The first element is the primary signer and the one which pays the fee. | +| `fee` | [Fee](#cosmos.tx.v1beta1.Fee) | | Fee is the fee and gas limit for the transaction. The first signer is the primary signer and the one which pays the fee. The fee can be calculated based on the cost of evaluating the body and doing signature verification of the signers. This can be estimated via simulation. | + + + + + + + + +### Fee +Fee includes the amount of coins paid in fees and the maximum +gas to be used by the transaction. The ratio yields an effective "gasprice", +which must be above some miminum to be accepted into the mempool. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | amount is the amount of coins to be paid as a fee | +| `gas_limit` | [uint64](#uint64) | | gas_limit is the maximum gas that can be used in transaction processing before an out of gas error occurs | +| `payer` | [string](#string) | | if unset, the first signer is responsible for paying the fees. If set, the specified account must pay the fees. the payer must be a tx signer (and thus have signed this field in AuthInfo). setting this field does *not* change the ordering of required signers for the transaction. | +| `granter` | [string](#string) | | if set, the fee payer (either the first signer or the value of the payer field) requests that a fee grant be used to pay fees instead of the fee payer's own balance. If an appropriate fee grant does not exist or the chain does not support fee grants, this will fail | + + + + + + + + +### ModeInfo +ModeInfo describes the signing mode of a single or nested multisig signer. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `single` | [ModeInfo.Single](#cosmos.tx.v1beta1.ModeInfo.Single) | | single represents a single signer | +| `multi` | [ModeInfo.Multi](#cosmos.tx.v1beta1.ModeInfo.Multi) | | multi represents a nested multisig signer | + + + + + + + + +### ModeInfo.Multi +Multi is the mode info for a multisig public key + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `bitarray` | [cosmos.crypto.multisig.v1beta1.CompactBitArray](#cosmos.crypto.multisig.v1beta1.CompactBitArray) | | bitarray specifies which keys within the multisig are signing | +| `mode_infos` | [ModeInfo](#cosmos.tx.v1beta1.ModeInfo) | repeated | mode_infos is the corresponding modes of the signers of the multisig which could include nested multisig public keys | + + + + + + + + +### ModeInfo.Single +Single is the mode info for a single signer. It is structured as a message +to allow for additional fields such as locale for SIGN_MODE_TEXTUAL in the +future + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `mode` | [cosmos.tx.signing.v1beta1.SignMode](#cosmos.tx.signing.v1beta1.SignMode) | | mode is the signing mode of the single signer | + -## cosmos/auth/v1beta1/auth.proto - -### BaseAccount -BaseAccount defines a base account type. It contains all the necessary fields -for basic account functionality. Any custom account type should extend this -type for additional functionality (e.g. vesting). + + +### SignDoc +SignDoc is the type used for generating sign bytes for SIGN_MODE_DIRECT. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | | -| `pub_key` | [google.protobuf.Any](#google.protobuf.Any) | | | -| `account_number` | [uint64](#uint64) | | | -| `sequence` | [uint64](#uint64) | | | +| `body_bytes` | [bytes](#bytes) | | body_bytes is protobuf serialization of a TxBody that matches the representation in TxRaw. | +| `auth_info_bytes` | [bytes](#bytes) | | auth_info_bytes is a protobuf serialization of an AuthInfo that matches the representation in TxRaw. | +| `chain_id` | [string](#string) | | chain_id is the unique identifier of the chain this transaction targets. It prevents signed transactions from being used on another chain by an attacker | +| `account_number` | [uint64](#uint64) | | account_number is the account number of the account in state | - + -### ModuleAccount -ModuleAccount defines an account for modules that holds coins on a pool. +### SignerInfo +SignerInfo describes the public key and signing mode of a single top-level +signer. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `base_account` | [BaseAccount](#cosmos.auth.v1beta1.BaseAccount) | | | -| `name` | [string](#string) | | | -| `permissions` | [string](#string) | repeated | | +| `public_key` | [google.protobuf.Any](#google.protobuf.Any) | | public_key is the public key of the signer. It is optional for accounts that already exist in state. If unset, the verifier can use the required \ signer address for this position and lookup the public key. | +| `mode_info` | [ModeInfo](#cosmos.tx.v1beta1.ModeInfo) | | mode_info describes the signing mode of the signer and is a nested structure to support nested multisig pubkey's | +| `sequence` | [uint64](#uint64) | | sequence is the sequence of the account, which describes the number of committed transactions signed by a given address. It is used to prevent replay attacks. | - + -### Params -Params defines the parameters for the auth module. +### Tx +Tx is the standard type used for broadcasting transactions. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `max_memo_characters` | [uint64](#uint64) | | | -| `tx_sig_limit` | [uint64](#uint64) | | | -| `tx_size_cost_per_byte` | [uint64](#uint64) | | | -| `sig_verify_cost_ed25519` | [uint64](#uint64) | | | -| `sig_verify_cost_secp256k1` | [uint64](#uint64) | | | +| `body` | [TxBody](#cosmos.tx.v1beta1.TxBody) | | body is the processable content of the transaction | +| `auth_info` | [AuthInfo](#cosmos.tx.v1beta1.AuthInfo) | | auth_info is the authorization related content of the transaction, specifically signers, signer modes and fee | +| `signatures` | [bytes](#bytes) | repeated | signatures is a list of signatures that matches the length and order of AuthInfo's signer_infos to allow connecting signature meta information like public key and signing mode by position. | - - + - +### TxBody +TxBody is the body of a transaction that all signers sign over. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `messages` | [google.protobuf.Any](#google.protobuf.Any) | repeated | messages is a list of messages to be executed. The required signers of those messages define the number and order of elements in AuthInfo's signer_infos and Tx's signatures. Each required signer address is added to the list only the first time it occurs. By convention, the first required signer (usually from the first message) is referred to as the primary signer and pays the fee for the whole transaction. | +| `memo` | [string](#string) | | memo is any arbitrary memo to be added to the transaction | +| `timeout_height` | [uint64](#uint64) | | timeout is the block height after which this transaction will not be processed by the chain | +| `extension_options` | [google.protobuf.Any](#google.protobuf.Any) | repeated | extension_options are arbitrary options that can be added by chains when the default options are not sufficient. If any of these are present and can't be handled, the transaction will be rejected | +| `non_critical_extension_options` | [google.protobuf.Any](#google.protobuf.Any) | repeated | extension_options are arbitrary options that can be added by chains when the default options are not sufficient. If any of these are present and can't be handled, they will be ignored | - -

Top

-## cosmos/auth/v1beta1/genesis.proto - + -### GenesisState -GenesisState defines the auth module's genesis state. +### TxRaw +TxRaw is a variant of Tx that pins the signer's exact binary representation +of body and auth_info. This is used for signing, broadcasting and +verification. The binary `serialize(tx: TxRaw)` is stored in Tendermint and +the hash `sha256(serialize(tx: TxRaw))` becomes the "txhash", commonly used +as the transaction ID. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#cosmos.auth.v1beta1.Params) | | params defines all the paramaters of the module. | -| `accounts` | [google.protobuf.Any](#google.protobuf.Any) | repeated | accounts are the accounts present at genesis. | +| `body_bytes` | [bytes](#bytes) | | body_bytes is a protobuf serialization of a TxBody that matches the representation in SignDoc. | +| `auth_info_bytes` | [bytes](#bytes) | | auth_info_bytes is a protobuf serialization of an AuthInfo that matches the representation in SignDoc. | +| `signatures` | [bytes](#bytes) | repeated | signatures is a list of signatures that matches the length and order of AuthInfo's signer_infos to allow connecting signature meta information like public key and signing mode by position. | @@ -847,222 +938,266 @@ GenesisState defines the auth module's genesis state. - +

Top

-## cosmos/auth/v1beta1/query.proto +## cosmos/tx/v1beta1/service.proto - + -### QueryAccountRequest -QueryAccountRequest is the request type for the Query/Account RPC method. +### BroadcastTxRequest +BroadcastTxRequest is the request type for the Service.BroadcastTxRequest +RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | address defines the address to query for. | +| `tx_bytes` | [bytes](#bytes) | | tx_bytes is the raw transaction. | +| `mode` | [BroadcastMode](#cosmos.tx.v1beta1.BroadcastMode) | | | - + -### QueryAccountResponse -QueryAccountResponse is the response type for the Query/Account RPC method. +### BroadcastTxResponse +BroadcastTxResponse is the response type for the +Service.BroadcastTx method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `account` | [google.protobuf.Any](#google.protobuf.Any) | | account defines the account of the corresponding address. | +| `tx_response` | [cosmos.base.abci.v1beta1.TxResponse](#cosmos.base.abci.v1beta1.TxResponse) | | tx_response is the queried TxResponses. | - + + +### GetTxRequest +GetTxRequest is the request type for the Service.GetTx +RPC method. -### QueryParamsRequest -QueryParamsRequest is the request type for the Query/Params RPC method. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `hash` | [string](#string) | | hash is the tx hash to query, encoded as a hex string. | - -### QueryParamsResponse -QueryParamsResponse is the response type for the Query/Params RPC method. + + +### GetTxResponse +GetTxResponse is the response type for the Service.GetTx method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#cosmos.auth.v1beta1.Params) | | params defines the parameters of the module. | +| `tx` | [Tx](#cosmos.tx.v1beta1.Tx) | | tx is the queried transaction. | +| `tx_response` | [cosmos.base.abci.v1beta1.TxResponse](#cosmos.base.abci.v1beta1.TxResponse) | | tx_response is the queried TxResponses. | - - + - +### GetTxsEventRequest +GetTxsEventRequest is the request type for the Service.TxsByEvents +RPC method. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `events` | [string](#string) | repeated | events is the list of transaction event type. | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an pagination for the request. | -### Query -Query defines the gRPC querier service. -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Account` | [QueryAccountRequest](#cosmos.auth.v1beta1.QueryAccountRequest) | [QueryAccountResponse](#cosmos.auth.v1beta1.QueryAccountResponse) | Account returns account details based on address. | GET|/cosmos/auth/v1beta1/accounts/{address}| -| `Params` | [QueryParamsRequest](#cosmos.auth.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#cosmos.auth.v1beta1.QueryParamsResponse) | Params queries all parameters. | GET|/cosmos/auth/v1beta1/params| - - -

Top

+ -## cosmos/base/v1beta1/coin.proto +### GetTxsEventResponse +GetTxsEventResponse is the response type for the Service.TxsByEvents +RPC method. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `txs` | [Tx](#cosmos.tx.v1beta1.Tx) | repeated | txs is the list of queried transactions. | +| `tx_responses` | [cosmos.base.abci.v1beta1.TxResponse](#cosmos.base.abci.v1beta1.TxResponse) | repeated | tx_responses is the list of queried TxResponses. | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines an pagination for the response. | - -### Coin -Coin defines a token with a denomination and an amount. -NOTE: The amount field is an Int which implements the custom method -signatures required by gogoproto. + + + + + +### SimulateRequest +SimulateRequest is the request type for the Service.Simulate +RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `denom` | [string](#string) | | | -| `amount` | [string](#string) | | | - +| `tx` | [Tx](#cosmos.tx.v1beta1.Tx) | | tx is the transaction to simulate. | - -### DecCoin -DecCoin defines a token with a denomination and a decimal amount. + -NOTE: The amount field is an Dec which implements the custom method -signatures required by gogoproto. +### SimulateResponse +SimulateResponse is the response type for the +Service.SimulateRPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `denom` | [string](#string) | | | -| `amount` | [string](#string) | | | +| `gas_info` | [cosmos.base.abci.v1beta1.GasInfo](#cosmos.base.abci.v1beta1.GasInfo) | | gas_info is the information about gas used in the simulation. | +| `result` | [cosmos.base.abci.v1beta1.Result](#cosmos.base.abci.v1beta1.Result) | | result is the result of the simulation. | + - -### DecProto -DecProto defines a Protobuf wrapper around a Dec object. + +### BroadcastMode +BroadcastMode specifies the broadcast mode for the TxService.Broadcast RPC method. -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `dec` | [string](#string) | | | +| Name | Number | Description | +| ---- | ------ | ----------- | +| BROADCAST_MODE_UNSPECIFIED | 0 | zero-value for mode ordering | +| BROADCAST_MODE_BLOCK | 1 | BROADCAST_MODE_BLOCK defines a tx broadcasting mode where the client waits for the tx to be committed in a block. | +| BROADCAST_MODE_SYNC | 2 | BROADCAST_MODE_SYNC defines a tx broadcasting mode where the client waits for a CheckTx execution response only. | +| BROADCAST_MODE_ASYNC | 3 | BROADCAST_MODE_ASYNC defines a tx broadcasting mode where the client returns immediately. | + + + - +### Service +Service defines a gRPC service for interacting with transactions. -### IntProto -IntProto defines a Protobuf wrapper around an Int object. +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Simulate` | [SimulateRequest](#cosmos.tx.v1beta1.SimulateRequest) | [SimulateResponse](#cosmos.tx.v1beta1.SimulateResponse) | Simulate simulates executing a transaction for estimating gas usage. | POST|/cosmos/tx/v1beta1/simulate| +| `GetTx` | [GetTxRequest](#cosmos.tx.v1beta1.GetTxRequest) | [GetTxResponse](#cosmos.tx.v1beta1.GetTxResponse) | GetTx fetches a tx by hash. | GET|/cosmos/tx/v1beta1/txs/{hash}| +| `BroadcastTx` | [BroadcastTxRequest](#cosmos.tx.v1beta1.BroadcastTxRequest) | [BroadcastTxResponse](#cosmos.tx.v1beta1.BroadcastTxResponse) | BroadcastTx broadcast transaction. | POST|/cosmos/tx/v1beta1/txs| +| `GetTxsEvent` | [GetTxsEventRequest](#cosmos.tx.v1beta1.GetTxsEventRequest) | [GetTxsEventResponse](#cosmos.tx.v1beta1.GetTxsEventResponse) | GetTxsEvent fetches txs by event. | GET|/cosmos/tx/v1beta1/txs| + + + + + + +

Top

+ +## cosmos/tx/signing/v1beta1/signing.proto + + + + + +### SignatureDescriptor +SignatureDescriptor is a convenience type which represents the full data for +a signature including the public key of the signer, signing modes and the +signature itself. It is primarily used for coordinating signatures between +clients. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `int` | [string](#string) | | | +| `public_key` | [google.protobuf.Any](#google.protobuf.Any) | | public_key is the public key of the signer | +| `data` | [SignatureDescriptor.Data](#cosmos.tx.signing.v1beta1.SignatureDescriptor.Data) | | | +| `sequence` | [uint64](#uint64) | | sequence is the sequence of the account, which describes the number of committed transactions signed by a given address. It is used to prevent replay attacks. | - - + - +### SignatureDescriptor.Data +Data represents signature data - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `single` | [SignatureDescriptor.Data.Single](#cosmos.tx.signing.v1beta1.SignatureDescriptor.Data.Single) | | single represents a single signer | +| `multi` | [SignatureDescriptor.Data.Multi](#cosmos.tx.signing.v1beta1.SignatureDescriptor.Data.Multi) | | multi represents a multisig signer | - -

Top

-## cosmos/authz/v1beta1/authz.proto - + -### AuthorizationGrant -AuthorizationGrant gives permissions to execute -the provide method with expiration time. +### SignatureDescriptor.Data.Multi +Multi is the signature data for a multisig public key | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `authorization` | [google.protobuf.Any](#google.protobuf.Any) | | | -| `expiration` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | +| `bitarray` | [cosmos.crypto.multisig.v1beta1.CompactBitArray](#cosmos.crypto.multisig.v1beta1.CompactBitArray) | | bitarray specifies which keys within the multisig are signing | +| `signatures` | [SignatureDescriptor.Data](#cosmos.tx.signing.v1beta1.SignatureDescriptor.Data) | repeated | signatures is the signatures of the multi-signature | - + -### GenericAuthorization -GenericAuthorization gives the grantee unrestricted permissions to execute -the provided method on behalf of the granter's account. +### SignatureDescriptor.Data.Single +Single is the signature data for a single signer | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `method_name` | [string](#string) | | method name to grant unrestricted permissions to execute Note: MethodName() is already a method on `GenericAuthorization` type, we need some custom naming here so using `MessageName` | +| `mode` | [SignMode](#cosmos.tx.signing.v1beta1.SignMode) | | mode is the signing mode of the single signer | +| `signature` | [bytes](#bytes) | | signature is the raw signature bytes | - + -### SendAuthorization -SendAuthorization allows the grantee to spend up to spend_limit coins from -the granter's account. +### SignatureDescriptors +SignatureDescriptors wraps multiple SignatureDescriptor's. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `spend_limit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `signatures` | [SignatureDescriptor](#cosmos.tx.signing.v1beta1.SignatureDescriptor) | repeated | signatures are the signature descriptors | @@ -1070,6 +1205,20 @@ the granter's account. + + + +### SignMode +SignMode represents a signing mode with its own security guarantees. + +| Name | Number | Description | +| ---- | ------ | ----------- | +| SIGN_MODE_UNSPECIFIED | 0 | SIGN_MODE_UNSPECIFIED specifies an unknown signing mode and will be rejected | +| SIGN_MODE_DIRECT | 1 | SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is verified with raw bytes from Tx | +| SIGN_MODE_TEXTUAL | 2 | SIGN_MODE_TEXTUAL is a future signing mode that will verify some human-readable textual representation on top of the binary representation from SIGN_MODE_DIRECT | +| SIGN_MODE_LEGACY_AMINO_JSON | 127 | SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses Amino JSON and will be removed in the future | + + @@ -1078,188 +1227,161 @@ the granter's account. - +

Top

-## cosmos/base/abci/v1beta1/abci.proto +## cosmos/crisis/v1beta1/tx.proto - + -### ABCIMessageLog -ABCIMessageLog defines a structure containing an indexed tx ABCI message log. +### MsgVerifyInvariant +MsgVerifyInvariant represents a message to verify a particular invariance. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `msg_index` | [uint32](#uint32) | | | -| `log` | [string](#string) | | | -| `events` | [StringEvent](#cosmos.base.abci.v1beta1.StringEvent) | repeated | Events contains a slice of Event objects that were emitted during some execution. | - - - - - - - - -### Attribute -Attribute defines an attribute wrapper where the key and value are -strings instead of raw bytes. +| `sender` | [string](#string) | | | +| `invariant_module_name` | [string](#string) | | | +| `invariant_route` | [string](#string) | | | -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `key` | [string](#string) | | | -| `value` | [string](#string) | | | + +### MsgVerifyInvariantResponse +MsgVerifyInvariantResponse defines the Msg/VerifyInvariant response type. - -### GasInfo -GasInfo defines tx execution gas context. -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `gas_wanted` | [uint64](#uint64) | | GasWanted is the maximum units of work we allow this tx to perform. | -| `gas_used` | [uint64](#uint64) | | GasUsed is the amount of gas actually consumed. | + + + + - +### Msg +Msg defines the bank Msg service. -### MsgData -MsgData defines the data returned in a Result object during message -execution. +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `VerifyInvariant` | [MsgVerifyInvariant](#cosmos.crisis.v1beta1.MsgVerifyInvariant) | [MsgVerifyInvariantResponse](#cosmos.crisis.v1beta1.MsgVerifyInvariantResponse) | VerifyInvariant defines a method to verify a particular invariance. | | + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `msg_type` | [string](#string) | | | -| `data` | [bytes](#bytes) | | | + +

Top

+## cosmos/crisis/v1beta1/genesis.proto - + -### Result -Result is the union of ResponseFormat and ResponseCheckTx. +### GenesisState +GenesisState defines the crisis module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `data` | [bytes](#bytes) | | Data is any data returned from message or handler execution. It MUST be length prefixed in order to separate data from multiple message executions. | -| `log` | [string](#string) | | Log contains the log information from message or handler execution. | -| `events` | [tendermint.abci.Event](#tendermint.abci.Event) | repeated | Events contains a slice of Event objects that were emitted during message or handler execution. | +| `constant_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | constant_fee is the fee used to verify the invariant in the crisis module. | + - + -### SearchTxsResult -SearchTxsResult defines a structure for querying txs pageable + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `total_count` | [uint64](#uint64) | | Count of all txs | -| `count` | [uint64](#uint64) | | Count of txs in current page | -| `page_number` | [uint64](#uint64) | | Index of current page, start from 1 | -| `page_total` | [uint64](#uint64) | | Count of total pages | -| `limit` | [uint64](#uint64) | | Max count txs per page | -| `txs` | [TxResponse](#cosmos.base.abci.v1beta1.TxResponse) | repeated | List of txs in current page | + +

Top

+## cosmos/crypto/multisig/keys.proto - + -### SimulationResponse -SimulationResponse defines the response generated when a transaction is -successfully simulated. +### LegacyAminoPubKey +LegacyAminoPubKey specifies a public key type +which nests multiple public keys and a threshold, +it uses legacy amino address rules. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `gas_info` | [GasInfo](#cosmos.base.abci.v1beta1.GasInfo) | | | -| `result` | [Result](#cosmos.base.abci.v1beta1.Result) | | | +| `threshold` | [uint32](#uint32) | | | +| `public_keys` | [google.protobuf.Any](#google.protobuf.Any) | repeated | | + - + -### StringEvent -StringEvent defines en Event object wrapper where all the attributes -contain key/value pairs that are strings instead of raw bytes. + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `type` | [string](#string) | | | -| `attributes` | [Attribute](#cosmos.base.abci.v1beta1.Attribute) | repeated | | + +

Top

+## cosmos/crypto/multisig/v1beta1/multisig.proto - + -### TxMsgData -TxMsgData defines a list of MsgData. A transaction will have a MsgData object -for each message. +### CompactBitArray +CompactBitArray is an implementation of a space efficient bit array. +This is used to ensure that the encoded data takes up a minimal amount of +space after proto encoding. +This is not thread safe, and is not intended for concurrent usage. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `data` | [MsgData](#cosmos.base.abci.v1beta1.MsgData) | repeated | | +| `extra_bits_stored` | [uint32](#uint32) | | | +| `elems` | [bytes](#bytes) | | | - + -### TxResponse -TxResponse defines a structure containing relevant tx data and metadata. The -tags are stringified and the log is JSON decoded. +### MultiSignature +MultiSignature wraps the signatures from a multisig.LegacyAminoPubKey. +See cosmos.tx.v1betata1.ModeInfo.Multi for how to specify which signers +signed and with which modes. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `height` | [int64](#int64) | | The block height | -| `txhash` | [string](#string) | | The transaction hash. | -| `codespace` | [string](#string) | | Namespace for the Code | -| `code` | [uint32](#uint32) | | Response code. | -| `data` | [string](#string) | | Result bytes, if any. | -| `raw_log` | [string](#string) | | The output of the application's logger (raw string). May be non-deterministic. | -| `logs` | [ABCIMessageLog](#cosmos.base.abci.v1beta1.ABCIMessageLog) | repeated | The output of the application's logger (typed). May be non-deterministic. | -| `info` | [string](#string) | | Additional information. May be non-deterministic. | -| `gas_wanted` | [int64](#int64) | | Amount of gas requested for transaction. | -| `gas_used` | [int64](#int64) | | Amount of gas consumed by transaction. | -| `tx` | [google.protobuf.Any](#google.protobuf.Any) | | The request transaction bytes. | -| `timestamp` | [string](#string) | | Time of the previous block. For heights > 1, it's the weighted median of the timestamps of the valid votes in the block.LastCommit. For height == 1, it's genesis time. | +| `signatures` | [bytes](#bytes) | repeated | | @@ -1275,97 +1397,91 @@ tags are stringified and the log is JSON decoded. - +

Top

-## cosmos/authz/v1beta1/tx.proto +## cosmos/crypto/secp256k1/keys.proto - + -### MsgExecAuthorizedRequest -MsgExecAuthorizedRequest attempts to execute the provided messages using -authorizations granted to the grantee. Each message should have only -one signer corresponding to the granter of the authorization. +### PrivKey +PrivKey defines a secp256k1 private key. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `grantee` | [string](#string) | | | -| `msgs` | [google.protobuf.Any](#google.protobuf.Any) | repeated | | +| `key` | [bytes](#bytes) | | | - + -### MsgExecAuthorizedResponse -MsgExecAuthorizedResponse defines the Msg/MsgExecAuthorizedResponse response type. +### PubKey +PubKey defines a secp256k1 public key +Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte +if the y-coordinate is the lexicographically largest of the two associated with +the x-coordinate. Otherwise the first byte is a 0x03. +This prefix is followed with the x-coordinate. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `result` | [cosmos.base.abci.v1beta1.Result](#cosmos.base.abci.v1beta1.Result) | | | - - - - - - - - -### MsgGrantAuthorizationRequest -MsgGrantAuthorizationRequest grants the provided authorization to the grantee on the granter's -account with the provided expiration time. - +| `key` | [bytes](#bytes) | | | -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `granter` | [string](#string) | | | -| `grantee` | [string](#string) | | | -| `authorization` | [google.protobuf.Any](#google.protobuf.Any) | | | -| `expiration` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | + + - + -### MsgGrantAuthorizationResponse -MsgGrantAuthorizationResponse defines the Msg/MsgGrantAuthorization response type. + + +

Top

+## cosmos/crypto/ed25519/keys.proto - -### MsgRevokeAuthorizationRequest -MsgRevokeAuthorizationRequest revokes any authorization with the provided sdk.Msg type on the -granter's account with that has been granted to the grantee. + + +### PrivKey +PrivKey defines a ed25519 private key. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `granter` | [string](#string) | | | -| `grantee` | [string](#string) | | | -| `method_name` | [string](#string) | | | +| `key` | [bytes](#bytes) | | | - + -### MsgRevokeAuthorizationResponse -MsgRevokeAuthorizationResponse defines the Msg/MsgRevokeAuthorizationResponse response type. +### PubKey +PubKey defines a ed25519 public key +Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte +if the y-coordinate is the lexicographically largest of the two associated with +the x-coordinate. Otherwise the first byte is a 0x03. +This prefix is followed with the x-coordinate. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `key` | [bytes](#bytes) | | | @@ -1377,118 +1493,89 @@ MsgRevokeAuthorizationResponse defines the Msg/MsgRevokeAuthorizationResponse re - - - -### Msg -Msg defines the authz Msg service. - -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `GrantAuthorization` | [MsgGrantAuthorizationRequest](#cosmos.authz.v1beta1.MsgGrantAuthorizationRequest) | [MsgGrantAuthorizationResponse](#cosmos.authz.v1beta1.MsgGrantAuthorizationResponse) | GrantAuthorization grants the provided authorization to the grantee on the granter's account with the provided expiration time. | | -| `ExecAuthorized` | [MsgExecAuthorizedRequest](#cosmos.authz.v1beta1.MsgExecAuthorizedRequest) | [MsgExecAuthorizedResponse](#cosmos.authz.v1beta1.MsgExecAuthorizedResponse) | ExecAuthorized attempts to execute the provided messages using authorizations granted to the grantee. Each message should have only one signer corresponding to the granter of the authorization. | | -| `RevokeAuthorization` | [MsgRevokeAuthorizationRequest](#cosmos.authz.v1beta1.MsgRevokeAuthorizationRequest) | [MsgRevokeAuthorizationResponse](#cosmos.authz.v1beta1.MsgRevokeAuthorizationResponse) | RevokeAuthorization revokes any authorization corresponding to the provided method name on the granter's account that has been granted to the grantee. | | - - +

Top

-## cosmos/authz/v1beta1/genesis.proto - - +## cosmos/mint/v1beta1/query.proto - -### GenesisState -GenesisState defines the authz module's genesis state. + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `authorization` | [GrantAuthorization](#cosmos.authz.v1beta1.GrantAuthorization) | repeated | | +### QueryAnnualProvisionsRequest +QueryAnnualProvisionsRequest is the request type for the +Query/AnnualProvisions RPC method. - + -### GrantAuthorization -GrantAuthorization defines the GenesisState/GrantAuthorization type. +### QueryAnnualProvisionsResponse +QueryAnnualProvisionsResponse is the response type for the +Query/AnnualProvisions RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `granter` | [string](#string) | | | -| `grantee` | [string](#string) | | | -| `authorization` | [google.protobuf.Any](#google.protobuf.Any) | | | -| `expiration` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | +| `annual_provisions` | [bytes](#bytes) | | annual_provisions is the current minting annual provisions value. | - - + - +### QueryInflationRequest +QueryInflationRequest is the request type for the Query/Inflation RPC method. - - -

Top

-## cosmos/base/query/v1beta1/pagination.proto + +### QueryInflationResponse +QueryInflationResponse is the response type for the Query/Inflation RPC +method. - -### PageRequest -PageRequest is to be embedded in gRPC request messages for efficient -pagination. Ex: +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `inflation` | [bytes](#bytes) | | inflation is the current minting inflation value. | - message SomeRequest { - Foo some_parameter = 1; - PageRequest pagination = 2; - } -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `key` | [bytes](#bytes) | | key is a value returned in PageResponse.next_key to begin querying the next page most efficiently. Only one of offset or key should be set. | -| `offset` | [uint64](#uint64) | | offset is a numeric offset that can be used when key is unavailable. It is less efficient than using key. Only one of offset or key should be set. | -| `limit` | [uint64](#uint64) | | limit is the total number of results to be returned in the result page. If left empty it will default to a value to be set by each app. | -| `count_total` | [bool](#bool) | | count_total is set to true to indicate that the result set should include a count of the total number of items available for pagination in UIs. count_total is only respected when offset is used. It is ignored when key is set. | + + +### QueryParamsRequest +QueryParamsRequest is the request type for the Query/Params RPC method. + + - -### PageResponse -PageResponse is to be embedded in gRPC response messages where the -corresponding request message has used PageRequest. + - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } +### QueryParamsResponse +QueryParamsResponse is the response type for the Query/Params RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `next_key` | [bytes](#bytes) | | next_key is the key to be passed to PageRequest.key to query the next page most efficiently | -| `total` | [uint64](#uint64) | | total is total number of results available if PageRequest.count_total was set, its value is undefined otherwise | +| `params` | [Params](#cosmos.mint.v1beta1.Params) | | params defines the parameters of the module. | @@ -1500,76 +1587,91 @@ corresponding request message has used PageRequest. + + + +### Query +Query provides defines the gRPC querier service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Params` | [QueryParamsRequest](#cosmos.mint.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#cosmos.mint.v1beta1.QueryParamsResponse) | Params returns the total set of minting parameters. | GET|/cosmos/mint/v1beta1/params| +| `Inflation` | [QueryInflationRequest](#cosmos.mint.v1beta1.QueryInflationRequest) | [QueryInflationResponse](#cosmos.mint.v1beta1.QueryInflationResponse) | Inflation returns the current minting inflation value. | GET|/cosmos/mint/v1beta1/inflation| +| `AnnualProvisions` | [QueryAnnualProvisionsRequest](#cosmos.mint.v1beta1.QueryAnnualProvisionsRequest) | [QueryAnnualProvisionsResponse](#cosmos.mint.v1beta1.QueryAnnualProvisionsResponse) | AnnualProvisions current minting annual provisions value. | GET|/cosmos/mint/v1beta1/annual_provisions| + - +

Top

-## cosmos/authz/v1beta1/query.proto +## cosmos/mint/v1beta1/genesis.proto - + -### QueryAuthorizationRequest -QueryAuthorizationRequest is the request type for the Query/Authorization RPC method. +### GenesisState +GenesisState defines the mint module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `granter` | [string](#string) | | | -| `grantee` | [string](#string) | | | -| `method_name` | [string](#string) | | | +| `minter` | [Minter](#cosmos.mint.v1beta1.Minter) | | minter is a space for holding current inflation information. | +| `params` | [Params](#cosmos.mint.v1beta1.Params) | | params defines all the paramaters of the module. | + - + -### QueryAuthorizationResponse -QueryAuthorizationResponse is the response type for the Query/Authorization RPC method. + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `authorization` | [AuthorizationGrant](#cosmos.authz.v1beta1.AuthorizationGrant) | | authorization is a authorization granted for grantee by granter. | + +

Top

+## cosmos/mint/v1beta1/mint.proto - + -### QueryAuthorizationsRequest -QueryAuthorizationsRequest is the request type for the Query/Authorizations RPC method. +### Minter +Minter represents the minting state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `granter` | [string](#string) | | | -| `grantee` | [string](#string) | | | -| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an pagination for the request. | +| `inflation` | [string](#string) | | current annual inflation rate | +| `annual_provisions` | [string](#string) | | current annual expected provisions | - + -### QueryAuthorizationsResponse -QueryAuthorizationsResponse is the response type for the Query/Authorizations RPC method. +### Params +Params holds parameters for the mint module. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `authorizations` | [AuthorizationGrant](#cosmos.authz.v1beta1.AuthorizationGrant) | repeated | authorizations is a list of grants granted for grantee by granter. | -| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines an pagination for the response. | +| `mint_denom` | [string](#string) | | type of coin to mint | +| `inflation_rate_change` | [string](#string) | | maximum annual change in inflation rate | +| `inflation_max` | [string](#string) | | maximum inflation rate | +| `inflation_min` | [string](#string) | | minimum inflation rate | +| `goal_bonded` | [string](#string) | | goal of percent bonded atoms | +| `blocks_per_year` | [uint64](#uint64) | | expected blocks per year | @@ -1581,191 +1683,178 @@ QueryAuthorizationsResponse is the response type for the Query/Authorizations RP - - - -### Query -Query defines the gRPC querier service. - -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Authorization` | [QueryAuthorizationRequest](#cosmos.authz.v1beta1.QueryAuthorizationRequest) | [QueryAuthorizationResponse](#cosmos.authz.v1beta1.QueryAuthorizationResponse) | Returns any `Authorization` (or `nil`), with the expiration time, granted to the grantee by the granter for the provided msg type. | GET|/cosmos/authz/v1beta1/granters/{granter}/grantees/{grantee}/grant| -| `Authorizations` | [QueryAuthorizationsRequest](#cosmos.authz.v1beta1.QueryAuthorizationsRequest) | [QueryAuthorizationsResponse](#cosmos.authz.v1beta1.QueryAuthorizationsResponse) | Returns list of `Authorization`, granted to the grantee by the granter. | GET|/cosmos/authz/v1beta1/granters/{granter}/grantees/{grantee}/grants| - - +

Top

-## cosmos/bank/v1beta1/bank.proto +## cosmos/feegrant/v1beta1/feegrant.proto - + -### DenomUnit -DenomUnit represents a struct that describes a given -denomination unit of the basic token. +### BasicFeeAllowance +BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens +that optionally expires. The delegatee can use up to SpendLimit to cover fees. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `denom` | [string](#string) | | denom represents the string name of the given denom unit (e.g uatom). | -| `exponent` | [uint32](#uint32) | | exponent represents power of 10 exponent that one must raise the base_denom to in order to equal the given DenomUnit's denom 1 denom = 1^exponent base_denom (e.g. with a base_denom of uatom, one can create a DenomUnit of 'atom' with exponent = 6, thus: 1 atom = 10^6 uatom). | -| `aliases` | [string](#string) | repeated | aliases is a list of string aliases for the given denom | +| `spend_limit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `expiration` | [ExpiresAt](#cosmos.feegrant.v1beta1.ExpiresAt) | | | - + -### Input -Input models transaction input. +### Duration +Duration is a span of a clock time or number of blocks. +This is designed to be added to an ExpiresAt struct. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | | -| `coins` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `duration` | [google.protobuf.Duration](#google.protobuf.Duration) | | | +| `blocks` | [uint64](#uint64) | | | - + -### Metadata -Metadata represents a struct that describes -a basic token. +### ExpiresAt +ExpiresAt is a point in time where something expires. +It may be *either* block time or block height | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `description` | [string](#string) | | | -| `denom_units` | [DenomUnit](#cosmos.bank.v1beta1.DenomUnit) | repeated | denom_units represents the list of DenomUnit's for a given coin | -| `base` | [string](#string) | | base represents the base denom (should be the DenomUnit with exponent = 0). | -| `display` | [string](#string) | | display indicates the suggested denom that should be displayed in clients. | +| `time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | +| `height` | [int64](#int64) | | | - + -### Output -Output models transaction outputs. +### FeeAllowanceGrant +FeeAllowanceGrant is stored in the KVStore to record a grant with full context | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | | -| `coins` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `granter` | [string](#string) | | | +| `grantee` | [string](#string) | | | +| `allowance` | [google.protobuf.Any](#google.protobuf.Any) | | | - + -### Params -Params defines the parameters for the bank module. +### PeriodicFeeAllowance +PeriodicFeeAllowance extends FeeAllowance to allow for both a maximum cap, +as well as a limit per time period. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `send_enabled` | [SendEnabled](#cosmos.bank.v1beta1.SendEnabled) | repeated | | -| `default_send_enabled` | [bool](#bool) | | | - +| `basic` | [BasicFeeAllowance](#cosmos.feegrant.v1beta1.BasicFeeAllowance) | | | +| `period` | [Duration](#cosmos.feegrant.v1beta1.Duration) | | | +| `period_spend_limit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `period_can_spend` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `period_reset` | [ExpiresAt](#cosmos.feegrant.v1beta1.ExpiresAt) | | | - + -### SendEnabled -SendEnabled maps coin denom to a send_enabled status (whether a denom is -sendable). + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `denom` | [string](#string) | | | -| `enabled` | [bool](#bool) | | | + + +

Top

+## cosmos/feegrant/v1beta1/query.proto - -### Supply -Supply represents a struct that passively keeps track of the total supply -amounts in the network. + + +### QueryFeeAllowanceRequest +QueryFeeAllowanceRequest is the request type for the Query/FeeAllowance RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `total` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `granter` | [string](#string) | | | +| `grantee` | [string](#string) | | | - - + - +### QueryFeeAllowanceResponse +QueryFeeAllowanceResponse is the response type for the Query/FeeAllowance RPC method. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `fee_allowance` | [FeeAllowanceGrant](#cosmos.feegrant.v1beta1.FeeAllowanceGrant) | | fee_allowance is a fee_allowance granted for grantee by granter. | - -

Top

-## cosmos/bank/v1beta1/genesis.proto - + -### Balance -Balance defines an account address and balance pair used in the bank module's -genesis state. +### QueryFeeAllowancesRequest +QueryFeeAllowancesRequest is the request type for the Query/FeeAllowances RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | address is the address of the balance holder. | -| `coins` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | coins defines the different coins this balance holds. | +| `grantee` | [string](#string) | | | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an pagination for the request. | - + -### GenesisState -GenesisState defines the bank module's genesis state. +### QueryFeeAllowancesResponse +QueryFeeAllowancesResponse is the response type for the Query/FeeAllowances RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#cosmos.bank.v1beta1.Params) | | params defines all the paramaters of the module. | -| `balances` | [Balance](#cosmos.bank.v1beta1.Balance) | repeated | balances is an array containing the balances of all the accounts. | -| `supply` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | supply represents the total supply. | -| `denom_metadata` | [Metadata](#cosmos.bank.v1beta1.Metadata) | repeated | denom_metadata defines the metadata of the differents coins. | +| `fee_allowances` | [FeeAllowanceGrant](#cosmos.feegrant.v1beta1.FeeAllowanceGrant) | repeated | fee_allowances are fee_allowance's granted for grantee by granter. | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines an pagination for the response. | @@ -1777,305 +1866,365 @@ GenesisState defines the bank module's genesis state. + + + +### Query +Query defines the gRPC querier service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `FeeAllowance` | [QueryFeeAllowanceRequest](#cosmos.feegrant.v1beta1.QueryFeeAllowanceRequest) | [QueryFeeAllowanceResponse](#cosmos.feegrant.v1beta1.QueryFeeAllowanceResponse) | FeeAllowance returns fee granted to the grantee by the granter. | GET|/cosmos/feegrant/v1beta1/fee_allowance/{granter}/{grantee}| +| `FeeAllowances` | [QueryFeeAllowancesRequest](#cosmos.feegrant.v1beta1.QueryFeeAllowancesRequest) | [QueryFeeAllowancesResponse](#cosmos.feegrant.v1beta1.QueryFeeAllowancesResponse) | FeeAllowances returns all the grants for address. | GET|/cosmos/feegrant/v1beta1/fee_allowances/{grantee}| + - +

Top

-## cosmos/bank/v1beta1/query.proto +## cosmos/feegrant/v1beta1/tx.proto - + -### QueryAllBalancesRequest -QueryBalanceRequest is the request type for the Query/AllBalances RPC method. +### MsgGrantFeeAllowance +MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance +of fees from the account of Granter. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | address is the address to query balances for. | -| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | +| `granter` | [string](#string) | | | +| `grantee` | [string](#string) | | | +| `allowance` | [google.protobuf.Any](#google.protobuf.Any) | | | - + + +### MsgGrantFeeAllowanceResponse +MsgGrantFeeAllowanceResponse defines the Msg/GrantFeeAllowanceResponse response type. + + -### QueryAllBalancesResponse -QueryAllBalancesResponse is the response type for the Query/AllBalances RPC -method. + + + + + +### MsgRevokeFeeAllowance +MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `balances` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | balances is the balances of all the coins. | -| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | +| `granter` | [string](#string) | | | +| `grantee` | [string](#string) | | | - + -### QueryBalanceRequest -QueryBalanceRequest is the request type for the Query/Balance RPC method. +### MsgRevokeFeeAllowanceResponse +MsgRevokeFeeAllowanceResponse defines the Msg/RevokeFeeAllowanceResponse response type. -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | address is the address to query balances for. | -| `denom` | [string](#string) | | denom is the coin denom to query balances for. | + + + - -### QueryBalanceResponse -QueryBalanceResponse is the response type for the Query/Balance RPC method. + +### Msg +Msg defines the feegrant msg service. -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `balance` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | balance is the balance of the coin. | +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `GrantFeeAllowance` | [MsgGrantFeeAllowance](#cosmos.feegrant.v1beta1.MsgGrantFeeAllowance) | [MsgGrantFeeAllowanceResponse](#cosmos.feegrant.v1beta1.MsgGrantFeeAllowanceResponse) | GrantFeeAllowance grants fee allowance to the grantee on the granter's account with the provided expiration time. | | +| `RevokeFeeAllowance` | [MsgRevokeFeeAllowance](#cosmos.feegrant.v1beta1.MsgRevokeFeeAllowance) | [MsgRevokeFeeAllowanceResponse](#cosmos.feegrant.v1beta1.MsgRevokeFeeAllowanceResponse) | RevokeFeeAllowance revokes any fee allowance of granter's account that has been granted to the grantee. | | + + +

Top

+## cosmos/feegrant/v1beta1/genesis.proto - -### QueryDenomMetadataRequest -QueryDenomMetadataRequest is the request type for the Query/DenomMetadata RPC method. + + + +### GenesisState +GenesisState contains a set of fee allowances, persisted from the store | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `denom` | [string](#string) | | denom is the coin denom to query the metadata for. | +| `fee_allowances` | [FeeAllowanceGrant](#cosmos.feegrant.v1beta1.FeeAllowanceGrant) | repeated | | + - + -### QueryDenomMetadataResponse -QueryDenomMetadataResponse is the response type for the Query/DenomMetadata RPC -method. + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `metadata` | [Metadata](#cosmos.bank.v1beta1.Metadata) | | metadata describes and provides all the client information for the requested token. | + +

Top

+## cosmos/capability/v1beta1/capability.proto - + -### QueryDenomsMetadataRequest -QueryDenomsMetadataRequest is the request type for the Query/DenomsMetadata RPC method. +### Capability +Capability defines an implementation of an object capability. The index +provided to a Capability must be globally unique. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | +| `index` | [uint64](#uint64) | | | - + -### QueryDenomsMetadataResponse -QueryDenomsMetadataResponse is the response type for the Query/DenomsMetadata RPC -method. +### CapabilityOwners +CapabilityOwners defines a set of owners of a single Capability. The set of +owners must be unique. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `metadatas` | [Metadata](#cosmos.bank.v1beta1.Metadata) | repeated | metadata provides the client information for all the registered tokens. | -| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | +| `owners` | [Owner](#cosmos.capability.v1beta1.Owner) | repeated | | - + -### QueryParamsRequest -QueryParamsRequest defines the request type for querying x/bank parameters. +### Owner +Owner defines a single capability owner. An owner is defined by the name of +capability and the module name. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `module` | [string](#string) | | | +| `name` | [string](#string) | | | - -### QueryParamsResponse -QueryParamsResponse defines the response type for querying x/bank parameters. + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `params` | [Params](#cosmos.bank.v1beta1.Params) | | | + + + + +

Top

+## cosmos/capability/v1beta1/genesis.proto - -### QuerySupplyOfRequest -QuerySupplyOfRequest is the request type for the Query/SupplyOf RPC method. + + +### GenesisOwners +GenesisOwners defines the capability owners with their corresponding index. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `denom` | [string](#string) | | denom is the coin denom to query balances for. | +| `index` | [uint64](#uint64) | | index is the index of the capability owner. | +| `index_owners` | [CapabilityOwners](#cosmos.capability.v1beta1.CapabilityOwners) | | index_owners are the owners at the given index. | - + -### QuerySupplyOfResponse -QuerySupplyOfResponse is the response type for the Query/SupplyOf RPC method. +### GenesisState +GenesisState defines the capability module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | amount is the supply of the coin. | +| `index` | [uint64](#uint64) | | index is the capability global index. | +| `owners` | [GenesisOwners](#cosmos.capability.v1beta1.GenesisOwners) | repeated | owners represents a map from index to owners of the capability index index key is string to allow amino marshalling. | + - + -### QueryTotalSupplyRequest -QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC -method. + + + + +

Top

+## cosmos/bank/v1beta1/bank.proto - -### QueryTotalSupplyResponse -QueryTotalSupplyResponse is the response type for the Query/TotalSupply RPC -method + + +### DenomUnit +DenomUnit represents a struct that describes a given +denomination unit of the basic token. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `supply` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | supply is the supply of the coins | +| `denom` | [string](#string) | | denom represents the string name of the given denom unit (e.g uatom). | +| `exponent` | [uint32](#uint32) | | exponent represents power of 10 exponent that one must raise the base_denom to in order to equal the given DenomUnit's denom 1 denom = 1^exponent base_denom (e.g. with a base_denom of uatom, one can create a DenomUnit of 'atom' with exponent = 6, thus: 1 atom = 10^6 uatom). | +| `aliases` | [string](#string) | repeated | aliases is a list of string aliases for the given denom | - - + - +### Input +Input models transaction input. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [string](#string) | | | +| `coins` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | -### Query -Query defines the gRPC querier service. -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Balance` | [QueryBalanceRequest](#cosmos.bank.v1beta1.QueryBalanceRequest) | [QueryBalanceResponse](#cosmos.bank.v1beta1.QueryBalanceResponse) | Balance queries the balance of a single coin for a single account. | GET|/cosmos/bank/v1beta1/balances/{address}/{denom}| -| `AllBalances` | [QueryAllBalancesRequest](#cosmos.bank.v1beta1.QueryAllBalancesRequest) | [QueryAllBalancesResponse](#cosmos.bank.v1beta1.QueryAllBalancesResponse) | AllBalances queries the balance of all coins for a single account. | GET|/cosmos/bank/v1beta1/balances/{address}| -| `TotalSupply` | [QueryTotalSupplyRequest](#cosmos.bank.v1beta1.QueryTotalSupplyRequest) | [QueryTotalSupplyResponse](#cosmos.bank.v1beta1.QueryTotalSupplyResponse) | TotalSupply queries the total supply of all coins. | GET|/cosmos/bank/v1beta1/supply| -| `SupplyOf` | [QuerySupplyOfRequest](#cosmos.bank.v1beta1.QuerySupplyOfRequest) | [QuerySupplyOfResponse](#cosmos.bank.v1beta1.QuerySupplyOfResponse) | SupplyOf queries the supply of a single coin. | GET|/cosmos/bank/v1beta1/supply/{denom}| -| `Params` | [QueryParamsRequest](#cosmos.bank.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#cosmos.bank.v1beta1.QueryParamsResponse) | Params queries the parameters of x/bank module. | GET|/cosmos/bank/v1beta1/params| -| `DenomMetadata` | [QueryDenomMetadataRequest](#cosmos.bank.v1beta1.QueryDenomMetadataRequest) | [QueryDenomMetadataResponse](#cosmos.bank.v1beta1.QueryDenomMetadataResponse) | DenomsMetadata queries the client metadata of a given coin denomination. | GET|/cosmos/bank/v1beta1/denoms_metadata/{denom}| -| `DenomsMetadata` | [QueryDenomsMetadataRequest](#cosmos.bank.v1beta1.QueryDenomsMetadataRequest) | [QueryDenomsMetadataResponse](#cosmos.bank.v1beta1.QueryDenomsMetadataResponse) | DenomsMetadata queries the client metadata for all registered coin denominations. | GET|/cosmos/bank/v1beta1/denoms_metadata| - - -

Top

+ + +### Metadata +Metadata represents a struct that describes +a basic token. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `description` | [string](#string) | | | +| `denom_units` | [DenomUnit](#cosmos.bank.v1beta1.DenomUnit) | repeated | denom_units represents the list of DenomUnit's for a given coin | +| `base` | [string](#string) | | base represents the base denom (should be the DenomUnit with exponent = 0). | +| `display` | [string](#string) | | display indicates the suggested denom that should be displayed in clients. | + -## cosmos/bank/v1beta1/tx.proto - -### MsgMultiSend -MsgMultiSend represents an arbitrary multi-in, multi-out send message. + + +### Output +Output models transaction outputs. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `inputs` | [Input](#cosmos.bank.v1beta1.Input) | repeated | | -| `outputs` | [Output](#cosmos.bank.v1beta1.Output) | repeated | | +| `address` | [string](#string) | | | +| `coins` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | - + -### MsgMultiSendResponse -MsgMultiSendResponse defines the Msg/MultiSend response type. +### Params +Params defines the parameters for the bank module. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `send_enabled` | [SendEnabled](#cosmos.bank.v1beta1.SendEnabled) | repeated | | +| `default_send_enabled` | [bool](#bool) | | | - -### MsgSend -MsgSend represents a message to send coins from one account to another. + + + +### SendEnabled +SendEnabled maps coin denom to a send_enabled status (whether a denom is +sendable). | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `from_address` | [string](#string) | | | -| `to_address` | [string](#string) | | | -| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `denom` | [string](#string) | | | +| `enabled` | [bool](#bool) | | | - + -### MsgSendResponse -MsgSendResponse defines the Msg/Send response type. +### Supply +Supply represents a struct that passively keeps track of the total supply +amounts in the network. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `total` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | @@ -2087,319 +2236,305 @@ MsgSendResponse defines the Msg/Send response type. - - - -### Msg -Msg defines the bank Msg service. - -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Send` | [MsgSend](#cosmos.bank.v1beta1.MsgSend) | [MsgSendResponse](#cosmos.bank.v1beta1.MsgSendResponse) | Send defines a method for sending coins from one account to another account. | | -| `MultiSend` | [MsgMultiSend](#cosmos.bank.v1beta1.MsgMultiSend) | [MsgMultiSendResponse](#cosmos.bank.v1beta1.MsgMultiSendResponse) | MultiSend defines a method for sending coins from some accounts to other accounts. | | - - +

Top

-## cosmos/base/kv/v1beta1/kv.proto +## cosmos/bank/v1beta1/query.proto - + -### Pair -Pair defines a key/value bytes tuple. +### QueryAllBalancesRequest +QueryBalanceRequest is the request type for the Query/AllBalances RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `key` | [bytes](#bytes) | | | -| `value` | [bytes](#bytes) | | | +| `address` | [string](#string) | | address is the address to query balances for. | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | - + -### Pairs -Pairs defines a repeated slice of Pair objects. +### QueryAllBalancesResponse +QueryAllBalancesResponse is the response type for the Query/AllBalances RPC +method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `pairs` | [Pair](#cosmos.base.kv.v1beta1.Pair) | repeated | | +| `balances` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | balances is the balances of all the coins. | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | - - + - +### QueryBalanceRequest +QueryBalanceRequest is the request type for the Query/Balance RPC method. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [string](#string) | | address is the address to query balances for. | +| `denom` | [string](#string) | | denom is the coin denom to query balances for. | - -

Top

-## cosmos/base/reflection/v1beta1/reflection.proto - + + +### QueryBalanceResponse +QueryBalanceResponse is the response type for the Query/Balance RPC method. -### ListAllInterfacesRequest -ListAllInterfacesRequest is the request type of the ListAllInterfaces RPC. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `balance` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | balance is the balance of the coin. | - -### ListAllInterfacesResponse -ListAllInterfacesResponse is the response type of the ListAllInterfaces RPC. + + +### QueryDenomMetadataRequest +QueryDenomMetadataRequest is the request type for the Query/DenomMetadata RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `interface_names` | [string](#string) | repeated | interface_names is an array of all the registered interfaces. | +| `denom` | [string](#string) | | denom is the coin denom to query the metadata for. | - + -### ListImplementationsRequest -ListImplementationsRequest is the request type of the ListImplementations -RPC. +### QueryDenomMetadataResponse +QueryDenomMetadataResponse is the response type for the Query/DenomMetadata RPC +method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `interface_name` | [string](#string) | | interface_name defines the interface to query the implementations for. | +| `metadata` | [Metadata](#cosmos.bank.v1beta1.Metadata) | | metadata describes and provides all the client information for the requested token. | - + -### ListImplementationsResponse -ListImplementationsResponse is the response type of the ListImplementations -RPC. +### QueryDenomsMetadataRequest +QueryDenomsMetadataRequest is the request type for the Query/DenomsMetadata RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `implementation_message_names` | [string](#string) | repeated | | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | - - + - +### QueryDenomsMetadataResponse +QueryDenomsMetadataResponse is the response type for the Query/DenomsMetadata RPC +method. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `metadatas` | [Metadata](#cosmos.bank.v1beta1.Metadata) | repeated | metadata provides the client information for all the registered tokens. | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | -### ReflectionService -ReflectionService defines a service for interface reflection. -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `ListAllInterfaces` | [ListAllInterfacesRequest](#cosmos.base.reflection.v1beta1.ListAllInterfacesRequest) | [ListAllInterfacesResponse](#cosmos.base.reflection.v1beta1.ListAllInterfacesResponse) | ListAllInterfaces lists all the interfaces registered in the interface registry. | GET|/cosmos/base/reflection/v1beta1/interfaces| -| `ListImplementations` | [ListImplementationsRequest](#cosmos.base.reflection.v1beta1.ListImplementationsRequest) | [ListImplementationsResponse](#cosmos.base.reflection.v1beta1.ListImplementationsResponse) | ListImplementations list all the concrete types that implement a given interface. | GET|/cosmos/base/reflection/v1beta1/interfaces/{interface_name}/implementations| - - -

Top

+ -## cosmos/base/snapshots/v1beta1/snapshot.proto +### QueryParamsRequest +QueryParamsRequest defines the request type for querying x/bank parameters. - -### Metadata -Metadata contains SDK-specific snapshot metadata. + + + + +### QueryParamsResponse +QueryParamsResponse defines the response type for querying x/bank parameters. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `chunk_hashes` | [bytes](#bytes) | repeated | SHA-256 chunk hashes | +| `params` | [Params](#cosmos.bank.v1beta1.Params) | | | - + -### Snapshot -Snapshot contains Tendermint state sync snapshot info. +### QuerySupplyOfRequest +QuerySupplyOfRequest is the request type for the Query/SupplyOf RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `height` | [uint64](#uint64) | | | -| `format` | [uint32](#uint32) | | | -| `chunks` | [uint32](#uint32) | | | -| `hash` | [bytes](#bytes) | | | -| `metadata` | [Metadata](#cosmos.base.snapshots.v1beta1.Metadata) | | | - - +| `denom` | [string](#string) | | denom is the coin denom to query balances for. | - - - - + +### QuerySupplyOfResponse +QuerySupplyOfResponse is the response type for the Query/SupplyOf RPC method. - -

Top

+| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | amount is the supply of the coin. | -## cosmos/base/store/v1beta1/commit_info.proto - -### CommitID -CommitID defines the committment information when a specific store is -committed. + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `version` | [int64](#int64) | | | -| `hash` | [bytes](#bytes) | | | +### QueryTotalSupplyRequest +QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC +method. - + -### CommitInfo -CommitInfo defines commit information used by the multi-store when committing -a version/height. +### QueryTotalSupplyResponse +QueryTotalSupplyResponse is the response type for the Query/TotalSupply RPC +method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `version` | [int64](#int64) | | | -| `store_infos` | [StoreInfo](#cosmos.base.store.v1beta1.StoreInfo) | repeated | | +| `supply` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | supply is the supply of the coins | + - + -### StoreInfo -StoreInfo defines store-specific commit information. It contains a reference -between a store name and the commit ID. + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `name` | [string](#string) | | | -| `commit_id` | [CommitID](#cosmos.base.store.v1beta1.CommitID) | | | + + +### Query +Query defines the gRPC querier service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Balance` | [QueryBalanceRequest](#cosmos.bank.v1beta1.QueryBalanceRequest) | [QueryBalanceResponse](#cosmos.bank.v1beta1.QueryBalanceResponse) | Balance queries the balance of a single coin for a single account. | GET|/cosmos/bank/v1beta1/balances/{address}/{denom}| +| `AllBalances` | [QueryAllBalancesRequest](#cosmos.bank.v1beta1.QueryAllBalancesRequest) | [QueryAllBalancesResponse](#cosmos.bank.v1beta1.QueryAllBalancesResponse) | AllBalances queries the balance of all coins for a single account. | GET|/cosmos/bank/v1beta1/balances/{address}| +| `TotalSupply` | [QueryTotalSupplyRequest](#cosmos.bank.v1beta1.QueryTotalSupplyRequest) | [QueryTotalSupplyResponse](#cosmos.bank.v1beta1.QueryTotalSupplyResponse) | TotalSupply queries the total supply of all coins. | GET|/cosmos/bank/v1beta1/supply| +| `SupplyOf` | [QuerySupplyOfRequest](#cosmos.bank.v1beta1.QuerySupplyOfRequest) | [QuerySupplyOfResponse](#cosmos.bank.v1beta1.QuerySupplyOfResponse) | SupplyOf queries the supply of a single coin. | GET|/cosmos/bank/v1beta1/supply/{denom}| +| `Params` | [QueryParamsRequest](#cosmos.bank.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#cosmos.bank.v1beta1.QueryParamsResponse) | Params queries the parameters of x/bank module. | GET|/cosmos/bank/v1beta1/params| +| `DenomMetadata` | [QueryDenomMetadataRequest](#cosmos.bank.v1beta1.QueryDenomMetadataRequest) | [QueryDenomMetadataResponse](#cosmos.bank.v1beta1.QueryDenomMetadataResponse) | DenomsMetadata queries the client metadata of a given coin denomination. | GET|/cosmos/bank/v1beta1/denoms_metadata/{denom}| +| `DenomsMetadata` | [QueryDenomsMetadataRequest](#cosmos.bank.v1beta1.QueryDenomsMetadataRequest) | [QueryDenomsMetadataResponse](#cosmos.bank.v1beta1.QueryDenomsMetadataResponse) | DenomsMetadata queries the client metadata for all registered coin denominations. | GET|/cosmos/bank/v1beta1/denoms_metadata| + + +

Top

- +## cosmos/bank/v1beta1/tx.proto - - - + +### MsgMultiSend +MsgMultiSend represents an arbitrary multi-in, multi-out send message. - -

Top

+| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `inputs` | [Input](#cosmos.bank.v1beta1.Input) | repeated | | +| `outputs` | [Output](#cosmos.bank.v1beta1.Output) | repeated | | -## cosmos/base/store/v1beta1/snapshot.proto - -### SnapshotIAVLItem -SnapshotIAVLItem is an exported IAVL node. + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `key` | [bytes](#bytes) | | | -| `value` | [bytes](#bytes) | | | -| `version` | [int64](#int64) | | | -| `height` | [int32](#int32) | | | +### MsgMultiSendResponse +MsgMultiSendResponse defines the Msg/MultiSend response type. - + -### SnapshotItem -SnapshotItem is an item contained in a rootmulti.Store snapshot. +### MsgSend +MsgSend represents a message to send coins from one account to another. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `store` | [SnapshotStoreItem](#cosmos.base.store.v1beta1.SnapshotStoreItem) | | | -| `iavl` | [SnapshotIAVLItem](#cosmos.base.store.v1beta1.SnapshotIAVLItem) | | | - - +| `from_address` | [string](#string) | | | +| `to_address` | [string](#string) | | | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | - -### SnapshotStoreItem -SnapshotStoreItem contains metadata about a snapshotted store. + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `name` | [string](#string) | | | +### MsgSendResponse +MsgSendResponse defines the Msg/Send response type. @@ -2411,166 +2546,186 @@ SnapshotStoreItem contains metadata about a snapshotted store. + + + +### Msg +Msg defines the bank Msg service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Send` | [MsgSend](#cosmos.bank.v1beta1.MsgSend) | [MsgSendResponse](#cosmos.bank.v1beta1.MsgSendResponse) | Send defines a method for sending coins from one account to another account. | | +| `MultiSend` | [MsgMultiSend](#cosmos.bank.v1beta1.MsgMultiSend) | [MsgMultiSendResponse](#cosmos.bank.v1beta1.MsgMultiSendResponse) | MultiSend defines a method for sending coins from some accounts to other accounts. | | + - +

Top

-## cosmos/base/tendermint/v1beta1/query.proto +## cosmos/bank/v1beta1/genesis.proto - + -### GetBlockByHeightRequest -GetBlockByHeightRequest is the request type for the Query/GetBlockByHeight RPC method. +### Balance +Balance defines an account address and balance pair used in the bank module's +genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `height` | [int64](#int64) | | | +| `address` | [string](#string) | | address is the address of the balance holder. | +| `coins` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | coins defines the different coins this balance holds. | - + -### GetBlockByHeightResponse -GetBlockByHeightResponse is the response type for the Query/GetBlockByHeight RPC method. +### GenesisState +GenesisState defines the bank module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `block_id` | [tendermint.types.BlockID](#tendermint.types.BlockID) | | | -| `block` | [tendermint.types.Block](#tendermint.types.Block) | | | +| `params` | [Params](#cosmos.bank.v1beta1.Params) | | params defines all the paramaters of the module. | +| `balances` | [Balance](#cosmos.bank.v1beta1.Balance) | repeated | balances is an array containing the balances of all the accounts. | +| `supply` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | supply represents the total supply. | +| `denom_metadata` | [Metadata](#cosmos.bank.v1beta1.Metadata) | repeated | denom_metadata defines the metadata of the differents coins. | + + + - + + + -### GetLatestBlockRequest -GetLatestBlockRequest is the request type for the Query/GetLatestBlock RPC method. + +

Top

+## cosmos/authz/v1beta1/authz.proto - + -### GetLatestBlockResponse -GetLatestBlockResponse is the response type for the Query/GetLatestBlock RPC method. +### AuthorizationGrant +AuthorizationGrant gives permissions to execute +the provide method with expiration time. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `block_id` | [tendermint.types.BlockID](#tendermint.types.BlockID) | | | -| `block` | [tendermint.types.Block](#tendermint.types.Block) | | | +| `authorization` | [google.protobuf.Any](#google.protobuf.Any) | | | +| `expiration` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | - + -### GetLatestValidatorSetRequest -GetLatestValidatorSetRequest is the request type for the Query/GetValidatorSetByHeight RPC method. +### GenericAuthorization +GenericAuthorization gives the grantee unrestricted permissions to execute +the provided method on behalf of the granter's account. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an pagination for the request. | +| `method_name` | [string](#string) | | method name to grant unrestricted permissions to execute Note: MethodName() is already a method on `GenericAuthorization` type, we need some custom naming here so using `MessageName` | - + -### GetLatestValidatorSetResponse -GetLatestValidatorSetResponse is the response type for the Query/GetValidatorSetByHeight RPC method. +### SendAuthorization +SendAuthorization allows the grantee to spend up to spend_limit coins from +the granter's account. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `block_height` | [int64](#int64) | | | -| `validators` | [Validator](#cosmos.base.tendermint.v1beta1.Validator) | repeated | | -| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines an pagination for the response. | - - - - - +| `spend_limit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | - -### GetNodeInfoRequest -GetNodeInfoRequest is the request type for the Query/GetNodeInfo RPC method. + + + - + -### GetNodeInfoResponse -GetNodeInfoResponse is the request type for the Query/GetNodeInfo RPC method. -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `default_node_info` | [tendermint.p2p.DefaultNodeInfo](#tendermint.p2p.DefaultNodeInfo) | | | -| `application_version` | [VersionInfo](#cosmos.base.tendermint.v1beta1.VersionInfo) | | | + +

Top

+## cosmos/authz/v1beta1/query.proto + +### QueryAuthorizationRequest +QueryAuthorizationRequest is the request type for the Query/Authorization RPC method. - -### GetSyncingRequest -GetSyncingRequest is the request type for the Query/GetSyncing RPC method. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `granter` | [string](#string) | | | +| `grantee` | [string](#string) | | | +| `method_name` | [string](#string) | | | - + -### GetSyncingResponse -GetSyncingResponse is the response type for the Query/GetSyncing RPC method. +### QueryAuthorizationResponse +QueryAuthorizationResponse is the response type for the Query/Authorization RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `syncing` | [bool](#bool) | | | +| `authorization` | [AuthorizationGrant](#cosmos.authz.v1beta1.AuthorizationGrant) | | authorization is a authorization granted for grantee by granter. | - + -### GetValidatorSetByHeightRequest -GetValidatorSetByHeightRequest is the request type for the Query/GetValidatorSetByHeight RPC method. +### QueryAuthorizationsRequest +QueryAuthorizationsRequest is the request type for the Query/Authorizations RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `height` | [int64](#int64) | | | +| `granter` | [string](#string) | | | +| `grantee` | [string](#string) | | | | `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an pagination for the request. | @@ -2578,153 +2733,133 @@ GetValidatorSetByHeightRequest is the request type for the Query/GetValidatorSet - + -### GetValidatorSetByHeightResponse -GetValidatorSetByHeightResponse is the response type for the Query/GetValidatorSetByHeight RPC method. +### QueryAuthorizationsResponse +QueryAuthorizationsResponse is the response type for the Query/Authorizations RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `block_height` | [int64](#int64) | | | -| `validators` | [Validator](#cosmos.base.tendermint.v1beta1.Validator) | repeated | | +| `authorizations` | [AuthorizationGrant](#cosmos.authz.v1beta1.AuthorizationGrant) | repeated | authorizations is a list of grants granted for grantee by granter. | | `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines an pagination for the response. | + - - -### Module -Module is the type for VersionInfo - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `path` | [string](#string) | | module path | -| `version` | [string](#string) | | module version | -| `sum` | [string](#string) | | checksum | - - + + + - +### Query +Query defines the gRPC querier service. -### Validator -Validator is the type for the validator-set. +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Authorization` | [QueryAuthorizationRequest](#cosmos.authz.v1beta1.QueryAuthorizationRequest) | [QueryAuthorizationResponse](#cosmos.authz.v1beta1.QueryAuthorizationResponse) | Returns any `Authorization` (or `nil`), with the expiration time, granted to the grantee by the granter for the provided msg type. | GET|/cosmos/authz/v1beta1/granters/{granter}/grantees/{grantee}/grant| +| `Authorizations` | [QueryAuthorizationsRequest](#cosmos.authz.v1beta1.QueryAuthorizationsRequest) | [QueryAuthorizationsResponse](#cosmos.authz.v1beta1.QueryAuthorizationsResponse) | Returns list of `Authorization`, granted to the grantee by the granter. | GET|/cosmos/authz/v1beta1/granters/{granter}/grantees/{grantee}/grants| + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | | -| `pub_key` | [google.protobuf.Any](#google.protobuf.Any) | | | -| `voting_power` | [int64](#int64) | | | -| `proposer_priority` | [int64](#int64) | | | + +

Top

+## cosmos/authz/v1beta1/tx.proto - + -### VersionInfo -VersionInfo is the type for the GetNodeInfoResponse message. +### MsgExecAuthorizedRequest +MsgExecAuthorizedRequest attempts to execute the provided messages using +authorizations granted to the grantee. Each message should have only +one signer corresponding to the granter of the authorization. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `name` | [string](#string) | | | -| `app_name` | [string](#string) | | | -| `version` | [string](#string) | | | -| `git_commit` | [string](#string) | | | -| `build_tags` | [string](#string) | | | -| `go_version` | [string](#string) | | | -| `build_deps` | [Module](#cosmos.base.tendermint.v1beta1.Module) | repeated | | +| `grantee` | [string](#string) | | | +| `msgs` | [google.protobuf.Any](#google.protobuf.Any) | repeated | | - - + - +### MsgExecAuthorizedResponse +MsgExecAuthorizedResponse defines the Msg/MsgExecAuthorizedResponse response type. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `result` | [cosmos.base.abci.v1beta1.Result](#cosmos.base.abci.v1beta1.Result) | | | - -### Service -Service defines the gRPC querier service for tendermint queries. -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `GetNodeInfo` | [GetNodeInfoRequest](#cosmos.base.tendermint.v1beta1.GetNodeInfoRequest) | [GetNodeInfoResponse](#cosmos.base.tendermint.v1beta1.GetNodeInfoResponse) | GetNodeInfo queries the current node info. | GET|/cosmos/base/tendermint/v1beta1/node_info| -| `GetSyncing` | [GetSyncingRequest](#cosmos.base.tendermint.v1beta1.GetSyncingRequest) | [GetSyncingResponse](#cosmos.base.tendermint.v1beta1.GetSyncingResponse) | GetSyncing queries node syncing. | GET|/cosmos/base/tendermint/v1beta1/syncing| -| `GetLatestBlock` | [GetLatestBlockRequest](#cosmos.base.tendermint.v1beta1.GetLatestBlockRequest) | [GetLatestBlockResponse](#cosmos.base.tendermint.v1beta1.GetLatestBlockResponse) | GetLatestBlock returns the latest block. | GET|/cosmos/base/tendermint/v1beta1/blocks/latest| -| `GetBlockByHeight` | [GetBlockByHeightRequest](#cosmos.base.tendermint.v1beta1.GetBlockByHeightRequest) | [GetBlockByHeightResponse](#cosmos.base.tendermint.v1beta1.GetBlockByHeightResponse) | GetBlockByHeight queries block for given height. | GET|/cosmos/base/tendermint/v1beta1/blocks/{height}| -| `GetLatestValidatorSet` | [GetLatestValidatorSetRequest](#cosmos.base.tendermint.v1beta1.GetLatestValidatorSetRequest) | [GetLatestValidatorSetResponse](#cosmos.base.tendermint.v1beta1.GetLatestValidatorSetResponse) | GetLatestValidatorSet queries latest validator-set. | GET|/cosmos/base/tendermint/v1beta1/validatorsets/latest| -| `GetValidatorSetByHeight` | [GetValidatorSetByHeightRequest](#cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightRequest) | [GetValidatorSetByHeightResponse](#cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightResponse) | GetValidatorSetByHeight queries validator-set at a given height. | GET|/cosmos/base/tendermint/v1beta1/validatorsets/{height}| - + +### MsgGrantAuthorizationRequest +MsgGrantAuthorizationRequest grants the provided authorization to the grantee on the granter's +account with the provided expiration time. - -

Top

-## cosmos/capability/v1beta1/capability.proto +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `granter` | [string](#string) | | | +| `grantee` | [string](#string) | | | +| `authorization` | [google.protobuf.Any](#google.protobuf.Any) | | | +| `expiration` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | - -### Capability -Capability defines an implementation of an object capability. The index -provided to a Capability must be globally unique. -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `index` | [uint64](#uint64) | | | + + +### MsgGrantAuthorizationResponse +MsgGrantAuthorizationResponse defines the Msg/MsgGrantAuthorization response type. - + -### CapabilityOwners -CapabilityOwners defines a set of owners of a single Capability. The set of -owners must be unique. +### MsgRevokeAuthorizationRequest +MsgRevokeAuthorizationRequest revokes any authorization with the provided sdk.Msg type on the +granter's account with that has been granted to the grantee. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `owners` | [Owner](#cosmos.capability.v1beta1.Owner) | repeated | | - - +| `granter` | [string](#string) | | | +| `grantee` | [string](#string) | | | +| `method_name` | [string](#string) | | | - -### Owner -Owner defines a single capability owner. An owner is defined by the name of -capability and the module name. + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `module` | [string](#string) | | | -| `name` | [string](#string) | | | +### MsgRevokeAuthorizationResponse +MsgRevokeAuthorizationResponse defines the Msg/MsgRevokeAuthorizationResponse response type. @@ -2736,43 +2871,56 @@ capability and the module name. + + + +### Msg +Msg defines the authz Msg service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `GrantAuthorization` | [MsgGrantAuthorizationRequest](#cosmos.authz.v1beta1.MsgGrantAuthorizationRequest) | [MsgGrantAuthorizationResponse](#cosmos.authz.v1beta1.MsgGrantAuthorizationResponse) | GrantAuthorization grants the provided authorization to the grantee on the granter's account with the provided expiration time. | | +| `ExecAuthorized` | [MsgExecAuthorizedRequest](#cosmos.authz.v1beta1.MsgExecAuthorizedRequest) | [MsgExecAuthorizedResponse](#cosmos.authz.v1beta1.MsgExecAuthorizedResponse) | ExecAuthorized attempts to execute the provided messages using authorizations granted to the grantee. Each message should have only one signer corresponding to the granter of the authorization. | | +| `RevokeAuthorization` | [MsgRevokeAuthorizationRequest](#cosmos.authz.v1beta1.MsgRevokeAuthorizationRequest) | [MsgRevokeAuthorizationResponse](#cosmos.authz.v1beta1.MsgRevokeAuthorizationResponse) | RevokeAuthorization revokes any authorization corresponding to the provided method name on the granter's account that has been granted to the grantee. | | + - +

Top

-## cosmos/capability/v1beta1/genesis.proto +## cosmos/authz/v1beta1/genesis.proto - + -### GenesisOwners -GenesisOwners defines the capability owners with their corresponding index. +### GenesisState +GenesisState defines the authz module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `index` | [uint64](#uint64) | | index is the index of the capability owner. | -| `index_owners` | [CapabilityOwners](#cosmos.capability.v1beta1.CapabilityOwners) | | index_owners are the owners at the given index. | +| `authorization` | [GrantAuthorization](#cosmos.authz.v1beta1.GrantAuthorization) | repeated | | - + -### GenesisState -GenesisState defines the capability module's genesis state. +### GrantAuthorization +GrantAuthorization defines the GenesisState/GrantAuthorization type. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `index` | [uint64](#uint64) | | index is the capability global index. | -| `owners` | [GenesisOwners](#cosmos.capability.v1beta1.GenesisOwners) | repeated | owners represents a map from index to owners of the capability index index key is string to allow amino marshalling. | +| `granter` | [string](#string) | | | +| `grantee` | [string](#string) | | | +| `authorization` | [google.protobuf.Any](#google.protobuf.Any) | | | +| `expiration` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | @@ -2788,165 +2936,186 @@ GenesisState defines the capability module's genesis state. - +

Top

-## cosmos/crisis/v1beta1/genesis.proto +## cosmos/gov/v1beta1/gov.proto - + -### GenesisState -GenesisState defines the crisis module's genesis state. +### Deposit +Deposit defines an amount deposited by an account address to an active +proposal. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `constant_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | constant_fee is the fee used to verify the invariant in the crisis module. | +| `proposal_id` | [uint64](#uint64) | | | +| `depositor` | [string](#string) | | | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | - - + - +### DepositParams +DepositParams defines the params for deposits on governance proposals. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `min_deposit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | Minimum deposit for a proposal to enter voting period. | +| `max_deposit_period` | [google.protobuf.Duration](#google.protobuf.Duration) | | Maximum period for Atom holders to deposit on a proposal. Initial value: 2 months. | - -

Top

-## cosmos/crisis/v1beta1/tx.proto - + -### MsgVerifyInvariant -MsgVerifyInvariant represents a message to verify a particular invariance. +### Proposal +Proposal defines the core field members of a governance proposal. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `sender` | [string](#string) | | | -| `invariant_module_name` | [string](#string) | | | -| `invariant_route` | [string](#string) | | | - - +| `proposal_id` | [uint64](#uint64) | | | +| `content` | [google.protobuf.Any](#google.protobuf.Any) | | | +| `status` | [ProposalStatus](#cosmos.gov.v1beta1.ProposalStatus) | | | +| `final_tally_result` | [TallyResult](#cosmos.gov.v1beta1.TallyResult) | | | +| `submit_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | +| `deposit_end_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | +| `total_deposit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `voting_start_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | +| `voting_end_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | - -### MsgVerifyInvariantResponse -MsgVerifyInvariantResponse defines the Msg/VerifyInvariant response type. + +### TallyParams +TallyParams defines the params for tallying votes on governance proposals. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `quorum` | [bytes](#bytes) | | Minimum percentage of total stake needed to vote for a result to be considered valid. | +| `threshold` | [bytes](#bytes) | | Minimum proportion of Yes votes for proposal to pass. Default value: 0.5. | +| `veto_threshold` | [bytes](#bytes) | | Minimum value of Veto votes to Total votes ratio for proposal to be vetoed. Default value: 1/3. | - - - - -### Msg -Msg defines the bank Msg service. + -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `VerifyInvariant` | [MsgVerifyInvariant](#cosmos.crisis.v1beta1.MsgVerifyInvariant) | [MsgVerifyInvariantResponse](#cosmos.crisis.v1beta1.MsgVerifyInvariantResponse) | VerifyInvariant defines a method to verify a particular invariance. | | +### TallyResult +TallyResult defines a standard tally for a governance proposal. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `yes` | [string](#string) | | | +| `abstain` | [string](#string) | | | +| `no` | [string](#string) | | | +| `no_with_veto` | [string](#string) | | | - -

Top

-## cosmos/crypto/ed25519/keys.proto - + -### PrivKey -PrivKey defines a ed25519 private key. +### TextProposal +TextProposal defines a standard text proposal whose changes need to be +manually updated in case of approval. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `key` | [bytes](#bytes) | | | +| `title` | [string](#string) | | | +| `description` | [string](#string) | | | - + -### PubKey -PubKey defines a ed25519 public key -Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte -if the y-coordinate is the lexicographically largest of the two associated with -the x-coordinate. Otherwise the first byte is a 0x03. -This prefix is followed with the x-coordinate. +### Vote +Vote defines a vote on a governance proposal. +A Vote consists of a proposal ID, the voter, and the vote option. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `key` | [bytes](#bytes) | | | +| `proposal_id` | [uint64](#uint64) | | | +| `voter` | [string](#string) | | | +| `option` | [VoteOption](#cosmos.gov.v1beta1.VoteOption) | | | - - + - +### VotingParams +VotingParams defines the params for voting on governance proposals. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `voting_period` | [google.protobuf.Duration](#google.protobuf.Duration) | | Length of the voting period. | - -

Top

-## cosmos/crypto/multisig/keys.proto + - -### LegacyAminoPubKey -LegacyAminoPubKey specifies a public key type -which nests multiple public keys and a threshold, -it uses legacy amino address rules. + +### ProposalStatus +ProposalStatus enumerates the valid statuses of a proposal. -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `threshold` | [uint32](#uint32) | | | -| `public_keys` | [google.protobuf.Any](#google.protobuf.Any) | repeated | | +| Name | Number | Description | +| ---- | ------ | ----------- | +| PROPOSAL_STATUS_UNSPECIFIED | 0 | PROPOSAL_STATUS_UNSPECIFIED defines the default propopsal status. | +| PROPOSAL_STATUS_DEPOSIT_PERIOD | 1 | PROPOSAL_STATUS_DEPOSIT_PERIOD defines a proposal status during the deposit period. | +| PROPOSAL_STATUS_VOTING_PERIOD | 2 | PROPOSAL_STATUS_VOTING_PERIOD defines a proposal status during the voting period. | +| PROPOSAL_STATUS_PASSED | 3 | PROPOSAL_STATUS_PASSED defines a proposal status of a proposal that has passed. | +| PROPOSAL_STATUS_REJECTED | 4 | PROPOSAL_STATUS_REJECTED defines a proposal status of a proposal that has been rejected. | +| PROPOSAL_STATUS_FAILED | 5 | PROPOSAL_STATUS_FAILED defines a proposal status of a proposal that has failed. | + +### VoteOption +VoteOption enumerates the valid vote options for a given governance proposal. + +| Name | Number | Description | +| ---- | ------ | ----------- | +| VOTE_OPTION_UNSPECIFIED | 0 | VOTE_OPTION_UNSPECIFIED defines a no-op vote option. | +| VOTE_OPTION_YES | 1 | VOTE_OPTION_YES defines a yes vote option. | +| VOTE_OPTION_ABSTAIN | 2 | VOTE_OPTION_ABSTAIN defines an abstain vote option. | +| VOTE_OPTION_NO | 3 | VOTE_OPTION_NO defines a no vote option. | +| VOTE_OPTION_NO_WITH_VETO | 4 | VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. | - @@ -2956,492 +3125,460 @@ it uses legacy amino address rules. - +

Top

-## cosmos/crypto/multisig/v1beta1/multisig.proto +## cosmos/gov/v1beta1/query.proto - + -### CompactBitArray -CompactBitArray is an implementation of a space efficient bit array. -This is used to ensure that the encoded data takes up a minimal amount of -space after proto encoding. -This is not thread safe, and is not intended for concurrent usage. +### QueryDepositRequest +QueryDepositRequest is the request type for the Query/Deposit RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `extra_bits_stored` | [uint32](#uint32) | | | -| `elems` | [bytes](#bytes) | | | +| `proposal_id` | [uint64](#uint64) | | proposal_id defines the unique id of the proposal. | +| `depositor` | [string](#string) | | depositor defines the deposit addresses from the proposals. | - + -### MultiSignature -MultiSignature wraps the signatures from a multisig.LegacyAminoPubKey. -See cosmos.tx.v1betata1.ModeInfo.Multi for how to specify which signers -signed and with which modes. +### QueryDepositResponse +QueryDepositResponse is the response type for the Query/Deposit RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `signatures` | [bytes](#bytes) | repeated | | +| `deposit` | [Deposit](#cosmos.gov.v1beta1.Deposit) | | deposit defines the requested deposit. | - - + - +### QueryDepositsRequest +QueryDepositsRequest is the request type for the Query/Deposits RPC method. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `proposal_id` | [uint64](#uint64) | | proposal_id defines the unique id of the proposal. | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | - -

Top

-## cosmos/crypto/secp256k1/keys.proto - + -### PrivKey -PrivKey defines a secp256k1 private key. +### QueryDepositsResponse +QueryDepositsResponse is the response type for the Query/Deposits RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `key` | [bytes](#bytes) | | | +| `deposits` | [Deposit](#cosmos.gov.v1beta1.Deposit) | repeated | | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | - + -### PubKey -PubKey defines a secp256k1 public key -Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte -if the y-coordinate is the lexicographically largest of the two associated with -the x-coordinate. Otherwise the first byte is a 0x03. -This prefix is followed with the x-coordinate. +### QueryParamsRequest +QueryParamsRequest is the request type for the Query/Params RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `key` | [bytes](#bytes) | | | +| `params_type` | [string](#string) | | params_type defines which parameters to query for, can be one of "voting", "tallying" or "deposit". | - - + - +### QueryParamsResponse +QueryParamsResponse is the response type for the Query/Params RPC method. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `voting_params` | [VotingParams](#cosmos.gov.v1beta1.VotingParams) | | voting_params defines the parameters related to voting. | +| `deposit_params` | [DepositParams](#cosmos.gov.v1beta1.DepositParams) | | deposit_params defines the parameters related to deposit. | +| `tally_params` | [TallyParams](#cosmos.gov.v1beta1.TallyParams) | | tally_params defines the parameters related to tally. | - -

Top

-## cosmos/distribution/v1beta1/distribution.proto - + -### CommunityPoolSpendProposal -CommunityPoolSpendProposal details a proposal for use of community funds, -together with how many coins are proposed to be spent, and to which -recipient account. +### QueryProposalRequest +QueryProposalRequest is the request type for the Query/Proposal RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `title` | [string](#string) | | | -| `description` | [string](#string) | | | -| `recipient` | [string](#string) | | | -| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `proposal_id` | [uint64](#uint64) | | proposal_id defines the unique id of the proposal. | - + -### CommunityPoolSpendProposalWithDeposit -CommunityPoolSpendProposalWithDeposit defines a CommunityPoolSpendProposal -with a deposit +### QueryProposalResponse +QueryProposalResponse is the response type for the Query/Proposal RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `title` | [string](#string) | | | -| `description` | [string](#string) | | | -| `recipient` | [string](#string) | | | -| `amount` | [string](#string) | | | -| `deposit` | [string](#string) | | | +| `proposal` | [Proposal](#cosmos.gov.v1beta1.Proposal) | | | - + -### DelegationDelegatorReward -DelegationDelegatorReward represents the properties -of a delegator's delegation reward. +### QueryProposalsRequest +QueryProposalsRequest is the request type for the Query/Proposals RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `validator_address` | [string](#string) | | | -| `reward` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | | +| `proposal_status` | [ProposalStatus](#cosmos.gov.v1beta1.ProposalStatus) | | proposal_status defines the status of the proposals. | +| `voter` | [string](#string) | | voter defines the voter address for the proposals. | +| `depositor` | [string](#string) | | depositor defines the deposit addresses from the proposals. | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | - + -### DelegatorStartingInfo -DelegatorStartingInfo represents the starting info for a delegator reward -period. It tracks the previous validator period, the delegation's amount of -staking token, and the creation height (to check later on if any slashes have -occurred). NOTE: Even though validators are slashed to whole staking tokens, -the delegators within the validator may be left with less than a full token, -thus sdk.Dec is used. +### QueryProposalsResponse +QueryProposalsResponse is the response type for the Query/Proposals RPC +method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `previous_period` | [uint64](#uint64) | | | -| `stake` | [string](#string) | | | -| `height` | [uint64](#uint64) | | | +| `proposals` | [Proposal](#cosmos.gov.v1beta1.Proposal) | repeated | | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | - + -### FeePool -FeePool is the global fee pool for distribution. +### QueryTallyResultRequest +QueryTallyResultRequest is the request type for the Query/Tally RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `community_pool` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | | +| `proposal_id` | [uint64](#uint64) | | proposal_id defines the unique id of the proposal. | - + -### Params -Params defines the set of params for the distribution module. +### QueryTallyResultResponse +QueryTallyResultResponse is the response type for the Query/Tally RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `community_tax` | [string](#string) | | | -| `base_proposer_reward` | [string](#string) | | | -| `bonus_proposer_reward` | [string](#string) | | | -| `withdraw_addr_enabled` | [bool](#bool) | | | +| `tally` | [TallyResult](#cosmos.gov.v1beta1.TallyResult) | | tally defines the requested tally. | - + -### ValidatorAccumulatedCommission -ValidatorAccumulatedCommission represents accumulated commission -for a validator kept as a running counter, can be withdrawn at any time. +### QueryVoteRequest +QueryVoteRequest is the request type for the Query/Vote RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `commission` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | | +| `proposal_id` | [uint64](#uint64) | | proposal_id defines the unique id of the proposal. | +| `voter` | [string](#string) | | voter defines the oter address for the proposals. | - + -### ValidatorCurrentRewards -ValidatorCurrentRewards represents current rewards and current -period for a validator kept as a running counter and incremented -each block as long as the validator's tokens remain constant. +### QueryVoteResponse +QueryVoteResponse is the response type for the Query/Vote RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `rewards` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | | -| `period` | [uint64](#uint64) | | | +| `vote` | [Vote](#cosmos.gov.v1beta1.Vote) | | vote defined the queried vote. | - + -### ValidatorHistoricalRewards -ValidatorHistoricalRewards represents historical rewards for a validator. -Height is implicit within the store key. -Cumulative reward ratio is the sum from the zeroeth period -until this period of rewards / tokens, per the spec. -The reference count indicates the number of objects -which might need to reference this historical entry at any point. -ReferenceCount = - number of outstanding delegations which ended the associated period (and - might need to read that record) - + number of slashes which ended the associated period (and might need to - read that record) - + one per validator for the zeroeth period, set on initialization +### QueryVotesRequest +QueryVotesRequest is the request type for the Query/Votes RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `cumulative_reward_ratio` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | | -| `reference_count` | [uint32](#uint32) | | | +| `proposal_id` | [uint64](#uint64) | | proposal_id defines the unique id of the proposal. | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | - + -### ValidatorOutstandingRewards -ValidatorOutstandingRewards represents outstanding (un-withdrawn) rewards -for a validator inexpensive to track, allows simple sanity checks. +### QueryVotesResponse +QueryVotesResponse is the response type for the Query/Votes RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `rewards` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | | +| `votes` | [Vote](#cosmos.gov.v1beta1.Vote) | repeated | votes defined the queried votes. | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | + - + -### ValidatorSlashEvent -ValidatorSlashEvent represents a validator slash event. -Height is implicit within the store key. -This is needed to calculate appropriate amount of staking tokens -for delegations which are withdrawn after a slash has occurred. + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `validator_period` | [uint64](#uint64) | | | -| `fraction` | [string](#string) | | | + +### Query +Query defines the gRPC querier service for gov module +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Proposal` | [QueryProposalRequest](#cosmos.gov.v1beta1.QueryProposalRequest) | [QueryProposalResponse](#cosmos.gov.v1beta1.QueryProposalResponse) | Proposal queries proposal details based on ProposalID. | GET|/cosmos/gov/v1beta1/proposals/{proposal_id}| +| `Proposals` | [QueryProposalsRequest](#cosmos.gov.v1beta1.QueryProposalsRequest) | [QueryProposalsResponse](#cosmos.gov.v1beta1.QueryProposalsResponse) | Proposals queries all proposals based on given status. | GET|/cosmos/gov/v1beta1/proposals| +| `Vote` | [QueryVoteRequest](#cosmos.gov.v1beta1.QueryVoteRequest) | [QueryVoteResponse](#cosmos.gov.v1beta1.QueryVoteResponse) | Vote queries voted information based on proposalID, voterAddr. | GET|/cosmos/gov/v1beta1/proposals/{proposal_id}/votes/{voter}| +| `Votes` | [QueryVotesRequest](#cosmos.gov.v1beta1.QueryVotesRequest) | [QueryVotesResponse](#cosmos.gov.v1beta1.QueryVotesResponse) | Votes queries votes of a given proposal. | GET|/cosmos/gov/v1beta1/proposals/{proposal_id}/votes| +| `Params` | [QueryParamsRequest](#cosmos.gov.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#cosmos.gov.v1beta1.QueryParamsResponse) | Params queries all parameters of the gov module. | GET|/cosmos/gov/v1beta1/params/{params_type}| +| `Deposit` | [QueryDepositRequest](#cosmos.gov.v1beta1.QueryDepositRequest) | [QueryDepositResponse](#cosmos.gov.v1beta1.QueryDepositResponse) | Deposit queries single deposit information based proposalID, depositAddr. | GET|/cosmos/gov/v1beta1/proposals/{proposal_id}/deposits/{depositor}| +| `Deposits` | [QueryDepositsRequest](#cosmos.gov.v1beta1.QueryDepositsRequest) | [QueryDepositsResponse](#cosmos.gov.v1beta1.QueryDepositsResponse) | Deposits queries all deposits of a single proposal. | GET|/cosmos/gov/v1beta1/proposals/{proposal_id}/deposits| +| `TallyResult` | [QueryTallyResultRequest](#cosmos.gov.v1beta1.QueryTallyResultRequest) | [QueryTallyResultResponse](#cosmos.gov.v1beta1.QueryTallyResultResponse) | TallyResult queries the tally of a proposal vote. | GET|/cosmos/gov/v1beta1/proposals/{proposal_id}/tally| + - + +

Top

-### ValidatorSlashEvents -ValidatorSlashEvents is a collection of ValidatorSlashEvent messages. +## cosmos/gov/v1beta1/tx.proto -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `validator_slash_events` | [ValidatorSlashEvent](#cosmos.distribution.v1beta1.ValidatorSlashEvent) | repeated | | + +### MsgDeposit +MsgDeposit defines a message to submit a deposit to an existing proposal. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `proposal_id` | [uint64](#uint64) | | | +| `depositor` | [string](#string) | | | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | - - - - + - -

Top

+### MsgDepositResponse +MsgDepositResponse defines the Msg/Deposit response type. -## cosmos/distribution/v1beta1/genesis.proto - -### DelegatorStartingInfoRecord -DelegatorStartingInfoRecord used for import / export via genesis json. + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `delegator_address` | [string](#string) | | delegator_address is the address of the delegator. | -| `validator_address` | [string](#string) | | validator_address is the address of the validator. | -| `starting_info` | [DelegatorStartingInfo](#cosmos.distribution.v1beta1.DelegatorStartingInfo) | | starting_info defines the starting info of a delegator. | +### MsgSubmitProposal +MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary +proposal Content. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `content` | [google.protobuf.Any](#google.protobuf.Any) | | | +| `initial_deposit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `proposer` | [string](#string) | | | - + -### DelegatorWithdrawInfo -DelegatorWithdrawInfo is the address for where distributions rewards are -withdrawn to by default this struct is only used at genesis to feed in -default withdraw addresses. +### MsgSubmitProposalResponse +MsgSubmitProposalResponse defines the Msg/SubmitProposal response type. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `delegator_address` | [string](#string) | | delegator_address is the address of the delegator. | -| `withdraw_address` | [string](#string) | | withdraw_address is the address to withdraw the delegation rewards to. | +| `proposal_id` | [uint64](#uint64) | | | - + -### GenesisState -GenesisState defines the distribution module's genesis state. +### MsgVote +MsgVote defines a message to cast a vote. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#cosmos.distribution.v1beta1.Params) | | params defines all the paramaters of the module. | -| `fee_pool` | [FeePool](#cosmos.distribution.v1beta1.FeePool) | | fee_pool defines the fee pool at genesis. | -| `delegator_withdraw_infos` | [DelegatorWithdrawInfo](#cosmos.distribution.v1beta1.DelegatorWithdrawInfo) | repeated | fee_pool defines the delegator withdraw infos at genesis. | -| `previous_proposer` | [string](#string) | | fee_pool defines the previous proposer at genesis. | -| `outstanding_rewards` | [ValidatorOutstandingRewardsRecord](#cosmos.distribution.v1beta1.ValidatorOutstandingRewardsRecord) | repeated | fee_pool defines the outstanding rewards of all validators at genesis. | -| `validator_accumulated_commissions` | [ValidatorAccumulatedCommissionRecord](#cosmos.distribution.v1beta1.ValidatorAccumulatedCommissionRecord) | repeated | fee_pool defines the accumulated commisions of all validators at genesis. | -| `validator_historical_rewards` | [ValidatorHistoricalRewardsRecord](#cosmos.distribution.v1beta1.ValidatorHistoricalRewardsRecord) | repeated | fee_pool defines the historical rewards of all validators at genesis. | -| `validator_current_rewards` | [ValidatorCurrentRewardsRecord](#cosmos.distribution.v1beta1.ValidatorCurrentRewardsRecord) | repeated | fee_pool defines the current rewards of all validators at genesis. | -| `delegator_starting_infos` | [DelegatorStartingInfoRecord](#cosmos.distribution.v1beta1.DelegatorStartingInfoRecord) | repeated | fee_pool defines the delegator starting infos at genesis. | -| `validator_slash_events` | [ValidatorSlashEventRecord](#cosmos.distribution.v1beta1.ValidatorSlashEventRecord) | repeated | fee_pool defines the validator slash events at genesis. | +| `proposal_id` | [uint64](#uint64) | | | +| `voter` | [string](#string) | | | +| `option` | [VoteOption](#cosmos.gov.v1beta1.VoteOption) | | | - + -### ValidatorAccumulatedCommissionRecord -ValidatorAccumulatedCommissionRecord is used for import / export via genesis -json. +### MsgVoteResponse +MsgVoteResponse defines the Msg/Vote response type. -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `validator_address` | [string](#string) | | validator_address is the address of the validator. | -| `accumulated` | [ValidatorAccumulatedCommission](#cosmos.distribution.v1beta1.ValidatorAccumulatedCommission) | | accumulated is the accumulated commission of a validator. | + + + - -### ValidatorCurrentRewardsRecord -ValidatorCurrentRewardsRecord is used for import / export via genesis json. + +### Msg +Msg defines the bank Msg service. -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `validator_address` | [string](#string) | | validator_address is the address of the validator. | -| `rewards` | [ValidatorCurrentRewards](#cosmos.distribution.v1beta1.ValidatorCurrentRewards) | | rewards defines the current rewards of a validator. | +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `SubmitProposal` | [MsgSubmitProposal](#cosmos.gov.v1beta1.MsgSubmitProposal) | [MsgSubmitProposalResponse](#cosmos.gov.v1beta1.MsgSubmitProposalResponse) | SubmitProposal defines a method to create new proposal given a content. | | +| `Vote` | [MsgVote](#cosmos.gov.v1beta1.MsgVote) | [MsgVoteResponse](#cosmos.gov.v1beta1.MsgVoteResponse) | Vote defines a method to add a vote on a specific proposal. | | +| `Deposit` | [MsgDeposit](#cosmos.gov.v1beta1.MsgDeposit) | [MsgDepositResponse](#cosmos.gov.v1beta1.MsgDepositResponse) | Deposit defines a method to add deposit on a specific proposal. | | + + +

Top

+## cosmos/gov/v1beta1/genesis.proto - -### ValidatorHistoricalRewardsRecord -ValidatorHistoricalRewardsRecord is used for import / export via genesis -json. + + + +### GenesisState +GenesisState defines the gov module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `validator_address` | [string](#string) | | validator_address is the address of the validator. | -| `period` | [uint64](#uint64) | | period defines the period the historical rewards apply to. | -| `rewards` | [ValidatorHistoricalRewards](#cosmos.distribution.v1beta1.ValidatorHistoricalRewards) | | rewards defines the historical rewards of a validator. | +| `starting_proposal_id` | [uint64](#uint64) | | starting_proposal_id is the ID of the starting proposal. | +| `deposits` | [Deposit](#cosmos.gov.v1beta1.Deposit) | repeated | deposits defines all the deposits present at genesis. | +| `votes` | [Vote](#cosmos.gov.v1beta1.Vote) | repeated | votes defines all the votes present at genesis. | +| `proposals` | [Proposal](#cosmos.gov.v1beta1.Proposal) | repeated | proposals defines all the proposals present at genesis. | +| `deposit_params` | [DepositParams](#cosmos.gov.v1beta1.DepositParams) | | params defines all the paramaters of related to deposit. | +| `voting_params` | [VotingParams](#cosmos.gov.v1beta1.VotingParams) | | params defines all the paramaters of related to voting. | +| `tally_params` | [TallyParams](#cosmos.gov.v1beta1.TallyParams) | | params defines all the paramaters of related to tally. | + - + -### ValidatorOutstandingRewardsRecord -ValidatorOutstandingRewardsRecord is used for import/export via genesis json. + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `validator_address` | [string](#string) | | validator_address is the address of the validator. | -| `outstanding_rewards` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | outstanding_rewards represents the oustanding rewards of a validator. | + +

Top

+## cosmos/genutil/v1beta1/genesis.proto - + -### ValidatorSlashEventRecord -ValidatorSlashEventRecord is used for import / export via genesis json. +### GenesisState +GenesisState defines the raw genesis transaction in JSON. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `validator_address` | [string](#string) | | validator_address is the address of the validator. | -| `height` | [uint64](#uint64) | | height defines the block height at which the slash event occured. | -| `period` | [uint64](#uint64) | | period is the period of the slash event. | -| `validator_slash_event` | [ValidatorSlashEvent](#cosmos.distribution.v1beta1.ValidatorSlashEvent) | | validator_slash_event describes the slash event. | +| `gen_txs` | [bytes](#bytes) | repeated | gen_txs defines the genesis transactions. | @@ -3909,195 +4046,151 @@ Msg defines the distribution Msg service. - +

Top

-## cosmos/evidence/v1beta1/evidence.proto +## cosmos/distribution/v1beta1/genesis.proto - + -### Equivocation -Equivocation implements the Evidence interface and defines evidence of double -signing misbehavior. +### DelegatorStartingInfoRecord +DelegatorStartingInfoRecord used for import / export via genesis json. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `height` | [int64](#int64) | | | -| `time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | -| `power` | [int64](#int64) | | | -| `consensus_address` | [string](#string) | | | - - - - - - - - - - - - - +| `delegator_address` | [string](#string) | | delegator_address is the address of the delegator. | +| `validator_address` | [string](#string) | | validator_address is the address of the validator. | +| `starting_info` | [DelegatorStartingInfo](#cosmos.distribution.v1beta1.DelegatorStartingInfo) | | starting_info defines the starting info of a delegator. | - -

Top

-## cosmos/evidence/v1beta1/genesis.proto - + -### GenesisState -GenesisState defines the evidence module's genesis state. +### DelegatorWithdrawInfo +DelegatorWithdrawInfo is the address for where distributions rewards are +withdrawn to by default this struct is only used at genesis to feed in +default withdraw addresses. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `evidence` | [google.protobuf.Any](#google.protobuf.Any) | repeated | evidence defines all the evidence at genesis. | - - - - - - - - - - - - - +| `delegator_address` | [string](#string) | | delegator_address is the address of the delegator. | +| `withdraw_address` | [string](#string) | | withdraw_address is the address to withdraw the delegation rewards to. | - -

Top

-## cosmos/evidence/v1beta1/query.proto - + -### QueryAllEvidenceRequest -QueryEvidenceRequest is the request type for the Query/AllEvidence RPC -method. +### GenesisState +GenesisState defines the distribution module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | +| `params` | [Params](#cosmos.distribution.v1beta1.Params) | | params defines all the paramaters of the module. | +| `fee_pool` | [FeePool](#cosmos.distribution.v1beta1.FeePool) | | fee_pool defines the fee pool at genesis. | +| `delegator_withdraw_infos` | [DelegatorWithdrawInfo](#cosmos.distribution.v1beta1.DelegatorWithdrawInfo) | repeated | fee_pool defines the delegator withdraw infos at genesis. | +| `previous_proposer` | [string](#string) | | fee_pool defines the previous proposer at genesis. | +| `outstanding_rewards` | [ValidatorOutstandingRewardsRecord](#cosmos.distribution.v1beta1.ValidatorOutstandingRewardsRecord) | repeated | fee_pool defines the outstanding rewards of all validators at genesis. | +| `validator_accumulated_commissions` | [ValidatorAccumulatedCommissionRecord](#cosmos.distribution.v1beta1.ValidatorAccumulatedCommissionRecord) | repeated | fee_pool defines the accumulated commisions of all validators at genesis. | +| `validator_historical_rewards` | [ValidatorHistoricalRewardsRecord](#cosmos.distribution.v1beta1.ValidatorHistoricalRewardsRecord) | repeated | fee_pool defines the historical rewards of all validators at genesis. | +| `validator_current_rewards` | [ValidatorCurrentRewardsRecord](#cosmos.distribution.v1beta1.ValidatorCurrentRewardsRecord) | repeated | fee_pool defines the current rewards of all validators at genesis. | +| `delegator_starting_infos` | [DelegatorStartingInfoRecord](#cosmos.distribution.v1beta1.DelegatorStartingInfoRecord) | repeated | fee_pool defines the delegator starting infos at genesis. | +| `validator_slash_events` | [ValidatorSlashEventRecord](#cosmos.distribution.v1beta1.ValidatorSlashEventRecord) | repeated | fee_pool defines the validator slash events at genesis. | - + -### QueryAllEvidenceResponse -QueryAllEvidenceResponse is the response type for the Query/AllEvidence RPC -method. +### ValidatorAccumulatedCommissionRecord +ValidatorAccumulatedCommissionRecord is used for import / export via genesis +json. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `evidence` | [google.protobuf.Any](#google.protobuf.Any) | repeated | evidence returns all evidences. | -| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | +| `validator_address` | [string](#string) | | validator_address is the address of the validator. | +| `accumulated` | [ValidatorAccumulatedCommission](#cosmos.distribution.v1beta1.ValidatorAccumulatedCommission) | | accumulated is the accumulated commission of a validator. | - + -### QueryEvidenceRequest -QueryEvidenceRequest is the request type for the Query/Evidence RPC method. +### ValidatorCurrentRewardsRecord +ValidatorCurrentRewardsRecord is used for import / export via genesis json. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `evidence_hash` | [bytes](#bytes) | | evidence_hash defines the hash of the requested evidence. | +| `validator_address` | [string](#string) | | validator_address is the address of the validator. | +| `rewards` | [ValidatorCurrentRewards](#cosmos.distribution.v1beta1.ValidatorCurrentRewards) | | rewards defines the current rewards of a validator. | - + -### QueryEvidenceResponse -QueryEvidenceResponse is the response type for the Query/Evidence RPC method. +### ValidatorHistoricalRewardsRecord +ValidatorHistoricalRewardsRecord is used for import / export via genesis +json. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `evidence` | [google.protobuf.Any](#google.protobuf.Any) | | evidence returns the requested evidence. | - - - - - - - - - - - - - - -### Query -Query defines the gRPC querier service. - -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Evidence` | [QueryEvidenceRequest](#cosmos.evidence.v1beta1.QueryEvidenceRequest) | [QueryEvidenceResponse](#cosmos.evidence.v1beta1.QueryEvidenceResponse) | Evidence queries evidence based on evidence hash. | GET|/cosmos/evidence/v1beta1/evidence/{evidence_hash}| -| `AllEvidence` | [QueryAllEvidenceRequest](#cosmos.evidence.v1beta1.QueryAllEvidenceRequest) | [QueryAllEvidenceResponse](#cosmos.evidence.v1beta1.QueryAllEvidenceResponse) | AllEvidence queries all evidence. | GET|/cosmos/evidence/v1beta1/evidence| - - - +| `validator_address` | [string](#string) | | validator_address is the address of the validator. | +| `period` | [uint64](#uint64) | | period defines the period the historical rewards apply to. | +| `rewards` | [ValidatorHistoricalRewards](#cosmos.distribution.v1beta1.ValidatorHistoricalRewards) | | rewards defines the historical rewards of a validator. | - -

Top

-## cosmos/evidence/v1beta1/tx.proto - + -### MsgSubmitEvidence -MsgSubmitEvidence represents a message that supports submitting arbitrary -Evidence of misbehavior such as equivocation or counterfactual signing. +### ValidatorOutstandingRewardsRecord +ValidatorOutstandingRewardsRecord is used for import/export via genesis json. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `submitter` | [string](#string) | | | -| `evidence` | [google.protobuf.Any](#google.protobuf.Any) | | | +| `validator_address` | [string](#string) | | validator_address is the address of the validator. | +| `outstanding_rewards` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | outstanding_rewards represents the oustanding rewards of a validator. | - + -### MsgSubmitEvidenceResponse -MsgSubmitEvidenceResponse defines the Msg/SubmitEvidence response type. +### ValidatorSlashEventRecord +ValidatorSlashEventRecord is used for import / export via genesis json. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `hash` | [bytes](#bytes) | | hash defines the hash of the evidence. | +| `validator_address` | [string](#string) | | validator_address is the address of the validator. | +| `height` | [uint64](#uint64) | | height defines the block height at which the slash event occured. | +| `period` | [uint64](#uint64) | | period is the period of the slash event. | +| `validator_slash_event` | [ValidatorSlashEvent](#cosmos.distribution.v1beta1.ValidatorSlashEvent) | | validator_slash_event describes the slash event. | @@ -4109,219 +4202,234 @@ MsgSubmitEvidenceResponse defines the Msg/SubmitEvidence response type. - - - -### Msg -Msg defines the evidence Msg service. - -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `SubmitEvidence` | [MsgSubmitEvidence](#cosmos.evidence.v1beta1.MsgSubmitEvidence) | [MsgSubmitEvidenceResponse](#cosmos.evidence.v1beta1.MsgSubmitEvidenceResponse) | SubmitEvidence submits an arbitrary Evidence of misbehavior such as equivocation or counterfactual signing. | | - - +

Top

-## cosmos/fee_grant/v1beta1/fee_grant.proto +## cosmos/distribution/v1beta1/distribution.proto - + -### BasicFeeAllowance -BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens -that optionally expires. The delegatee can use up to SpendLimit to cover fees. +### CommunityPoolSpendProposal +CommunityPoolSpendProposal details a proposal for use of community funds, +together with how many coins are proposed to be spent, and to which +recipient account. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `spend_limit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | -| `expiration` | [ExpiresAt](#cosmos.fee_grant.v1beta1.ExpiresAt) | | | +| `title` | [string](#string) | | | +| `description` | [string](#string) | | | +| `recipient` | [string](#string) | | | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | - + -### Duration -Duration is a repeating unit of either clock time or number of blocks. -This is designed to be added to an ExpiresAt struct. +### CommunityPoolSpendProposalWithDeposit +CommunityPoolSpendProposalWithDeposit defines a CommunityPoolSpendProposal +with a deposit | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `duration` | [google.protobuf.Duration](#google.protobuf.Duration) | | | -| `block` | [int64](#int64) | | | +| `title` | [string](#string) | | | +| `description` | [string](#string) | | | +| `recipient` | [string](#string) | | | +| `amount` | [string](#string) | | | +| `deposit` | [string](#string) | | | - + -### ExpiresAt -ExpiresAt is a point in time where something expires. -It may be *either* block time or block height +### DelegationDelegatorReward +DelegationDelegatorReward represents the properties +of a delegator's delegation reward. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | -| `height` | [int64](#int64) | | | +| `validator_address` | [string](#string) | | | +| `reward` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | | - + -### FeeAllowanceGrant -FeeAllowanceGrant is stored in the KVStore to record a grant with full context +### DelegatorStartingInfo +DelegatorStartingInfo represents the starting info for a delegator reward +period. It tracks the previous validator period, the delegation's amount of +staking token, and the creation height (to check later on if any slashes have +occurred). NOTE: Even though validators are slashed to whole staking tokens, +the delegators within the validator may be left with less than a full token, +thus sdk.Dec is used. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `granter` | [string](#string) | | | -| `grantee` | [string](#string) | | | -| `allowance` | [google.protobuf.Any](#google.protobuf.Any) | | | +| `previous_period` | [uint64](#uint64) | | | +| `stake` | [string](#string) | | | +| `height` | [uint64](#uint64) | | | - + -### PeriodicFeeAllowance -PeriodicFeeAllowance extends FeeAllowance to allow for both a maximum cap, -as well as a limit per time period. +### FeePool +FeePool is the global fee pool for distribution. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `basic` | [BasicFeeAllowance](#cosmos.fee_grant.v1beta1.BasicFeeAllowance) | | | -| `period` | [Duration](#cosmos.fee_grant.v1beta1.Duration) | | | -| `period_spend_limit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | -| `period_can_spend` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | -| `period_reset` | [ExpiresAt](#cosmos.fee_grant.v1beta1.ExpiresAt) | | | +| `community_pool` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | | - - + - +### Params +Params defines the set of params for the distribution module. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `community_tax` | [string](#string) | | | +| `base_proposer_reward` | [string](#string) | | | +| `bonus_proposer_reward` | [string](#string) | | | +| `withdraw_addr_enabled` | [bool](#bool) | | | - -

Top

-## cosmos/fee_grant/v1beta1/genesis.proto - + -### GenesisState -GenesisState contains a set of fee allowances, persisted from the store +### ValidatorAccumulatedCommission +ValidatorAccumulatedCommission represents accumulated commission +for a validator kept as a running counter, can be withdrawn at any time. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `fee_allowances` | [FeeAllowanceGrant](#cosmos.fee_grant.v1beta1.FeeAllowanceGrant) | repeated | | +| `commission` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | | - - + - +### ValidatorCurrentRewards +ValidatorCurrentRewards represents current rewards and current +period for a validator kept as a running counter and incremented +each block as long as the validator's tokens remain constant. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `rewards` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | | +| `period` | [uint64](#uint64) | | | - -

Top

-## cosmos/fee_grant/v1beta1/query.proto - + -### QueryFeeAllowanceRequest -QueryFeeAllowanceRequest is the request type for the Query/FeeAllowance RPC method. +### ValidatorHistoricalRewards +ValidatorHistoricalRewards represents historical rewards for a validator. +Height is implicit within the store key. +Cumulative reward ratio is the sum from the zeroeth period +until this period of rewards / tokens, per the spec. +The reference count indicates the number of objects +which might need to reference this historical entry at any point. +ReferenceCount = + number of outstanding delegations which ended the associated period (and + might need to read that record) + + number of slashes which ended the associated period (and might need to + read that record) + + one per validator for the zeroeth period, set on initialization | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `granter` | [string](#string) | | | -| `grantee` | [string](#string) | | | +| `cumulative_reward_ratio` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | | +| `reference_count` | [uint32](#uint32) | | | - + -### QueryFeeAllowanceResponse -QueryFeeAllowanceResponse is the response type for the Query/FeeAllowance RPC method. +### ValidatorOutstandingRewards +ValidatorOutstandingRewards represents outstanding (un-withdrawn) rewards +for a validator inexpensive to track, allows simple sanity checks. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `fee_allowance` | [FeeAllowanceGrant](#cosmos.fee_grant.v1beta1.FeeAllowanceGrant) | | fee_allowance is a fee_allowance granted for grantee by granter. | +| `rewards` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | | - + -### QueryFeeAllowancesRequest -QueryFeeAllowancesRequest is the request type for the Query/FeeAllowances RPC method. +### ValidatorSlashEvent +ValidatorSlashEvent represents a validator slash event. +Height is implicit within the store key. +This is needed to calculate appropriate amount of staking tokens +for delegations which are withdrawn after a slash has occurred. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `grantee` | [string](#string) | | | -| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an pagination for the request. | +| `validator_period` | [uint64](#uint64) | | | +| `fraction` | [string](#string) | | | - + -### QueryFeeAllowancesResponse -QueryFeeAllowancesResponse is the response type for the Query/FeeAllowances RPC method. +### ValidatorSlashEvents +ValidatorSlashEvents is a collection of ValidatorSlashEvent messages. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `fee_allowances` | [FeeAllowanceGrant](#cosmos.fee_grant.v1beta1.FeeAllowanceGrant) | repeated | fee_allowance is a fee_allowance granted for grantee by granter. | -| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines an pagination for the response. | +| `validator_slash_events` | [ValidatorSlashEvent](#cosmos.distribution.v1beta1.ValidatorSlashEvent) | repeated | | @@ -4333,118 +4441,102 @@ QueryFeeAllowancesResponse is the response type for the Query/FeeAllowances RPC - - - -### Query -Query defines the gRPC querier service. - -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `FeeAllowance` | [QueryFeeAllowanceRequest](#cosmos.fee_grant.v1beta1.QueryFeeAllowanceRequest) | [QueryFeeAllowanceResponse](#cosmos.fee_grant.v1beta1.QueryFeeAllowanceResponse) | FeeAllowance returns fee granted to the grantee by the granter. | GET|/cosmos/feegrant/v1beta1/fee_allowance/{granter}/{grantee}| -| `FeeAllowances` | [QueryFeeAllowancesRequest](#cosmos.fee_grant.v1beta1.QueryFeeAllowancesRequest) | [QueryFeeAllowancesResponse](#cosmos.fee_grant.v1beta1.QueryFeeAllowancesResponse) | FeeAllowances returns all the grants for address. | GET|/cosmos/feegrant/v1beta1/fee_allowances/{grantee}| - - +

Top

-## cosmos/fee_grant/v1beta1/tx.proto +## cosmos/upgrade/v1beta1/query.proto - + -### MsgGrantFeeAllowance -MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance -of fees from the account of Granter. +### QueryAppliedPlanRequest +QueryCurrentPlanRequest is the request type for the Query/AppliedPlan RPC +method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `granter` | [string](#string) | | | -| `grantee` | [string](#string) | | | -| `allowance` | [google.protobuf.Any](#google.protobuf.Any) | | | - - +| `name` | [string](#string) | | name is the name of the applied plan to query for. | - -### MsgGrantFeeAllowanceResponse -MsgGrantFeeAllowanceResponse defines the Msg/GrantFeeAllowanceResponse response type. + +### QueryAppliedPlanResponse +QueryAppliedPlanResponse is the response type for the Query/AppliedPlan RPC +method. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `height` | [int64](#int64) | | height is the block height at which the plan was applied. | - -### MsgRevokeFeeAllowance -MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee. -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `granter` | [string](#string) | | | -| `grantee` | [string](#string) | | | + +### QueryCurrentPlanRequest +QueryCurrentPlanRequest is the request type for the Query/CurrentPlan RPC +method. - -### MsgRevokeFeeAllowanceResponse -MsgRevokeFeeAllowanceResponse defines the Msg/RevokeFeeAllowanceResponse response type. + +### QueryCurrentPlanResponse +QueryCurrentPlanResponse is the response type for the Query/CurrentPlan RPC +method. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `plan` | [Plan](#cosmos.upgrade.v1beta1.Plan) | | plan is the current upgrade plan. | - - - - -### Msg -Msg defines the feegrant msg service. + -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `GrantFeeAllowance` | [MsgGrantFeeAllowance](#cosmos.fee_grant.v1beta1.MsgGrantFeeAllowance) | [MsgGrantFeeAllowanceResponse](#cosmos.fee_grant.v1beta1.MsgGrantFeeAllowanceResponse) | GrantFeeAllowance grants fee allowance to the grantee on the granter's account with the provided expiration time. | | -| `RevokeFeeAllowance` | [MsgRevokeFeeAllowance](#cosmos.fee_grant.v1beta1.MsgRevokeFeeAllowance) | [MsgRevokeFeeAllowanceResponse](#cosmos.fee_grant.v1beta1.MsgRevokeFeeAllowanceResponse) | RevokeFeeAllowance revokes any fee allowance of granter's account that has been granted to the grantee. | | +### QueryUpgradedConsensusStateRequest +QueryUpgradedConsensusStateRequest is the request type for the Query/UpgradedConsensusState +RPC method. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `last_height` | [int64](#int64) | | last height of the current chain must be sent in request as this is the height under which next consensus state is stored | - -

Top

-## cosmos/genutil/v1beta1/genesis.proto - + -### GenesisState -GenesisState defines the raw genesis transaction in JSON. +### QueryUpgradedConsensusStateResponse +QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState +RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `gen_txs` | [bytes](#bytes) | repeated | gen_txs defines the genesis transactions. | +| `upgraded_consensus_state` | [google.protobuf.Any](#google.protobuf.Any) | | | @@ -4456,490 +4548,515 @@ GenesisState defines the raw genesis transaction in JSON. + + + +### Query +Query defines the gRPC upgrade querier service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `CurrentPlan` | [QueryCurrentPlanRequest](#cosmos.upgrade.v1beta1.QueryCurrentPlanRequest) | [QueryCurrentPlanResponse](#cosmos.upgrade.v1beta1.QueryCurrentPlanResponse) | CurrentPlan queries the current upgrade plan. | GET|/cosmos/upgrade/v1beta1/current_plan| +| `AppliedPlan` | [QueryAppliedPlanRequest](#cosmos.upgrade.v1beta1.QueryAppliedPlanRequest) | [QueryAppliedPlanResponse](#cosmos.upgrade.v1beta1.QueryAppliedPlanResponse) | AppliedPlan queries a previously applied upgrade plan by its name. | GET|/cosmos/upgrade/v1beta1/applied_plan/{name}| +| `UpgradedConsensusState` | [QueryUpgradedConsensusStateRequest](#cosmos.upgrade.v1beta1.QueryUpgradedConsensusStateRequest) | [QueryUpgradedConsensusStateResponse](#cosmos.upgrade.v1beta1.QueryUpgradedConsensusStateResponse) | UpgradedConsensusState queries the consensus state that will serve as a trusted kernel for the next version of this chain. It will only be stored at the last height of this chain. UpgradedConsensusState RPC not supported with legacy querier | GET|/cosmos/upgrade/v1beta1/upgraded_consensus_state/{last_height}| + - +

Top

-## cosmos/gov/v1beta1/gov.proto +## cosmos/upgrade/v1beta1/upgrade.proto - + -### Deposit -Deposit defines an amount deposited by an account address to an active -proposal. +### CancelSoftwareUpgradeProposal +CancelSoftwareUpgradeProposal is a gov Content type for cancelling a software +upgrade. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `proposal_id` | [uint64](#uint64) | | | -| `depositor` | [string](#string) | | | -| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `title` | [string](#string) | | | +| `description` | [string](#string) | | | - + -### DepositParams -DepositParams defines the params for deposits on governance proposals. +### Plan +Plan specifies information about a planned upgrade and when it should occur. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `min_deposit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | Minimum deposit for a proposal to enter voting period. | -| `max_deposit_period` | [google.protobuf.Duration](#google.protobuf.Duration) | | Maximum period for Atom holders to deposit on a proposal. Initial value: 2 months. | +| `name` | [string](#string) | | Sets the name for the upgrade. This name will be used by the upgraded version of the software to apply any special "on-upgrade" commands during the first BeginBlock method after the upgrade is applied. It is also used to detect whether a software version can handle a given upgrade. If no upgrade handler with this name has been set in the software, it will be assumed that the software is out-of-date when the upgrade Time or Height is reached and the software will exit. | +| `time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | The time after which the upgrade must be performed. Leave set to its zero value to use a pre-defined Height instead. | +| `height` | [int64](#int64) | | The height at which the upgrade must be performed. Only used if Time is not set. | +| `info` | [string](#string) | | Any application specific upgrade info to be included on-chain such as a git commit that validators could automatically upgrade to | +| `upgraded_client_state` | [google.protobuf.Any](#google.protobuf.Any) | | IBC-enabled chains can opt-in to including the upgraded client state in its upgrade plan This will make the chain commit to the correct upgraded (self) client state before the upgrade occurs, so that connecting chains can verify that the new upgraded client is valid by verifying a proof on the previous version of the chain. This will allow IBC connections to persist smoothly across planned chain upgrades | - + -### Proposal -Proposal defines the core field members of a governance proposal. +### SoftwareUpgradeProposal +SoftwareUpgradeProposal is a gov Content type for initiating a software +upgrade. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `proposal_id` | [uint64](#uint64) | | | -| `content` | [google.protobuf.Any](#google.protobuf.Any) | | | -| `status` | [ProposalStatus](#cosmos.gov.v1beta1.ProposalStatus) | | | -| `final_tally_result` | [TallyResult](#cosmos.gov.v1beta1.TallyResult) | | | -| `submit_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | -| `deposit_end_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | -| `total_deposit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | -| `voting_start_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | -| `voting_end_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | +| `title` | [string](#string) | | | +| `description` | [string](#string) | | | +| `plan` | [Plan](#cosmos.upgrade.v1beta1.Plan) | | | + - + -### TallyParams -TallyParams defines the params for tallying votes on governance proposals. + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `quorum` | [bytes](#bytes) | | Minimum percentage of total stake needed to vote for a result to be considered valid. | -| `threshold` | [bytes](#bytes) | | Minimum proportion of Yes votes for proposal to pass. Default value: 0.5. | -| `veto_threshold` | [bytes](#bytes) | | Minimum value of Veto votes to Total votes ratio for proposal to be vetoed. Default value: 1/3. | + +

Top

+## cosmos/base/kv/v1beta1/kv.proto - + -### TallyResult -TallyResult defines a standard tally for a governance proposal. +### Pair +Pair defines a key/value bytes tuple. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `yes` | [string](#string) | | | -| `abstain` | [string](#string) | | | -| `no` | [string](#string) | | | -| `no_with_veto` | [string](#string) | | | +| `key` | [bytes](#bytes) | | | +| `value` | [bytes](#bytes) | | | - + -### TextProposal -TextProposal defines a standard text proposal whose changes need to be -manually updated in case of approval. +### Pairs +Pairs defines a repeated slice of Pair objects. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `title` | [string](#string) | | | -| `description` | [string](#string) | | | +| `pairs` | [Pair](#cosmos.base.kv.v1beta1.Pair) | repeated | | + - + -### Vote -Vote defines a vote on a governance proposal. -A Vote consists of a proposal ID, the voter, and the vote option. + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `proposal_id` | [uint64](#uint64) | | | -| `voter` | [string](#string) | | | -| `option` | [VoteOption](#cosmos.gov.v1beta1.VoteOption) | | | + +

Top

+## cosmos/base/abci/v1beta1/abci.proto - + -### VotingParams -VotingParams defines the params for voting on governance proposals. +### ABCIMessageLog +ABCIMessageLog defines a structure containing an indexed tx ABCI message log. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `voting_period` | [google.protobuf.Duration](#google.protobuf.Duration) | | Length of the voting period. | - +| `msg_index` | [uint32](#uint32) | | | +| `log` | [string](#string) | | | +| `events` | [StringEvent](#cosmos.base.abci.v1beta1.StringEvent) | repeated | Events contains a slice of Event objects that were emitted during some execution. | - - + -### ProposalStatus -ProposalStatus enumerates the valid statuses of a proposal. +### Attribute +Attribute defines an attribute wrapper where the key and value are +strings instead of raw bytes. -| Name | Number | Description | -| ---- | ------ | ----------- | -| PROPOSAL_STATUS_UNSPECIFIED | 0 | PROPOSAL_STATUS_UNSPECIFIED defines the default propopsal status. | -| PROPOSAL_STATUS_DEPOSIT_PERIOD | 1 | PROPOSAL_STATUS_DEPOSIT_PERIOD defines a proposal status during the deposit period. | -| PROPOSAL_STATUS_VOTING_PERIOD | 2 | PROPOSAL_STATUS_VOTING_PERIOD defines a proposal status during the voting period. | -| PROPOSAL_STATUS_PASSED | 3 | PROPOSAL_STATUS_PASSED defines a proposal status of a proposal that has passed. | -| PROPOSAL_STATUS_REJECTED | 4 | PROPOSAL_STATUS_REJECTED defines a proposal status of a proposal that has been rejected. | -| PROPOSAL_STATUS_FAILED | 5 | PROPOSAL_STATUS_FAILED defines a proposal status of a proposal that has failed. | +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `key` | [string](#string) | | | +| `value` | [string](#string) | | | - -### VoteOption -VoteOption enumerates the valid vote options for a given governance proposal. -| Name | Number | Description | -| ---- | ------ | ----------- | -| VOTE_OPTION_UNSPECIFIED | 0 | VOTE_OPTION_UNSPECIFIED defines a no-op vote option. | -| VOTE_OPTION_YES | 1 | VOTE_OPTION_YES defines a yes vote option. | -| VOTE_OPTION_ABSTAIN | 2 | VOTE_OPTION_ABSTAIN defines an abstain vote option. | -| VOTE_OPTION_NO | 3 | VOTE_OPTION_NO defines a no vote option. | -| VOTE_OPTION_NO_WITH_VETO | 4 | VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. | - + - +### GasInfo +GasInfo defines tx execution gas context. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `gas_wanted` | [uint64](#uint64) | | GasWanted is the maximum units of work we allow this tx to perform. | +| `gas_used` | [uint64](#uint64) | | GasUsed is the amount of gas actually consumed. | - -

Top

-## cosmos/gov/v1beta1/genesis.proto - + -### GenesisState -GenesisState defines the gov module's genesis state. +### MsgData +MsgData defines the data returned in a Result object during message +execution. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `starting_proposal_id` | [uint64](#uint64) | | starting_proposal_id is the ID of the starting proposal. | -| `deposits` | [Deposit](#cosmos.gov.v1beta1.Deposit) | repeated | deposits defines all the deposits present at genesis. | -| `votes` | [Vote](#cosmos.gov.v1beta1.Vote) | repeated | votes defines all the votes present at genesis. | -| `proposals` | [Proposal](#cosmos.gov.v1beta1.Proposal) | repeated | proposals defines all the proposals present at genesis. | -| `deposit_params` | [DepositParams](#cosmos.gov.v1beta1.DepositParams) | | params defines all the paramaters of related to deposit. | -| `voting_params` | [VotingParams](#cosmos.gov.v1beta1.VotingParams) | | params defines all the paramaters of related to voting. | -| `tally_params` | [TallyParams](#cosmos.gov.v1beta1.TallyParams) | | params defines all the paramaters of related to tally. | +| `msg_type` | [string](#string) | | | +| `data` | [bytes](#bytes) | | | - - + - +### Result +Result is the union of ResponseFormat and ResponseCheckTx. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `data` | [bytes](#bytes) | | Data is any data returned from message or handler execution. It MUST be length prefixed in order to separate data from multiple message executions. | +| `log` | [string](#string) | | Log contains the log information from message or handler execution. | +| `events` | [tendermint.abci.Event](#tendermint.abci.Event) | repeated | Events contains a slice of Event objects that were emitted during message or handler execution. | - -

Top

-## cosmos/gov/v1beta1/query.proto - + -### QueryDepositRequest -QueryDepositRequest is the request type for the Query/Deposit RPC method. +### SearchTxsResult +SearchTxsResult defines a structure for querying txs pageable | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `proposal_id` | [uint64](#uint64) | | proposal_id defines the unique id of the proposal. | -| `depositor` | [string](#string) | | depositor defines the deposit addresses from the proposals. | +| `total_count` | [uint64](#uint64) | | Count of all txs | +| `count` | [uint64](#uint64) | | Count of txs in current page | +| `page_number` | [uint64](#uint64) | | Index of current page, start from 1 | +| `page_total` | [uint64](#uint64) | | Count of total pages | +| `limit` | [uint64](#uint64) | | Max count txs per page | +| `txs` | [TxResponse](#cosmos.base.abci.v1beta1.TxResponse) | repeated | List of txs in current page | - + -### QueryDepositResponse -QueryDepositResponse is the response type for the Query/Deposit RPC method. +### SimulationResponse +SimulationResponse defines the response generated when a transaction is +successfully simulated. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `deposit` | [Deposit](#cosmos.gov.v1beta1.Deposit) | | deposit defines the requested deposit. | +| `gas_info` | [GasInfo](#cosmos.base.abci.v1beta1.GasInfo) | | | +| `result` | [Result](#cosmos.base.abci.v1beta1.Result) | | | - + -### QueryDepositsRequest -QueryDepositsRequest is the request type for the Query/Deposits RPC method. +### StringEvent +StringEvent defines en Event object wrapper where all the attributes +contain key/value pairs that are strings instead of raw bytes. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `proposal_id` | [uint64](#uint64) | | proposal_id defines the unique id of the proposal. | -| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | +| `type` | [string](#string) | | | +| `attributes` | [Attribute](#cosmos.base.abci.v1beta1.Attribute) | repeated | | - + -### QueryDepositsResponse -QueryDepositsResponse is the response type for the Query/Deposits RPC method. +### TxMsgData +TxMsgData defines a list of MsgData. A transaction will have a MsgData object +for each message. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `deposits` | [Deposit](#cosmos.gov.v1beta1.Deposit) | repeated | | -| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | +| `data` | [MsgData](#cosmos.base.abci.v1beta1.MsgData) | repeated | | - + + +### TxResponse +TxResponse defines a structure containing relevant tx data and metadata. The +tags are stringified and the log is JSON decoded. -### QueryParamsRequest -QueryParamsRequest is the request type for the Query/Params RPC method. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `height` | [int64](#int64) | | The block height | +| `txhash` | [string](#string) | | The transaction hash. | +| `codespace` | [string](#string) | | Namespace for the Code | +| `code` | [uint32](#uint32) | | Response code. | +| `data` | [string](#string) | | Result bytes, if any. | +| `raw_log` | [string](#string) | | The output of the application's logger (raw string). May be non-deterministic. | +| `logs` | [ABCIMessageLog](#cosmos.base.abci.v1beta1.ABCIMessageLog) | repeated | The output of the application's logger (typed). May be non-deterministic. | +| `info` | [string](#string) | | Additional information. May be non-deterministic. | +| `gas_wanted` | [int64](#int64) | | Amount of gas requested for transaction. | +| `gas_used` | [int64](#int64) | | Amount of gas consumed by transaction. | +| `tx` | [google.protobuf.Any](#google.protobuf.Any) | | The request transaction bytes. | +| `timestamp` | [string](#string) | | Time of the previous block. For heights > 1, it's the weighted median of the timestamps of the valid votes in the block.LastCommit. For height == 1, it's genesis time. | -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `params_type` | [string](#string) | | params_type defines which parameters to query for, can be one of "voting", "tallying" or "deposit". | + + - + -### QueryParamsResponse -QueryParamsResponse is the response type for the Query/Params RPC method. + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `voting_params` | [VotingParams](#cosmos.gov.v1beta1.VotingParams) | | voting_params defines the parameters related to voting. | -| `deposit_params` | [DepositParams](#cosmos.gov.v1beta1.DepositParams) | | deposit_params defines the parameters related to deposit. | -| `tally_params` | [TallyParams](#cosmos.gov.v1beta1.TallyParams) | | tally_params defines the parameters related to tally. | + +

Top

+## cosmos/base/query/v1beta1/pagination.proto + - +### PageRequest +PageRequest is to be embedded in gRPC request messages for efficient +pagination. Ex: -### QueryProposalRequest -QueryProposalRequest is the request type for the Query/Proposal RPC method. + message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `proposal_id` | [uint64](#uint64) | | proposal_id defines the unique id of the proposal. | +| `key` | [bytes](#bytes) | | key is a value returned in PageResponse.next_key to begin querying the next page most efficiently. Only one of offset or key should be set. | +| `offset` | [uint64](#uint64) | | offset is a numeric offset that can be used when key is unavailable. It is less efficient than using key. Only one of offset or key should be set. | +| `limit` | [uint64](#uint64) | | limit is the total number of results to be returned in the result page. If left empty it will default to a value to be set by each app. | +| `count_total` | [bool](#bool) | | count_total is set to true to indicate that the result set should include a count of the total number of items available for pagination in UIs. count_total is only respected when offset is used. It is ignored when key is set. | - + -### QueryProposalResponse -QueryProposalResponse is the response type for the Query/Proposal RPC method. +### PageResponse +PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `proposal` | [Proposal](#cosmos.gov.v1beta1.Proposal) | | | +| `next_key` | [bytes](#bytes) | | next_key is the key to be passed to PageRequest.key to query the next page most efficiently | +| `total` | [uint64](#uint64) | | total is total number of results available if PageRequest.count_total was set, its value is undefined otherwise | + - + -### QueryProposalsRequest -QueryProposalsRequest is the request type for the Query/Proposals RPC method. + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `proposal_status` | [ProposalStatus](#cosmos.gov.v1beta1.ProposalStatus) | | proposal_status defines the status of the proposals. | -| `voter` | [string](#string) | | voter defines the voter address for the proposals. | -| `depositor` | [string](#string) | | depositor defines the deposit addresses from the proposals. | -| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | + +

Top

+## cosmos/base/store/v1beta1/snapshot.proto - + -### QueryProposalsResponse -QueryProposalsResponse is the response type for the Query/Proposals RPC -method. +### SnapshotIAVLItem +SnapshotIAVLItem is an exported IAVL node. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `proposals` | [Proposal](#cosmos.gov.v1beta1.Proposal) | repeated | | -| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | +| `key` | [bytes](#bytes) | | | +| `value` | [bytes](#bytes) | | | +| `version` | [int64](#int64) | | | +| `height` | [int32](#int32) | | | - + -### QueryTallyResultRequest -QueryTallyResultRequest is the request type for the Query/Tally RPC method. +### SnapshotItem +SnapshotItem is an item contained in a rootmulti.Store snapshot. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `proposal_id` | [uint64](#uint64) | | proposal_id defines the unique id of the proposal. | +| `store` | [SnapshotStoreItem](#cosmos.base.store.v1beta1.SnapshotStoreItem) | | | +| `iavl` | [SnapshotIAVLItem](#cosmos.base.store.v1beta1.SnapshotIAVLItem) | | | - + -### QueryTallyResultResponse -QueryTallyResultResponse is the response type for the Query/Tally RPC method. +### SnapshotStoreItem +SnapshotStoreItem contains metadata about a snapshotted store. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `tally` | [TallyResult](#cosmos.gov.v1beta1.TallyResult) | | tally defines the requested tally. | +| `name` | [string](#string) | | | + - + -### QueryVoteRequest -QueryVoteRequest is the request type for the Query/Vote RPC method. + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `proposal_id` | [uint64](#uint64) | | proposal_id defines the unique id of the proposal. | -| `voter` | [string](#string) | | voter defines the oter address for the proposals. | + +

Top

+## cosmos/base/store/v1beta1/commit_info.proto - + -### QueryVoteResponse -QueryVoteResponse is the response type for the Query/Vote RPC method. +### CommitID +CommitID defines the committment information when a specific store is +committed. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `vote` | [Vote](#cosmos.gov.v1beta1.Vote) | | vote defined the queried vote. | +| `version` | [int64](#int64) | | | +| `hash` | [bytes](#bytes) | | | - + -### QueryVotesRequest -QueryVotesRequest is the request type for the Query/Votes RPC method. +### CommitInfo +CommitInfo defines commit information used by the multi-store when committing +a version/height. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `proposal_id` | [uint64](#uint64) | | proposal_id defines the unique id of the proposal. | -| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | +| `version` | [int64](#int64) | | | +| `store_infos` | [StoreInfo](#cosmos.base.store.v1beta1.StoreInfo) | repeated | | - + -### QueryVotesResponse -QueryVotesResponse is the response type for the Query/Votes RPC method. +### StoreInfo +StoreInfo defines store-specific commit information. It contains a reference +between a store name and the commit ID. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `votes` | [Vote](#cosmos.gov.v1beta1.Vote) | repeated | votes defined the queried votes. | -| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | +| `name` | [string](#string) | | | +| `commit_id` | [CommitID](#cosmos.base.store.v1beta1.CommitID) | | | @@ -4951,368 +5068,324 @@ QueryVotesResponse is the response type for the Query/Votes RPC method. - - - -### Query -Query defines the gRPC querier service for gov module - -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Proposal` | [QueryProposalRequest](#cosmos.gov.v1beta1.QueryProposalRequest) | [QueryProposalResponse](#cosmos.gov.v1beta1.QueryProposalResponse) | Proposal queries proposal details based on ProposalID. | GET|/cosmos/gov/v1beta1/proposals/{proposal_id}| -| `Proposals` | [QueryProposalsRequest](#cosmos.gov.v1beta1.QueryProposalsRequest) | [QueryProposalsResponse](#cosmos.gov.v1beta1.QueryProposalsResponse) | Proposals queries all proposals based on given status. | GET|/cosmos/gov/v1beta1/proposals| -| `Vote` | [QueryVoteRequest](#cosmos.gov.v1beta1.QueryVoteRequest) | [QueryVoteResponse](#cosmos.gov.v1beta1.QueryVoteResponse) | Vote queries voted information based on proposalID, voterAddr. | GET|/cosmos/gov/v1beta1/proposals/{proposal_id}/votes/{voter}| -| `Votes` | [QueryVotesRequest](#cosmos.gov.v1beta1.QueryVotesRequest) | [QueryVotesResponse](#cosmos.gov.v1beta1.QueryVotesResponse) | Votes queries votes of a given proposal. | GET|/cosmos/gov/v1beta1/proposals/{proposal_id}/votes| -| `Params` | [QueryParamsRequest](#cosmos.gov.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#cosmos.gov.v1beta1.QueryParamsResponse) | Params queries all parameters of the gov module. | GET|/cosmos/gov/v1beta1/params/{params_type}| -| `Deposit` | [QueryDepositRequest](#cosmos.gov.v1beta1.QueryDepositRequest) | [QueryDepositResponse](#cosmos.gov.v1beta1.QueryDepositResponse) | Deposit queries single deposit information based proposalID, depositAddr. | GET|/cosmos/gov/v1beta1/proposals/{proposal_id}/deposits/{depositor}| -| `Deposits` | [QueryDepositsRequest](#cosmos.gov.v1beta1.QueryDepositsRequest) | [QueryDepositsResponse](#cosmos.gov.v1beta1.QueryDepositsResponse) | Deposits queries all deposits of a single proposal. | GET|/cosmos/gov/v1beta1/proposals/{proposal_id}/deposits| -| `TallyResult` | [QueryTallyResultRequest](#cosmos.gov.v1beta1.QueryTallyResultRequest) | [QueryTallyResultResponse](#cosmos.gov.v1beta1.QueryTallyResultResponse) | TallyResult queries the tally of a proposal vote. | GET|/cosmos/gov/v1beta1/proposals/{proposal_id}/tally| - - +

Top

-## cosmos/gov/v1beta1/tx.proto +## cosmos/base/v1beta1/coin.proto - + -### MsgDeposit -MsgDeposit defines a message to submit a deposit to an existing proposal. +### Coin +Coin defines a token with a denomination and an amount. + +NOTE: The amount field is an Int which implements the custom method +signatures required by gogoproto. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `proposal_id` | [uint64](#uint64) | | | -| `depositor` | [string](#string) | | | -| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | - - - - - - - +| `denom` | [string](#string) | | | +| `amount` | [string](#string) | | | -### MsgDepositResponse -MsgDepositResponse defines the Msg/Deposit response type. + - +### DecCoin +DecCoin defines a token with a denomination and a decimal amount. -### MsgSubmitProposal -MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary -proposal Content. +NOTE: The amount field is an Dec which implements the custom method +signatures required by gogoproto. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `content` | [google.protobuf.Any](#google.protobuf.Any) | | | -| `initial_deposit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | -| `proposer` | [string](#string) | | | +| `denom` | [string](#string) | | | +| `amount` | [string](#string) | | | - + -### MsgSubmitProposalResponse -MsgSubmitProposalResponse defines the Msg/SubmitProposal response type. +### DecProto +DecProto defines a Protobuf wrapper around a Dec object. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `proposal_id` | [uint64](#uint64) | | | +| `dec` | [string](#string) | | | - + -### MsgVote -MsgVote defines a message to cast a vote. +### IntProto +IntProto defines a Protobuf wrapper around an Int object. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `proposal_id` | [uint64](#uint64) | | | -| `voter` | [string](#string) | | | -| `option` | [VoteOption](#cosmos.gov.v1beta1.VoteOption) | | | - - +| `int` | [string](#string) | | | - -### MsgVoteResponse -MsgVoteResponse defines the Msg/Vote response type. + + + + - - + +

Top

- +## cosmos/base/tendermint/v1beta1/query.proto - -### Msg -Msg defines the bank Msg service. + -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `SubmitProposal` | [MsgSubmitProposal](#cosmos.gov.v1beta1.MsgSubmitProposal) | [MsgSubmitProposalResponse](#cosmos.gov.v1beta1.MsgSubmitProposalResponse) | SubmitProposal defines a method to create new proposal given a content. | | -| `Vote` | [MsgVote](#cosmos.gov.v1beta1.MsgVote) | [MsgVoteResponse](#cosmos.gov.v1beta1.MsgVoteResponse) | Vote defines a method to add a vote on a specific proposal. | | -| `Deposit` | [MsgDeposit](#cosmos.gov.v1beta1.MsgDeposit) | [MsgDepositResponse](#cosmos.gov.v1beta1.MsgDepositResponse) | Deposit defines a method to add deposit on a specific proposal. | | +### GetBlockByHeightRequest +GetBlockByHeightRequest is the request type for the Query/GetBlockByHeight RPC method. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `height` | [int64](#int64) | | | - -

Top

-## cosmos/mint/v1beta1/mint.proto - + -### Minter -Minter represents the minting state. +### GetBlockByHeightResponse +GetBlockByHeightResponse is the response type for the Query/GetBlockByHeight RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `inflation` | [string](#string) | | current annual inflation rate | -| `annual_provisions` | [string](#string) | | current annual expected provisions | - - +| `block_id` | [tendermint.types.BlockID](#tendermint.types.BlockID) | | | +| `block` | [tendermint.types.Block](#tendermint.types.Block) | | | - -### Params -Params holds parameters for the mint module. + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `mint_denom` | [string](#string) | | type of coin to mint | -| `inflation_rate_change` | [string](#string) | | maximum annual change in inflation rate | -| `inflation_max` | [string](#string) | | maximum inflation rate | -| `inflation_min` | [string](#string) | | minimum inflation rate | -| `goal_bonded` | [string](#string) | | goal of percent bonded atoms | -| `blocks_per_year` | [uint64](#uint64) | | expected blocks per year | +### GetLatestBlockRequest +GetLatestBlockRequest is the request type for the Query/GetLatestBlock RPC method. - - + - +### GetLatestBlockResponse +GetLatestBlockResponse is the response type for the Query/GetLatestBlock RPC method. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `block_id` | [tendermint.types.BlockID](#tendermint.types.BlockID) | | | +| `block` | [tendermint.types.Block](#tendermint.types.Block) | | | - -

Top

-## cosmos/mint/v1beta1/genesis.proto - + -### GenesisState -GenesisState defines the mint module's genesis state. +### GetLatestValidatorSetRequest +GetLatestValidatorSetRequest is the request type for the Query/GetValidatorSetByHeight RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `minter` | [Minter](#cosmos.mint.v1beta1.Minter) | | minter is a space for holding current inflation information. | -| `params` | [Params](#cosmos.mint.v1beta1.Params) | | params defines all the paramaters of the module. | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an pagination for the request. | - - + - +### GetLatestValidatorSetResponse +GetLatestValidatorSetResponse is the response type for the Query/GetValidatorSetByHeight RPC method. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `block_height` | [int64](#int64) | | | +| `validators` | [Validator](#cosmos.base.tendermint.v1beta1.Validator) | repeated | | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines an pagination for the response. | - -

Top

-## cosmos/mint/v1beta1/query.proto - + -### QueryAnnualProvisionsRequest -QueryAnnualProvisionsRequest is the request type for the -Query/AnnualProvisions RPC method. +### GetNodeInfoRequest +GetNodeInfoRequest is the request type for the Query/GetNodeInfo RPC method. - + -### QueryAnnualProvisionsResponse -QueryAnnualProvisionsResponse is the response type for the -Query/AnnualProvisions RPC method. +### GetNodeInfoResponse +GetNodeInfoResponse is the request type for the Query/GetNodeInfo RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `annual_provisions` | [bytes](#bytes) | | annual_provisions is the current minting annual provisions value. | +| `default_node_info` | [tendermint.p2p.DefaultNodeInfo](#tendermint.p2p.DefaultNodeInfo) | | | +| `application_version` | [VersionInfo](#cosmos.base.tendermint.v1beta1.VersionInfo) | | | - + -### QueryInflationRequest -QueryInflationRequest is the request type for the Query/Inflation RPC method. +### GetSyncingRequest +GetSyncingRequest is the request type for the Query/GetSyncing RPC method. - + -### QueryInflationResponse -QueryInflationResponse is the response type for the Query/Inflation RPC -method. +### GetSyncingResponse +GetSyncingResponse is the response type for the Query/GetSyncing RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `inflation` | [bytes](#bytes) | | inflation is the current minting inflation value. | - - +| `syncing` | [bool](#bool) | | | - -### QueryParamsRequest -QueryParamsRequest is the request type for the Query/Params RPC method. + +### GetValidatorSetByHeightRequest +GetValidatorSetByHeightRequest is the request type for the Query/GetValidatorSetByHeight RPC method. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `height` | [int64](#int64) | | | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an pagination for the request. | - -### QueryParamsResponse -QueryParamsResponse is the response type for the Query/Params RPC method. -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `params` | [Params](#cosmos.mint.v1beta1.Params) | | params defines the parameters of the module. | + +### GetValidatorSetByHeightResponse +GetValidatorSetByHeightResponse is the response type for the Query/GetValidatorSetByHeight RPC method. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `block_height` | [int64](#int64) | | | +| `validators` | [Validator](#cosmos.base.tendermint.v1beta1.Validator) | repeated | | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines an pagination for the response. | - - - - -### Query -Query provides defines the gRPC querier service. + -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Params` | [QueryParamsRequest](#cosmos.mint.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#cosmos.mint.v1beta1.QueryParamsResponse) | Params returns the total set of minting parameters. | GET|/cosmos/mint/v1beta1/params| -| `Inflation` | [QueryInflationRequest](#cosmos.mint.v1beta1.QueryInflationRequest) | [QueryInflationResponse](#cosmos.mint.v1beta1.QueryInflationResponse) | Inflation returns the current minting inflation value. | GET|/cosmos/mint/v1beta1/inflation| -| `AnnualProvisions` | [QueryAnnualProvisionsRequest](#cosmos.mint.v1beta1.QueryAnnualProvisionsRequest) | [QueryAnnualProvisionsResponse](#cosmos.mint.v1beta1.QueryAnnualProvisionsResponse) | AnnualProvisions current minting annual provisions value. | GET|/cosmos/mint/v1beta1/annual_provisions| +### Module +Module is the type for VersionInfo - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `path` | [string](#string) | | module path | +| `version` | [string](#string) | | module version | +| `sum` | [string](#string) | | checksum | - -

Top

-## cosmos/params/v1beta1/params.proto - + -### ParamChange -ParamChange defines an individual parameter change, for use in -ParameterChangeProposal. +### Validator +Validator is the type for the validator-set. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `subspace` | [string](#string) | | | -| `key` | [string](#string) | | | -| `value` | [string](#string) | | | +| `address` | [string](#string) | | | +| `pub_key` | [google.protobuf.Any](#google.protobuf.Any) | | | +| `voting_power` | [int64](#int64) | | | +| `proposer_priority` | [int64](#int64) | | | - + -### ParameterChangeProposal -ParameterChangeProposal defines a proposal to change one or more parameters. +### VersionInfo +VersionInfo is the type for the GetNodeInfoResponse message. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `title` | [string](#string) | | | -| `description` | [string](#string) | | | -| `changes` | [ParamChange](#cosmos.params.v1beta1.ParamChange) | repeated | | +| `name` | [string](#string) | | | +| `app_name` | [string](#string) | | | +| `version` | [string](#string) | | | +| `git_commit` | [string](#string) | | | +| `build_tags` | [string](#string) | | | +| `go_version` | [string](#string) | | | +| `build_deps` | [Module](#cosmos.base.tendermint.v1beta1.Module) | repeated | | @@ -5324,42 +5397,60 @@ ParameterChangeProposal defines a proposal to change one or more parameters. + + + +### Service +Service defines the gRPC querier service for tendermint queries. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `GetNodeInfo` | [GetNodeInfoRequest](#cosmos.base.tendermint.v1beta1.GetNodeInfoRequest) | [GetNodeInfoResponse](#cosmos.base.tendermint.v1beta1.GetNodeInfoResponse) | GetNodeInfo queries the current node info. | GET|/cosmos/base/tendermint/v1beta1/node_info| +| `GetSyncing` | [GetSyncingRequest](#cosmos.base.tendermint.v1beta1.GetSyncingRequest) | [GetSyncingResponse](#cosmos.base.tendermint.v1beta1.GetSyncingResponse) | GetSyncing queries node syncing. | GET|/cosmos/base/tendermint/v1beta1/syncing| +| `GetLatestBlock` | [GetLatestBlockRequest](#cosmos.base.tendermint.v1beta1.GetLatestBlockRequest) | [GetLatestBlockResponse](#cosmos.base.tendermint.v1beta1.GetLatestBlockResponse) | GetLatestBlock returns the latest block. | GET|/cosmos/base/tendermint/v1beta1/blocks/latest| +| `GetBlockByHeight` | [GetBlockByHeightRequest](#cosmos.base.tendermint.v1beta1.GetBlockByHeightRequest) | [GetBlockByHeightResponse](#cosmos.base.tendermint.v1beta1.GetBlockByHeightResponse) | GetBlockByHeight queries block for given height. | GET|/cosmos/base/tendermint/v1beta1/blocks/{height}| +| `GetLatestValidatorSet` | [GetLatestValidatorSetRequest](#cosmos.base.tendermint.v1beta1.GetLatestValidatorSetRequest) | [GetLatestValidatorSetResponse](#cosmos.base.tendermint.v1beta1.GetLatestValidatorSetResponse) | GetLatestValidatorSet queries latest validator-set. | GET|/cosmos/base/tendermint/v1beta1/validatorsets/latest| +| `GetValidatorSetByHeight` | [GetValidatorSetByHeightRequest](#cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightRequest) | [GetValidatorSetByHeightResponse](#cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightResponse) | GetValidatorSetByHeight queries validator-set at a given height. | GET|/cosmos/base/tendermint/v1beta1/validatorsets/{height}| + - +

Top

-## cosmos/params/v1beta1/query.proto +## cosmos/base/snapshots/v1beta1/snapshot.proto - + -### QueryParamsRequest -QueryParamsRequest is request type for the Query/Params RPC method. +### Metadata +Metadata contains SDK-specific snapshot metadata. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `subspace` | [string](#string) | | subspace defines the module to query the parameter for. | -| `key` | [string](#string) | | key defines the key of the parameter in the subspace. | +| `chunk_hashes` | [bytes](#bytes) | repeated | SHA-256 chunk hashes | - + -### QueryParamsResponse -QueryParamsResponse is response type for the Query/Params RPC method. +### Snapshot +Snapshot contains Tendermint state sync snapshot info. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `param` | [ParamChange](#cosmos.params.v1beta1.ParamChange) | | param defines the queried parameter. | +| `height` | [uint64](#uint64) | | | +| `format` | [uint32](#uint32) | | | +| `chunks` | [uint32](#uint32) | | | +| `hash` | [bytes](#bytes) | | | +| `metadata` | [Metadata](#cosmos.base.snapshots.v1beta1.Metadata) | | | @@ -5371,143 +5462,135 @@ QueryParamsResponse is response type for the Query/Params RPC method. - - - -### Query -Query defines the gRPC querier service. - -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Params` | [QueryParamsRequest](#cosmos.params.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#cosmos.params.v1beta1.QueryParamsResponse) | Params queries a specific parameter of a module, given its subspace and key. | GET|/cosmos/params/v1beta1/params| - - +

Top

-## cosmos/slashing/v1beta1/slashing.proto - - - - +## cosmos/base/reflection/v1beta1/reflection.proto -### Params -Params represents the parameters used for by the slashing module. -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `signed_blocks_window` | [int64](#int64) | | | -| `min_signed_per_window` | [bytes](#bytes) | | | -| `downtime_jail_duration` | [google.protobuf.Duration](#google.protobuf.Duration) | | | -| `slash_fraction_double_sign` | [bytes](#bytes) | | | -| `slash_fraction_downtime` | [bytes](#bytes) | | | + +### ListAllInterfacesRequest +ListAllInterfacesRequest is the request type of the ListAllInterfaces RPC. - -### ValidatorSigningInfo -ValidatorSigningInfo defines a validator's signing info for monitoring their -liveness activity. + +### ListAllInterfacesResponse +ListAllInterfacesResponse is the response type of the ListAllInterfaces RPC. -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | | -| `start_height` | [int64](#int64) | | Height at which validator was first a candidate OR was unjailed | -| `index_offset` | [int64](#int64) | | Index which is incremented each time the validator was a bonded in a block and may have signed a precommit or not. This in conjunction with the `SignedBlocksWindow` param determines the index in the `MissedBlocksBitArray`. | -| `jailed_until` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | Timestamp until which the validator is jailed due to liveness downtime. | -| `tombstoned` | [bool](#bool) | | Whether or not a validator has been tombstoned (killed out of validator set). It is set once the validator commits an equivocation or for any other configured misbehiavor. | -| `missed_blocks_counter` | [int64](#int64) | | A counter kept to avoid unnecessary array reads. Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`. | +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `interface_names` | [string](#string) | repeated | interface_names is an array of all the registered interfaces. | - - - + - +### ListImplementationsRequest +ListImplementationsRequest is the request type of the ListImplementations +RPC. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `interface_name` | [string](#string) | | interface_name defines the interface to query the implementations for. | - -

Top

-## cosmos/slashing/v1beta1/genesis.proto - -### GenesisState -GenesisState defines the slashing module's genesis state. + + +### ListImplementationsResponse +ListImplementationsResponse is the response type of the ListImplementations +RPC. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#cosmos.slashing.v1beta1.Params) | | params defines all the paramaters of related to deposit. | -| `signing_infos` | [SigningInfo](#cosmos.slashing.v1beta1.SigningInfo) | repeated | signing_infos represents a map between validator addresses and their signing infos. | -| `missed_blocks` | [ValidatorMissedBlocks](#cosmos.slashing.v1beta1.ValidatorMissedBlocks) | repeated | signing_infos represents a map between validator addresses and their missed blocks. | +| `implementation_message_names` | [string](#string) | repeated | | + - + -### MissedBlock -MissedBlock contains height and missed status as boolean. + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `index` | [int64](#int64) | | index is the height at which the block was missed. | -| `missed` | [bool](#bool) | | missed is the missed status. | + +### ReflectionService +ReflectionService defines a service for interface reflection. +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `ListAllInterfaces` | [ListAllInterfacesRequest](#cosmos.base.reflection.v1beta1.ListAllInterfacesRequest) | [ListAllInterfacesResponse](#cosmos.base.reflection.v1beta1.ListAllInterfacesResponse) | ListAllInterfaces lists all the interfaces registered in the interface registry. | GET|/cosmos/base/reflection/v1beta1/interfaces| +| `ListImplementations` | [ListImplementationsRequest](#cosmos.base.reflection.v1beta1.ListImplementationsRequest) | [ListImplementationsResponse](#cosmos.base.reflection.v1beta1.ListImplementationsResponse) | ListImplementations list all the concrete types that implement a given interface. | GET|/cosmos/base/reflection/v1beta1/interfaces/{interface_name}/implementations| + - + +

Top

-### SigningInfo -SigningInfo stores validator signing info of corresponding address. +## cosmos/slashing/v1beta1/slashing.proto + + + + + +### Params +Params represents the parameters used for by the slashing module. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | address is the validator address. | -| `validator_signing_info` | [ValidatorSigningInfo](#cosmos.slashing.v1beta1.ValidatorSigningInfo) | | validator_signing_info represents the signing info of this validator. | +| `signed_blocks_window` | [int64](#int64) | | | +| `min_signed_per_window` | [bytes](#bytes) | | | +| `downtime_jail_duration` | [google.protobuf.Duration](#google.protobuf.Duration) | | | +| `slash_fraction_double_sign` | [bytes](#bytes) | | | +| `slash_fraction_downtime` | [bytes](#bytes) | | | - + -### ValidatorMissedBlocks -ValidatorMissedBlocks contains array of missed blocks of corresponding -address. +### ValidatorSigningInfo +ValidatorSigningInfo defines a validator's signing info for monitoring their +liveness activity. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | address is the validator address. | -| `missed_blocks` | [MissedBlock](#cosmos.slashing.v1beta1.MissedBlock) | repeated | missed_blocks is an array of missed blocks by the validator. | +| `address` | [string](#string) | | | +| `start_height` | [int64](#int64) | | Height at which validator was first a candidate OR was unjailed | +| `index_offset` | [int64](#int64) | | Index which is incremented each time the validator was a bonded in a block and may have signed a precommit or not. This in conjunction with the `SignedBlocksWindow` param determines the index in the `MissedBlocksBitArray`. | +| `jailed_until` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | Timestamp until which the validator is jailed due to liveness downtime. | +| `tombstoned` | [bool](#bool) | | Whether or not a validator has been tombstoned (killed out of validator set). It is set once the validator commits an equivocation or for any other configured misbehiavor. | +| `missed_blocks_counter` | [int64](#int64) | | A counter kept to avoid unnecessary array reads. Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`. | @@ -5692,375 +5775,430 @@ Msg defines the slashing Msg service. - +

Top

-## cosmos/staking/v1beta1/staking.proto +## cosmos/slashing/v1beta1/genesis.proto - + -### Commission -Commission defines commission parameters for a given validator. +### GenesisState +GenesisState defines the slashing module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `commission_rates` | [CommissionRates](#cosmos.staking.v1beta1.CommissionRates) | | | -| `update_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | +| `params` | [Params](#cosmos.slashing.v1beta1.Params) | | params defines all the paramaters of related to deposit. | +| `signing_infos` | [SigningInfo](#cosmos.slashing.v1beta1.SigningInfo) | repeated | signing_infos represents a map between validator addresses and their signing infos. | +| `missed_blocks` | [ValidatorMissedBlocks](#cosmos.slashing.v1beta1.ValidatorMissedBlocks) | repeated | signing_infos represents a map between validator addresses and their missed blocks. | - + -### CommissionRates -CommissionRates defines the initial commission rates to be used for creating -a validator. +### MissedBlock +MissedBlock contains height and missed status as boolean. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `rate` | [string](#string) | | | -| `max_rate` | [string](#string) | | | -| `max_change_rate` | [string](#string) | | | +| `index` | [int64](#int64) | | index is the height at which the block was missed. | +| `missed` | [bool](#bool) | | missed is the missed status. | - + -### DVPair -DVPair is struct that just has a delegator-validator pair with no other data. -It is intended to be used as a marshalable pointer. For example, a DVPair can -be used to construct the key to getting an UnbondingDelegation from state. +### SigningInfo +SigningInfo stores validator signing info of corresponding address. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `delegator_address` | [string](#string) | | | -| `validator_address` | [string](#string) | | | +| `address` | [string](#string) | | address is the validator address. | +| `validator_signing_info` | [ValidatorSigningInfo](#cosmos.slashing.v1beta1.ValidatorSigningInfo) | | validator_signing_info represents the signing info of this validator. | - + -### DVPairs -DVPairs defines an array of DVPair objects. +### ValidatorMissedBlocks +ValidatorMissedBlocks contains array of missed blocks of corresponding +address. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `pairs` | [DVPair](#cosmos.staking.v1beta1.DVPair) | repeated | | +| `address` | [string](#string) | | address is the validator address. | +| `missed_blocks` | [MissedBlock](#cosmos.slashing.v1beta1.MissedBlock) | repeated | missed_blocks is an array of missed blocks by the validator. | + - + + + + + -### DVVTriplet -DVVTriplet is struct that just has a delegator-validator-validator triplet -with no other data. It is intended to be used as a marshalable pointer. For -example, a DVVTriplet can be used to construct the key to getting a -Redelegation from state. + + + +

Top

+ +## cosmos/evidence/v1beta1/evidence.proto + + + + + +### Equivocation +Equivocation implements the Evidence interface and defines evidence of double +signing misbehavior. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `delegator_address` | [string](#string) | | | -| `validator_src_address` | [string](#string) | | | -| `validator_dst_address` | [string](#string) | | | +| `height` | [int64](#int64) | | | +| `time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | +| `power` | [int64](#int64) | | | +| `consensus_address` | [string](#string) | | | + - + -### DVVTriplets -DVVTriplets defines an array of DVVTriplet objects. + + + + + + + +

Top

+ +## cosmos/evidence/v1beta1/query.proto + + + + + +### QueryAllEvidenceRequest +QueryEvidenceRequest is the request type for the Query/AllEvidence RPC +method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `triplets` | [DVVTriplet](#cosmos.staking.v1beta1.DVVTriplet) | repeated | | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | - + -### Delegation -Delegation represents the bond with tokens held by an account. It is -owned by one delegator, and is associated with the voting power of one -validator. +### QueryAllEvidenceResponse +QueryAllEvidenceResponse is the response type for the Query/AllEvidence RPC +method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `delegator_address` | [string](#string) | | | -| `validator_address` | [string](#string) | | | -| `shares` | [string](#string) | | | +| `evidence` | [google.protobuf.Any](#google.protobuf.Any) | repeated | evidence returns all evidences. | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | + + + + + + + + +### QueryEvidenceRequest +QueryEvidenceRequest is the request type for the Query/Evidence RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `evidence_hash` | [bytes](#bytes) | | evidence_hash defines the hash of the requested evidence. | + + + + + + + + +### QueryEvidenceResponse +QueryEvidenceResponse is the response type for the Query/Evidence RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `evidence` | [google.protobuf.Any](#google.protobuf.Any) | | evidence returns the requested evidence. | + + + + + + + + + + + + + + +### Query +Query defines the gRPC querier service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Evidence` | [QueryEvidenceRequest](#cosmos.evidence.v1beta1.QueryEvidenceRequest) | [QueryEvidenceResponse](#cosmos.evidence.v1beta1.QueryEvidenceResponse) | Evidence queries evidence based on evidence hash. | GET|/cosmos/evidence/v1beta1/evidence/{evidence_hash}| +| `AllEvidence` | [QueryAllEvidenceRequest](#cosmos.evidence.v1beta1.QueryAllEvidenceRequest) | [QueryAllEvidenceResponse](#cosmos.evidence.v1beta1.QueryAllEvidenceResponse) | AllEvidence queries all evidence. | GET|/cosmos/evidence/v1beta1/evidence| + + + +

Top

+## cosmos/evidence/v1beta1/tx.proto - -### DelegationResponse -DelegationResponse is equivalent to Delegation except that it contains a -balance in addition to shares which is more suitable for client responses. + + +### MsgSubmitEvidence +MsgSubmitEvidence represents a message that supports submitting arbitrary +Evidence of misbehavior such as equivocation or counterfactual signing. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `delegation` | [Delegation](#cosmos.staking.v1beta1.Delegation) | | | -| `balance` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | +| `submitter` | [string](#string) | | | +| `evidence` | [google.protobuf.Any](#google.protobuf.Any) | | | - + -### Description -Description defines a validator description. +### MsgSubmitEvidenceResponse +MsgSubmitEvidenceResponse defines the Msg/SubmitEvidence response type. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `moniker` | [string](#string) | | | -| `identity` | [string](#string) | | | -| `website` | [string](#string) | | | -| `security_contact` | [string](#string) | | | -| `details` | [string](#string) | | | +| `hash` | [bytes](#bytes) | | hash defines the hash of the evidence. | + - + -### HistoricalInfo -HistoricalInfo contains header and validator information for a given block. -It is stored as part of staking module's state, which persists the `n` most -recent HistoricalInfo -(`n` is set by the staking module's `historical_entries` parameter). + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `header` | [tendermint.types.Header](#tendermint.types.Header) | | | -| `valset` | [Validator](#cosmos.staking.v1beta1.Validator) | repeated | | + + +### Msg +Msg defines the evidence Msg service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `SubmitEvidence` | [MsgSubmitEvidence](#cosmos.evidence.v1beta1.MsgSubmitEvidence) | [MsgSubmitEvidenceResponse](#cosmos.evidence.v1beta1.MsgSubmitEvidenceResponse) | SubmitEvidence submits an arbitrary Evidence of misbehavior such as equivocation or counterfactual signing. | | + + +

Top

+## cosmos/evidence/v1beta1/genesis.proto - -### Params -Params defines the parameters for the staking module. + + + +### GenesisState +GenesisState defines the evidence module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `unbonding_time` | [google.protobuf.Duration](#google.protobuf.Duration) | | | -| `max_validators` | [uint32](#uint32) | | | -| `max_entries` | [uint32](#uint32) | | | -| `historical_entries` | [uint32](#uint32) | | | -| `bond_denom` | [string](#string) | | | +| `evidence` | [google.protobuf.Any](#google.protobuf.Any) | repeated | evidence defines all the evidence at genesis. | + - + -### Pool -Pool is used for tracking bonded and not-bonded token supply of the bond -denomination. + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `not_bonded_tokens` | [string](#string) | | | -| `bonded_tokens` | [string](#string) | | | + +

Top

+## cosmos/auth/v1beta1/auth.proto - + -### Redelegation -Redelegation contains the list of a particular delegator's redelegating bonds -from a particular source validator to a particular destination validator. +### BaseAccount +BaseAccount defines a base account type. It contains all the necessary fields +for basic account functionality. Any custom account type should extend this +type for additional functionality (e.g. vesting). | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `delegator_address` | [string](#string) | | | -| `validator_src_address` | [string](#string) | | | -| `validator_dst_address` | [string](#string) | | | -| `entries` | [RedelegationEntry](#cosmos.staking.v1beta1.RedelegationEntry) | repeated | redelegation entries | +| `address` | [string](#string) | | | +| `pub_key` | [google.protobuf.Any](#google.protobuf.Any) | | | +| `account_number` | [uint64](#uint64) | | | +| `sequence` | [uint64](#uint64) | | | - + -### RedelegationEntry -RedelegationEntry defines a redelegation object with relevant metadata. +### ModuleAccount +ModuleAccount defines an account for modules that holds coins on a pool. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `creation_height` | [int64](#int64) | | | -| `completion_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | -| `initial_balance` | [string](#string) | | | -| `shares_dst` | [string](#string) | | | +| `base_account` | [BaseAccount](#cosmos.auth.v1beta1.BaseAccount) | | | +| `name` | [string](#string) | | | +| `permissions` | [string](#string) | repeated | | - + -### RedelegationEntryResponse -RedelegationEntryResponse is equivalent to a RedelegationEntry except that it -contains a balance in addition to shares which is more suitable for client -responses. +### Params +Params defines the parameters for the auth module. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `redelegation_entry` | [RedelegationEntry](#cosmos.staking.v1beta1.RedelegationEntry) | | | -| `balance` | [string](#string) | | | +| `max_memo_characters` | [uint64](#uint64) | | | +| `tx_sig_limit` | [uint64](#uint64) | | | +| `tx_size_cost_per_byte` | [uint64](#uint64) | | | +| `sig_verify_cost_ed25519` | [uint64](#uint64) | | | +| `sig_verify_cost_secp256k1` | [uint64](#uint64) | | | + - + -### RedelegationResponse -RedelegationResponse is equivalent to a Redelegation except that its entries -contain a balance in addition to shares which is more suitable for client -responses. + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `redelegation` | [Redelegation](#cosmos.staking.v1beta1.Redelegation) | | | -| `entries` | [RedelegationEntryResponse](#cosmos.staking.v1beta1.RedelegationEntryResponse) | repeated | | + +

Top

+## cosmos/auth/v1beta1/query.proto - + -### UnbondingDelegation -UnbondingDelegation stores all of a single delegator's unbonding bonds -for a single validator in an time-ordered list. +### QueryAccountRequest +QueryAccountRequest is the request type for the Query/Account RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `delegator_address` | [string](#string) | | | -| `validator_address` | [string](#string) | | | -| `entries` | [UnbondingDelegationEntry](#cosmos.staking.v1beta1.UnbondingDelegationEntry) | repeated | unbonding delegation entries | +| `address` | [string](#string) | | address defines the address to query for. | - + -### UnbondingDelegationEntry -UnbondingDelegationEntry defines an unbonding object with relevant metadata. +### QueryAccountResponse +QueryAccountResponse is the response type for the Query/Account RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `creation_height` | [int64](#int64) | | | -| `completion_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | -| `initial_balance` | [string](#string) | | | -| `balance` | [string](#string) | | | - - +| `account` | [google.protobuf.Any](#google.protobuf.Any) | | account defines the account of the corresponding address. | - -### ValAddresses -ValAddresses defines a repeated set of validator addresses. + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `addresses` | [string](#string) | repeated | | +### QueryParamsRequest +QueryParamsRequest is the request type for the Query/Params RPC method. - + -### Validator -Validator defines a validator, together with the total amount of the -Validator's bond shares and their exchange rate to coins. Slashing results in -a decrease in the exchange rate, allowing correct calculation of future -undelegations without iterating over delegators. When coins are delegated to -this validator, the validator is credited with a delegation whose number of -bond shares is based on the amount of coins delegated divided by the current -exchange rate. Voting power can be calculated as total bonded shares -multiplied by exchange rate. +### QueryParamsResponse +QueryParamsResponse is the response type for the Query/Params RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `operator_address` | [string](#string) | | | -| `consensus_pubkey` | [google.protobuf.Any](#google.protobuf.Any) | | | -| `jailed` | [bool](#bool) | | | -| `status` | [BondStatus](#cosmos.staking.v1beta1.BondStatus) | | | -| `tokens` | [string](#string) | | | -| `delegator_shares` | [string](#string) | | | -| `description` | [Description](#cosmos.staking.v1beta1.Description) | | | -| `unbonding_height` | [int64](#int64) | | | -| `unbonding_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | -| `commission` | [Commission](#cosmos.staking.v1beta1.Commission) | | | -| `min_self_delegation` | [string](#string) | | | +| `params` | [Params](#cosmos.auth.v1beta1.Params) | | params defines the parameters of the module. | @@ -6068,67 +6206,42 @@ multiplied by exchange rate. + - - -### BondStatus -BondStatus is the status of a validator. + -| Name | Number | Description | -| ---- | ------ | ----------- | -| BOND_STATUS_UNSPECIFIED | 0 | UNSPECIFIED defines an invalid validator status. | -| BOND_STATUS_UNBONDED | 1 | UNBONDED defines a validator that is not bonded. | -| BOND_STATUS_UNBONDING | 2 | UNBONDING defines a validator that is unbonding. | -| BOND_STATUS_BONDED | 3 | BONDED defines a validator that is bonded. | + - +### Query +Query defines the gRPC querier service. - +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Account` | [QueryAccountRequest](#cosmos.auth.v1beta1.QueryAccountRequest) | [QueryAccountResponse](#cosmos.auth.v1beta1.QueryAccountResponse) | Account returns account details based on address. | GET|/cosmos/auth/v1beta1/accounts/{address}| +| `Params` | [QueryParamsRequest](#cosmos.auth.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#cosmos.auth.v1beta1.QueryParamsResponse) | Params queries all parameters. | GET|/cosmos/auth/v1beta1/params| - +

Top

-## cosmos/staking/v1beta1/genesis.proto +## cosmos/auth/v1beta1/genesis.proto - + ### GenesisState -GenesisState defines the staking module's genesis state. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `params` | [Params](#cosmos.staking.v1beta1.Params) | | params defines all the paramaters of related to deposit. | -| `last_total_power` | [bytes](#bytes) | | last_total_power tracks the total amounts of bonded tokens recorded during the previous end block. | -| `last_validator_powers` | [LastValidatorPower](#cosmos.staking.v1beta1.LastValidatorPower) | repeated | last_validator_powers is a special index that provides a historical list of the last-block's bonded validators. | -| `validators` | [Validator](#cosmos.staking.v1beta1.Validator) | repeated | delegations defines the validator set at genesis. | -| `delegations` | [Delegation](#cosmos.staking.v1beta1.Delegation) | repeated | delegations defines the delegations active at genesis. | -| `unbonding_delegations` | [UnbondingDelegation](#cosmos.staking.v1beta1.UnbondingDelegation) | repeated | unbonding_delegations defines the unbonding delegations active at genesis. | -| `redelegations` | [Redelegation](#cosmos.staking.v1beta1.Redelegation) | repeated | redelegations defines the redelegations active at genesis. | -| `exported` | [bool](#bool) | | | - - - - - - - - -### LastValidatorPower -LastValidatorPower required for validator set update logic. +GenesisState defines the auth module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | address is the address of the validator. | -| `power` | [int64](#int64) | | power defines the power of the validator. | +| `params` | [Params](#cosmos.auth.v1beta1.Params) | | params defines all the paramaters of the module. | +| `accounts` | [google.protobuf.Any](#google.protobuf.Any) | repeated | accounts are the accounts present at genesis. | @@ -6630,483 +6743,229 @@ Query defines the gRPC querier service. - -

Top

- -## cosmos/staking/v1beta1/tx.proto - - - - - -### MsgBeginRedelegate -MsgBeginRedelegate defines a SDK message for performing a redelegation -of coins from a delegator and source validator to a destination validator. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `delegator_address` | [string](#string) | | | -| `validator_src_address` | [string](#string) | | | -| `validator_dst_address` | [string](#string) | | | -| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | - - - - - - - - -### MsgBeginRedelegateResponse -MsgBeginRedelegateResponse defines the Msg/BeginRedelegate response type. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `completion_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | - - - - - - - - -### MsgCreateValidator -MsgCreateValidator defines a SDK message for creating a new validator. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `description` | [Description](#cosmos.staking.v1beta1.Description) | | | -| `commission` | [CommissionRates](#cosmos.staking.v1beta1.CommissionRates) | | | -| `min_self_delegation` | [string](#string) | | | -| `delegator_address` | [string](#string) | | | -| `validator_address` | [string](#string) | | | -| `pubkey` | [google.protobuf.Any](#google.protobuf.Any) | | | -| `value` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | - - - - - - - - -### MsgCreateValidatorResponse -MsgCreateValidatorResponse defines the Msg/CreateValidator response type. - - - - - - - - -### MsgDelegate -MsgDelegate defines a SDK message for performing a delegation of coins -from a delegator to a validator. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `delegator_address` | [string](#string) | | | -| `validator_address` | [string](#string) | | | -| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | - - - - - - - - -### MsgDelegateResponse -MsgDelegateResponse defines the Msg/Delegate response type. - - - - - - - - -### MsgEditValidator -MsgEditValidator defines a SDK message for editing an existing validator. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `description` | [Description](#cosmos.staking.v1beta1.Description) | | | -| `validator_address` | [string](#string) | | | -| `commission_rate` | [string](#string) | | We pass a reference to the new commission rate and min self delegation as it's not mandatory to update. If not updated, the deserialized rate will be zero with no way to distinguish if an update was intended. REF: #2373 | -| `min_self_delegation` | [string](#string) | | | - - - - - - - - -### MsgEditValidatorResponse -MsgEditValidatorResponse defines the Msg/EditValidator response type. - - - - - - - - -### MsgUndelegate -MsgUndelegate defines a SDK message for performing an undelegation from a -delegate and a validator. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `delegator_address` | [string](#string) | | | -| `validator_address` | [string](#string) | | | -| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | - - - - - - - - -### MsgUndelegateResponse -MsgUndelegateResponse defines the Msg/Undelegate response type. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `completion_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | - - - - - - - - - - - - - - -### Msg -Msg defines the staking Msg service. - -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `CreateValidator` | [MsgCreateValidator](#cosmos.staking.v1beta1.MsgCreateValidator) | [MsgCreateValidatorResponse](#cosmos.staking.v1beta1.MsgCreateValidatorResponse) | CreateValidator defines a method for creating a new validator. | | -| `EditValidator` | [MsgEditValidator](#cosmos.staking.v1beta1.MsgEditValidator) | [MsgEditValidatorResponse](#cosmos.staking.v1beta1.MsgEditValidatorResponse) | EditValidator defines a method for editing an existing validator. | | -| `Delegate` | [MsgDelegate](#cosmos.staking.v1beta1.MsgDelegate) | [MsgDelegateResponse](#cosmos.staking.v1beta1.MsgDelegateResponse) | Delegate defines a method for performing a delegation of coins from a delegator to a validator. | | -| `BeginRedelegate` | [MsgBeginRedelegate](#cosmos.staking.v1beta1.MsgBeginRedelegate) | [MsgBeginRedelegateResponse](#cosmos.staking.v1beta1.MsgBeginRedelegateResponse) | BeginRedelegate defines a method for performing a redelegation of coins from a delegator and source validator to a destination validator. | | -| `Undelegate` | [MsgUndelegate](#cosmos.staking.v1beta1.MsgUndelegate) | [MsgUndelegateResponse](#cosmos.staking.v1beta1.MsgUndelegateResponse) | Undelegate defines a method for performing an undelegation from a delegate and a validator. | | - - - - - - -

Top

- -## cosmos/tx/signing/v1beta1/signing.proto - - - - - -### SignatureDescriptor -SignatureDescriptor is a convenience type which represents the full data for -a signature including the public key of the signer, signing modes and the -signature itself. It is primarily used for coordinating signatures between -clients. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `public_key` | [google.protobuf.Any](#google.protobuf.Any) | | public_key is the public key of the signer | -| `data` | [SignatureDescriptor.Data](#cosmos.tx.signing.v1beta1.SignatureDescriptor.Data) | | | -| `sequence` | [uint64](#uint64) | | sequence is the sequence of the account, which describes the number of committed transactions signed by a given address. It is used to prevent replay attacks. | - - - - - - - - -### SignatureDescriptor.Data -Data represents signature data - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `single` | [SignatureDescriptor.Data.Single](#cosmos.tx.signing.v1beta1.SignatureDescriptor.Data.Single) | | single represents a single signer | -| `multi` | [SignatureDescriptor.Data.Multi](#cosmos.tx.signing.v1beta1.SignatureDescriptor.Data.Multi) | | multi represents a multisig signer | - - - - - - - - -### SignatureDescriptor.Data.Multi -Multi is the signature data for a multisig public key - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `bitarray` | [cosmos.crypto.multisig.v1beta1.CompactBitArray](#cosmos.crypto.multisig.v1beta1.CompactBitArray) | | bitarray specifies which keys within the multisig are signing | -| `signatures` | [SignatureDescriptor.Data](#cosmos.tx.signing.v1beta1.SignatureDescriptor.Data) | repeated | signatures is the signatures of the multi-signature | - - - - - - - - -### SignatureDescriptor.Data.Single -Single is the signature data for a single signer - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `mode` | [SignMode](#cosmos.tx.signing.v1beta1.SignMode) | | mode is the signing mode of the single signer | -| `signature` | [bytes](#bytes) | | signature is the raw signature bytes | - - + +

Top

+## cosmos/staking/v1beta1/tx.proto - + -### SignatureDescriptors -SignatureDescriptors wraps multiple SignatureDescriptor's. +### MsgBeginRedelegate +MsgBeginRedelegate defines a SDK message for performing a redelegation +of coins from a delegator and source validator to a destination validator. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `signatures` | [SignatureDescriptor](#cosmos.tx.signing.v1beta1.SignatureDescriptor) | repeated | signatures are the signature descriptors | +| `delegator_address` | [string](#string) | | | +| `validator_src_address` | [string](#string) | | | +| `validator_dst_address` | [string](#string) | | | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | - + - +### MsgBeginRedelegateResponse +MsgBeginRedelegateResponse defines the Msg/BeginRedelegate response type. -### SignMode -SignMode represents a signing mode with its own security guarantees. -| Name | Number | Description | -| ---- | ------ | ----------- | -| SIGN_MODE_UNSPECIFIED | 0 | SIGN_MODE_UNSPECIFIED specifies an unknown signing mode and will be rejected | -| SIGN_MODE_DIRECT | 1 | SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is verified with raw bytes from Tx | -| SIGN_MODE_TEXTUAL | 2 | SIGN_MODE_TEXTUAL is a future signing mode that will verify some human-readable textual representation on top of the binary representation from SIGN_MODE_DIRECT | -| SIGN_MODE_LEGACY_AMINO_JSON | 127 | SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses Amino JSON and will be removed in the future | +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `completion_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | - - - + - -

Top

+### MsgCreateValidator +MsgCreateValidator defines a SDK message for creating a new validator. -## cosmos/tx/v1beta1/tx.proto +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `description` | [Description](#cosmos.staking.v1beta1.Description) | | | +| `commission` | [CommissionRates](#cosmos.staking.v1beta1.CommissionRates) | | | +| `min_self_delegation` | [string](#string) | | | +| `delegator_address` | [string](#string) | | | +| `validator_address` | [string](#string) | | | +| `pubkey` | [google.protobuf.Any](#google.protobuf.Any) | | | +| `value` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | - -### AuthInfo -AuthInfo describes the fee and signer modes that are used to sign a -transaction. -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `signer_infos` | [SignerInfo](#cosmos.tx.v1beta1.SignerInfo) | repeated | signer_infos defines the signing modes for the required signers. The number and order of elements must match the required signers from TxBody's messages. The first element is the primary signer and the one which pays the fee. | -| `fee` | [Fee](#cosmos.tx.v1beta1.Fee) | | Fee is the fee and gas limit for the transaction. The first signer is the primary signer and the one which pays the fee. The fee can be calculated based on the cost of evaluating the body and doing signature verification of the signers. This can be estimated via simulation. | + +### MsgCreateValidatorResponse +MsgCreateValidatorResponse defines the Msg/CreateValidator response type. - -### Fee -Fee includes the amount of coins paid in fees and the maximum -gas to be used by the transaction. The ratio yields an effective "gasprice", -which must be above some miminum to be accepted into the mempool. + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | amount is the amount of coins to be paid as a fee | -| `gas_limit` | [uint64](#uint64) | | gas_limit is the maximum gas that can be used in transaction processing before an out of gas error occurs | -| `payer` | [string](#string) | | if unset, the first signer is responsible for paying the fees. If set, the specified account must pay the fees. the payer must be a tx signer (and thus have signed this field in AuthInfo). setting this field does *not* change the ordering of required signers for the transaction. | -| `granter` | [string](#string) | | if set, the fee payer (either the first signer or the value of the payer field) requests that a fee grant be used to pay fees instead of the fee payer's own balance. If an appropriate fee grant does not exist or the chain does not support fee grants, this will fail | +### MsgDelegate +MsgDelegate defines a SDK message for performing a delegation of coins +from a delegator to a validator. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `delegator_address` | [string](#string) | | | +| `validator_address` | [string](#string) | | | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | - -### ModeInfo -ModeInfo describes the signing mode of a single or nested multisig signer. + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `single` | [ModeInfo.Single](#cosmos.tx.v1beta1.ModeInfo.Single) | | single represents a single signer | -| `multi` | [ModeInfo.Multi](#cosmos.tx.v1beta1.ModeInfo.Multi) | | multi represents a nested multisig signer | +### MsgDelegateResponse +MsgDelegateResponse defines the Msg/Delegate response type. - + -### ModeInfo.Multi -Multi is the mode info for a multisig public key +### MsgEditValidator +MsgEditValidator defines a SDK message for editing an existing validator. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `bitarray` | [cosmos.crypto.multisig.v1beta1.CompactBitArray](#cosmos.crypto.multisig.v1beta1.CompactBitArray) | | bitarray specifies which keys within the multisig are signing | -| `mode_infos` | [ModeInfo](#cosmos.tx.v1beta1.ModeInfo) | repeated | mode_infos is the corresponding modes of the signers of the multisig which could include nested multisig public keys | - - +| `description` | [Description](#cosmos.staking.v1beta1.Description) | | | +| `validator_address` | [string](#string) | | | +| `commission_rate` | [string](#string) | | We pass a reference to the new commission rate and min self delegation as it's not mandatory to update. If not updated, the deserialized rate will be zero with no way to distinguish if an update was intended. REF: #2373 | +| `min_self_delegation` | [string](#string) | | | - -### ModeInfo.Single -Single is the mode info for a single signer. It is structured as a message -to allow for additional fields such as locale for SIGN_MODE_TEXTUAL in the -future + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `mode` | [cosmos.tx.signing.v1beta1.SignMode](#cosmos.tx.signing.v1beta1.SignMode) | | mode is the signing mode of the single signer | +### MsgEditValidatorResponse +MsgEditValidatorResponse defines the Msg/EditValidator response type. - + -### SignDoc -SignDoc is the type used for generating sign bytes for SIGN_MODE_DIRECT. +### MsgUndelegate +MsgUndelegate defines a SDK message for performing an undelegation from a +delegate and a validator. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `body_bytes` | [bytes](#bytes) | | body_bytes is protobuf serialization of a TxBody that matches the representation in TxRaw. | -| `auth_info_bytes` | [bytes](#bytes) | | auth_info_bytes is a protobuf serialization of an AuthInfo that matches the representation in TxRaw. | -| `chain_id` | [string](#string) | | chain_id is the unique identifier of the chain this transaction targets. It prevents signed transactions from being used on another chain by an attacker | -| `account_number` | [uint64](#uint64) | | account_number is the account number of the account in state | +| `delegator_address` | [string](#string) | | | +| `validator_address` | [string](#string) | | | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | - + -### SignerInfo -SignerInfo describes the public key and signing mode of a single top-level -signer. +### MsgUndelegateResponse +MsgUndelegateResponse defines the Msg/Undelegate response type. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `public_key` | [google.protobuf.Any](#google.protobuf.Any) | | public_key is the public key of the signer. It is optional for accounts that already exist in state. If unset, the verifier can use the required \ signer address for this position and lookup the public key. | -| `mode_info` | [ModeInfo](#cosmos.tx.v1beta1.ModeInfo) | | mode_info describes the signing mode of the signer and is a nested structure to support nested multisig pubkey's | -| `sequence` | [uint64](#uint64) | | sequence is the sequence of the account, which describes the number of committed transactions signed by a given address. It is used to prevent replay attacks. | +| `completion_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | + - + -### Tx -Tx is the standard type used for broadcasting transactions. + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `body` | [TxBody](#cosmos.tx.v1beta1.TxBody) | | body is the processable content of the transaction | -| `auth_info` | [AuthInfo](#cosmos.tx.v1beta1.AuthInfo) | | auth_info is the authorization related content of the transaction, specifically signers, signer modes and fee | -| `signatures` | [bytes](#bytes) | repeated | signatures is a list of signatures that matches the length and order of AuthInfo's signer_infos to allow connecting signature meta information like public key and signing mode by position. | + + +### Msg +Msg defines the staking Msg service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `CreateValidator` | [MsgCreateValidator](#cosmos.staking.v1beta1.MsgCreateValidator) | [MsgCreateValidatorResponse](#cosmos.staking.v1beta1.MsgCreateValidatorResponse) | CreateValidator defines a method for creating a new validator. | | +| `EditValidator` | [MsgEditValidator](#cosmos.staking.v1beta1.MsgEditValidator) | [MsgEditValidatorResponse](#cosmos.staking.v1beta1.MsgEditValidatorResponse) | EditValidator defines a method for editing an existing validator. | | +| `Delegate` | [MsgDelegate](#cosmos.staking.v1beta1.MsgDelegate) | [MsgDelegateResponse](#cosmos.staking.v1beta1.MsgDelegateResponse) | Delegate defines a method for performing a delegation of coins from a delegator to a validator. | | +| `BeginRedelegate` | [MsgBeginRedelegate](#cosmos.staking.v1beta1.MsgBeginRedelegate) | [MsgBeginRedelegateResponse](#cosmos.staking.v1beta1.MsgBeginRedelegateResponse) | BeginRedelegate defines a method for performing a redelegation of coins from a delegator and source validator to a destination validator. | | +| `Undelegate` | [MsgUndelegate](#cosmos.staking.v1beta1.MsgUndelegate) | [MsgUndelegateResponse](#cosmos.staking.v1beta1.MsgUndelegateResponse) | Undelegate defines a method for performing an undelegation from a delegate and a validator. | | + + +

Top

+## cosmos/staking/v1beta1/genesis.proto - -### TxBody -TxBody is the body of a transaction that all signers sign over. + + + +### GenesisState +GenesisState defines the staking module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `messages` | [google.protobuf.Any](#google.protobuf.Any) | repeated | messages is a list of messages to be executed. The required signers of those messages define the number and order of elements in AuthInfo's signer_infos and Tx's signatures. Each required signer address is added to the list only the first time it occurs. By convention, the first required signer (usually from the first message) is referred to as the primary signer and pays the fee for the whole transaction. | -| `memo` | [string](#string) | | memo is any arbitrary memo to be added to the transaction | -| `timeout_height` | [uint64](#uint64) | | timeout is the block height after which this transaction will not be processed by the chain | -| `extension_options` | [google.protobuf.Any](#google.protobuf.Any) | repeated | extension_options are arbitrary options that can be added by chains when the default options are not sufficient. If any of these are present and can't be handled, the transaction will be rejected | -| `non_critical_extension_options` | [google.protobuf.Any](#google.protobuf.Any) | repeated | extension_options are arbitrary options that can be added by chains when the default options are not sufficient. If any of these are present and can't be handled, they will be ignored | +| `params` | [Params](#cosmos.staking.v1beta1.Params) | | params defines all the paramaters of related to deposit. | +| `last_total_power` | [bytes](#bytes) | | last_total_power tracks the total amounts of bonded tokens recorded during the previous end block. | +| `last_validator_powers` | [LastValidatorPower](#cosmos.staking.v1beta1.LastValidatorPower) | repeated | last_validator_powers is a special index that provides a historical list of the last-block's bonded validators. | +| `validators` | [Validator](#cosmos.staking.v1beta1.Validator) | repeated | delegations defines the validator set at genesis. | +| `delegations` | [Delegation](#cosmos.staking.v1beta1.Delegation) | repeated | delegations defines the delegations active at genesis. | +| `unbonding_delegations` | [UnbondingDelegation](#cosmos.staking.v1beta1.UnbondingDelegation) | repeated | unbonding_delegations defines the unbonding delegations active at genesis. | +| `redelegations` | [Redelegation](#cosmos.staking.v1beta1.Redelegation) | repeated | redelegations defines the redelegations active at genesis. | +| `exported` | [bool](#bool) | | | - + -### TxRaw -TxRaw is a variant of Tx that pins the signer's exact binary representation -of body and auth_info. This is used for signing, broadcasting and -verification. The binary `serialize(tx: TxRaw)` is stored in Tendermint and -the hash `sha256(serialize(tx: TxRaw))` becomes the "txhash", commonly used -as the transaction ID. +### LastValidatorPower +LastValidatorPower required for validator set update logic. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `body_bytes` | [bytes](#bytes) | | body_bytes is a protobuf serialization of a TxBody that matches the representation in SignDoc. | -| `auth_info_bytes` | [bytes](#bytes) | | auth_info_bytes is a protobuf serialization of an AuthInfo that matches the representation in SignDoc. | -| `signatures` | [bytes](#bytes) | repeated | signatures is a list of signatures that matches the length and order of AuthInfo's signer_infos to allow connecting signature meta information like public key and signing mode by position. | +| `address` | [string](#string) | | address is the address of the validator. | +| `power` | [int64](#int64) | | power defines the power of the validator. | @@ -7122,344 +6981,375 @@ as the transaction ID. - +

Top

-## cosmos/tx/v1beta1/service.proto +## cosmos/staking/v1beta1/staking.proto - + -### BroadcastTxRequest -BroadcastTxRequest is the request type for the Service.BroadcastTxRequest -RPC method. +### Commission +Commission defines commission parameters for a given validator. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `tx_bytes` | [bytes](#bytes) | | tx_bytes is the raw transaction. | -| `mode` | [BroadcastMode](#cosmos.tx.v1beta1.BroadcastMode) | | | +| `commission_rates` | [CommissionRates](#cosmos.staking.v1beta1.CommissionRates) | | | +| `update_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | - + -### BroadcastTxResponse -BroadcastTxResponse is the response type for the -Service.BroadcastTx method. +### CommissionRates +CommissionRates defines the initial commission rates to be used for creating +a validator. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `tx_response` | [cosmos.base.abci.v1beta1.TxResponse](#cosmos.base.abci.v1beta1.TxResponse) | | tx_response is the queried TxResponses. | +| `rate` | [string](#string) | | | +| `max_rate` | [string](#string) | | | +| `max_change_rate` | [string](#string) | | | - + -### GetTxRequest -GetTxRequest is the request type for the Service.GetTx -RPC method. +### DVPair +DVPair is struct that just has a delegator-validator pair with no other data. +It is intended to be used as a marshalable pointer. For example, a DVPair can +be used to construct the key to getting an UnbondingDelegation from state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `hash` | [string](#string) | | hash is the tx hash to query, encoded as a hex string. | +| `delegator_address` | [string](#string) | | | +| `validator_address` | [string](#string) | | | - + -### GetTxResponse -GetTxResponse is the response type for the Service.GetTx method. +### DVPairs +DVPairs defines an array of DVPair objects. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `tx` | [Tx](#cosmos.tx.v1beta1.Tx) | | tx is the queried transaction. | -| `tx_response` | [cosmos.base.abci.v1beta1.TxResponse](#cosmos.base.abci.v1beta1.TxResponse) | | tx_response is the queried TxResponses. | +| `pairs` | [DVPair](#cosmos.staking.v1beta1.DVPair) | repeated | | - + -### GetTxsEventRequest -GetTxsEventRequest is the request type for the Service.TxsByEvents -RPC method. +### DVVTriplet +DVVTriplet is struct that just has a delegator-validator-validator triplet +with no other data. It is intended to be used as a marshalable pointer. For +example, a DVVTriplet can be used to construct the key to getting a +Redelegation from state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `events` | [string](#string) | repeated | events is the list of transaction event type. | -| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an pagination for the request. | +| `delegator_address` | [string](#string) | | | +| `validator_src_address` | [string](#string) | | | +| `validator_dst_address` | [string](#string) | | | - + -### GetTxsEventResponse -GetTxsEventResponse is the response type for the Service.TxsByEvents -RPC method. +### DVVTriplets +DVVTriplets defines an array of DVVTriplet objects. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `txs` | [Tx](#cosmos.tx.v1beta1.Tx) | repeated | txs is the list of queried transactions. | -| `tx_responses` | [cosmos.base.abci.v1beta1.TxResponse](#cosmos.base.abci.v1beta1.TxResponse) | repeated | tx_responses is the list of queried TxResponses. | -| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines an pagination for the response. | +| `triplets` | [DVVTriplet](#cosmos.staking.v1beta1.DVVTriplet) | repeated | | - + -### SimulateRequest -SimulateRequest is the request type for the Service.Simulate -RPC method. +### Delegation +Delegation represents the bond with tokens held by an account. It is +owned by one delegator, and is associated with the voting power of one +validator. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `tx` | [Tx](#cosmos.tx.v1beta1.Tx) | | tx is the transaction to simulate. | +| `delegator_address` | [string](#string) | | | +| `validator_address` | [string](#string) | | | +| `shares` | [string](#string) | | | - + -### SimulateResponse -SimulateResponse is the response type for the -Service.SimulateRPC method. +### DelegationResponse +DelegationResponse is equivalent to Delegation except that it contains a +balance in addition to shares which is more suitable for client responses. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `gas_info` | [cosmos.base.abci.v1beta1.GasInfo](#cosmos.base.abci.v1beta1.GasInfo) | | gas_info is the information about gas used in the simulation. | -| `result` | [cosmos.base.abci.v1beta1.Result](#cosmos.base.abci.v1beta1.Result) | | result is the result of the simulation. | +| `delegation` | [Delegation](#cosmos.staking.v1beta1.Delegation) | | | +| `balance` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | - + - +### Description +Description defines a validator description. -### BroadcastMode -BroadcastMode specifies the broadcast mode for the TxService.Broadcast RPC method. -| Name | Number | Description | -| ---- | ------ | ----------- | -| BROADCAST_MODE_UNSPECIFIED | 0 | zero-value for mode ordering | -| BROADCAST_MODE_BLOCK | 1 | BROADCAST_MODE_BLOCK defines a tx broadcasting mode where the client waits for the tx to be committed in a block. | -| BROADCAST_MODE_SYNC | 2 | BROADCAST_MODE_SYNC defines a tx broadcasting mode where the client waits for a CheckTx execution response only. | -| BROADCAST_MODE_ASYNC | 3 | BROADCAST_MODE_ASYNC defines a tx broadcasting mode where the client returns immediately. | +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `moniker` | [string](#string) | | | +| `identity` | [string](#string) | | | +| `website` | [string](#string) | | | +| `security_contact` | [string](#string) | | | +| `details` | [string](#string) | | | - - - -### Service -Service defines a gRPC service for interacting with transactions. + -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Simulate` | [SimulateRequest](#cosmos.tx.v1beta1.SimulateRequest) | [SimulateResponse](#cosmos.tx.v1beta1.SimulateResponse) | Simulate simulates executing a transaction for estimating gas usage. | POST|/cosmos/tx/v1beta1/simulate| -| `GetTx` | [GetTxRequest](#cosmos.tx.v1beta1.GetTxRequest) | [GetTxResponse](#cosmos.tx.v1beta1.GetTxResponse) | GetTx fetches a tx by hash. | GET|/cosmos/tx/v1beta1/txs/{hash}| -| `BroadcastTx` | [BroadcastTxRequest](#cosmos.tx.v1beta1.BroadcastTxRequest) | [BroadcastTxResponse](#cosmos.tx.v1beta1.BroadcastTxResponse) | BroadcastTx broadcast transaction. | POST|/cosmos/tx/v1beta1/txs| -| `GetTxsEvent` | [GetTxsEventRequest](#cosmos.tx.v1beta1.GetTxsEventRequest) | [GetTxsEventResponse](#cosmos.tx.v1beta1.GetTxsEventResponse) | GetTxsEvent fetches txs by event. | GET|/cosmos/tx/v1beta1/txs| +### HistoricalInfo +HistoricalInfo contains header and validator information for a given block. +It is stored as part of staking module's state, which persists the `n` most +recent HistoricalInfo +(`n` is set by the staking module's `historical_entries` parameter). - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `header` | [tendermint.types.Header](#tendermint.types.Header) | | | +| `valset` | [Validator](#cosmos.staking.v1beta1.Validator) | repeated | | - -

Top

-## cosmos/upgrade/v1beta1/upgrade.proto - + -### CancelSoftwareUpgradeProposal -CancelSoftwareUpgradeProposal is a gov Content type for cancelling a software -upgrade. +### Params +Params defines the parameters for the staking module. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `title` | [string](#string) | | | -| `description` | [string](#string) | | | +| `unbonding_time` | [google.protobuf.Duration](#google.protobuf.Duration) | | | +| `max_validators` | [uint32](#uint32) | | | +| `max_entries` | [uint32](#uint32) | | | +| `historical_entries` | [uint32](#uint32) | | | +| `bond_denom` | [string](#string) | | | - + -### Plan -Plan specifies information about a planned upgrade and when it should occur. +### Pool +Pool is used for tracking bonded and not-bonded token supply of the bond +denomination. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `name` | [string](#string) | | Sets the name for the upgrade. This name will be used by the upgraded version of the software to apply any special "on-upgrade" commands during the first BeginBlock method after the upgrade is applied. It is also used to detect whether a software version can handle a given upgrade. If no upgrade handler with this name has been set in the software, it will be assumed that the software is out-of-date when the upgrade Time or Height is reached and the software will exit. | -| `time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | The time after which the upgrade must be performed. Leave set to its zero value to use a pre-defined Height instead. | -| `height` | [int64](#int64) | | The height at which the upgrade must be performed. Only used if Time is not set. | -| `info` | [string](#string) | | Any application specific upgrade info to be included on-chain such as a git commit that validators could automatically upgrade to | -| `upgraded_client_state` | [google.protobuf.Any](#google.protobuf.Any) | | IBC-enabled chains can opt-in to including the upgraded client state in its upgrade plan This will make the chain commit to the correct upgraded (self) client state before the upgrade occurs, so that connecting chains can verify that the new upgraded client is valid by verifying a proof on the previous version of the chain. This will allow IBC connections to persist smoothly across planned chain upgrades | +| `not_bonded_tokens` | [string](#string) | | | +| `bonded_tokens` | [string](#string) | | | - + -### SoftwareUpgradeProposal -SoftwareUpgradeProposal is a gov Content type for initiating a software -upgrade. +### Redelegation +Redelegation contains the list of a particular delegator's redelegating bonds +from a particular source validator to a particular destination validator. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `title` | [string](#string) | | | -| `description` | [string](#string) | | | -| `plan` | [Plan](#cosmos.upgrade.v1beta1.Plan) | | | +| `delegator_address` | [string](#string) | | | +| `validator_src_address` | [string](#string) | | | +| `validator_dst_address` | [string](#string) | | | +| `entries` | [RedelegationEntry](#cosmos.staking.v1beta1.RedelegationEntry) | repeated | redelegation entries | - - + - +### RedelegationEntry +RedelegationEntry defines a redelegation object with relevant metadata. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `creation_height` | [int64](#int64) | | | +| `completion_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | +| `initial_balance` | [string](#string) | | | +| `shares_dst` | [string](#string) | | | - -

Top

-## cosmos/upgrade/v1beta1/query.proto - + -### QueryAppliedPlanRequest -QueryCurrentPlanRequest is the request type for the Query/AppliedPlan RPC -method. +### RedelegationEntryResponse +RedelegationEntryResponse is equivalent to a RedelegationEntry except that it +contains a balance in addition to shares which is more suitable for client +responses. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `name` | [string](#string) | | name is the name of the applied plan to query for. | +| `redelegation_entry` | [RedelegationEntry](#cosmos.staking.v1beta1.RedelegationEntry) | | | +| `balance` | [string](#string) | | | - + -### QueryAppliedPlanResponse -QueryAppliedPlanResponse is the response type for the Query/AppliedPlan RPC -method. +### RedelegationResponse +RedelegationResponse is equivalent to a Redelegation except that its entries +contain a balance in addition to shares which is more suitable for client +responses. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `height` | [int64](#int64) | | height is the block height at which the plan was applied. | +| `redelegation` | [Redelegation](#cosmos.staking.v1beta1.Redelegation) | | | +| `entries` | [RedelegationEntryResponse](#cosmos.staking.v1beta1.RedelegationEntryResponse) | repeated | | - + -### QueryCurrentPlanRequest -QueryCurrentPlanRequest is the request type for the Query/CurrentPlan RPC -method. +### UnbondingDelegation +UnbondingDelegation stores all of a single delegator's unbonding bonds +for a single validator in an time-ordered list. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `delegator_address` | [string](#string) | | | +| `validator_address` | [string](#string) | | | +| `entries` | [UnbondingDelegationEntry](#cosmos.staking.v1beta1.UnbondingDelegationEntry) | repeated | unbonding delegation entries | + - -### QueryCurrentPlanResponse -QueryCurrentPlanResponse is the response type for the Query/CurrentPlan RPC -method. + + +### UnbondingDelegationEntry +UnbondingDelegationEntry defines an unbonding object with relevant metadata. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `plan` | [Plan](#cosmos.upgrade.v1beta1.Plan) | | plan is the current upgrade plan. | +| `creation_height` | [int64](#int64) | | | +| `completion_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | +| `initial_balance` | [string](#string) | | | +| `balance` | [string](#string) | | | - + -### QueryUpgradedConsensusStateRequest -QueryUpgradedConsensusStateRequest is the request type for the Query/UpgradedConsensusState -RPC method. +### ValAddresses +ValAddresses defines a repeated set of validator addresses. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `last_height` | [int64](#int64) | | last height of the current chain must be sent in request as this is the height under which next consensus state is stored | +| `addresses` | [string](#string) | repeated | | - + -### QueryUpgradedConsensusStateResponse -QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState -RPC method. +### Validator +Validator defines a validator, together with the total amount of the +Validator's bond shares and their exchange rate to coins. Slashing results in +a decrease in the exchange rate, allowing correct calculation of future +undelegations without iterating over delegators. When coins are delegated to +this validator, the validator is credited with a delegation whose number of +bond shares is based on the amount of coins delegated divided by the current +exchange rate. Voting power can be calculated as total bonded shares +multiplied by exchange rate. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `upgraded_consensus_state` | [google.protobuf.Any](#google.protobuf.Any) | | | +| `operator_address` | [string](#string) | | | +| `consensus_pubkey` | [google.protobuf.Any](#google.protobuf.Any) | | | +| `jailed` | [bool](#bool) | | | +| `status` | [BondStatus](#cosmos.staking.v1beta1.BondStatus) | | | +| `tokens` | [string](#string) | | | +| `delegator_shares` | [string](#string) | | | +| `description` | [Description](#cosmos.staking.v1beta1.Description) | | | +| `unbonding_height` | [int64](#int64) | | | +| `unbonding_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | +| `commission` | [Commission](#cosmos.staking.v1beta1.Commission) | | | +| `min_self_delegation` | [string](#string) | | | @@ -7467,21 +7357,23 @@ RPC method. - - - + - +### BondStatus +BondStatus is the status of a validator. -### Query -Query defines the gRPC upgrade querier service. +| Name | Number | Description | +| ---- | ------ | ----------- | +| BOND_STATUS_UNSPECIFIED | 0 | UNSPECIFIED defines an invalid validator status. | +| BOND_STATUS_UNBONDED | 1 | UNBONDED defines a validator that is not bonded. | +| BOND_STATUS_UNBONDING | 2 | UNBONDING defines a validator that is unbonding. | +| BOND_STATUS_BONDED | 3 | BONDED defines a validator that is bonded. | -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `CurrentPlan` | [QueryCurrentPlanRequest](#cosmos.upgrade.v1beta1.QueryCurrentPlanRequest) | [QueryCurrentPlanResponse](#cosmos.upgrade.v1beta1.QueryCurrentPlanResponse) | CurrentPlan queries the current upgrade plan. | GET|/cosmos/upgrade/v1beta1/current_plan| -| `AppliedPlan` | [QueryAppliedPlanRequest](#cosmos.upgrade.v1beta1.QueryAppliedPlanRequest) | [QueryAppliedPlanResponse](#cosmos.upgrade.v1beta1.QueryAppliedPlanResponse) | AppliedPlan queries a previously applied upgrade plan by its name. | GET|/cosmos/upgrade/v1beta1/applied_plan/{name}| -| `UpgradedConsensusState` | [QueryUpgradedConsensusStateRequest](#cosmos.upgrade.v1beta1.QueryUpgradedConsensusStateRequest) | [QueryUpgradedConsensusStateResponse](#cosmos.upgrade.v1beta1.QueryUpgradedConsensusStateResponse) | UpgradedConsensusState queries the consensus state that will serve as a trusted kernel for the next version of this chain. It will only be stored at the last height of this chain. UpgradedConsensusState RPC not supported with legacy querier | GET|/cosmos/upgrade/v1beta1/upgraded_consensus_state/{last_height}| + + + + @@ -7647,96 +7539,99 @@ periodically vests by unlocking coins during each specified period. - +

Top

-## ibc/applications/transfer/v1/transfer.proto +## cosmos/params/v1beta1/query.proto - + -### DenomTrace -DenomTrace contains the base denomination for ICS20 fungible tokens and the -source tracing information path. +### QueryParamsRequest +QueryParamsRequest is request type for the Query/Params RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `path` | [string](#string) | | path defines the chain of port/channel identifiers used for tracing the source of the fungible token. | -| `base_denom` | [string](#string) | | base denomination of the relayed fungible token. | +| `subspace` | [string](#string) | | subspace defines the module to query the parameter for. | +| `key` | [string](#string) | | key defines the key of the parameter in the subspace. | - + -### FungibleTokenPacketData -FungibleTokenPacketData defines a struct for the packet payload -See FungibleTokenPacketData spec: -https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures +### QueryParamsResponse +QueryParamsResponse is response type for the Query/Params RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `denom` | [string](#string) | | the token denomination to be transferred | -| `amount` | [uint64](#uint64) | | the token amount to be transferred | -| `sender` | [string](#string) | | the sender address | -| `receiver` | [string](#string) | | the recipient address on the destination chain | +| `param` | [ParamChange](#cosmos.params.v1beta1.ParamChange) | | param defines the queried parameter. | + - + -### Params -Params defines the set of IBC transfer parameters. -NOTE: To prevent a single token from being transferred, set the -TransfersEnabled parameter to true and then set the bank module's SendEnabled -parameter for the denomination to false. + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `send_enabled` | [bool](#bool) | | send_enabled enables or disables all cross-chain token transfers from this chain. | -| `receive_enabled` | [bool](#bool) | | receive_enabled enables or disables all cross-chain token transfers to this chain. | + +### Query +Query defines the gRPC querier service. +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Params` | [QueryParamsRequest](#cosmos.params.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#cosmos.params.v1beta1.QueryParamsResponse) | Params queries a specific parameter of a module, given its subspace and key. | GET|/cosmos/params/v1beta1/params| + - - + +

Top

- +## cosmos/params/v1beta1/params.proto - + - -

Top

+### ParamChange +ParamChange defines an individual parameter change, for use in +ParameterChangeProposal. -## ibc/applications/transfer/v1/genesis.proto +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `subspace` | [string](#string) | | | +| `key` | [string](#string) | | | +| `value` | [string](#string) | | | - -### GenesisState -GenesisState defines the ibc-transfer genesis state + + + + + +### ParameterChangeProposal +ParameterChangeProposal defines a proposal to change one or more parameters. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | | -| `denom_traces` | [DenomTrace](#ibc.applications.transfer.v1.DenomTrace) | repeated | | -| `params` | [Params](#ibc.applications.transfer.v1.Params) | | | +| `title` | [string](#string) | | | +| `description` | [string](#string) | | | +| `changes` | [ParamChange](#cosmos.params.v1beta1.ParamChange) | repeated | | @@ -7855,16 +7750,180 @@ QueryParamsResponse is the response type for the Query/Params RPC method. - + + +### Query +Query provides defines the gRPC querier service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `DenomTrace` | [QueryDenomTraceRequest](#ibc.applications.transfer.v1.QueryDenomTraceRequest) | [QueryDenomTraceResponse](#ibc.applications.transfer.v1.QueryDenomTraceResponse) | DenomTrace queries a denomination trace information. | GET|/ibc/applications/transfer/v1beta1/denom_traces/{hash}| +| `DenomTraces` | [QueryDenomTracesRequest](#ibc.applications.transfer.v1.QueryDenomTracesRequest) | [QueryDenomTracesResponse](#ibc.applications.transfer.v1.QueryDenomTracesResponse) | DenomTraces queries all denomination traces. | GET|/ibc/applications/transfer/v1beta1/denom_traces| +| `Params` | [QueryParamsRequest](#ibc.applications.transfer.v1.QueryParamsRequest) | [QueryParamsResponse](#ibc.applications.transfer.v1.QueryParamsResponse) | Params queries all parameters of the ibc-transfer module. | GET|/ibc/applications/transfer/v1beta1/params| + + + + + + +

Top

+ +## ibc/applications/transfer/v1/tx.proto + + + + + +### MsgTransfer +MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) between +ICS20 enabled chains. See ICS Spec here: +https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `source_port` | [string](#string) | | the port on which the packet will be sent | +| `source_channel` | [string](#string) | | the channel by which the packet will be sent | +| `token` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | the tokens to be transferred | +| `sender` | [string](#string) | | the sender address | +| `receiver` | [string](#string) | | the recipient address on the destination chain | +| `timeout_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | Timeout height relative to the current block height. The timeout is disabled when set to 0. | +| `timeout_timestamp` | [uint64](#uint64) | | Timeout timestamp (in nanoseconds) relative to the current block timestamp. The timeout is disabled when set to 0. | + + + + + + + + +### MsgTransferResponse +MsgTransferResponse defines the Msg/Transfer response type. + + + + + + + + + + + + + + +### Msg +Msg defines the ibc/transfer Msg service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Transfer` | [MsgTransfer](#ibc.applications.transfer.v1.MsgTransfer) | [MsgTransferResponse](#ibc.applications.transfer.v1.MsgTransferResponse) | Transfer defines a rpc handler method for MsgTransfer. | | + + + + + + +

Top

+ +## ibc/applications/transfer/v1/transfer.proto + + + + + +### DenomTrace +DenomTrace contains the base denomination for ICS20 fungible tokens and the +source tracing information path. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `path` | [string](#string) | | path defines the chain of port/channel identifiers used for tracing the source of the fungible token. | +| `base_denom` | [string](#string) | | base denomination of the relayed fungible token. | + + + + + + + + +### FungibleTokenPacketData +FungibleTokenPacketData defines a struct for the packet payload +See FungibleTokenPacketData spec: +https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `denom` | [string](#string) | | the token denomination to be transferred | +| `amount` | [uint64](#uint64) | | the token amount to be transferred | +| `sender` | [string](#string) | | the sender address | +| `receiver` | [string](#string) | | the recipient address on the destination chain | + + + + + + + + +### Params +Params defines the set of IBC transfer parameters. +NOTE: To prevent a single token from being transferred, set the +TransfersEnabled parameter to true and then set the bank module's SendEnabled +parameter for the denomination to false. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `send_enabled` | [bool](#bool) | | send_enabled enables or disables all cross-chain token transfers from this chain. | +| `receive_enabled` | [bool](#bool) | | receive_enabled enables or disables all cross-chain token transfers to this chain. | + + + + + + + + + + + + + + + + +

Top

+ +## ibc/applications/transfer/v1/genesis.proto + + + + + +### GenesisState +GenesisState defines the ibc-transfer genesis state + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `port_id` | [string](#string) | | | +| `denom_traces` | [DenomTrace](#ibc.applications.transfer.v1.DenomTrace) | repeated | | +| `params` | [Params](#ibc.applications.transfer.v1.Params) | | | + + + + + + -### Query -Query provides defines the gRPC querier service. + -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `DenomTrace` | [QueryDenomTraceRequest](#ibc.applications.transfer.v1.QueryDenomTraceRequest) | [QueryDenomTraceResponse](#ibc.applications.transfer.v1.QueryDenomTraceResponse) | DenomTrace queries a denomination trace information. | GET|/ibc/applications/transfer/v1beta1/denom_traces/{hash}| -| `DenomTraces` | [QueryDenomTracesRequest](#ibc.applications.transfer.v1.QueryDenomTracesRequest) | [QueryDenomTracesResponse](#ibc.applications.transfer.v1.QueryDenomTracesResponse) | DenomTraces queries all denomination traces. | GET|/ibc/applications/transfer/v1beta1/denom_traces| -| `Params` | [QueryParamsRequest](#ibc.applications.transfer.v1.QueryParamsRequest) | [QueryParamsResponse](#ibc.applications.transfer.v1.QueryParamsResponse) | Params queries all parameters of the ibc-transfer module. | GET|/ibc/applications/transfer/v1beta1/params| + @@ -7995,682 +8054,615 @@ Params defines the set of IBC light client parameters. - +

Top

-## ibc/applications/transfer/v1/tx.proto - - - - - -### MsgTransfer -MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) between -ICS20 enabled chains. See ICS Spec here: -https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures +## ibc/core/client/v1/query.proto -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `source_port` | [string](#string) | | the port on which the packet will be sent | -| `source_channel` | [string](#string) | | the channel by which the packet will be sent | -| `token` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | the tokens to be transferred | -| `sender` | [string](#string) | | the sender address | -| `receiver` | [string](#string) | | the recipient address on the destination chain | -| `timeout_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | Timeout height relative to the current block height. The timeout is disabled when set to 0. | -| `timeout_timestamp` | [uint64](#uint64) | | Timeout timestamp (in nanoseconds) relative to the current block timestamp. The timeout is disabled when set to 0. | + +### QueryClientParamsRequest +QueryClientParamsRequest is the request type for the Query/ClientParams RPC method. - -### MsgTransferResponse -MsgTransferResponse defines the Msg/Transfer response type. + +### QueryClientParamsResponse +QueryClientParamsResponse is the response type for the Query/ClientParams RPC method. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `params` | [Params](#ibc.core.client.v1.Params) | | params defines the parameters of the module. | - - - - -### Msg -Msg defines the ibc/transfer Msg service. + -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Transfer` | [MsgTransfer](#ibc.applications.transfer.v1.MsgTransfer) | [MsgTransferResponse](#ibc.applications.transfer.v1.MsgTransferResponse) | Transfer defines a rpc handler method for MsgTransfer. | | +### QueryClientStateRequest +QueryClientStateRequest is the request type for the Query/ClientState RPC +method - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `client_id` | [string](#string) | | client state unique identifier | - -

Top

-## ibc/core/channel/v1/channel.proto - + -### Acknowledgement -Acknowledgement is the recommended acknowledgement format to be used by -app-specific protocols. -NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental -conflicts with other protobuf message formats used for acknowledgements. -The first byte of any message with this format will be the non-ASCII values -`0xaa` (result) or `0xb2` (error). Implemented as defined by ICS: -https://github.com/cosmos/ics/tree/master/spec/ics-004-channel-and-packet-semantics#acknowledgement-envelope +### QueryClientStateResponse +QueryClientStateResponse is the response type for the Query/ClientState RPC +method. Besides the client state, it includes a proof and the height from +which the proof was retrieved. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `result` | [bytes](#bytes) | | | -| `error` | [string](#string) | | | +| `client_state` | [google.protobuf.Any](#google.protobuf.Any) | | client state associated with the request identifier | +| `proof` | [bytes](#bytes) | | merkle proof of existence | +| `proof_height` | [Height](#ibc.core.client.v1.Height) | | height at which the proof was retrieved | - + -### Channel -Channel defines pipeline for exactly-once packet delivery between specific -modules on separate blockchains, which has at least one end capable of -sending packets and one end capable of receiving packets. +### QueryClientStatesRequest +QueryClientStatesRequest is the request type for the Query/ClientStates RPC +method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `state` | [State](#ibc.core.channel.v1.State) | | current state of the channel end | -| `ordering` | [Order](#ibc.core.channel.v1.Order) | | whether the channel is ordered or unordered | -| `counterparty` | [Counterparty](#ibc.core.channel.v1.Counterparty) | | counterparty channel end | -| `connection_hops` | [string](#string) | repeated | list of connection identifiers, in order, along which packets sent on this channel will travel | -| `version` | [string](#string) | | opaque channel version, which is agreed upon during the handshake | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination request | - + -### Counterparty -Counterparty defines a channel end counterparty +### QueryClientStatesResponse +QueryClientStatesResponse is the response type for the Query/ClientStates RPC +method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | port on the counterparty chain which owns the other end of the channel. | -| `channel_id` | [string](#string) | | channel end on the counterparty chain | +| `client_states` | [IdentifiedClientState](#ibc.core.client.v1.IdentifiedClientState) | repeated | list of stored ClientStates of the chain. | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination response | - + -### IdentifiedChannel -IdentifiedChannel defines a channel with additional port and channel -identifier fields. +### QueryConsensusStateRequest +QueryConsensusStateRequest is the request type for the Query/ConsensusState +RPC method. Besides the consensus state, it includes a proof and the height +from which the proof was retrieved. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `state` | [State](#ibc.core.channel.v1.State) | | current state of the channel end | -| `ordering` | [Order](#ibc.core.channel.v1.Order) | | whether the channel is ordered or unordered | -| `counterparty` | [Counterparty](#ibc.core.channel.v1.Counterparty) | | counterparty channel end | -| `connection_hops` | [string](#string) | repeated | list of connection identifiers, in order, along which packets sent on this channel will travel | -| `version` | [string](#string) | | opaque channel version, which is agreed upon during the handshake | -| `port_id` | [string](#string) | | port identifier | -| `channel_id` | [string](#string) | | channel identifier | +| `client_id` | [string](#string) | | client identifier | +| `revision_number` | [uint64](#uint64) | | consensus state revision number | +| `revision_height` | [uint64](#uint64) | | consensus state revision height | +| `latest_height` | [bool](#bool) | | latest_height overrrides the height field and queries the latest stored ConsensusState | - + -### Packet -Packet defines a type that carries data across different chains through IBC +### QueryConsensusStateResponse +QueryConsensusStateResponse is the response type for the Query/ConsensusState +RPC method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `sequence` | [uint64](#uint64) | | number corresponds to the order of sends and receives, where a Packet with an earlier sequence number must be sent and received before a Packet with a later sequence number. | -| `source_port` | [string](#string) | | identifies the port on the sending chain. | -| `source_channel` | [string](#string) | | identifies the channel end on the sending chain. | -| `destination_port` | [string](#string) | | identifies the port on the receiving chain. | -| `destination_channel` | [string](#string) | | identifies the channel end on the receiving chain. | -| `data` | [bytes](#bytes) | | actual opaque bytes transferred directly to the application module | -| `timeout_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | block height after which the packet times out | -| `timeout_timestamp` | [uint64](#uint64) | | block timestamp (in nanoseconds) after which the packet times out | +| `consensus_state` | [google.protobuf.Any](#google.protobuf.Any) | | consensus state associated with the client identifier at the given height | +| `proof` | [bytes](#bytes) | | merkle proof of existence | +| `proof_height` | [Height](#ibc.core.client.v1.Height) | | height at which the proof was retrieved | - + -### PacketState -PacketState defines the generic type necessary to retrieve and store -packet commitments, acknowledgements, and receipts. -Caller is responsible for knowing the context necessary to interpret this -state as a commitment, acknowledgement, or a receipt. +### QueryConsensusStatesRequest +QueryConsensusStatesRequest is the request type for the Query/ConsensusStates +RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | channel port identifier. | -| `channel_id` | [string](#string) | | channel unique identifier. | -| `sequence` | [uint64](#uint64) | | packet sequence. | -| `data` | [bytes](#bytes) | | embedded data that represents packet state. | - +| `client_id` | [string](#string) | | client identifier | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination request | - - + -### Order -Order defines if a channel is ORDERED or UNORDERED +### QueryConsensusStatesResponse +QueryConsensusStatesResponse is the response type for the +Query/ConsensusStates RPC method -| Name | Number | Description | -| ---- | ------ | ----------- | -| ORDER_NONE_UNSPECIFIED | 0 | zero-value for channel ordering | -| ORDER_UNORDERED | 1 | packets can be delivered in any order, which may differ from the order in which they were sent. | -| ORDER_ORDERED | 2 | packets are delivered exactly in the order which they were sent | +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `consensus_states` | [ConsensusStateWithHeight](#ibc.core.client.v1.ConsensusStateWithHeight) | repeated | consensus states associated with the identifier | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination response | - -### State -State defines if a channel is in one of the following states: -CLOSED, INIT, TRYOPEN, OPEN or UNINITIALIZED. -| Name | Number | Description | -| ---- | ------ | ----------- | -| STATE_UNINITIALIZED_UNSPECIFIED | 0 | Default State | -| STATE_INIT | 1 | A channel has just started the opening handshake. | -| STATE_TRYOPEN | 2 | A channel has acknowledged the handshake step on the counterparty chain. | -| STATE_OPEN | 3 | A channel has completed the handshake. Open channels are ready to send and receive packets. | -| STATE_CLOSED | 4 | A channel has been closed and can no longer be used to send or receive packets. | + - - - - - -

Top

- -## ibc/core/channel/v1/genesis.proto - - - - - -### GenesisState -GenesisState defines the ibc channel submodule's genesis state. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `channels` | [IdentifiedChannel](#ibc.core.channel.v1.IdentifiedChannel) | repeated | | -| `acknowledgements` | [PacketState](#ibc.core.channel.v1.PacketState) | repeated | | -| `commitments` | [PacketState](#ibc.core.channel.v1.PacketState) | repeated | | -| `receipts` | [PacketState](#ibc.core.channel.v1.PacketState) | repeated | | -| `send_sequences` | [PacketSequence](#ibc.core.channel.v1.PacketSequence) | repeated | | -| `recv_sequences` | [PacketSequence](#ibc.core.channel.v1.PacketSequence) | repeated | | -| `ack_sequences` | [PacketSequence](#ibc.core.channel.v1.PacketSequence) | repeated | | -| `next_channel_sequence` | [uint64](#uint64) | | the sequence for the next generated channel identifier | - - - + +### Query +Query provides defines the gRPC querier service - - -### PacketSequence -PacketSequence defines the genesis type necessary to retrieve and store -next send and receive sequences. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | | -| `channel_id` | [string](#string) | | | -| `sequence` | [uint64](#uint64) | | | +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `ClientState` | [QueryClientStateRequest](#ibc.core.client.v1.QueryClientStateRequest) | [QueryClientStateResponse](#ibc.core.client.v1.QueryClientStateResponse) | ClientState queries an IBC light client. | GET|/ibc/core/client/v1beta1/client_states/{client_id}| +| `ClientStates` | [QueryClientStatesRequest](#ibc.core.client.v1.QueryClientStatesRequest) | [QueryClientStatesResponse](#ibc.core.client.v1.QueryClientStatesResponse) | ClientStates queries all the IBC light clients of a chain. | GET|/ibc/core/client/v1beta1/client_states| +| `ConsensusState` | [QueryConsensusStateRequest](#ibc.core.client.v1.QueryConsensusStateRequest) | [QueryConsensusStateResponse](#ibc.core.client.v1.QueryConsensusStateResponse) | ConsensusState queries a consensus state associated with a client state at a given height. | GET|/ibc/core/client/v1beta1/consensus_states/{client_id}/revision/{revision_number}/height/{revision_height}| +| `ConsensusStates` | [QueryConsensusStatesRequest](#ibc.core.client.v1.QueryConsensusStatesRequest) | [QueryConsensusStatesResponse](#ibc.core.client.v1.QueryConsensusStatesResponse) | ConsensusStates queries all the consensus state associated with a given client. | GET|/ibc/core/client/v1beta1/consensus_states/{client_id}| +| `ClientParams` | [QueryClientParamsRequest](#ibc.core.client.v1.QueryClientParamsRequest) | [QueryClientParamsResponse](#ibc.core.client.v1.QueryClientParamsResponse) | ClientParams queries all parameters of the ibc client. | GET|/ibc/client/v1beta1/params| + + +

Top

- +## ibc/core/client/v1/tx.proto - - - + +### MsgCreateClient +MsgCreateClient defines a message to create an IBC client - -

Top

+| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `client_state` | [google.protobuf.Any](#google.protobuf.Any) | | light client state | +| `consensus_state` | [google.protobuf.Any](#google.protobuf.Any) | | consensus state associated with the client that corresponds to a given height. | +| `signer` | [string](#string) | | signer address | -## ibc/core/channel/v1/query.proto - -### QueryChannelClientStateRequest -QueryChannelClientStateRequest is the request type for the Query/ClientState -RPC method + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | port unique identifier | -| `channel_id` | [string](#string) | | channel unique identifier | +### MsgCreateClientResponse +MsgCreateClientResponse defines the Msg/CreateClient response type. - + -### QueryChannelClientStateResponse -QueryChannelClientStateResponse is the Response type for the -Query/QueryChannelClientState RPC method +### MsgSubmitMisbehaviour +MsgSubmitMisbehaviour defines an sdk.Msg type that submits Evidence for +light client misbehaviour. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `identified_client_state` | [ibc.core.client.v1.IdentifiedClientState](#ibc.core.client.v1.IdentifiedClientState) | | client state associated with the channel | -| `proof` | [bytes](#bytes) | | merkle proof of existence | -| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | height at which the proof was retrieved | - - +| `client_id` | [string](#string) | | client unique identifier | +| `misbehaviour` | [google.protobuf.Any](#google.protobuf.Any) | | misbehaviour used for freezing the light client | +| `signer` | [string](#string) | | signer address | - -### QueryChannelConsensusStateRequest -QueryChannelConsensusStateRequest is the request type for the -Query/ConsensusState RPC method + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | port unique identifier | -| `channel_id` | [string](#string) | | channel unique identifier | -| `revision_number` | [uint64](#uint64) | | revision number of the consensus state | -| `revision_height` | [uint64](#uint64) | | revision height of the consensus state | +### MsgSubmitMisbehaviourResponse +MsgSubmitMisbehaviourResponse defines the Msg/SubmitMisbehaviour response type. - + -### QueryChannelConsensusStateResponse -QueryChannelClientStateResponse is the Response type for the -Query/QueryChannelClientState RPC method +### MsgUpdateClient +MsgUpdateClient defines an sdk.Msg to update a IBC client state using +the given header. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `consensus_state` | [google.protobuf.Any](#google.protobuf.Any) | | consensus state associated with the channel | -| `client_id` | [string](#string) | | client ID associated with the consensus state | -| `proof` | [bytes](#bytes) | | merkle proof of existence | -| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | height at which the proof was retrieved | - - +| `client_id` | [string](#string) | | client unique identifier | +| `header` | [google.protobuf.Any](#google.protobuf.Any) | | header to update the light client | +| `signer` | [string](#string) | | signer address | - -### QueryChannelRequest -QueryChannelRequest is the request type for the Query/Channel RPC method + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | port unique identifier | -| `channel_id` | [string](#string) | | channel unique identifier | +### MsgUpdateClientResponse +MsgUpdateClientResponse defines the Msg/UpdateClient response type. - + -### QueryChannelResponse -QueryChannelResponse is the response type for the Query/Channel RPC method. -Besides the Channel end, it includes a proof and the height from which the -proof was retrieved. +### MsgUpgradeClient +MsgUpgradeClient defines an sdk.Msg to upgrade an IBC client to a new client state | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `channel` | [Channel](#ibc.core.channel.v1.Channel) | | channel associated with the request identifiers | -| `proof` | [bytes](#bytes) | | merkle proof of existence | -| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | height at which the proof was retrieved | +| `client_id` | [string](#string) | | client unique identifier | +| `client_state` | [google.protobuf.Any](#google.protobuf.Any) | | upgraded client state | +| `consensus_state` | [google.protobuf.Any](#google.protobuf.Any) | | upgraded consensus state, only contains enough information to serve as a basis of trust in update logic | +| `proof_upgrade_client` | [bytes](#bytes) | | proof that old chain committed to new client | +| `proof_upgrade_consensus_state` | [bytes](#bytes) | | proof that old chain committed to new consensus state | +| `signer` | [string](#string) | | signer address | - + -### QueryChannelsRequest -QueryChannelsRequest is the request type for the Query/Channels RPC method +### MsgUpgradeClientResponse +MsgUpgradeClientResponse defines the Msg/UpgradeClient response type. -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination request | + + + - -### QueryChannelsResponse -QueryChannelsResponse is the response type for the Query/Channels RPC method. + +### Msg +Msg defines the ibc/client Msg service. -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `channels` | [IdentifiedChannel](#ibc.core.channel.v1.IdentifiedChannel) | repeated | list of stored channels of the chain. | -| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination response | -| `height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | query block height | +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `CreateClient` | [MsgCreateClient](#ibc.core.client.v1.MsgCreateClient) | [MsgCreateClientResponse](#ibc.core.client.v1.MsgCreateClientResponse) | CreateClient defines a rpc handler method for MsgCreateClient. | | +| `UpdateClient` | [MsgUpdateClient](#ibc.core.client.v1.MsgUpdateClient) | [MsgUpdateClientResponse](#ibc.core.client.v1.MsgUpdateClientResponse) | UpdateClient defines a rpc handler method for MsgUpdateClient. | | +| `UpgradeClient` | [MsgUpgradeClient](#ibc.core.client.v1.MsgUpgradeClient) | [MsgUpgradeClientResponse](#ibc.core.client.v1.MsgUpgradeClientResponse) | UpgradeClient defines a rpc handler method for MsgUpgradeClient. | | +| `SubmitMisbehaviour` | [MsgSubmitMisbehaviour](#ibc.core.client.v1.MsgSubmitMisbehaviour) | [MsgSubmitMisbehaviourResponse](#ibc.core.client.v1.MsgSubmitMisbehaviourResponse) | SubmitMisbehaviour defines a rpc handler method for MsgSubmitMisbehaviour. | | + + +

Top

+## ibc/core/client/v1/genesis.proto - -### QueryConnectionChannelsRequest -QueryConnectionChannelsRequest is the request type for the -Query/QueryConnectionChannels RPC method + + + +### GenesisMetadata +GenesisMetadata defines the genesis type for metadata that clients may return +with ExportMetadata | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `connection` | [string](#string) | | connection unique identifier | -| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination request | +| `key` | [bytes](#bytes) | | store key of metadata without clientID-prefix | +| `value` | [bytes](#bytes) | | metadata value | - + -### QueryConnectionChannelsResponse -QueryConnectionChannelsResponse is the Response type for the -Query/QueryConnectionChannels RPC method +### GenesisState +GenesisState defines the ibc client submodule's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `channels` | [IdentifiedChannel](#ibc.core.channel.v1.IdentifiedChannel) | repeated | list of channels associated with a connection. | -| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination response | -| `height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | query block height | +| `clients` | [IdentifiedClientState](#ibc.core.client.v1.IdentifiedClientState) | repeated | client states with their corresponding identifiers | +| `clients_consensus` | [ClientConsensusStates](#ibc.core.client.v1.ClientConsensusStates) | repeated | consensus states from each client | +| `clients_metadata` | [IdentifiedGenesisMetadata](#ibc.core.client.v1.IdentifiedGenesisMetadata) | repeated | metadata from each client | +| `params` | [Params](#ibc.core.client.v1.Params) | | | +| `create_localhost` | [bool](#bool) | | create localhost on initialization | +| `next_client_sequence` | [uint64](#uint64) | | the sequence for the next generated client identifier | - + -### QueryNextSequenceReceiveRequest -QueryNextSequenceReceiveRequest is the request type for the -Query/QueryNextSequenceReceiveRequest RPC method +### IdentifiedGenesisMetadata +IdentifiedGenesisMetadata has the client metadata with the corresponding client id. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | port unique identifier | -| `channel_id` | [string](#string) | | channel unique identifier | +| `client_id` | [string](#string) | | | +| `client_metadata` | [GenesisMetadata](#ibc.core.client.v1.GenesisMetadata) | repeated | | + - + -### QueryNextSequenceReceiveResponse -QuerySequenceResponse is the request type for the -Query/QueryNextSequenceReceiveResponse RPC method + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `next_sequence_receive` | [uint64](#uint64) | | next sequence receive number | -| `proof` | [bytes](#bytes) | | merkle proof of existence | -| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | height at which the proof was retrieved | + +

Top

+## ibc/core/channel/v1/channel.proto - + -### QueryPacketAcknowledgementRequest -QueryPacketAcknowledgementRequest is the request type for the -Query/PacketAcknowledgement RPC method +### Acknowledgement +Acknowledgement is the recommended acknowledgement format to be used by +app-specific protocols. +NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental +conflicts with other protobuf message formats used for acknowledgements. +The first byte of any message with this format will be the non-ASCII values +`0xaa` (result) or `0xb2` (error). Implemented as defined by ICS: +https://github.com/cosmos/ics/tree/master/spec/ics-004-channel-and-packet-semantics#acknowledgement-envelope | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | port unique identifier | -| `channel_id` | [string](#string) | | channel unique identifier | -| `sequence` | [uint64](#uint64) | | packet sequence | +| `result` | [bytes](#bytes) | | | +| `error` | [string](#string) | | | - + -### QueryPacketAcknowledgementResponse -QueryPacketAcknowledgementResponse defines the client query response for a -packet which also includes a proof and the height from which the -proof was retrieved +### Channel +Channel defines pipeline for exactly-once packet delivery between specific +modules on separate blockchains, which has at least one end capable of +sending packets and one end capable of receiving packets. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `acknowledgement` | [bytes](#bytes) | | packet associated with the request fields | -| `proof` | [bytes](#bytes) | | merkle proof of existence | -| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | height at which the proof was retrieved | +| `state` | [State](#ibc.core.channel.v1.State) | | current state of the channel end | +| `ordering` | [Order](#ibc.core.channel.v1.Order) | | whether the channel is ordered or unordered | +| `counterparty` | [Counterparty](#ibc.core.channel.v1.Counterparty) | | counterparty channel end | +| `connection_hops` | [string](#string) | repeated | list of connection identifiers, in order, along which packets sent on this channel will travel | +| `version` | [string](#string) | | opaque channel version, which is agreed upon during the handshake | - + -### QueryPacketAcknowledgementsRequest -QueryPacketAcknowledgementsRequest is the request type for the -Query/QueryPacketCommitments RPC method +### Counterparty +Counterparty defines a channel end counterparty | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | port unique identifier | -| `channel_id` | [string](#string) | | channel unique identifier | -| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination request | +| `port_id` | [string](#string) | | port on the counterparty chain which owns the other end of the channel. | +| `channel_id` | [string](#string) | | channel end on the counterparty chain | - + -### QueryPacketAcknowledgementsResponse -QueryPacketAcknowledgemetsResponse is the request type for the -Query/QueryPacketAcknowledgements RPC method +### IdentifiedChannel +IdentifiedChannel defines a channel with additional port and channel +identifier fields. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `acknowledgements` | [PacketState](#ibc.core.channel.v1.PacketState) | repeated | | -| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination response | -| `height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | query block height | +| `state` | [State](#ibc.core.channel.v1.State) | | current state of the channel end | +| `ordering` | [Order](#ibc.core.channel.v1.Order) | | whether the channel is ordered or unordered | +| `counterparty` | [Counterparty](#ibc.core.channel.v1.Counterparty) | | counterparty channel end | +| `connection_hops` | [string](#string) | repeated | list of connection identifiers, in order, along which packets sent on this channel will travel | +| `version` | [string](#string) | | opaque channel version, which is agreed upon during the handshake | +| `port_id` | [string](#string) | | port identifier | +| `channel_id` | [string](#string) | | channel identifier | - + -### QueryPacketCommitmentRequest -QueryPacketCommitmentRequest is the request type for the -Query/PacketCommitment RPC method +### Packet +Packet defines a type that carries data across different chains through IBC | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | port unique identifier | -| `channel_id` | [string](#string) | | channel unique identifier | -| `sequence` | [uint64](#uint64) | | packet sequence | +| `sequence` | [uint64](#uint64) | | number corresponds to the order of sends and receives, where a Packet with an earlier sequence number must be sent and received before a Packet with a later sequence number. | +| `source_port` | [string](#string) | | identifies the port on the sending chain. | +| `source_channel` | [string](#string) | | identifies the channel end on the sending chain. | +| `destination_port` | [string](#string) | | identifies the port on the receiving chain. | +| `destination_channel` | [string](#string) | | identifies the channel end on the receiving chain. | +| `data` | [bytes](#bytes) | | actual opaque bytes transferred directly to the application module | +| `timeout_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | block height after which the packet times out | +| `timeout_timestamp` | [uint64](#uint64) | | block timestamp (in nanoseconds) after which the packet times out | - + -### QueryPacketCommitmentResponse -QueryPacketCommitmentResponse defines the client query response for a packet -which also includes a proof and the height from which the proof was -retrieved +### PacketState +PacketState defines the generic type necessary to retrieve and store +packet commitments, acknowledgements, and receipts. +Caller is responsible for knowing the context necessary to interpret this +state as a commitment, acknowledgement, or a receipt. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `commitment` | [bytes](#bytes) | | packet associated with the request fields | -| `proof` | [bytes](#bytes) | | merkle proof of existence | -| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | height at which the proof was retrieved | +| `port_id` | [string](#string) | | channel port identifier. | +| `channel_id` | [string](#string) | | channel unique identifier. | +| `sequence` | [uint64](#uint64) | | packet sequence. | +| `data` | [bytes](#bytes) | | embedded data that represents packet state. | + - -### QueryPacketCommitmentsRequest -QueryPacketCommitmentsRequest is the request type for the -Query/QueryPacketCommitments RPC method + +### Order +Order defines if a channel is ORDERED or UNORDERED + +| Name | Number | Description | +| ---- | ------ | ----------- | +| ORDER_NONE_UNSPECIFIED | 0 | zero-value for channel ordering | +| ORDER_UNORDERED | 1 | packets can be delivered in any order, which may differ from the order in which they were sent. | +| ORDER_ORDERED | 2 | packets are delivered exactly in the order which they were sent | -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | port unique identifier | -| `channel_id` | [string](#string) | | channel unique identifier | -| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination request | + +### State +State defines if a channel is in one of the following states: +CLOSED, INIT, TRYOPEN, OPEN or UNINITIALIZED. +| Name | Number | Description | +| ---- | ------ | ----------- | +| STATE_UNINITIALIZED_UNSPECIFIED | 0 | Default State | +| STATE_INIT | 1 | A channel has just started the opening handshake. | +| STATE_TRYOPEN | 2 | A channel has acknowledged the handshake step on the counterparty chain. | +| STATE_OPEN | 3 | A channel has completed the handshake. Open channels are ready to send and receive packets. | +| STATE_CLOSED | 4 | A channel has been closed and can no longer be used to send or receive packets. | - + -### QueryPacketCommitmentsResponse -QueryPacketCommitmentsResponse is the request type for the -Query/QueryPacketCommitments RPC method + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `commitments` | [PacketState](#ibc.core.channel.v1.PacketState) | repeated | | -| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination response | -| `height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | query block height | + +

Top

+## ibc/core/channel/v1/query.proto - + -### QueryPacketReceiptRequest -QueryPacketReceiptRequest is the request type for the -Query/PacketReceipt RPC method +### QueryChannelClientStateRequest +QueryChannelClientStateRequest is the request type for the Query/ClientState +RPC method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `port_id` | [string](#string) | | port unique identifier | | `channel_id` | [string](#string) | | channel unique identifier | -| `sequence` | [uint64](#uint64) | | packet sequence | - + -### QueryPacketReceiptResponse -QueryPacketReceiptResponse defines the client query response for a packet receipt -which also includes a proof, and the height from which the proof was -retrieved +### QueryChannelClientStateResponse +QueryChannelClientStateResponse is the Response type for the +Query/QueryChannelClientState RPC method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `received` | [bool](#bool) | | success flag for if receipt exists | +| `identified_client_state` | [ibc.core.client.v1.IdentifiedClientState](#ibc.core.client.v1.IdentifiedClientState) | | client state associated with the channel | | `proof` | [bytes](#bytes) | | merkle proof of existence | | `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | height at which the proof was retrieved | @@ -8679,404 +8671,428 @@ retrieved - + -### QueryUnreceivedAcksRequest -QueryUnreceivedAcks is the request type for the -Query/UnreceivedAcks RPC method +### QueryChannelConsensusStateRequest +QueryChannelConsensusStateRequest is the request type for the +Query/ConsensusState RPC method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `port_id` | [string](#string) | | port unique identifier | | `channel_id` | [string](#string) | | channel unique identifier | -| `packet_ack_sequences` | [uint64](#uint64) | repeated | list of acknowledgement sequences | +| `revision_number` | [uint64](#uint64) | | revision number of the consensus state | +| `revision_height` | [uint64](#uint64) | | revision height of the consensus state | - + -### QueryUnreceivedAcksResponse -QueryUnreceivedAcksResponse is the response type for the -Query/UnreceivedAcks RPC method +### QueryChannelConsensusStateResponse +QueryChannelClientStateResponse is the Response type for the +Query/QueryChannelClientState RPC method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `sequences` | [uint64](#uint64) | repeated | list of unreceived acknowledgement sequences | -| `height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | query block height | +| `consensus_state` | [google.protobuf.Any](#google.protobuf.Any) | | consensus state associated with the channel | +| `client_id` | [string](#string) | | client ID associated with the consensus state | +| `proof` | [bytes](#bytes) | | merkle proof of existence | +| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | height at which the proof was retrieved | - + -### QueryUnreceivedPacketsRequest -QueryUnreceivedPacketsRequest is the request type for the -Query/UnreceivedPackets RPC method +### QueryChannelRequest +QueryChannelRequest is the request type for the Query/Channel RPC method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `port_id` | [string](#string) | | port unique identifier | | `channel_id` | [string](#string) | | channel unique identifier | -| `packet_commitment_sequences` | [uint64](#uint64) | repeated | list of packet sequences | - + -### QueryUnreceivedPacketsResponse -QueryUnreceivedPacketsResponse is the response type for the -Query/UnreceivedPacketCommitments RPC method +### QueryChannelResponse +QueryChannelResponse is the response type for the Query/Channel RPC method. +Besides the Channel end, it includes a proof and the height from which the +proof was retrieved. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `sequences` | [uint64](#uint64) | repeated | list of unreceived packet sequences | -| `height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | query block height | - - - - +| `channel` | [Channel](#ibc.core.channel.v1.Channel) | | channel associated with the request identifiers | +| `proof` | [bytes](#bytes) | | merkle proof of existence | +| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | height at which the proof was retrieved | - - - - -### Query -Query provides defines the gRPC querier service + -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Channel` | [QueryChannelRequest](#ibc.core.channel.v1.QueryChannelRequest) | [QueryChannelResponse](#ibc.core.channel.v1.QueryChannelResponse) | Channel queries an IBC Channel. | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}| -| `Channels` | [QueryChannelsRequest](#ibc.core.channel.v1.QueryChannelsRequest) | [QueryChannelsResponse](#ibc.core.channel.v1.QueryChannelsResponse) | Channels queries all the IBC channels of a chain. | GET|/ibc/core/channel/v1beta1/channels| -| `ConnectionChannels` | [QueryConnectionChannelsRequest](#ibc.core.channel.v1.QueryConnectionChannelsRequest) | [QueryConnectionChannelsResponse](#ibc.core.channel.v1.QueryConnectionChannelsResponse) | ConnectionChannels queries all the channels associated with a connection end. | GET|/ibc/core/channel/v1beta1/connections/{connection}/channels| -| `ChannelClientState` | [QueryChannelClientStateRequest](#ibc.core.channel.v1.QueryChannelClientStateRequest) | [QueryChannelClientStateResponse](#ibc.core.channel.v1.QueryChannelClientStateResponse) | ChannelClientState queries for the client state for the channel associated with the provided channel identifiers. | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/client_state| -| `ChannelConsensusState` | [QueryChannelConsensusStateRequest](#ibc.core.channel.v1.QueryChannelConsensusStateRequest) | [QueryChannelConsensusStateResponse](#ibc.core.channel.v1.QueryChannelConsensusStateResponse) | ChannelConsensusState queries for the consensus state for the channel associated with the provided channel identifiers. | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/consensus_state/revision/{revision_number}/height/{revision_height}| -| `PacketCommitment` | [QueryPacketCommitmentRequest](#ibc.core.channel.v1.QueryPacketCommitmentRequest) | [QueryPacketCommitmentResponse](#ibc.core.channel.v1.QueryPacketCommitmentResponse) | PacketCommitment queries a stored packet commitment hash. | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/{sequence}| -| `PacketCommitments` | [QueryPacketCommitmentsRequest](#ibc.core.channel.v1.QueryPacketCommitmentsRequest) | [QueryPacketCommitmentsResponse](#ibc.core.channel.v1.QueryPacketCommitmentsResponse) | PacketCommitments returns all the packet commitments hashes associated with a channel. | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments| -| `PacketReceipt` | [QueryPacketReceiptRequest](#ibc.core.channel.v1.QueryPacketReceiptRequest) | [QueryPacketReceiptResponse](#ibc.core.channel.v1.QueryPacketReceiptResponse) | PacketReceipt queries if a given packet sequence has been received on the queried chain | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_receipts/{sequence}| -| `PacketAcknowledgement` | [QueryPacketAcknowledgementRequest](#ibc.core.channel.v1.QueryPacketAcknowledgementRequest) | [QueryPacketAcknowledgementResponse](#ibc.core.channel.v1.QueryPacketAcknowledgementResponse) | PacketAcknowledgement queries a stored packet acknowledgement hash. | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acks/{sequence}| -| `PacketAcknowledgements` | [QueryPacketAcknowledgementsRequest](#ibc.core.channel.v1.QueryPacketAcknowledgementsRequest) | [QueryPacketAcknowledgementsResponse](#ibc.core.channel.v1.QueryPacketAcknowledgementsResponse) | PacketAcknowledgements returns all the packet acknowledgements associated with a channel. | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acknowledgements| -| `UnreceivedPackets` | [QueryUnreceivedPacketsRequest](#ibc.core.channel.v1.QueryUnreceivedPacketsRequest) | [QueryUnreceivedPacketsResponse](#ibc.core.channel.v1.QueryUnreceivedPacketsResponse) | UnreceivedPackets returns all the unreceived IBC packets associated with a channel and sequences. | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/{packet_commitment_sequences}/unreceived_packets| -| `UnreceivedAcks` | [QueryUnreceivedAcksRequest](#ibc.core.channel.v1.QueryUnreceivedAcksRequest) | [QueryUnreceivedAcksResponse](#ibc.core.channel.v1.QueryUnreceivedAcksResponse) | UnreceivedAcks returns all the unreceived IBC acknowledgements associated with a channel and sequences. | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/{packet_ack_sequences}/unreceived_acks| -| `NextSequenceReceive` | [QueryNextSequenceReceiveRequest](#ibc.core.channel.v1.QueryNextSequenceReceiveRequest) | [QueryNextSequenceReceiveResponse](#ibc.core.channel.v1.QueryNextSequenceReceiveResponse) | NextSequenceReceive returns the next receive sequence for a given channel. | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/next_sequence| +### QueryChannelsRequest +QueryChannelsRequest is the request type for the Query/Channels RPC method - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination request | - -

Top

-## ibc/core/channel/v1/tx.proto - + -### MsgAcknowledgement -MsgAcknowledgement receives incoming IBC acknowledgement +### QueryChannelsResponse +QueryChannelsResponse is the response type for the Query/Channels RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `packet` | [Packet](#ibc.core.channel.v1.Packet) | | | -| `acknowledgement` | [bytes](#bytes) | | | -| `proof_acked` | [bytes](#bytes) | | | -| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | -| `signer` | [string](#string) | | | - - - - - - - - -### MsgAcknowledgementResponse -MsgAcknowledgementResponse defines the Msg/Acknowledgement response type. +| `channels` | [IdentifiedChannel](#ibc.core.channel.v1.IdentifiedChannel) | repeated | list of stored channels of the chain. | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination response | +| `height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | query block height | - + -### MsgChannelCloseConfirm -MsgChannelCloseConfirm defines a msg sent by a Relayer to Chain B -to acknowledge the change of channel state to CLOSED on Chain A. +### QueryConnectionChannelsRequest +QueryConnectionChannelsRequest is the request type for the +Query/QueryConnectionChannels RPC method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | | -| `channel_id` | [string](#string) | | | -| `proof_init` | [bytes](#bytes) | | | -| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | -| `signer` | [string](#string) | | | +| `connection` | [string](#string) | | connection unique identifier | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination request | - + -### MsgChannelCloseConfirmResponse -MsgChannelCloseConfirmResponse defines the Msg/ChannelCloseConfirm response type. +### QueryConnectionChannelsResponse +QueryConnectionChannelsResponse is the Response type for the +Query/QueryConnectionChannels RPC method + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `channels` | [IdentifiedChannel](#ibc.core.channel.v1.IdentifiedChannel) | repeated | list of channels associated with a connection. | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination response | +| `height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | query block height | - + -### MsgChannelCloseInit -MsgChannelCloseInit defines a msg sent by a Relayer to Chain A -to close a channel with Chain B. +### QueryNextSequenceReceiveRequest +QueryNextSequenceReceiveRequest is the request type for the +Query/QueryNextSequenceReceiveRequest RPC method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | | -| `channel_id` | [string](#string) | | | -| `signer` | [string](#string) | | | +| `port_id` | [string](#string) | | port unique identifier | +| `channel_id` | [string](#string) | | channel unique identifier | - + -### MsgChannelCloseInitResponse -MsgChannelCloseInitResponse defines the Msg/ChannelCloseInit response type. +### QueryNextSequenceReceiveResponse +QuerySequenceResponse is the request type for the +Query/QueryNextSequenceReceiveResponse RPC method + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `next_sequence_receive` | [uint64](#uint64) | | next sequence receive number | +| `proof` | [bytes](#bytes) | | merkle proof of existence | +| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | height at which the proof was retrieved | - + -### MsgChannelOpenAck -MsgChannelOpenAck defines a msg sent by a Relayer to Chain A to acknowledge -the change of channel state to TRYOPEN on Chain B. +### QueryPacketAcknowledgementRequest +QueryPacketAcknowledgementRequest is the request type for the +Query/PacketAcknowledgement RPC method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | | -| `channel_id` | [string](#string) | | | -| `counterparty_channel_id` | [string](#string) | | | -| `counterparty_version` | [string](#string) | | | -| `proof_try` | [bytes](#bytes) | | | -| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | -| `signer` | [string](#string) | | | +| `port_id` | [string](#string) | | port unique identifier | +| `channel_id` | [string](#string) | | channel unique identifier | +| `sequence` | [uint64](#uint64) | | packet sequence | - + -### MsgChannelOpenAckResponse -MsgChannelOpenAckResponse defines the Msg/ChannelOpenAck response type. +### QueryPacketAcknowledgementResponse +QueryPacketAcknowledgementResponse defines the client query response for a +packet which also includes a proof and the height from which the +proof was retrieved +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `acknowledgement` | [bytes](#bytes) | | packet associated with the request fields | +| `proof` | [bytes](#bytes) | | merkle proof of existence | +| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | height at which the proof was retrieved | - -### MsgChannelOpenConfirm -MsgChannelOpenConfirm defines a msg sent by a Relayer to Chain B to -acknowledge the change of channel state to OPEN on Chain A. + + + +### QueryPacketAcknowledgementsRequest +QueryPacketAcknowledgementsRequest is the request type for the +Query/QueryPacketCommitments RPC method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | | -| `channel_id` | [string](#string) | | | -| `proof_ack` | [bytes](#bytes) | | | -| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | -| `signer` | [string](#string) | | | +| `port_id` | [string](#string) | | port unique identifier | +| `channel_id` | [string](#string) | | channel unique identifier | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination request | - + -### MsgChannelOpenConfirmResponse -MsgChannelOpenConfirmResponse defines the Msg/ChannelOpenConfirm response type. +### QueryPacketAcknowledgementsResponse +QueryPacketAcknowledgemetsResponse is the request type for the +Query/QueryPacketAcknowledgements RPC method +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `acknowledgements` | [PacketState](#ibc.core.channel.v1.PacketState) | repeated | | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination response | +| `height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | query block height | - -### MsgChannelOpenInit -MsgChannelOpenInit defines an sdk.Msg to initialize a channel handshake. It -is called by a relayer on Chain A. + + + +### QueryPacketCommitmentRequest +QueryPacketCommitmentRequest is the request type for the +Query/PacketCommitment RPC method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | | -| `channel` | [Channel](#ibc.core.channel.v1.Channel) | | | -| `signer` | [string](#string) | | | +| `port_id` | [string](#string) | | port unique identifier | +| `channel_id` | [string](#string) | | channel unique identifier | +| `sequence` | [uint64](#uint64) | | packet sequence | - + + +### QueryPacketCommitmentResponse +QueryPacketCommitmentResponse defines the client query response for a packet +which also includes a proof and the height from which the proof was +retrieved -### MsgChannelOpenInitResponse -MsgChannelOpenInitResponse defines the Msg/ChannelOpenInit response type. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `commitment` | [bytes](#bytes) | | packet associated with the request fields | +| `proof` | [bytes](#bytes) | | merkle proof of existence | +| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | height at which the proof was retrieved | - -### MsgChannelOpenTry -MsgChannelOpenInit defines a msg sent by a Relayer to try to open a channel -on Chain B. + + +### QueryPacketCommitmentsRequest +QueryPacketCommitmentsRequest is the request type for the +Query/QueryPacketCommitments RPC method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | | -| `previous_channel_id` | [string](#string) | | in the case of crossing hello's, when both chains call OpenInit, we need the channel identifier of the previous channel in state INIT | -| `channel` | [Channel](#ibc.core.channel.v1.Channel) | | | -| `counterparty_version` | [string](#string) | | | -| `proof_init` | [bytes](#bytes) | | | -| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | -| `signer` | [string](#string) | | | +| `port_id` | [string](#string) | | port unique identifier | +| `channel_id` | [string](#string) | | channel unique identifier | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination request | - + -### MsgChannelOpenTryResponse -MsgChannelOpenTryResponse defines the Msg/ChannelOpenTry response type. +### QueryPacketCommitmentsResponse +QueryPacketCommitmentsResponse is the request type for the +Query/QueryPacketCommitments RPC method + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `commitments` | [PacketState](#ibc.core.channel.v1.PacketState) | repeated | | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination response | +| `height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | query block height | - + -### MsgRecvPacket -MsgRecvPacket receives incoming IBC packet +### QueryPacketReceiptRequest +QueryPacketReceiptRequest is the request type for the +Query/PacketReceipt RPC method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `packet` | [Packet](#ibc.core.channel.v1.Packet) | | | -| `proof_commitment` | [bytes](#bytes) | | | -| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | -| `signer` | [string](#string) | | | +| `port_id` | [string](#string) | | port unique identifier | +| `channel_id` | [string](#string) | | channel unique identifier | +| `sequence` | [uint64](#uint64) | | packet sequence | - + -### MsgRecvPacketResponse -MsgRecvPacketResponse defines the Msg/RecvPacket response type. +### QueryPacketReceiptResponse +QueryPacketReceiptResponse defines the client query response for a packet receipt +which also includes a proof, and the height from which the proof was +retrieved +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `received` | [bool](#bool) | | success flag for if receipt exists | +| `proof` | [bytes](#bytes) | | merkle proof of existence | +| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | height at which the proof was retrieved | - -### MsgTimeout -MsgTimeout receives timed-out packet + + + +### QueryUnreceivedAcksRequest +QueryUnreceivedAcks is the request type for the +Query/UnreceivedAcks RPC method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `packet` | [Packet](#ibc.core.channel.v1.Packet) | | | -| `proof_unreceived` | [bytes](#bytes) | | | -| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | -| `next_sequence_recv` | [uint64](#uint64) | | | -| `signer` | [string](#string) | | | +| `port_id` | [string](#string) | | port unique identifier | +| `channel_id` | [string](#string) | | channel unique identifier | +| `packet_ack_sequences` | [uint64](#uint64) | repeated | list of acknowledgement sequences | - + -### MsgTimeoutOnClose -MsgTimeoutOnClose timed-out packet upon counterparty channel closure. +### QueryUnreceivedAcksResponse +QueryUnreceivedAcksResponse is the response type for the +Query/UnreceivedAcks RPC method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `packet` | [Packet](#ibc.core.channel.v1.Packet) | | | -| `proof_unreceived` | [bytes](#bytes) | | | -| `proof_close` | [bytes](#bytes) | | | -| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | -| `next_sequence_recv` | [uint64](#uint64) | | | -| `signer` | [string](#string) | | | +| `sequences` | [uint64](#uint64) | repeated | list of unreceived acknowledgement sequences | +| `height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | query block height | - + -### MsgTimeoutOnCloseResponse -MsgTimeoutOnCloseResponse defines the Msg/TimeoutOnClose response type. +### QueryUnreceivedPacketsRequest +QueryUnreceivedPacketsRequest is the request type for the +Query/UnreceivedPackets RPC method + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `port_id` | [string](#string) | | port unique identifier | +| `channel_id` | [string](#string) | | channel unique identifier | +| `packet_commitment_sequences` | [uint64](#uint64) | repeated | list of packet sequences | - + -### MsgTimeoutResponse -MsgTimeoutResponse defines the Msg/Timeout response type. +### QueryUnreceivedPacketsResponse +QueryUnreceivedPacketsResponse is the response type for the +Query/UnreceivedPacketCommitments RPC method + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sequences` | [uint64](#uint64) | repeated | list of unreceived packet sequences | +| `height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | query block height | @@ -9089,406 +9105,403 @@ MsgTimeoutResponse defines the Msg/Timeout response type. - + -### Msg -Msg defines the ibc/channel Msg service. +### Query +Query provides defines the gRPC querier service | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `ChannelOpenInit` | [MsgChannelOpenInit](#ibc.core.channel.v1.MsgChannelOpenInit) | [MsgChannelOpenInitResponse](#ibc.core.channel.v1.MsgChannelOpenInitResponse) | ChannelOpenInit defines a rpc handler method for MsgChannelOpenInit. | | -| `ChannelOpenTry` | [MsgChannelOpenTry](#ibc.core.channel.v1.MsgChannelOpenTry) | [MsgChannelOpenTryResponse](#ibc.core.channel.v1.MsgChannelOpenTryResponse) | ChannelOpenTry defines a rpc handler method for MsgChannelOpenTry. | | -| `ChannelOpenAck` | [MsgChannelOpenAck](#ibc.core.channel.v1.MsgChannelOpenAck) | [MsgChannelOpenAckResponse](#ibc.core.channel.v1.MsgChannelOpenAckResponse) | ChannelOpenAck defines a rpc handler method for MsgChannelOpenAck. | | -| `ChannelOpenConfirm` | [MsgChannelOpenConfirm](#ibc.core.channel.v1.MsgChannelOpenConfirm) | [MsgChannelOpenConfirmResponse](#ibc.core.channel.v1.MsgChannelOpenConfirmResponse) | ChannelOpenConfirm defines a rpc handler method for MsgChannelOpenConfirm. | | -| `ChannelCloseInit` | [MsgChannelCloseInit](#ibc.core.channel.v1.MsgChannelCloseInit) | [MsgChannelCloseInitResponse](#ibc.core.channel.v1.MsgChannelCloseInitResponse) | ChannelCloseInit defines a rpc handler method for MsgChannelCloseInit. | | -| `ChannelCloseConfirm` | [MsgChannelCloseConfirm](#ibc.core.channel.v1.MsgChannelCloseConfirm) | [MsgChannelCloseConfirmResponse](#ibc.core.channel.v1.MsgChannelCloseConfirmResponse) | ChannelCloseConfirm defines a rpc handler method for MsgChannelCloseConfirm. | | -| `RecvPacket` | [MsgRecvPacket](#ibc.core.channel.v1.MsgRecvPacket) | [MsgRecvPacketResponse](#ibc.core.channel.v1.MsgRecvPacketResponse) | RecvPacket defines a rpc handler method for MsgRecvPacket. | | -| `Timeout` | [MsgTimeout](#ibc.core.channel.v1.MsgTimeout) | [MsgTimeoutResponse](#ibc.core.channel.v1.MsgTimeoutResponse) | Timeout defines a rpc handler method for MsgTimeout. | | -| `TimeoutOnClose` | [MsgTimeoutOnClose](#ibc.core.channel.v1.MsgTimeoutOnClose) | [MsgTimeoutOnCloseResponse](#ibc.core.channel.v1.MsgTimeoutOnCloseResponse) | TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. | | -| `Acknowledgement` | [MsgAcknowledgement](#ibc.core.channel.v1.MsgAcknowledgement) | [MsgAcknowledgementResponse](#ibc.core.channel.v1.MsgAcknowledgementResponse) | Acknowledgement defines a rpc handler method for MsgAcknowledgement. | | +| `Channel` | [QueryChannelRequest](#ibc.core.channel.v1.QueryChannelRequest) | [QueryChannelResponse](#ibc.core.channel.v1.QueryChannelResponse) | Channel queries an IBC Channel. | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}| +| `Channels` | [QueryChannelsRequest](#ibc.core.channel.v1.QueryChannelsRequest) | [QueryChannelsResponse](#ibc.core.channel.v1.QueryChannelsResponse) | Channels queries all the IBC channels of a chain. | GET|/ibc/core/channel/v1beta1/channels| +| `ConnectionChannels` | [QueryConnectionChannelsRequest](#ibc.core.channel.v1.QueryConnectionChannelsRequest) | [QueryConnectionChannelsResponse](#ibc.core.channel.v1.QueryConnectionChannelsResponse) | ConnectionChannels queries all the channels associated with a connection end. | GET|/ibc/core/channel/v1beta1/connections/{connection}/channels| +| `ChannelClientState` | [QueryChannelClientStateRequest](#ibc.core.channel.v1.QueryChannelClientStateRequest) | [QueryChannelClientStateResponse](#ibc.core.channel.v1.QueryChannelClientStateResponse) | ChannelClientState queries for the client state for the channel associated with the provided channel identifiers. | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/client_state| +| `ChannelConsensusState` | [QueryChannelConsensusStateRequest](#ibc.core.channel.v1.QueryChannelConsensusStateRequest) | [QueryChannelConsensusStateResponse](#ibc.core.channel.v1.QueryChannelConsensusStateResponse) | ChannelConsensusState queries for the consensus state for the channel associated with the provided channel identifiers. | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/consensus_state/revision/{revision_number}/height/{revision_height}| +| `PacketCommitment` | [QueryPacketCommitmentRequest](#ibc.core.channel.v1.QueryPacketCommitmentRequest) | [QueryPacketCommitmentResponse](#ibc.core.channel.v1.QueryPacketCommitmentResponse) | PacketCommitment queries a stored packet commitment hash. | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/{sequence}| +| `PacketCommitments` | [QueryPacketCommitmentsRequest](#ibc.core.channel.v1.QueryPacketCommitmentsRequest) | [QueryPacketCommitmentsResponse](#ibc.core.channel.v1.QueryPacketCommitmentsResponse) | PacketCommitments returns all the packet commitments hashes associated with a channel. | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments| +| `PacketReceipt` | [QueryPacketReceiptRequest](#ibc.core.channel.v1.QueryPacketReceiptRequest) | [QueryPacketReceiptResponse](#ibc.core.channel.v1.QueryPacketReceiptResponse) | PacketReceipt queries if a given packet sequence has been received on the queried chain | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_receipts/{sequence}| +| `PacketAcknowledgement` | [QueryPacketAcknowledgementRequest](#ibc.core.channel.v1.QueryPacketAcknowledgementRequest) | [QueryPacketAcknowledgementResponse](#ibc.core.channel.v1.QueryPacketAcknowledgementResponse) | PacketAcknowledgement queries a stored packet acknowledgement hash. | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acks/{sequence}| +| `PacketAcknowledgements` | [QueryPacketAcknowledgementsRequest](#ibc.core.channel.v1.QueryPacketAcknowledgementsRequest) | [QueryPacketAcknowledgementsResponse](#ibc.core.channel.v1.QueryPacketAcknowledgementsResponse) | PacketAcknowledgements returns all the packet acknowledgements associated with a channel. | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acknowledgements| +| `UnreceivedPackets` | [QueryUnreceivedPacketsRequest](#ibc.core.channel.v1.QueryUnreceivedPacketsRequest) | [QueryUnreceivedPacketsResponse](#ibc.core.channel.v1.QueryUnreceivedPacketsResponse) | UnreceivedPackets returns all the unreceived IBC packets associated with a channel and sequences. | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/{packet_commitment_sequences}/unreceived_packets| +| `UnreceivedAcks` | [QueryUnreceivedAcksRequest](#ibc.core.channel.v1.QueryUnreceivedAcksRequest) | [QueryUnreceivedAcksResponse](#ibc.core.channel.v1.QueryUnreceivedAcksResponse) | UnreceivedAcks returns all the unreceived IBC acknowledgements associated with a channel and sequences. | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/{packet_ack_sequences}/unreceived_acks| +| `NextSequenceReceive` | [QueryNextSequenceReceiveRequest](#ibc.core.channel.v1.QueryNextSequenceReceiveRequest) | [QueryNextSequenceReceiveResponse](#ibc.core.channel.v1.QueryNextSequenceReceiveResponse) | NextSequenceReceive returns the next receive sequence for a given channel. | GET|/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/next_sequence| - +

Top

-## ibc/core/client/v1/genesis.proto +## ibc/core/channel/v1/tx.proto - + -### GenesisMetadata -GenesisMetadata defines the genesis type for metadata that clients may return -with ExportMetadata +### MsgAcknowledgement +MsgAcknowledgement receives incoming IBC acknowledgement | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `key` | [bytes](#bytes) | | store key of metadata without clientID-prefix | -| `value` | [bytes](#bytes) | | metadata value | - - +| `packet` | [Packet](#ibc.core.channel.v1.Packet) | | | +| `acknowledgement` | [bytes](#bytes) | | | +| `proof_acked` | [bytes](#bytes) | | | +| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | +| `signer` | [string](#string) | | | - -### GenesisState -GenesisState defines the ibc client submodule's genesis state. + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `clients` | [IdentifiedClientState](#ibc.core.client.v1.IdentifiedClientState) | repeated | client states with their corresponding identifiers | -| `clients_consensus` | [ClientConsensusStates](#ibc.core.client.v1.ClientConsensusStates) | repeated | consensus states from each client | -| `clients_metadata` | [IdentifiedGenesisMetadata](#ibc.core.client.v1.IdentifiedGenesisMetadata) | repeated | metadata from each client | -| `params` | [Params](#ibc.core.client.v1.Params) | | | -| `create_localhost` | [bool](#bool) | | create localhost on initialization | -| `next_client_sequence` | [uint64](#uint64) | | the sequence for the next generated client identifier | +### MsgAcknowledgementResponse +MsgAcknowledgementResponse defines the Msg/Acknowledgement response type. - + -### IdentifiedGenesisMetadata -IdentifiedGenesisMetadata has the client metadata with the corresponding client id. +### MsgChannelCloseConfirm +MsgChannelCloseConfirm defines a msg sent by a Relayer to Chain B +to acknowledge the change of channel state to CLOSED on Chain A. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `client_id` | [string](#string) | | | -| `client_metadata` | [GenesisMetadata](#ibc.core.client.v1.GenesisMetadata) | repeated | | - - +| `port_id` | [string](#string) | | | +| `channel_id` | [string](#string) | | | +| `proof_init` | [bytes](#bytes) | | | +| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | +| `signer` | [string](#string) | | | - - - - + +### MsgChannelCloseConfirmResponse +MsgChannelCloseConfirmResponse defines the Msg/ChannelCloseConfirm response type. - -

Top

-## ibc/core/client/v1/query.proto - + -### QueryClientParamsRequest -QueryClientParamsRequest is the request type for the Query/ClientParams RPC method. +### MsgChannelCloseInit +MsgChannelCloseInit defines a msg sent by a Relayer to Chain A +to close a channel with Chain B. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `port_id` | [string](#string) | | | +| `channel_id` | [string](#string) | | | +| `signer` | [string](#string) | | | - -### QueryClientParamsResponse -QueryClientParamsResponse is the response type for the Query/ClientParams RPC method. + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `params` | [Params](#ibc.core.client.v1.Params) | | params defines the parameters of the module. | +### MsgChannelCloseInitResponse +MsgChannelCloseInitResponse defines the Msg/ChannelCloseInit response type. - + -### QueryClientStateRequest -QueryClientStateRequest is the request type for the Query/ClientState RPC -method +### MsgChannelOpenAck +MsgChannelOpenAck defines a msg sent by a Relayer to Chain A to acknowledge +the change of channel state to TRYOPEN on Chain B. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `client_id` | [string](#string) | | client state unique identifier | - - +| `port_id` | [string](#string) | | | +| `channel_id` | [string](#string) | | | +| `counterparty_channel_id` | [string](#string) | | | +| `counterparty_version` | [string](#string) | | | +| `proof_try` | [bytes](#bytes) | | | +| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | +| `signer` | [string](#string) | | | - -### QueryClientStateResponse -QueryClientStateResponse is the response type for the Query/ClientState RPC -method. Besides the client state, it includes a proof and the height from -which the proof was retrieved. + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `client_state` | [google.protobuf.Any](#google.protobuf.Any) | | client state associated with the request identifier | -| `proof` | [bytes](#bytes) | | merkle proof of existence | -| `proof_height` | [Height](#ibc.core.client.v1.Height) | | height at which the proof was retrieved | +### MsgChannelOpenAckResponse +MsgChannelOpenAckResponse defines the Msg/ChannelOpenAck response type. - + -### QueryClientStatesRequest -QueryClientStatesRequest is the request type for the Query/ClientStates RPC -method +### MsgChannelOpenConfirm +MsgChannelOpenConfirm defines a msg sent by a Relayer to Chain B to +acknowledge the change of channel state to OPEN on Chain A. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination request | - - +| `port_id` | [string](#string) | | | +| `channel_id` | [string](#string) | | | +| `proof_ack` | [bytes](#bytes) | | | +| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | +| `signer` | [string](#string) | | | - -### QueryClientStatesResponse -QueryClientStatesResponse is the response type for the Query/ClientStates RPC -method. + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `client_states` | [IdentifiedClientState](#ibc.core.client.v1.IdentifiedClientState) | repeated | list of stored ClientStates of the chain. | -| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination response | +### MsgChannelOpenConfirmResponse +MsgChannelOpenConfirmResponse defines the Msg/ChannelOpenConfirm response type. - + -### QueryConsensusStateRequest -QueryConsensusStateRequest is the request type for the Query/ConsensusState -RPC method. Besides the consensus state, it includes a proof and the height -from which the proof was retrieved. +### MsgChannelOpenInit +MsgChannelOpenInit defines an sdk.Msg to initialize a channel handshake. It +is called by a relayer on Chain A. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `client_id` | [string](#string) | | client identifier | -| `revision_number` | [uint64](#uint64) | | consensus state revision number | -| `revision_height` | [uint64](#uint64) | | consensus state revision height | -| `latest_height` | [bool](#bool) | | latest_height overrrides the height field and queries the latest stored ConsensusState | - - +| `port_id` | [string](#string) | | | +| `channel` | [Channel](#ibc.core.channel.v1.Channel) | | | +| `signer` | [string](#string) | | | - -### QueryConsensusStateResponse -QueryConsensusStateResponse is the response type for the Query/ConsensusState -RPC method + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `consensus_state` | [google.protobuf.Any](#google.protobuf.Any) | | consensus state associated with the client identifier at the given height | -| `proof` | [bytes](#bytes) | | merkle proof of existence | -| `proof_height` | [Height](#ibc.core.client.v1.Height) | | height at which the proof was retrieved | +### MsgChannelOpenInitResponse +MsgChannelOpenInitResponse defines the Msg/ChannelOpenInit response type. - + -### QueryConsensusStatesRequest -QueryConsensusStatesRequest is the request type for the Query/ConsensusStates -RPC method. +### MsgChannelOpenTry +MsgChannelOpenInit defines a msg sent by a Relayer to try to open a channel +on Chain B. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `client_id` | [string](#string) | | client identifier | -| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination request | +| `port_id` | [string](#string) | | | +| `previous_channel_id` | [string](#string) | | in the case of crossing hello's, when both chains call OpenInit, we need the channel identifier of the previous channel in state INIT | +| `channel` | [Channel](#ibc.core.channel.v1.Channel) | | | +| `counterparty_version` | [string](#string) | | | +| `proof_init` | [bytes](#bytes) | | | +| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | +| `signer` | [string](#string) | | | - + -### QueryConsensusStatesResponse -QueryConsensusStatesResponse is the response type for the -Query/ConsensusStates RPC method +### MsgChannelOpenTryResponse +MsgChannelOpenTryResponse defines the Msg/ChannelOpenTry response type. -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `consensus_states` | [ConsensusStateWithHeight](#ibc.core.client.v1.ConsensusStateWithHeight) | repeated | consensus states associated with the identifier | -| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination response | + - +### MsgRecvPacket +MsgRecvPacket receives incoming IBC packet - - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `packet` | [Packet](#ibc.core.channel.v1.Packet) | | | +| `proof_commitment` | [bytes](#bytes) | | | +| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | +| `signer` | [string](#string) | | | - -### Query -Query provides defines the gRPC querier service -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `ClientState` | [QueryClientStateRequest](#ibc.core.client.v1.QueryClientStateRequest) | [QueryClientStateResponse](#ibc.core.client.v1.QueryClientStateResponse) | ClientState queries an IBC light client. | GET|/ibc/core/client/v1beta1/client_states/{client_id}| -| `ClientStates` | [QueryClientStatesRequest](#ibc.core.client.v1.QueryClientStatesRequest) | [QueryClientStatesResponse](#ibc.core.client.v1.QueryClientStatesResponse) | ClientStates queries all the IBC light clients of a chain. | GET|/ibc/core/client/v1beta1/client_states| -| `ConsensusState` | [QueryConsensusStateRequest](#ibc.core.client.v1.QueryConsensusStateRequest) | [QueryConsensusStateResponse](#ibc.core.client.v1.QueryConsensusStateResponse) | ConsensusState queries a consensus state associated with a client state at a given height. | GET|/ibc/core/client/v1beta1/consensus_states/{client_id}/revision/{revision_number}/height/{revision_height}| -| `ConsensusStates` | [QueryConsensusStatesRequest](#ibc.core.client.v1.QueryConsensusStatesRequest) | [QueryConsensusStatesResponse](#ibc.core.client.v1.QueryConsensusStatesResponse) | ConsensusStates queries all the consensus state associated with a given client. | GET|/ibc/core/client/v1beta1/consensus_states/{client_id}| -| `ClientParams` | [QueryClientParamsRequest](#ibc.core.client.v1.QueryClientParamsRequest) | [QueryClientParamsResponse](#ibc.core.client.v1.QueryClientParamsResponse) | ClientParams queries all parameters of the ibc client. | GET|/ibc/client/v1beta1/params| - + +### MsgRecvPacketResponse +MsgRecvPacketResponse defines the Msg/RecvPacket response type. - -

Top

-## ibc/core/client/v1/tx.proto - -### MsgCreateClient -MsgCreateClient defines a message to create an IBC client + + +### MsgTimeout +MsgTimeout receives timed-out packet | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `client_state` | [google.protobuf.Any](#google.protobuf.Any) | | light client state | -| `consensus_state` | [google.protobuf.Any](#google.protobuf.Any) | | consensus state associated with the client that corresponds to a given height. | -| `signer` | [string](#string) | | signer address | - - - +| `packet` | [Packet](#ibc.core.channel.v1.Packet) | | | +| `proof_unreceived` | [bytes](#bytes) | | | +| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | +| `next_sequence_recv` | [uint64](#uint64) | | | +| `signer` | [string](#string) | | | - -### MsgCreateClientResponse -MsgCreateClientResponse defines the Msg/CreateClient response type. + +### MsgTimeoutOnClose +MsgTimeoutOnClose timed-out packet upon counterparty channel closure. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `packet` | [Packet](#ibc.core.channel.v1.Packet) | | | +| `proof_unreceived` | [bytes](#bytes) | | | +| `proof_close` | [bytes](#bytes) | | | +| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | +| `next_sequence_recv` | [uint64](#uint64) | | | +| `signer` | [string](#string) | | | - -### MsgSubmitMisbehaviour -MsgSubmitMisbehaviour defines an sdk.Msg type that submits Evidence for -light client misbehaviour. -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `client_id` | [string](#string) | | client unique identifier | -| `misbehaviour` | [google.protobuf.Any](#google.protobuf.Any) | | misbehaviour used for freezing the light client | -| `signer` | [string](#string) | | signer address | + +### MsgTimeoutOnCloseResponse +MsgTimeoutOnCloseResponse defines the Msg/TimeoutOnClose response type. - -### MsgSubmitMisbehaviourResponse -MsgSubmitMisbehaviourResponse defines the Msg/SubmitMisbehaviour response type. + +### MsgTimeoutResponse +MsgTimeoutResponse defines the Msg/Timeout response type. - -### MsgUpdateClient -MsgUpdateClient defines an sdk.Msg to update a IBC client state using -the given header. + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `client_id` | [string](#string) | | client unique identifier | -| `header` | [google.protobuf.Any](#google.protobuf.Any) | | header to update the light client | -| `signer` | [string](#string) | | signer address | + + + +### Msg +Msg defines the ibc/channel Msg service. +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `ChannelOpenInit` | [MsgChannelOpenInit](#ibc.core.channel.v1.MsgChannelOpenInit) | [MsgChannelOpenInitResponse](#ibc.core.channel.v1.MsgChannelOpenInitResponse) | ChannelOpenInit defines a rpc handler method for MsgChannelOpenInit. | | +| `ChannelOpenTry` | [MsgChannelOpenTry](#ibc.core.channel.v1.MsgChannelOpenTry) | [MsgChannelOpenTryResponse](#ibc.core.channel.v1.MsgChannelOpenTryResponse) | ChannelOpenTry defines a rpc handler method for MsgChannelOpenTry. | | +| `ChannelOpenAck` | [MsgChannelOpenAck](#ibc.core.channel.v1.MsgChannelOpenAck) | [MsgChannelOpenAckResponse](#ibc.core.channel.v1.MsgChannelOpenAckResponse) | ChannelOpenAck defines a rpc handler method for MsgChannelOpenAck. | | +| `ChannelOpenConfirm` | [MsgChannelOpenConfirm](#ibc.core.channel.v1.MsgChannelOpenConfirm) | [MsgChannelOpenConfirmResponse](#ibc.core.channel.v1.MsgChannelOpenConfirmResponse) | ChannelOpenConfirm defines a rpc handler method for MsgChannelOpenConfirm. | | +| `ChannelCloseInit` | [MsgChannelCloseInit](#ibc.core.channel.v1.MsgChannelCloseInit) | [MsgChannelCloseInitResponse](#ibc.core.channel.v1.MsgChannelCloseInitResponse) | ChannelCloseInit defines a rpc handler method for MsgChannelCloseInit. | | +| `ChannelCloseConfirm` | [MsgChannelCloseConfirm](#ibc.core.channel.v1.MsgChannelCloseConfirm) | [MsgChannelCloseConfirmResponse](#ibc.core.channel.v1.MsgChannelCloseConfirmResponse) | ChannelCloseConfirm defines a rpc handler method for MsgChannelCloseConfirm. | | +| `RecvPacket` | [MsgRecvPacket](#ibc.core.channel.v1.MsgRecvPacket) | [MsgRecvPacketResponse](#ibc.core.channel.v1.MsgRecvPacketResponse) | RecvPacket defines a rpc handler method for MsgRecvPacket. | | +| `Timeout` | [MsgTimeout](#ibc.core.channel.v1.MsgTimeout) | [MsgTimeoutResponse](#ibc.core.channel.v1.MsgTimeoutResponse) | Timeout defines a rpc handler method for MsgTimeout. | | +| `TimeoutOnClose` | [MsgTimeoutOnClose](#ibc.core.channel.v1.MsgTimeoutOnClose) | [MsgTimeoutOnCloseResponse](#ibc.core.channel.v1.MsgTimeoutOnCloseResponse) | TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. | | +| `Acknowledgement` | [MsgAcknowledgement](#ibc.core.channel.v1.MsgAcknowledgement) | [MsgAcknowledgementResponse](#ibc.core.channel.v1.MsgAcknowledgementResponse) | Acknowledgement defines a rpc handler method for MsgAcknowledgement. | | - + -### MsgUpdateClientResponse -MsgUpdateClientResponse defines the Msg/UpdateClient response type. + +

Top

+## ibc/core/channel/v1/genesis.proto - + -### MsgUpgradeClient -MsgUpgradeClient defines an sdk.Msg to upgrade an IBC client to a new client state +### GenesisState +GenesisState defines the ibc channel submodule's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `client_id` | [string](#string) | | client unique identifier | -| `client_state` | [google.protobuf.Any](#google.protobuf.Any) | | upgraded client state | -| `consensus_state` | [google.protobuf.Any](#google.protobuf.Any) | | upgraded consensus state, only contains enough information to serve as a basis of trust in update logic | -| `proof_upgrade_client` | [bytes](#bytes) | | proof that old chain committed to new client | -| `proof_upgrade_consensus_state` | [bytes](#bytes) | | proof that old chain committed to new consensus state | -| `signer` | [string](#string) | | signer address | +| `channels` | [IdentifiedChannel](#ibc.core.channel.v1.IdentifiedChannel) | repeated | | +| `acknowledgements` | [PacketState](#ibc.core.channel.v1.PacketState) | repeated | | +| `commitments` | [PacketState](#ibc.core.channel.v1.PacketState) | repeated | | +| `receipts` | [PacketState](#ibc.core.channel.v1.PacketState) | repeated | | +| `send_sequences` | [PacketSequence](#ibc.core.channel.v1.PacketSequence) | repeated | | +| `recv_sequences` | [PacketSequence](#ibc.core.channel.v1.PacketSequence) | repeated | | +| `ack_sequences` | [PacketSequence](#ibc.core.channel.v1.PacketSequence) | repeated | | +| `next_channel_sequence` | [uint64](#uint64) | | the sequence for the next generated channel identifier | - + -### MsgUpgradeClientResponse -MsgUpgradeClientResponse defines the Msg/UpgradeClient response type. +### PacketSequence +PacketSequence defines the genesis type necessary to retrieve and store +next send and receive sequences. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `port_id` | [string](#string) | | | +| `channel_id` | [string](#string) | | | +| `sequence` | [uint64](#uint64) | | | @@ -9500,19 +9513,6 @@ MsgUpgradeClientResponse defines the Msg/UpgradeClient response type. - - - -### Msg -Msg defines the ibc/client Msg service. - -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `CreateClient` | [MsgCreateClient](#ibc.core.client.v1.MsgCreateClient) | [MsgCreateClientResponse](#ibc.core.client.v1.MsgCreateClientResponse) | CreateClient defines a rpc handler method for MsgCreateClient. | | -| `UpdateClient` | [MsgUpdateClient](#ibc.core.client.v1.MsgUpdateClient) | [MsgUpdateClientResponse](#ibc.core.client.v1.MsgUpdateClientResponse) | UpdateClient defines a rpc handler method for MsgUpdateClient. | | -| `UpgradeClient` | [MsgUpgradeClient](#ibc.core.client.v1.MsgUpgradeClient) | [MsgUpgradeClientResponse](#ibc.core.client.v1.MsgUpgradeClientResponse) | UpgradeClient defines a rpc handler method for MsgUpgradeClient. | | -| `SubmitMisbehaviour` | [MsgSubmitMisbehaviour](#ibc.core.client.v1.MsgSubmitMisbehaviour) | [MsgSubmitMisbehaviourResponse](#ibc.core.client.v1.MsgSubmitMisbehaviourResponse) | SubmitMisbehaviour defines a rpc handler method for MsgSubmitMisbehaviour. | | - @@ -9741,39 +9741,6 @@ INIT, TRYOPEN, OPEN or UNINITIALIZED. - -

Top

- -## ibc/core/connection/v1/genesis.proto - - - - - -### GenesisState -GenesisState defines the ibc connection submodule's genesis state. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `connections` | [IdentifiedConnection](#ibc.core.connection.v1.IdentifiedConnection) | repeated | | -| `client_connection_paths` | [ConnectionPaths](#ibc.core.connection.v1.ConnectionPaths) | repeated | | -| `next_connection_sequence` | [uint64](#uint64) | | the sequence for the next generated connection identifier | - - - - - - - - - - - - - - -

Top

@@ -10069,126 +10036,281 @@ initialize a connection with Chain B. - + + +### MsgConnectionOpenInitResponse +MsgConnectionOpenInitResponse defines the Msg/ConnectionOpenInit response type. + + + + + + + + +### MsgConnectionOpenTry +MsgConnectionOpenTry defines a msg sent by a Relayer to try to open a +connection on Chain B. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `client_id` | [string](#string) | | | +| `previous_connection_id` | [string](#string) | | in the case of crossing hello's, when both chains call OpenInit, we need the connection identifier of the previous connection in state INIT | +| `client_state` | [google.protobuf.Any](#google.protobuf.Any) | | | +| `counterparty` | [Counterparty](#ibc.core.connection.v1.Counterparty) | | | +| `delay_period` | [uint64](#uint64) | | | +| `counterparty_versions` | [Version](#ibc.core.connection.v1.Version) | repeated | | +| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | +| `proof_init` | [bytes](#bytes) | | proof of the initialization the connection on Chain A: `UNITIALIZED -> INIT` | +| `proof_client` | [bytes](#bytes) | | proof of client state included in message | +| `proof_consensus` | [bytes](#bytes) | | proof of client consensus state | +| `consensus_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | +| `signer` | [string](#string) | | | + + + + + + + + +### MsgConnectionOpenTryResponse +MsgConnectionOpenTryResponse defines the Msg/ConnectionOpenTry response type. + + + + + + + + + + + + + + +### Msg +Msg defines the ibc/connection Msg service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `ConnectionOpenInit` | [MsgConnectionOpenInit](#ibc.core.connection.v1.MsgConnectionOpenInit) | [MsgConnectionOpenInitResponse](#ibc.core.connection.v1.MsgConnectionOpenInitResponse) | ConnectionOpenInit defines a rpc handler method for MsgConnectionOpenInit. | | +| `ConnectionOpenTry` | [MsgConnectionOpenTry](#ibc.core.connection.v1.MsgConnectionOpenTry) | [MsgConnectionOpenTryResponse](#ibc.core.connection.v1.MsgConnectionOpenTryResponse) | ConnectionOpenTry defines a rpc handler method for MsgConnectionOpenTry. | | +| `ConnectionOpenAck` | [MsgConnectionOpenAck](#ibc.core.connection.v1.MsgConnectionOpenAck) | [MsgConnectionOpenAckResponse](#ibc.core.connection.v1.MsgConnectionOpenAckResponse) | ConnectionOpenAck defines a rpc handler method for MsgConnectionOpenAck. | | +| `ConnectionOpenConfirm` | [MsgConnectionOpenConfirm](#ibc.core.connection.v1.MsgConnectionOpenConfirm) | [MsgConnectionOpenConfirmResponse](#ibc.core.connection.v1.MsgConnectionOpenConfirmResponse) | ConnectionOpenConfirm defines a rpc handler method for MsgConnectionOpenConfirm. | | + + + + + + +

Top

+ +## ibc/core/connection/v1/genesis.proto + + + + + +### GenesisState +GenesisState defines the ibc connection submodule's genesis state. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `connections` | [IdentifiedConnection](#ibc.core.connection.v1.IdentifiedConnection) | repeated | | +| `client_connection_paths` | [ConnectionPaths](#ibc.core.connection.v1.ConnectionPaths) | repeated | | +| `next_connection_sequence` | [uint64](#uint64) | | the sequence for the next generated connection identifier | + + + + + + + + + + + + + + + + +

Top

+ +## ibc/core/types/v1/genesis.proto + + + + + +### GenesisState +GenesisState defines the ibc module's genesis state. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `client_genesis` | [ibc.core.client.v1.GenesisState](#ibc.core.client.v1.GenesisState) | | ICS002 - Clients genesis state | +| `connection_genesis` | [ibc.core.connection.v1.GenesisState](#ibc.core.connection.v1.GenesisState) | | ICS003 - Connections genesis state | +| `channel_genesis` | [ibc.core.channel.v1.GenesisState](#ibc.core.channel.v1.GenesisState) | | ICS004 - Channel genesis state | + + + + + + + + + + + + + + + + +

Top

+ +## ibc/lightclients/localhost/v1/localhost.proto + + + + -### MsgConnectionOpenInitResponse -MsgConnectionOpenInitResponse defines the Msg/ConnectionOpenInit response type. +### ClientState +ClientState defines a loopback (localhost) client. It requires (read-only) +access to keys outside the client prefix. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `chain_id` | [string](#string) | | self chain ID | +| `height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | self latest block height | - -### MsgConnectionOpenTry -MsgConnectionOpenTry defines a msg sent by a Relayer to try to open a -connection on Chain B. + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `client_id` | [string](#string) | | | -| `previous_connection_id` | [string](#string) | | in the case of crossing hello's, when both chains call OpenInit, we need the connection identifier of the previous connection in state INIT | -| `client_state` | [google.protobuf.Any](#google.protobuf.Any) | | | -| `counterparty` | [Counterparty](#ibc.core.connection.v1.Counterparty) | | | -| `delay_period` | [uint64](#uint64) | | | -| `counterparty_versions` | [Version](#ibc.core.connection.v1.Version) | repeated | | -| `proof_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | -| `proof_init` | [bytes](#bytes) | | proof of the initialization the connection on Chain A: `UNITIALIZED -> INIT` | -| `proof_client` | [bytes](#bytes) | | proof of client state included in message | -| `proof_consensus` | [bytes](#bytes) | | proof of client consensus state | -| `consensus_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | -| `signer` | [string](#string) | | | + + + +

Top

+## ibc/lightclients/tendermint/v1/tendermint.proto - -### MsgConnectionOpenTryResponse -MsgConnectionOpenTryResponse defines the Msg/ConnectionOpenTry response type. + +### ClientState +ClientState from Tendermint tracks the current validator set, latest height, +and a possible frozen height. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `chain_id` | [string](#string) | | | +| `trust_level` | [Fraction](#ibc.lightclients.tendermint.v1.Fraction) | | | +| `trusting_period` | [google.protobuf.Duration](#google.protobuf.Duration) | | duration of the period since the LastestTimestamp during which the submitted headers are valid for upgrade | +| `unbonding_period` | [google.protobuf.Duration](#google.protobuf.Duration) | | duration of the staking unbonding period | +| `max_clock_drift` | [google.protobuf.Duration](#google.protobuf.Duration) | | defines how much new (untrusted) header's Time can drift into the future. | +| `frozen_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | Block height when the client was frozen due to a misbehaviour | +| `latest_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | Latest height the client was updated to | +| `proof_specs` | [ics23.ProofSpec](#ics23.ProofSpec) | repeated | Proof specifications used in verifying counterparty state | +| `upgrade_path` | [string](#string) | repeated | Path at which next upgraded client will be committed. Each element corresponds to the key for a single CommitmentProof in the chained proof. NOTE: ClientState must stored under `{upgradePath}/{upgradeHeight}/clientState` ConsensusState must be stored under `{upgradepath}/{upgradeHeight}/consensusState` For SDK chains using the default upgrade module, upgrade_path should be []string{"upgrade", "upgradedIBCState"}` | +| `allow_update_after_expiry` | [bool](#bool) | | This flag, when set to true, will allow governance to recover a client which has expired | +| `allow_update_after_misbehaviour` | [bool](#bool) | | This flag, when set to true, will allow governance to unfreeze a client whose chain has experienced a misbehaviour event | - - - - -### Msg -Msg defines the ibc/connection Msg service. + -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `ConnectionOpenInit` | [MsgConnectionOpenInit](#ibc.core.connection.v1.MsgConnectionOpenInit) | [MsgConnectionOpenInitResponse](#ibc.core.connection.v1.MsgConnectionOpenInitResponse) | ConnectionOpenInit defines a rpc handler method for MsgConnectionOpenInit. | | -| `ConnectionOpenTry` | [MsgConnectionOpenTry](#ibc.core.connection.v1.MsgConnectionOpenTry) | [MsgConnectionOpenTryResponse](#ibc.core.connection.v1.MsgConnectionOpenTryResponse) | ConnectionOpenTry defines a rpc handler method for MsgConnectionOpenTry. | | -| `ConnectionOpenAck` | [MsgConnectionOpenAck](#ibc.core.connection.v1.MsgConnectionOpenAck) | [MsgConnectionOpenAckResponse](#ibc.core.connection.v1.MsgConnectionOpenAckResponse) | ConnectionOpenAck defines a rpc handler method for MsgConnectionOpenAck. | | -| `ConnectionOpenConfirm` | [MsgConnectionOpenConfirm](#ibc.core.connection.v1.MsgConnectionOpenConfirm) | [MsgConnectionOpenConfirmResponse](#ibc.core.connection.v1.MsgConnectionOpenConfirmResponse) | ConnectionOpenConfirm defines a rpc handler method for MsgConnectionOpenConfirm. | | +### ConsensusState +ConsensusState defines the consensus state from Tendermint. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `timestamp` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | timestamp that corresponds to the block height in which the ConsensusState was stored. | +| `root` | [ibc.core.commitment.v1.MerkleRoot](#ibc.core.commitment.v1.MerkleRoot) | | commitment root (i.e app hash) | +| `next_validators_hash` | [bytes](#bytes) | | | - -

Top

-## ibc/core/types/v1/genesis.proto - + -### GenesisState -GenesisState defines the ibc module's genesis state. +### Fraction +Fraction defines the protobuf message type for tmmath.Fraction that only supports positive values. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `client_genesis` | [ibc.core.client.v1.GenesisState](#ibc.core.client.v1.GenesisState) | | ICS002 - Clients genesis state | -| `connection_genesis` | [ibc.core.connection.v1.GenesisState](#ibc.core.connection.v1.GenesisState) | | ICS003 - Connections genesis state | -| `channel_genesis` | [ibc.core.channel.v1.GenesisState](#ibc.core.channel.v1.GenesisState) | | ICS004 - Channel genesis state | +| `numerator` | [uint64](#uint64) | | | +| `denominator` | [uint64](#uint64) | | | - - + - +### Header +Header defines the Tendermint client consensus Header. +It encapsulates all the information necessary to update from a trusted +Tendermint ConsensusState. The inclusion of TrustedHeight and +TrustedValidators allows this update to process correctly, so long as the +ConsensusState for the TrustedHeight exists, this removes race conditions +among relayers The SignedHeader and ValidatorSet are the new untrusted update +fields for the client. The TrustedHeight is the height of a stored +ConsensusState on the client that will be used to verify the new untrusted +header. The Trusted ConsensusState must be within the unbonding period of +current time in order to correctly verify, and the TrustedValidators must +hash to TrustedConsensusState.NextValidatorsHash since that is the last +trusted validator set at the TrustedHeight. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `signed_header` | [tendermint.types.SignedHeader](#tendermint.types.SignedHeader) | | | +| `validator_set` | [tendermint.types.ValidatorSet](#tendermint.types.ValidatorSet) | | | +| `trusted_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | +| `trusted_validators` | [tendermint.types.ValidatorSet](#tendermint.types.ValidatorSet) | | | - -

Top

-## ibc/lightclients/localhost/v1/localhost.proto - + -### ClientState -ClientState defines a loopback (localhost) client. It requires (read-only) -access to keys outside the client prefix. +### Misbehaviour +Misbehaviour is a wrapper over two conflicting Headers +that implements Misbehaviour interface expected by ICS-02 | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `chain_id` | [string](#string) | | self chain ID | -| `height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | self latest block height | +| `client_id` | [string](#string) | | | +| `header_1` | [Header](#ibc.lightclients.tendermint.v1.Header) | | | +| `header_2` | [Header](#ibc.lightclients.tendermint.v1.Header) | | | @@ -10521,128 +10643,6 @@ data sign byte encodings. - -

Top

- -## ibc/lightclients/tendermint/v1/tendermint.proto - - - - - -### ClientState -ClientState from Tendermint tracks the current validator set, latest height, -and a possible frozen height. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `chain_id` | [string](#string) | | | -| `trust_level` | [Fraction](#ibc.lightclients.tendermint.v1.Fraction) | | | -| `trusting_period` | [google.protobuf.Duration](#google.protobuf.Duration) | | duration of the period since the LastestTimestamp during which the submitted headers are valid for upgrade | -| `unbonding_period` | [google.protobuf.Duration](#google.protobuf.Duration) | | duration of the staking unbonding period | -| `max_clock_drift` | [google.protobuf.Duration](#google.protobuf.Duration) | | defines how much new (untrusted) header's Time can drift into the future. | -| `frozen_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | Block height when the client was frozen due to a misbehaviour | -| `latest_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | Latest height the client was updated to | -| `proof_specs` | [ics23.ProofSpec](#ics23.ProofSpec) | repeated | Proof specifications used in verifying counterparty state | -| `upgrade_path` | [string](#string) | repeated | Path at which next upgraded client will be committed. Each element corresponds to the key for a single CommitmentProof in the chained proof. NOTE: ClientState must stored under `{upgradePath}/{upgradeHeight}/clientState` ConsensusState must be stored under `{upgradepath}/{upgradeHeight}/consensusState` For SDK chains using the default upgrade module, upgrade_path should be []string{"upgrade", "upgradedIBCState"}` | -| `allow_update_after_expiry` | [bool](#bool) | | This flag, when set to true, will allow governance to recover a client which has expired | -| `allow_update_after_misbehaviour` | [bool](#bool) | | This flag, when set to true, will allow governance to unfreeze a client whose chain has experienced a misbehaviour event | - - - - - - - - -### ConsensusState -ConsensusState defines the consensus state from Tendermint. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `timestamp` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | timestamp that corresponds to the block height in which the ConsensusState was stored. | -| `root` | [ibc.core.commitment.v1.MerkleRoot](#ibc.core.commitment.v1.MerkleRoot) | | commitment root (i.e app hash) | -| `next_validators_hash` | [bytes](#bytes) | | | - - - - - - - - -### Fraction -Fraction defines the protobuf message type for tmmath.Fraction that only supports positive values. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `numerator` | [uint64](#uint64) | | | -| `denominator` | [uint64](#uint64) | | | - - - - - - - - -### Header -Header defines the Tendermint client consensus Header. -It encapsulates all the information necessary to update from a trusted -Tendermint ConsensusState. The inclusion of TrustedHeight and -TrustedValidators allows this update to process correctly, so long as the -ConsensusState for the TrustedHeight exists, this removes race conditions -among relayers The SignedHeader and ValidatorSet are the new untrusted update -fields for the client. The TrustedHeight is the height of a stored -ConsensusState on the client that will be used to verify the new untrusted -header. The Trusted ConsensusState must be within the unbonding period of -current time in order to correctly verify, and the TrustedValidators must -hash to TrustedConsensusState.NextValidatorsHash since that is the last -trusted validator set at the TrustedHeight. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `signed_header` | [tendermint.types.SignedHeader](#tendermint.types.SignedHeader) | | | -| `validator_set` | [tendermint.types.ValidatorSet](#tendermint.types.ValidatorSet) | | | -| `trusted_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | -| `trusted_validators` | [tendermint.types.ValidatorSet](#tendermint.types.ValidatorSet) | | | - - - - - - - - -### Misbehaviour -Misbehaviour is a wrapper over two conflicting Headers -that implements Misbehaviour interface expected by ICS-02 - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `client_id` | [string](#string) | | | -| `header_1` | [Header](#ibc.lightclients.tendermint.v1.Header) | | | -| `header_2` | [Header](#ibc.lightclients.tendermint.v1.Header) | | | - - - - - - - - - - - - - - - ## Scalar Value Types | .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby | From 6509b55e21d487be2310e047498c179d30d6a0c3 Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 28 Jan 2021 21:29:06 +0530 Subject: [PATCH 184/184] add docs --- proto/cosmos/feegrant/v1beta1/feegrant.proto | 21 ++++++++++++++++-- x/feegrant/types/feegrant.pb.go | 23 +++++++++++++++----- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/proto/cosmos/feegrant/v1beta1/feegrant.proto b/proto/cosmos/feegrant/v1beta1/feegrant.proto index 9879e488886e..534de582d977 100644 --- a/proto/cosmos/feegrant/v1beta1/feegrant.proto +++ b/proto/cosmos/feegrant/v1beta1/feegrant.proto @@ -15,8 +15,13 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; message BasicFeeAllowance { option (cosmos_proto.implements_interface) = "FeeAllowanceI"; + // spend_limit specifies the maximum amount of tokens that can be spent + // by this allowance and will be updated as tokens are spent. If it is + // empty, there is no spend limit and any amount of coins can be spent. repeated cosmos.base.v1beta1.Coin spend_limit = 1 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + + // expiration specifies an optional time when this allowance expires ExpiresAt expiration = 2 [(gogoproto.nullable) = false]; } @@ -25,13 +30,25 @@ message BasicFeeAllowance { message PeriodicFeeAllowance { option (cosmos_proto.implements_interface) = "FeeAllowanceI"; - BasicFeeAllowance basic = 1 [(gogoproto.nullable) = false]; - Duration period = 2 [(gogoproto.nullable) = false]; + // basic specifies a struct of `BasicFeeAllowance` + BasicFeeAllowance basic = 1 [(gogoproto.nullable) = false]; + + // period specifies the time duration in which period_spend_limit coins can + // be spent before that allowance is reset + Duration period = 2 [(gogoproto.nullable) = false]; + + // period_spend_limit specifies the maximum number of coins that can be spent + // in the period repeated cosmos.base.v1beta1.Coin period_spend_limit = 3 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + + // period_can_spend is the number of coins left to be spent before the period_reset time repeated cosmos.base.v1beta1.Coin period_can_spend = 4 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + // period_reset is the time at which this period resets and a new one begins, + // it is calculated from the start time of the first transaction after the + // last period ended ExpiresAt period_reset = 5 [(gogoproto.nullable) = false]; } diff --git a/x/feegrant/types/feegrant.pb.go b/x/feegrant/types/feegrant.pb.go index d60cf72a177e..2897bcc392d6 100644 --- a/x/feegrant/types/feegrant.pb.go +++ b/x/feegrant/types/feegrant.pb.go @@ -35,8 +35,12 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens // that optionally expires. The delegatee can use up to SpendLimit to cover fees. type BasicFeeAllowance struct { + // spend_limit specifies the maximum amount of tokens that can be spent + // by this allowance and will be updated as tokens are spent. If it is + // empty, there is no spend limit and any amount of coins can be spent. SpendLimit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=spend_limit,json=spendLimit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"spend_limit"` - Expiration ExpiresAt `protobuf:"bytes,2,opt,name=expiration,proto3" json:"expiration"` + // expiration specifies an optional time when this allowance expires + Expiration ExpiresAt `protobuf:"bytes,2,opt,name=expiration,proto3" json:"expiration"` } func (m *BasicFeeAllowance) Reset() { *m = BasicFeeAllowance{} } @@ -89,11 +93,20 @@ func (m *BasicFeeAllowance) GetExpiration() ExpiresAt { // PeriodicFeeAllowance extends FeeAllowance to allow for both a maximum cap, // as well as a limit per time period. type PeriodicFeeAllowance struct { - Basic BasicFeeAllowance `protobuf:"bytes,1,opt,name=basic,proto3" json:"basic"` - Period Duration `protobuf:"bytes,2,opt,name=period,proto3" json:"period"` + // basic specifies a struct of `BasicFeeAllowance` + Basic BasicFeeAllowance `protobuf:"bytes,1,opt,name=basic,proto3" json:"basic"` + // period specifies the time duration in which period_spend_limit coins can + // be spent before that allowance is reset + Period Duration `protobuf:"bytes,2,opt,name=period,proto3" json:"period"` + // period_spend_limit specifies the maximum number of coins that can be spent + // in the period PeriodSpendLimit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=period_spend_limit,json=periodSpendLimit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"period_spend_limit"` - PeriodCanSpend github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=period_can_spend,json=periodCanSpend,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"period_can_spend"` - PeriodReset ExpiresAt `protobuf:"bytes,5,opt,name=period_reset,json=periodReset,proto3" json:"period_reset"` + // period_can_spend is the number of coins left to be spent before the period_reset time + PeriodCanSpend github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=period_can_spend,json=periodCanSpend,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"period_can_spend"` + // period_reset is the time at which this period resets and a new one begins, + // it is calculated from the start time of the first transaction after the + // last period ended + PeriodReset ExpiresAt `protobuf:"bytes,5,opt,name=period_reset,json=periodReset,proto3" json:"period_reset"` } func (m *PeriodicFeeAllowance) Reset() { *m = PeriodicFeeAllowance{} }