forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add docs * Add BasicFeeAllowance implementation * Add expiration structs and complete basic fee * Add delegation messages, add validation logic * Add keeper and helper structs * Add alias and handler to top level * Add delegation module * Add basic querier * Add types tests * Add types tests * More internal test coverage * Solid internal test coverage * Expose Querier to top level module * Add FeeAccount to auth/types, like StdTx, SignDoc * Fix all tests in x/auth * All tests pass * Appease the Golang Linter * Add fee-account command line flag * Start on DelegatedDeductFeeDecorator * Cleanup the Decorator * Wire up delegation module in simapp * add basic test for decorator (no delegation) * Table tests for deduct fees * Table tests over all conditions of delegated fee decorator * Build full ante handler stack and test it * Start genesis * Implement Genesis * Rename package delegation to subkeys * Clarify antes test cases, handle empty account w/o fees * Allow paying delegated fees with no account * Pull mempool into delegated ante, for control on StdFee * Use custom DelegatedTx, DelegatedFee for subkeys * Revert all changes to x/auth.StdTx * Appease scopelint * Register DelegatedTx with codec * Address PR comments * Remove unnecessary DelegatedMempoolFeeDecorator * Cleaned up errors in querier * Clean up message sign bytes * Minor PR comments * Replace GetAllFees... with Iterator variants * PrepareForExport adjusts grant expiration height * Panic on de/serialization error in keeper * Move custom ante handler chain to tests, update docs * More cleanup * More doc cleanup * Renamed subkeys module to fee_grant * Rename subkeys/delegation to fee grant in all strings * Modify Msg and Keeper methods to use Grant not Delegate * Add PeriodicFeeAllowance * Update aliases * Cover all accept cases for PeriodicFeeAllowance * Et tu scopelint? * Update docs as requested * Remove error return from GetFeeGrant * Code cleanup as requested by PR * Updated all errors to use new sdk/errors package * Use test suite for keeper tests * Clean up alias.go file * Define expected interfaces in exported, rather than importing from account * Remove dependency on auth/ante * Improve godoc, Logger * Cleaned up ExpiresAt * Improve error reporting with UseGrantedFee * Enforce period limit subset of basic limit * Add events * Rename fee_grant to feegrant * Ensure KeeperTestSuite actually runs * Move types/tx to types * Update alias file, include ante * I do need nolint in alias.go * Properly emit events in the handler. Use cosmos-sdk in amino types * Update godoc * Linting... * Update errors * Update pkg doc and fix ante-handler order * Merge PR cosmos#5782: Migrate x/feegrant to proto * fix errors * proto changes * proto changes * fix errors * fix errors * genesis state changed to proto * fix keeper tests * fix test * fixed tests * fix tests * updated expected keepers * updated ante tests * lint * deleted alias.go * tx updated to proto tx * remove explicit signmode * tests * Added `cli/query.go` * Added tx.go in cli * updated `module.go` * resolve errors in tx.go * Add fee payer gentx func * updated tx * fixed error * WIP: cli tests * fix query error * fix tests * Unused types and funcs * fix tests * rename helper func to create tx * remove unused * update tx cfg * fix cli tests * added simulations * Add `decoder.go` * fix build fail * added init genesis code * update tx.go * fixed LGTM alert * modified cli * remove gogoproto extensions * change acc address type to string * lint * fix simulations * Add gen simulations * remove legacy querier * remove legacy code * add grpc queries tests * fix simulations * update module.go * lint * register feegrant NewSimulationManager * fix sims * fix sims * add genesis test * add periodic grant * updated cmd * changed times * updated flags * removed days as period clock * added condition for period and exp * add periodic fee cli tests * udpated tests * fix lint * fix tests * fix sims * renaming to `fee_grant` * review changes * fix test * add condition for duplicate grants * fix tests * add `genTxWithFeeGranter` in tests * fix simulation * one of changes & test fixes * fix test * fix lint * changed package name `feegrant` to `fee_grant` * review comments * review changes * review change * review changes * added fee-account in flags * address review changes * read fee granter from cli * updated create account with mnemonic * Address review comments * move `simapp/ante` file to `feegrant/ante` * update keeper logic to create account * update docs * fix tests * update `serviceMsgClientConn` from `msgservice` * review changes * add test case for using more fees than allowed * eliminate panic checks from keeper * fix lint * change store keys string to bytes * fix tests * review changes * review changes * udpate docs * make spend limit optional * fix tests * fix tests * review changes * add norace tag * proto-docs * add docs Co-authored-by: Ethan Frey <ethanfrey@users.noreply.github.com> Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <aleks.bezobchuk@gmail.com> Co-authored-by: SaReN <sahithnarahari@gmail.com> Co-authored-by: aleem1413 <aleem@vitwit.com> Co-authored-by: MD Aleem <72057206+aleem1314@users.noreply.github.com> Co-authored-by: Anil Kumar Kammari <anil@vitwit.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
3b8e0f9
commit d97e790
Showing
57 changed files
with
13,148 additions
and
3,636 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
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 "google/protobuf/timestamp.proto"; | ||
import "google/protobuf/duration.proto"; | ||
|
||
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 (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]; | ||
} | ||
|
||
// PeriodicFeeAllowance extends FeeAllowance to allow for both a maximum cap, | ||
// as well as a limit per time period. | ||
message PeriodicFeeAllowance { | ||
option (cosmos_proto.implements_interface) = "FeeAllowanceI"; | ||
|
||
// 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]; | ||
} | ||
|
||
// 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 | ||
oneof sum { | ||
google.protobuf.Duration duration = 1 [(gogoproto.stdduration) = true]; | ||
uint64 blocks = 2; | ||
} | ||
} | ||
|
||
// ExpiresAt is a point in time where something expires. | ||
// It may be *either* block time or block height | ||
message ExpiresAt { | ||
// 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 | ||
message FeeAllowanceGrant { | ||
|
||
string granter = 1; | ||
string grantee = 2; | ||
google.protobuf.Any allowance = 3 [(cosmos_proto.accepts_interface) = "FeeAllowanceI"]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
syntax = "proto3"; | ||
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) { | ||
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/fee_allowances/{grantee}"; | ||
} | ||
} | ||
|
||
// QueryFeeAllowanceRequest is the request type for the Query/FeeAllowance RPC method. | ||
message QueryFeeAllowanceRequest { | ||
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; | ||
} | ||
|
||
// QueryFeeAllowancesRequest is the request type for the Query/FeeAllowances RPC method. | ||
message QueryFeeAllowancesRequest { | ||
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_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. | ||
cosmos.base.query.v1beta1.PageResponse pagination = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
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"; | ||
|
||
// 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 { | ||
string granter = 1; | ||
string grantee = 2; | ||
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 { | ||
string granter = 1; | ||
string grantee = 2; | ||
} | ||
|
||
// MsgRevokeFeeAllowanceResponse defines the Msg/RevokeFeeAllowanceResponse response type. | ||
message MsgRevokeFeeAllowanceResponse {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.