Skip to content

Commit

Permalink
x/feegrant API Audit changes (#9194)
Browse files Browse the repository at this point in the history
* -add comments to proto fields
-add comments to msg and query server
-remove decorator from docs
-add coments to msgs.go
-remove decorator from godoc

* Update x/feegrant/spec/04_events.md

Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>

* refactor and add to docs
*refactor proto msg names and functions
*add docs pertaining to auth's ante handler for deducted fees

* lint

* update comment

* gofmt

Co-authored-by: technicallyty <48813565+tytech3@users.noreply.github.com>
Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored May 3, 2021
1 parent 711976e commit d3bcc15
Show file tree
Hide file tree
Showing 43 changed files with 1,008 additions and 991 deletions.
134 changes: 67 additions & 67 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,29 +307,29 @@
- [Msg](#cosmos.evidence.v1beta1.Msg)

- [cosmos/feegrant/v1beta1/feegrant.proto](#cosmos/feegrant/v1beta1/feegrant.proto)
- [AllowedMsgFeeAllowance](#cosmos.feegrant.v1beta1.AllowedMsgFeeAllowance)
- [BasicFeeAllowance](#cosmos.feegrant.v1beta1.BasicFeeAllowance)
- [AllowedMsgAllowance](#cosmos.feegrant.v1beta1.AllowedMsgAllowance)
- [BasicAllowance](#cosmos.feegrant.v1beta1.BasicAllowance)
- [Duration](#cosmos.feegrant.v1beta1.Duration)
- [ExpiresAt](#cosmos.feegrant.v1beta1.ExpiresAt)
- [FeeAllowanceGrant](#cosmos.feegrant.v1beta1.FeeAllowanceGrant)
- [PeriodicFeeAllowance](#cosmos.feegrant.v1beta1.PeriodicFeeAllowance)
- [Grant](#cosmos.feegrant.v1beta1.Grant)
- [PeriodicAllowance](#cosmos.feegrant.v1beta1.PeriodicAllowance)

- [cosmos/feegrant/v1beta1/genesis.proto](#cosmos/feegrant/v1beta1/genesis.proto)
- [GenesisState](#cosmos.feegrant.v1beta1.GenesisState)

- [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)
- [QueryAllowanceRequest](#cosmos.feegrant.v1beta1.QueryAllowanceRequest)
- [QueryAllowanceResponse](#cosmos.feegrant.v1beta1.QueryAllowanceResponse)
- [QueryAllowancesRequest](#cosmos.feegrant.v1beta1.QueryAllowancesRequest)
- [QueryAllowancesResponse](#cosmos.feegrant.v1beta1.QueryAllowancesResponse)

- [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)
- [MsgGrantAllowance](#cosmos.feegrant.v1beta1.MsgGrantAllowance)
- [MsgGrantAllowanceResponse](#cosmos.feegrant.v1beta1.MsgGrantAllowanceResponse)
- [MsgRevokeAllowance](#cosmos.feegrant.v1beta1.MsgRevokeAllowance)
- [MsgRevokeAllowanceResponse](#cosmos.feegrant.v1beta1.MsgRevokeAllowanceResponse)

- [Msg](#cosmos.feegrant.v1beta1.Msg)

Expand Down Expand Up @@ -4545,10 +4545,10 @@ Msg defines the evidence Msg service.



<a name="cosmos.feegrant.v1beta1.AllowedMsgFeeAllowance"></a>
<a name="cosmos.feegrant.v1beta1.AllowedMsgAllowance"></a>

### AllowedMsgFeeAllowance
AllowedMsgFeeAllowance creates allowance only for specified message types.
### AllowedMsgAllowance
AllowedMsgAllowance creates allowance only for specified message types.


| Field | Type | Label | Description |
Expand All @@ -4561,11 +4561,11 @@ AllowedMsgFeeAllowance creates allowance only for specified message types.



<a name="cosmos.feegrant.v1beta1.BasicFeeAllowance"></a>
<a name="cosmos.feegrant.v1beta1.BasicAllowance"></a>

### BasicFeeAllowance
BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens
that optionally expires. The delegatee can use up to SpendLimit to cover fees.
### BasicAllowance
BasicAllowance implements Allowance with a one-time grant of tokens
that optionally expires. The grantee can use up to SpendLimit to cover fees.


| Field | Type | Label | Description |
Expand Down Expand Up @@ -4612,33 +4612,33 @@ It may be *either* block time or block height



<a name="cosmos.feegrant.v1beta1.FeeAllowanceGrant"></a>
<a name="cosmos.feegrant.v1beta1.Grant"></a>

### FeeAllowanceGrant
FeeAllowanceGrant is stored in the KVStore to record a grant with full context
### Grant
Grant 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) | | |
| `granter` | [string](#string) | | granter is the address of the user granting an allowance of their funds. |
| `grantee` | [string](#string) | | grantee is the address of the user being granted an allowance of another user's funds. |
| `allowance` | [google.protobuf.Any](#google.protobuf.Any) | | allowance can be any of basic and filtered fee allowance. |






<a name="cosmos.feegrant.v1beta1.PeriodicFeeAllowance"></a>
<a name="cosmos.feegrant.v1beta1.PeriodicAllowance"></a>

### PeriodicFeeAllowance
PeriodicFeeAllowance extends FeeAllowance to allow for both a maximum cap,
### PeriodicAllowance
PeriodicAllowance extends Allowance to allow for both a maximum cap,
as well as a limit per time period.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `basic` | [BasicFeeAllowance](#cosmos.feegrant.v1beta1.BasicFeeAllowance) | | basic specifies a struct of `BasicFeeAllowance` |
| `basic` | [BasicAllowance](#cosmos.feegrant.v1beta1.BasicAllowance) | | basic specifies a struct of `BasicAllowance` |
| `period` | [Duration](#cosmos.feegrant.v1beta1.Duration) | | period specifies the time duration in which period_spend_limit coins can be spent before that allowance is reset |
| `period_spend_limit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | period_spend_limit specifies the maximum number of coins that can be spent in the period |
| `period_can_spend` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | period_can_spend is the number of coins left to be spent before the period_reset time |
Expand Down Expand Up @@ -4673,7 +4673,7 @@ GenesisState contains a set of fee allowances, persisted from the store

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `fee_allowances` | [FeeAllowanceGrant](#cosmos.feegrant.v1beta1.FeeAllowanceGrant) | repeated | |
| `allowances` | [Grant](#cosmos.feegrant.v1beta1.Grant) | repeated | |



Expand All @@ -4696,41 +4696,41 @@ GenesisState contains a set of fee allowances, persisted from the store



<a name="cosmos.feegrant.v1beta1.QueryFeeAllowanceRequest"></a>
<a name="cosmos.feegrant.v1beta1.QueryAllowanceRequest"></a>

### QueryFeeAllowanceRequest
QueryFeeAllowanceRequest is the request type for the Query/FeeAllowance RPC method.
### QueryAllowanceRequest
QueryAllowanceRequest is the request type for the Query/Allowance RPC method.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `granter` | [string](#string) | | |
| `grantee` | [string](#string) | | |
| `granter` | [string](#string) | | granter is the address of the user granting an allowance of their funds. |
| `grantee` | [string](#string) | | grantee is the address of the user being granted an allowance of another user's funds. |






<a name="cosmos.feegrant.v1beta1.QueryFeeAllowanceResponse"></a>
<a name="cosmos.feegrant.v1beta1.QueryAllowanceResponse"></a>

### QueryFeeAllowanceResponse
QueryFeeAllowanceResponse is the response type for the Query/FeeAllowance RPC method.
### QueryAllowanceResponse
QueryAllowanceResponse is the response type for the Query/Allowance RPC method.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `fee_allowance` | [FeeAllowanceGrant](#cosmos.feegrant.v1beta1.FeeAllowanceGrant) | | fee_allowance is a fee_allowance granted for grantee by granter. |
| `allowance` | [Grant](#cosmos.feegrant.v1beta1.Grant) | | allowance is a allowance granted for grantee by granter. |






<a name="cosmos.feegrant.v1beta1.QueryFeeAllowancesRequest"></a>
<a name="cosmos.feegrant.v1beta1.QueryAllowancesRequest"></a>

### QueryFeeAllowancesRequest
QueryFeeAllowancesRequest is the request type for the Query/FeeAllowances RPC method.
### QueryAllowancesRequest
QueryAllowancesRequest is the request type for the Query/Allowances RPC method.


| Field | Type | Label | Description |
Expand All @@ -4743,15 +4743,15 @@ QueryFeeAllowancesRequest is the request type for the Query/FeeAllowances RPC me



<a name="cosmos.feegrant.v1beta1.QueryFeeAllowancesResponse"></a>
<a name="cosmos.feegrant.v1beta1.QueryAllowancesResponse"></a>

### QueryFeeAllowancesResponse
QueryFeeAllowancesResponse is the response type for the Query/FeeAllowances RPC method.
### QueryAllowancesResponse
QueryAllowancesResponse is the response type for the Query/Allowances RPC method.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `fee_allowances` | [FeeAllowanceGrant](#cosmos.feegrant.v1beta1.FeeAllowanceGrant) | repeated | fee_allowances are fee_allowance's granted for grantee by granter. |
| `allowances` | [Grant](#cosmos.feegrant.v1beta1.Grant) | repeated | allowances are 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. |


Expand All @@ -4772,8 +4772,8 @@ 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}|
| `Allowance` | [QueryAllowanceRequest](#cosmos.feegrant.v1beta1.QueryAllowanceRequest) | [QueryAllowanceResponse](#cosmos.feegrant.v1beta1.QueryAllowanceResponse) | Allowance returns fee granted to the grantee by the granter. | GET|/cosmos/feegrant/v1beta1/allowance/{granter}/{grantee}|
| `Allowances` | [QueryAllowancesRequest](#cosmos.feegrant.v1beta1.QueryAllowancesRequest) | [QueryAllowancesResponse](#cosmos.feegrant.v1beta1.QueryAllowancesResponse) | Allowances returns all the grants for address. | GET|/cosmos/feegrant/v1beta1/allowances/{grantee}|

<!-- end services -->

Expand All @@ -4786,54 +4786,54 @@ Query defines the gRPC querier service.



<a name="cosmos.feegrant.v1beta1.MsgGrantFeeAllowance"></a>
<a name="cosmos.feegrant.v1beta1.MsgGrantAllowance"></a>

### MsgGrantFeeAllowance
MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance
### MsgGrantAllowance
MsgGrantAllowance 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) | | |
| `granter` | [string](#string) | | granter is the address of the user granting an allowance of their funds. |
| `grantee` | [string](#string) | | grantee is the address of the user being granted an allowance of another user's funds. |
| `allowance` | [google.protobuf.Any](#google.protobuf.Any) | | allowance can be any of basic and filtered fee allowance. |






<a name="cosmos.feegrant.v1beta1.MsgGrantFeeAllowanceResponse"></a>
<a name="cosmos.feegrant.v1beta1.MsgGrantAllowanceResponse"></a>

### MsgGrantFeeAllowanceResponse
MsgGrantFeeAllowanceResponse defines the Msg/GrantFeeAllowanceResponse response type.
### MsgGrantAllowanceResponse
MsgGrantAllowanceResponse defines the Msg/GrantAllowanceResponse response type.






<a name="cosmos.feegrant.v1beta1.MsgRevokeFeeAllowance"></a>
<a name="cosmos.feegrant.v1beta1.MsgRevokeAllowance"></a>

### MsgRevokeFeeAllowance
MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee.
### MsgRevokeAllowance
MsgRevokeAllowance removes any existing Allowance from Granter to Grantee.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `granter` | [string](#string) | | |
| `grantee` | [string](#string) | | |
| `granter` | [string](#string) | | granter is the address of the user granting an allowance of their funds. |
| `grantee` | [string](#string) | | grantee is the address of the user being granted an allowance of another user's funds. |






<a name="cosmos.feegrant.v1beta1.MsgRevokeFeeAllowanceResponse"></a>
<a name="cosmos.feegrant.v1beta1.MsgRevokeAllowanceResponse"></a>

### MsgRevokeFeeAllowanceResponse
MsgRevokeFeeAllowanceResponse defines the Msg/RevokeFeeAllowanceResponse response type.
### MsgRevokeAllowanceResponse
MsgRevokeAllowanceResponse defines the Msg/RevokeAllowanceResponse response type.



Expand All @@ -4853,8 +4853,8 @@ Msg defines the feegrant msg service.

| 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. | |
| `GrantAllowance` | [MsgGrantAllowance](#cosmos.feegrant.v1beta1.MsgGrantAllowance) | [MsgGrantAllowanceResponse](#cosmos.feegrant.v1beta1.MsgGrantAllowanceResponse) | GrantAllowance grants fee allowance to the grantee on the granter's account with the provided expiration time. | |
| `RevokeAllowance` | [MsgRevokeAllowance](#cosmos.feegrant.v1beta1.MsgRevokeAllowance) | [MsgRevokeAllowanceResponse](#cosmos.feegrant.v1beta1.MsgRevokeAllowanceResponse) | RevokeAllowance revokes any fee allowance of granter's account that has been granted to the grantee. | |

<!-- end services -->

Expand Down
28 changes: 16 additions & 12 deletions proto/cosmos/feegrant/v1beta1/feegrant.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ 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 {
// BasicAllowance implements Allowance with a one-time grant of tokens
// that optionally expires. The grantee can use up to SpendLimit to cover fees.
message BasicAllowance {
option (cosmos_proto.implements_interface) = "FeeAllowanceI";

// spend_limit specifies the maximum amount of tokens that can be spent
Expand All @@ -25,13 +25,13 @@ message BasicFeeAllowance {
ExpiresAt expiration = 2 [(gogoproto.nullable) = false];
}

// PeriodicFeeAllowance extends FeeAllowance to allow for both a maximum cap,
// PeriodicAllowance extends Allowance to allow for both a maximum cap,
// as well as a limit per time period.
message PeriodicFeeAllowance {
message PeriodicAllowance {
option (cosmos_proto.implements_interface) = "FeeAllowanceI";

// basic specifies a struct of `BasicFeeAllowance`
BasicFeeAllowance basic = 1 [(gogoproto.nullable) = false];
// basic specifies a struct of `BasicAllowance`
BasicAllowance basic = 1 [(gogoproto.nullable) = false];

// period specifies the time duration in which period_spend_limit coins can
// be spent before that allowance is reset
Expand All @@ -52,8 +52,8 @@ message PeriodicFeeAllowance {
ExpiresAt period_reset = 5 [(gogoproto.nullable) = false];
}

// AllowedMsgFeeAllowance creates allowance only for specified message types.
message AllowedMsgFeeAllowance {
// AllowedMsgAllowance creates allowance only for specified message types.
message AllowedMsgAllowance {
option (gogoproto.goproto_getters) = false;
option (cosmos_proto.implements_interface) = "FeeAllowanceI";

Expand Down Expand Up @@ -84,10 +84,14 @@ message ExpiresAt {
}
}

// FeeAllowanceGrant is stored in the KVStore to record a grant with full context
message FeeAllowanceGrant {

// Grant is stored in the KVStore to record a grant with full context
message Grant {
// granter is the address of the user granting an allowance of their funds.
string granter = 1;

// grantee is the address of the user being granted an allowance of another user's funds.
string grantee = 2;

// allowance can be any of basic and filtered fee allowance.
google.protobuf.Any allowance = 3 [(cosmos_proto.accepts_interface) = "FeeAllowanceI"];
}
2 changes: 1 addition & 1 deletion proto/cosmos/feegrant/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ 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];
repeated Grant allowances = 1 [(gogoproto.nullable) = false];
}
Loading

0 comments on commit d3bcc15

Please sign in to comment.