feat: add feegrant query to see allowances from a given granter (backport #10947) (#11885)

This commit is contained in:
Julien Robert 2022-05-06 16:27:38 +02:00 committed by GitHub
parent 85bf0aaeda
commit 8bbeba5b46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 2172 additions and 1197 deletions

File diff suppressed because it is too large Load Diff

View File

@ -325,6 +325,8 @@
- [cosmos/feegrant/v1beta1/query.proto](#cosmos/feegrant/v1beta1/query.proto) - [cosmos/feegrant/v1beta1/query.proto](#cosmos/feegrant/v1beta1/query.proto)
- [QueryAllowanceRequest](#cosmos.feegrant.v1beta1.QueryAllowanceRequest) - [QueryAllowanceRequest](#cosmos.feegrant.v1beta1.QueryAllowanceRequest)
- [QueryAllowanceResponse](#cosmos.feegrant.v1beta1.QueryAllowanceResponse) - [QueryAllowanceResponse](#cosmos.feegrant.v1beta1.QueryAllowanceResponse)
- [QueryAllowancesByGranterRequest](#cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest)
- [QueryAllowancesByGranterResponse](#cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse)
- [QueryAllowancesRequest](#cosmos.feegrant.v1beta1.QueryAllowancesRequest) - [QueryAllowancesRequest](#cosmos.feegrant.v1beta1.QueryAllowancesRequest)
- [QueryAllowancesResponse](#cosmos.feegrant.v1beta1.QueryAllowancesResponse) - [QueryAllowancesResponse](#cosmos.feegrant.v1beta1.QueryAllowancesResponse)
@ -932,6 +934,8 @@ the provide method with expiration time.
GrantAuthorization extends a grant with both the addresses of the grantee and granter. GrantAuthorization extends a grant with both the addresses of the grantee and granter.
It is used in genesis.proto and query.proto It is used in genesis.proto and query.proto
Since: cosmos-sdk 0.45.2
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
@ -1156,10 +1160,10 @@ Query defines the gRPC querier service.
| `Grants` | [QueryGrantsRequest](#cosmos.authz.v1beta1.QueryGrantsRequest) | [QueryGrantsResponse](#cosmos.authz.v1beta1.QueryGrantsResponse) | Returns list of `Authorization`, granted to the grantee by the granter. | GET|/cosmos/authz/v1beta1/grants| | `Grants` | [QueryGrantsRequest](#cosmos.authz.v1beta1.QueryGrantsRequest) | [QueryGrantsResponse](#cosmos.authz.v1beta1.QueryGrantsResponse) | Returns list of `Authorization`, granted to the grantee by the granter. | GET|/cosmos/authz/v1beta1/grants|
| `GranterGrants` | [QueryGranterGrantsRequest](#cosmos.authz.v1beta1.QueryGranterGrantsRequest) | [QueryGranterGrantsResponse](#cosmos.authz.v1beta1.QueryGranterGrantsResponse) | GranterGrants returns list of `GrantAuthorization`, granted by granter. | `GranterGrants` | [QueryGranterGrantsRequest](#cosmos.authz.v1beta1.QueryGranterGrantsRequest) | [QueryGranterGrantsResponse](#cosmos.authz.v1beta1.QueryGranterGrantsResponse) | GranterGrants returns list of `GrantAuthorization`, granted by granter.
Since: cosmos-sdk 0.46 | GET|/cosmos/authz/v1beta1/grants/granter/{granter}| Since: cosmos-sdk 0.45.2 | GET|/cosmos/authz/v1beta1/grants/granter/{granter}|
| `GranteeGrants` | [QueryGranteeGrantsRequest](#cosmos.authz.v1beta1.QueryGranteeGrantsRequest) | [QueryGranteeGrantsResponse](#cosmos.authz.v1beta1.QueryGranteeGrantsResponse) | GranteeGrants returns a list of `GrantAuthorization` by grantee. | `GranteeGrants` | [QueryGranteeGrantsRequest](#cosmos.authz.v1beta1.QueryGranteeGrantsRequest) | [QueryGranteeGrantsResponse](#cosmos.authz.v1beta1.QueryGranteeGrantsResponse) | GranteeGrants returns a list of `GrantAuthorization` by grantee.
Since: cosmos-sdk 0.46 | GET|/cosmos/authz/v1beta1/grants/grantee/{grantee}| Since: cosmos-sdk 0.45.2 | GET|/cosmos/authz/v1beta1/grants/grantee/{grantee}|
<!-- end services --> <!-- end services -->
@ -4850,6 +4854,38 @@ QueryAllowanceResponse is the response type for the Query/Allowance RPC method.
<a name="cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest"></a>
### QueryAllowancesByGranterRequest
QueryAllowancesByGranterRequest is the request type for the Query/AllowancesByGranter RPC method.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `granter` | [string](#string) | | |
| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an pagination for the request. |
<a name="cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse"></a>
### QueryAllowancesByGranterResponse
QueryAllowancesByGranterResponse is the response type for the Query/AllowancesByGranter RPC method.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `allowances` | [Grant](#cosmos.feegrant.v1beta1.Grant) | repeated | allowances that have been issued by the granter. |
| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines an pagination for the response. |
<a name="cosmos.feegrant.v1beta1.QueryAllowancesRequest"></a> <a name="cosmos.feegrant.v1beta1.QueryAllowancesRequest"></a>
### QueryAllowancesRequest ### QueryAllowancesRequest
@ -4897,6 +4933,7 @@ Query defines the gRPC querier service.
| ----------- | ------------ | ------------- | ------------| ------- | -------- | | ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `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}| | `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}| | `Allowances` | [QueryAllowancesRequest](#cosmos.feegrant.v1beta1.QueryAllowancesRequest) | [QueryAllowancesResponse](#cosmos.feegrant.v1beta1.QueryAllowancesResponse) | Allowances returns all the grants for address. | GET|/cosmos/feegrant/v1beta1/allowances/{grantee}|
| `AllowancesByGranter` | [QueryAllowancesByGranterRequest](#cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest) | [QueryAllowancesByGranterResponse](#cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse) | AllowancesByGranter returns all the grants given by an address Since v0.46 | GET|/cosmos/feegrant/v1beta1/issued/{granter}|
<!-- end services --> <!-- end services -->
@ -7595,6 +7632,11 @@ SignMode represents a signing mode with its own security guarantees.
| SIGN_MODE_DIRECT | 1 | SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is verified with raw bytes from Tx | | 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_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 | | 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 |
| SIGN_MODE_EIP_191 | 191 | SIGN_MODE_EIP_191 specifies the sign mode for EIP 191 signing on the Cosmos SDK. Ref: https://eips.ethereum.org/EIPS/eip-191
Currently, SIGN_MODE_EIP_191 is registered as a SignMode enum variant, but is not implemented on the SDK by default. To enable EIP-191, you need to pass a custom `TxConfig` that has an implementation of `SignModeHandler` for EIP-191. The SDK may decide to fully support EIP-191 in the future.
Since: cosmos-sdk 0.45.2 |
<!-- end enums --> <!-- end enums -->

View File

@ -55,7 +55,7 @@ service Query {
// QueryBalanceRequest is the request type for the Query/Balance RPC method. // QueryBalanceRequest is the request type for the Query/Balance RPC method.
message QueryBalanceRequest { message QueryBalanceRequest {
option (gogoproto.equal) = false; option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false; option (gogoproto.goproto_getters) = false;
// address is the address to query balances for. // address is the address to query balances for.
@ -73,7 +73,7 @@ message QueryBalanceResponse {
// QueryBalanceRequest is the request type for the Query/AllBalances RPC method. // QueryBalanceRequest is the request type for the Query/AllBalances RPC method.
message QueryAllBalancesRequest { message QueryAllBalancesRequest {
option (gogoproto.equal) = false; option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false; option (gogoproto.goproto_getters) = false;
// address is the address to query balances for. // address is the address to query balances for.
@ -88,7 +88,7 @@ message QueryAllBalancesRequest {
message QueryAllBalancesResponse { message QueryAllBalancesResponse {
// balances is the balances of all the coins. // balances is the balances of all the coins.
repeated cosmos.base.v1beta1.Coin balances = 1 repeated cosmos.base.v1beta1.Coin balances = 1
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
// pagination defines the pagination in the response. // pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2; cosmos.base.query.v1beta1.PageResponse pagination = 2;
@ -121,7 +121,7 @@ message QuerySpendableBalancesResponse {
// QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC // QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC
// method. // method.
message QueryTotalSupplyRequest { message QueryTotalSupplyRequest {
option (gogoproto.equal) = false; option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false; option (gogoproto.goproto_getters) = false;
// pagination defines an optional pagination for the request. // pagination defines an optional pagination for the request.
@ -135,7 +135,7 @@ message QueryTotalSupplyRequest {
message QueryTotalSupplyResponse { message QueryTotalSupplyResponse {
// supply is the supply of the coins // supply is the supply of the coins
repeated cosmos.base.v1beta1.Coin supply = 1 repeated cosmos.base.v1beta1.Coin supply = 1
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
// pagination defines the pagination in the response. // pagination defines the pagination in the response.
// //

View File

@ -37,12 +37,12 @@ message SnapshotStoreItem {
// SnapshotIAVLItem is an exported IAVL node. // SnapshotIAVLItem is an exported IAVL node.
message SnapshotIAVLItem { message SnapshotIAVLItem {
bytes key = 1; bytes key = 1;
bytes value = 2; bytes value = 2;
// version is block height // version is block height
int64 version = 3; int64 version = 3;
// height is depth of the tree. // height is depth of the tree.
int32 height = 4; int32 height = 4;
} }
// SnapshotExtensionMeta contains metadata about an external snapshotter. // SnapshotExtensionMeta contains metadata about an external snapshotter.

View File

@ -116,15 +116,15 @@ message GetNodeInfoResponse {
// VersionInfo is the type for the GetNodeInfoResponse message. // VersionInfo is the type for the GetNodeInfoResponse message.
message VersionInfo { message VersionInfo {
string name = 1; string name = 1;
string app_name = 2; string app_name = 2;
string version = 3; string version = 3;
string git_commit = 4; string git_commit = 4;
string build_tags = 5; string build_tags = 5;
string go_version = 6; string go_version = 6;
repeated Module build_deps = 7; repeated Module build_deps = 7;
// Since: cosmos-sdk 0.43 // Since: cosmos-sdk 0.43
string cosmos_sdk_version = 8; string cosmos_sdk_version = 8;
} }
// Module is the type for VersionInfo // Module is the type for VersionInfo

View File

@ -20,6 +20,12 @@ service Query {
rpc Allowances(QueryAllowancesRequest) returns (QueryAllowancesResponse) { rpc Allowances(QueryAllowancesRequest) returns (QueryAllowancesResponse) {
option (google.api.http).get = "/cosmos/feegrant/v1beta1/allowances/{grantee}"; option (google.api.http).get = "/cosmos/feegrant/v1beta1/allowances/{grantee}";
} }
// AllowancesByGranter returns all the grants given by an address
// Since v0.46
rpc AllowancesByGranter(QueryAllowancesByGranterRequest) returns (QueryAllowancesByGranterResponse) {
option (google.api.http).get = "/cosmos/feegrant/v1beta1/issued/{granter}";
}
} }
// QueryAllowanceRequest is the request type for the Query/Allowance RPC method. // QueryAllowanceRequest is the request type for the Query/Allowance RPC method.
@ -53,3 +59,20 @@ message QueryAllowancesResponse {
// pagination defines an pagination for the response. // pagination defines an pagination for the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2; cosmos.base.query.v1beta1.PageResponse pagination = 2;
} }
// QueryAllowancesByGranterRequest is the request type for the Query/AllowancesByGranter RPC method.
message QueryAllowancesByGranterRequest {
string granter = 1;
// pagination defines an pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}
// QueryAllowancesByGranterResponse is the response type for the Query/AllowancesByGranter RPC method.
message QueryAllowancesByGranterResponse {
// allowances that have been issued by the granter.
repeated cosmos.feegrant.v1beta1.Grant allowances = 1;
// pagination defines an pagination for the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

View File

@ -136,7 +136,7 @@ message Vote {
// Deprecated: Prefer to use `options` instead. This field is set in queries // Deprecated: Prefer to use `options` instead. This field is set in queries
// if and only if `len(options) == 1` and that option has weight 1. In all // if and only if `len(options) == 1` and that option has weight 1. In all
// other cases, this field will default to VOTE_OPTION_UNSPECIFIED. // other cases, this field will default to VOTE_OPTION_UNSPECIFIED.
VoteOption option = 3 [deprecated = true]; VoteOption option = 3 [deprecated = true];
// Since: cosmos-sdk 0.43 // Since: cosmos-sdk 0.43
repeated WeightedVoteOption options = 4 [(gogoproto.nullable) = false]; repeated WeightedVoteOption options = 4 [(gogoproto.nullable) = false];
} }

View File

@ -27,7 +27,7 @@ enum SignMode {
// SIGN_MODE_EIP_191 specifies the sign mode for EIP 191 signing on the Cosmos // SIGN_MODE_EIP_191 specifies the sign mode for EIP 191 signing on the Cosmos
// SDK. Ref: https://eips.ethereum.org/EIPS/eip-191 // SDK. Ref: https://eips.ethereum.org/EIPS/eip-191
// //
// Currently, SIGN_MODE_EIP_191 is registered as a SignMode enum variant, // Currently, SIGN_MODE_EIP_191 is registered as a SignMode enum variant,
// but is not implemented on the SDK by default. To enable EIP-191, you need // but is not implemented on the SDK by default. To enable EIP-191, you need
// to pass a custom `TxConfig` that has an implementation of // to pass a custom `TxConfig` that has an implementation of

View File

@ -157,9 +157,9 @@ message GetBlockWithTxsRequest {
// Since: cosmos-sdk 0.45.2 // Since: cosmos-sdk 0.45.2
message GetBlockWithTxsResponse { message GetBlockWithTxsResponse {
// txs are the transactions in the block. // txs are the transactions in the block.
repeated cosmos.tx.v1beta1.Tx txs = 1; repeated cosmos.tx.v1beta1.Tx txs = 1;
.tendermint.types.BlockID block_id = 2; .tendermint.types.BlockID block_id = 2;
.tendermint.types.Block block = 3; .tendermint.types.Block block = 3;
// pagination defines a pagination for the response. // pagination defines a pagination for the response.
cosmos.base.query.v1beta1.PageResponse pagination = 4; cosmos.base.query.v1beta1.PageResponse pagination = 4;
} }

17
types/kv/helpers.go Normal file
View File

@ -0,0 +1,17 @@
package kv
import "fmt"
// AssertKeyAtLeastLength panics when store key length is less than the given length.
func AssertKeyAtLeastLength(bz []byte, length int) {
if len(bz) < length {
panic(fmt.Sprintf("expected key of length at least %d, got %d", length, len(bz)))
}
}
// AssertKeyLength panics when store key length is not equal to the given length.
func AssertKeyLength(bz []byte, length int) {
if len(bz) != length {
panic(fmt.Sprintf("unexpected key length; got: %d, expected: %d", len(bz), length))
}
}

View File

@ -44,7 +44,13 @@ const (
// SIGN_MODE_EIP_191 specifies the sign mode for EIP 191 signing on the Cosmos // SIGN_MODE_EIP_191 specifies the sign mode for EIP 191 signing on the Cosmos
// SDK. Ref: https://eips.ethereum.org/EIPS/eip-191 // SDK. Ref: https://eips.ethereum.org/EIPS/eip-191
// //
// Since: cosmos-sdk 0.45 // Currently, SIGN_MODE_EIP_191 is registered as a SignMode enum variant,
// but is not implemented on the SDK by default. To enable EIP-191, you need
// to pass a custom `TxConfig` that has an implementation of
// `SignModeHandler` for EIP-191. The SDK may decide to fully support
// EIP-191 in the future.
//
// Since: cosmos-sdk 0.45.2
SignMode_SIGN_MODE_EIP_191 SignMode = 191 SignMode_SIGN_MODE_EIP_191 SignMode = 191
) )
@ -398,43 +404,43 @@ func init() {
} }
var fileDescriptor_9a54958ff3d0b1b9 = []byte{ var fileDescriptor_9a54958ff3d0b1b9 = []byte{
// 573 bytes of a gzipped FileDescriptorProto // 562 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xc1, 0x6e, 0xd3, 0x4c, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xcd, 0x6e, 0xd3, 0x4c,
0x10, 0xc7, 0xed, 0x26, 0xad, 0xda, 0xe9, 0xa7, 0x4f, 0x66, 0x49, 0x51, 0x6a, 0x90, 0xa9, 0xca, 0x14, 0x86, 0xed, 0xe6, 0x47, 0xe9, 0xf4, 0xd3, 0x27, 0x33, 0xa4, 0x28, 0x31, 0xc8, 0x44, 0x65,
0x81, 0x0a, 0xa9, 0x6b, 0xa5, 0x3d, 0xa0, 0x72, 0x73, 0x13, 0x93, 0x9a, 0x36, 0x69, 0xb1, 0x53, 0x41, 0x84, 0x94, 0xb1, 0x92, 0x2c, 0x50, 0xd9, 0xe5, 0xc7, 0xa4, 0xa6, 0x4d, 0x52, 0xec, 0x54,
0xa9, 0x70, 0xb1, 0x6c, 0x67, 0x6b, 0xac, 0xc6, 0x5e, 0xe3, 0x5d, 0xa3, 0xfa, 0xc4, 0x2b, 0xf0, 0x02, 0x36, 0x96, 0xed, 0x4c, 0x8d, 0xd5, 0xd8, 0x63, 0x3c, 0x63, 0x54, 0xaf, 0xb8, 0x00, 0x36,
0x12, 0x1c, 0x78, 0x0a, 0x0e, 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 0xbc, 0xde, 0xf5, 0x03, 0xfe, 0x26, 0x75, 0xb1, 0x47, 0x43, 0xb5, 0x7c, 0xf6, 0xf9, 0x67, 0x78, 0x72, 0xf6, 0xb8, 0x93, 0x4f, 0x83, 0x4e, 0xaf, 0x64, 0x16, 0x07, 0x78, 0xfb, 0x8f, 0x61,
0x97, 0xf5, 0xaf, 0x54, 0x9e, 0xc5, 0x64, 0xfe, 0x5f, 0xe2, 0xae, 0xe4, 0x8f, 0x66, 0xff, 0x67, 0x15, 0x93, 0xa7, 0xd1, 0xfe, 0x15, 0x00, 0x00, 0xff, 0xff, 0x7a, 0x72, 0xd3, 0x58, 0x4d, 0x04,
0x00, 0x00, 0x00, 0xff, 0xff, 0x02, 0x3d, 0xad, 0x03, 0x67, 0x04, 0x00, 0x00, 0x00, 0x00,
} }
func (m *SignatureDescriptors) Marshal() (dAtA []byte, err error) { func (m *SignatureDescriptors) Marshal() (dAtA []byte, err error) {

View File

@ -111,6 +111,8 @@ var xxx_messageInfo_Grant proto.InternalMessageInfo
// GrantAuthorization extends a grant with both the addresses of the grantee and granter. // GrantAuthorization extends a grant with both the addresses of the grantee and granter.
// It is used in genesis.proto and query.proto // It is used in genesis.proto and query.proto
//
// Since: cosmos-sdk 0.45.2
type GrantAuthorization struct { type GrantAuthorization struct {
Granter string `protobuf:"bytes,1,opt,name=granter,proto3" json:"granter,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"` Grantee string `protobuf:"bytes,2,opt,name=grantee,proto3" json:"grantee,omitempty"`

View File

@ -4,6 +4,7 @@ import (
"github.com/cosmos/cosmos-sdk/internal/conv" "github.com/cosmos/cosmos-sdk/internal/conv"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address" "github.com/cosmos/cosmos-sdk/types/address"
"github.com/cosmos/cosmos-sdk/types/kv"
"github.com/cosmos/cosmos-sdk/x/authz" "github.com/cosmos/cosmos-sdk/x/authz"
) )
@ -38,9 +39,12 @@ func grantStoreKey(grantee sdk.AccAddress, granter sdk.AccAddress, msgType strin
func addressesFromGrantStoreKey(key []byte) (granterAddr, granteeAddr sdk.AccAddress) { func addressesFromGrantStoreKey(key []byte) (granterAddr, granteeAddr sdk.AccAddress) {
// key is of format: // key is of format:
// 0x01<granterAddressLen (1 Byte)><granterAddress_Bytes><granteeAddressLen (1 Byte)><granteeAddress_Bytes><msgType_Bytes> // 0x01<granterAddressLen (1 Byte)><granterAddress_Bytes><granteeAddressLen (1 Byte)><granteeAddress_Bytes><msgType_Bytes>
kv.AssertKeyAtLeastLength(key, 2)
granterAddrLen := key[1] // remove prefix key granterAddrLen := key[1] // remove prefix key
kv.AssertKeyAtLeastLength(key, int(3+granterAddrLen))
granterAddr = sdk.AccAddress(key[2 : 2+granterAddrLen]) granterAddr = sdk.AccAddress(key[2 : 2+granterAddrLen])
granteeAddrLen := int(key[2+granterAddrLen]) granteeAddrLen := int(key[2+granterAddrLen])
kv.AssertKeyAtLeastLength(key, 4+int(granterAddrLen+byte(granteeAddrLen)))
granteeAddr = sdk.AccAddress(key[3+granterAddrLen : 3+granterAddrLen+byte(granteeAddrLen)]) granteeAddr = sdk.AccAddress(key[3+granterAddrLen : 3+granterAddrLen+byte(granteeAddrLen)])
return granterAddr, granteeAddr return granterAddr, granteeAddr

View File

@ -435,11 +435,11 @@ type QueryClient interface {
Grants(ctx context.Context, in *QueryGrantsRequest, opts ...grpc.CallOption) (*QueryGrantsResponse, error) Grants(ctx context.Context, in *QueryGrantsRequest, opts ...grpc.CallOption) (*QueryGrantsResponse, error)
// GranterGrants returns list of `GrantAuthorization`, granted by granter. // GranterGrants returns list of `GrantAuthorization`, granted by granter.
// //
// Since: cosmos-sdk 0.46 // Since: cosmos-sdk 0.45.2
GranterGrants(ctx context.Context, in *QueryGranterGrantsRequest, opts ...grpc.CallOption) (*QueryGranterGrantsResponse, error) GranterGrants(ctx context.Context, in *QueryGranterGrantsRequest, opts ...grpc.CallOption) (*QueryGranterGrantsResponse, error)
// GranteeGrants returns a list of `GrantAuthorization` by grantee. // GranteeGrants returns a list of `GrantAuthorization` by grantee.
// //
// Since: cosmos-sdk 0.46 // Since: cosmos-sdk 0.45.2
GranteeGrants(ctx context.Context, in *QueryGranteeGrantsRequest, opts ...grpc.CallOption) (*QueryGranteeGrantsResponse, error) GranteeGrants(ctx context.Context, in *QueryGranteeGrantsRequest, opts ...grpc.CallOption) (*QueryGranteeGrantsResponse, error)
} }
@ -484,11 +484,11 @@ type QueryServer interface {
Grants(context.Context, *QueryGrantsRequest) (*QueryGrantsResponse, error) Grants(context.Context, *QueryGrantsRequest) (*QueryGrantsResponse, error)
// GranterGrants returns list of `GrantAuthorization`, granted by granter. // GranterGrants returns list of `GrantAuthorization`, granted by granter.
// //
// Since: cosmos-sdk 0.46 // Since: cosmos-sdk 0.45.2
GranterGrants(context.Context, *QueryGranterGrantsRequest) (*QueryGranterGrantsResponse, error) GranterGrants(context.Context, *QueryGranterGrantsRequest) (*QueryGranterGrantsResponse, error)
// GranteeGrants returns a list of `GrantAuthorization` by grantee. // GranteeGrants returns a list of `GrantAuthorization` by grantee.
// //
// Since: cosmos-sdk 0.46 // Since: cosmos-sdk 0.45.2
GranteeGrants(context.Context, *QueryGranteeGrantsRequest) (*QueryGranteeGrantsResponse, error) GranteeGrants(context.Context, *QueryGranteeGrantsRequest) (*QueryGranteeGrantsResponse, error)
} }

View File

@ -3,9 +3,8 @@
package v040 package v040
import ( import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/kv"
v040auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v040" v040auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v040"
) )
@ -40,10 +39,8 @@ func DenomMetadataKey(denom string) []byte {
// store. The key must not contain the perfix BalancesPrefix as the prefix store // store. The key must not contain the perfix BalancesPrefix as the prefix store
// iterator discards the actual prefix. // iterator discards the actual prefix.
func AddressFromBalancesStore(key []byte) sdk.AccAddress { func AddressFromBalancesStore(key []byte) sdk.AccAddress {
kv.AssertKeyAtLeastLength(key, 1+v040auth.AddrLen)
addr := key[:v040auth.AddrLen] addr := key[:v040auth.AddrLen]
if len(addr) != v040auth.AddrLen { kv.AssertKeyLength(addr, v040auth.AddrLen)
panic(fmt.Sprintf("unexpected account address key length; got: %d, expected: %d", len(addr), v040auth.AddrLen))
}
return sdk.AccAddress(addr) return sdk.AccAddress(addr)
} }

View File

@ -3,6 +3,7 @@ package types
import ( import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address" "github.com/cosmos/cosmos-sdk/types/address"
"github.com/cosmos/cosmos-sdk/types/kv"
) )
const ( const (
@ -43,6 +44,7 @@ func AddressFromBalancesStore(key []byte) (sdk.AccAddress, error) {
if len(key) == 0 { if len(key) == 0 {
return nil, ErrInvalidKey return nil, ErrInvalidKey
} }
kv.AssertKeyAtLeastLength(key, 1)
addrLen := key[0] addrLen := key[0]
bound := int(addrLen) bound := int(addrLen)
if len(key)-1 < bound { if len(key)-1 < bound {

View File

@ -6,6 +6,7 @@ import (
"encoding/binary" "encoding/binary"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/kv"
v040auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v040" v040auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v040"
) )
@ -58,78 +59,68 @@ var (
// gets an address from a validator's outstanding rewards key // gets an address from a validator's outstanding rewards key
func GetValidatorOutstandingRewardsAddress(key []byte) (valAddr sdk.ValAddress) { func GetValidatorOutstandingRewardsAddress(key []byte) (valAddr sdk.ValAddress) {
kv.AssertKeyAtLeastLength(key, 2)
addr := key[1:] addr := key[1:]
if len(addr) != v040auth.AddrLen { kv.AssertKeyLength(addr, v040auth.AddrLen)
panic("unexpected key length")
}
return sdk.ValAddress(addr) return sdk.ValAddress(addr)
} }
// gets an address from a delegator's withdraw info key // gets an address from a delegator's withdraw info key
func GetDelegatorWithdrawInfoAddress(key []byte) (delAddr sdk.AccAddress) { func GetDelegatorWithdrawInfoAddress(key []byte) (delAddr sdk.AccAddress) {
kv.AssertKeyAtLeastLength(key, 2)
addr := key[1:] addr := key[1:]
if len(addr) != v040auth.AddrLen { kv.AssertKeyLength(addr, v040auth.AddrLen)
panic("unexpected key length")
}
return sdk.AccAddress(addr) return sdk.AccAddress(addr)
} }
// gets the addresses from a delegator starting info key // gets the addresses from a delegator starting info key
func GetDelegatorStartingInfoAddresses(key []byte) (valAddr sdk.ValAddress, delAddr sdk.AccAddress) { func GetDelegatorStartingInfoAddresses(key []byte) (valAddr sdk.ValAddress, delAddr sdk.AccAddress) {
kv.AssertKeyAtLeastLength(key, 2+v040auth.AddrLen)
addr := key[1 : 1+v040auth.AddrLen] addr := key[1 : 1+v040auth.AddrLen]
if len(addr) != v040auth.AddrLen { kv.AssertKeyLength(addr, v040auth.AddrLen)
panic("unexpected key length")
}
valAddr = sdk.ValAddress(addr) valAddr = sdk.ValAddress(addr)
addr = key[1+v040auth.AddrLen:] addr = key[1+v040auth.AddrLen:]
if len(addr) != v040auth.AddrLen { kv.AssertKeyLength(addr, v040auth.AddrLen)
panic("unexpected key length")
}
delAddr = sdk.AccAddress(addr) delAddr = sdk.AccAddress(addr)
return return
} }
// gets the address & period from a validator's historical rewards key // gets the address & period from a validator's historical rewards key
func GetValidatorHistoricalRewardsAddressPeriod(key []byte) (valAddr sdk.ValAddress, period uint64) { func GetValidatorHistoricalRewardsAddressPeriod(key []byte) (valAddr sdk.ValAddress, period uint64) {
kv.AssertKeyAtLeastLength(key, 2+v040auth.AddrLen)
addr := key[1 : 1+v040auth.AddrLen] addr := key[1 : 1+v040auth.AddrLen]
if len(addr) != v040auth.AddrLen { kv.AssertKeyLength(addr, v040auth.AddrLen)
panic("unexpected key length")
}
valAddr = sdk.ValAddress(addr) valAddr = sdk.ValAddress(addr)
b := key[1+v040auth.AddrLen:] b := key[1+v040auth.AddrLen:]
if len(b) != 8 { kv.AssertKeyLength(addr, 8)
panic("unexpected key length")
}
period = binary.LittleEndian.Uint64(b) period = binary.LittleEndian.Uint64(b)
return return
} }
// gets the address from a validator's current rewards key // gets the address from a validator's current rewards key
func GetValidatorCurrentRewardsAddress(key []byte) (valAddr sdk.ValAddress) { func GetValidatorCurrentRewardsAddress(key []byte) (valAddr sdk.ValAddress) {
kv.AssertKeyAtLeastLength(key, 2)
addr := key[1:] addr := key[1:]
if len(addr) != v040auth.AddrLen { kv.AssertKeyLength(addr, v040auth.AddrLen)
panic("unexpected key length")
}
return sdk.ValAddress(addr) return sdk.ValAddress(addr)
} }
// gets the address from a validator's accumulated commission key // gets the address from a validator's accumulated commission key
func GetValidatorAccumulatedCommissionAddress(key []byte) (valAddr sdk.ValAddress) { func GetValidatorAccumulatedCommissionAddress(key []byte) (valAddr sdk.ValAddress) {
kv.AssertKeyAtLeastLength(key, 2)
addr := key[1:] addr := key[1:]
if len(addr) != v040auth.AddrLen { kv.AssertKeyLength(addr, v040auth.AddrLen)
panic("unexpected key length")
}
return sdk.ValAddress(addr) return sdk.ValAddress(addr)
} }
// gets the height from a validator's slash event key // gets the height from a validator's slash event key
func GetValidatorSlashEventAddressHeight(key []byte) (valAddr sdk.ValAddress, height uint64) { func GetValidatorSlashEventAddressHeight(key []byte) (valAddr sdk.ValAddress, height uint64) {
kv.AssertKeyAtLeastLength(key, 2+v040auth.AddrLen)
addr := key[1 : 1+v040auth.AddrLen] addr := key[1 : 1+v040auth.AddrLen]
if len(addr) != v040auth.AddrLen { kv.AssertKeyLength(addr, v040auth.AddrLen)
panic("unexpected key length")
}
valAddr = sdk.ValAddress(addr) valAddr = sdk.ValAddress(addr)
startB := 1 + v040auth.AddrLen startB := 1 + v040auth.AddrLen
kv.AssertKeyAtLeastLength(key, startB+9)
b := key[startB : startB+8] // the next 8 bytes represent the height b := key[startB : startB+8] // the next 8 bytes represent the height
height = binary.BigEndian.Uint64(b) height = binary.BigEndian.Uint64(b)
return return

View File

@ -5,6 +5,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address" "github.com/cosmos/cosmos-sdk/types/address"
"github.com/cosmos/cosmos-sdk/types/kv"
) )
const ( const (
@ -60,10 +61,9 @@ func GetValidatorOutstandingRewardsAddress(key []byte) (valAddr sdk.ValAddress)
// 0x02<valAddrLen (1 Byte)><valAddr_Bytes> // 0x02<valAddrLen (1 Byte)><valAddr_Bytes>
// Remove prefix and address length. // Remove prefix and address length.
kv.AssertKeyAtLeastLength(key, 3)
addr := key[2:] addr := key[2:]
if len(addr) != int(key[1]) { kv.AssertKeyLength(addr, int(key[1]))
panic("unexpected key length")
}
return sdk.ValAddress(addr) return sdk.ValAddress(addr)
} }
@ -74,10 +74,9 @@ func GetDelegatorWithdrawInfoAddress(key []byte) (delAddr sdk.AccAddress) {
// 0x03<accAddrLen (1 Byte)><accAddr_Bytes> // 0x03<accAddrLen (1 Byte)><accAddr_Bytes>
// Remove prefix and address length. // Remove prefix and address length.
kv.AssertKeyAtLeastLength(key, 3)
addr := key[2:] addr := key[2:]
if len(addr) != int(key[1]) { kv.AssertKeyLength(addr, int(key[1]))
panic("unexpected key length")
}
return sdk.AccAddress(addr) return sdk.AccAddress(addr)
} }
@ -86,13 +85,14 @@ func GetDelegatorWithdrawInfoAddress(key []byte) (delAddr sdk.AccAddress) {
func GetDelegatorStartingInfoAddresses(key []byte) (valAddr sdk.ValAddress, delAddr sdk.AccAddress) { func GetDelegatorStartingInfoAddresses(key []byte) (valAddr sdk.ValAddress, delAddr sdk.AccAddress) {
// key is in the format: // key is in the format:
// 0x04<valAddrLen (1 Byte)><valAddr_Bytes><accAddrLen (1 Byte)><accAddr_Bytes> // 0x04<valAddrLen (1 Byte)><valAddr_Bytes><accAddrLen (1 Byte)><accAddr_Bytes>
kv.AssertKeyAtLeastLength(key, 2)
valAddrLen := int(key[1]) valAddrLen := int(key[1])
kv.AssertKeyAtLeastLength(key, 3+valAddrLen)
valAddr = sdk.ValAddress(key[2 : 2+valAddrLen]) valAddr = sdk.ValAddress(key[2 : 2+valAddrLen])
delAddrLen := int(key[2+valAddrLen]) delAddrLen := int(key[2+valAddrLen])
kv.AssertKeyAtLeastLength(key, 4+valAddrLen)
delAddr = sdk.AccAddress(key[3+valAddrLen:]) delAddr = sdk.AccAddress(key[3+valAddrLen:])
if len(delAddr.Bytes()) != delAddrLen { kv.AssertKeyLength(delAddr.Bytes(), delAddrLen)
panic("unexpected key length")
}
return return
} }
@ -101,12 +101,12 @@ func GetDelegatorStartingInfoAddresses(key []byte) (valAddr sdk.ValAddress, delA
func GetValidatorHistoricalRewardsAddressPeriod(key []byte) (valAddr sdk.ValAddress, period uint64) { func GetValidatorHistoricalRewardsAddressPeriod(key []byte) (valAddr sdk.ValAddress, period uint64) {
// key is in the format: // key is in the format:
// 0x05<valAddrLen (1 Byte)><valAddr_Bytes><period_Bytes> // 0x05<valAddrLen (1 Byte)><valAddr_Bytes><period_Bytes>
kv.AssertKeyAtLeastLength(key, 2)
valAddrLen := int(key[1]) valAddrLen := int(key[1])
kv.AssertKeyAtLeastLength(key, 3+valAddrLen)
valAddr = sdk.ValAddress(key[2 : 2+valAddrLen]) valAddr = sdk.ValAddress(key[2 : 2+valAddrLen])
b := key[2+valAddrLen:] b := key[2+valAddrLen:]
if len(b) != 8 { kv.AssertKeyLength(b, 8)
panic("unexpected key length")
}
period = binary.LittleEndian.Uint64(b) period = binary.LittleEndian.Uint64(b)
return return
} }
@ -117,10 +117,9 @@ func GetValidatorCurrentRewardsAddress(key []byte) (valAddr sdk.ValAddress) {
// 0x06<valAddrLen (1 Byte)><valAddr_Bytes>: ValidatorCurrentRewards // 0x06<valAddrLen (1 Byte)><valAddr_Bytes>: ValidatorCurrentRewards
// Remove prefix and address length. // Remove prefix and address length.
kv.AssertKeyAtLeastLength(key, 3)
addr := key[2:] addr := key[2:]
if len(addr) != int(key[1]) { kv.AssertKeyLength(addr, int(key[1]))
panic("unexpected key length")
}
return sdk.ValAddress(addr) return sdk.ValAddress(addr)
} }
@ -131,10 +130,9 @@ func GetValidatorAccumulatedCommissionAddress(key []byte) (valAddr sdk.ValAddres
// 0x07<valAddrLen (1 Byte)><valAddr_Bytes>: ValidatorCurrentRewards // 0x07<valAddrLen (1 Byte)><valAddr_Bytes>: ValidatorCurrentRewards
// Remove prefix and address length. // Remove prefix and address length.
kv.AssertKeyAtLeastLength(key, 3)
addr := key[2:] addr := key[2:]
if len(addr) != int(key[1]) { kv.AssertKeyLength(addr, int(key[1]))
panic("unexpected key length")
}
return sdk.ValAddress(addr) return sdk.ValAddress(addr)
} }
@ -143,9 +141,12 @@ func GetValidatorAccumulatedCommissionAddress(key []byte) (valAddr sdk.ValAddres
func GetValidatorSlashEventAddressHeight(key []byte) (valAddr sdk.ValAddress, height uint64) { func GetValidatorSlashEventAddressHeight(key []byte) (valAddr sdk.ValAddress, height uint64) {
// key is in the format: // key is in the format:
// 0x08<valAddrLen (1 Byte)><valAddr_Bytes><height>: ValidatorSlashEvent // 0x08<valAddrLen (1 Byte)><valAddr_Bytes><height>: ValidatorSlashEvent
kv.AssertKeyAtLeastLength(key, 2)
valAddrLen := int(key[1]) valAddrLen := int(key[1])
kv.AssertKeyAtLeastLength(key, 3+valAddrLen)
valAddr = key[2 : 2+valAddrLen] valAddr = key[2 : 2+valAddrLen]
startB := 2 + valAddrLen startB := 2 + valAddrLen
kv.AssertKeyAtLeastLength(key, startB+9)
b := key[startB : startB+8] // the next 8 bytes represent the height b := key[startB : startB+8] // the next 8 bytes represent the height
height = binary.BigEndian.Uint64(b) height = binary.BigEndian.Uint64(b)
return return

View File

@ -25,7 +25,8 @@ func GetQueryCmd() *cobra.Command {
feegrantQueryCmd.AddCommand( feegrantQueryCmd.AddCommand(
GetCmdQueryFeeGrant(), GetCmdQueryFeeGrant(),
GetCmdQueryFeeGrants(), GetCmdQueryFeeGrantsByGrantee(),
GetCmdQueryFeeGrantsByGranter(),
) )
return feegrantQueryCmd return feegrantQueryCmd
@ -80,8 +81,8 @@ $ %s query feegrant grant [granter] [grantee]
return cmd return cmd
} }
// GetCmdQueryFeeGrants returns cmd to query for all grants for a grantee. // GetCmdQueryFeeGrantsByGrantee returns cmd to query for all grants for a grantee.
func GetCmdQueryFeeGrants() *cobra.Command { func GetCmdQueryFeeGrantsByGrantee() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "grants [grantee]", Use: "grants [grantee]",
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
@ -128,3 +129,52 @@ $ %s query feegrant grants [grantee]
return cmd return cmd
} }
// GetCmdQueryFeeGrantsByGranter returns cmd to query for all grants by a granter.
func GetCmdQueryFeeGrantsByGranter() *cobra.Command {
cmd := &cobra.Command{
Use: "grants [granter]",
Args: cobra.ExactArgs(1),
Short: "Query all grants by a granter",
Long: strings.TrimSpace(
fmt.Sprintf(`Queries all the grants issued for a granter address.
Example:
$ %s query feegrant grants [granter]
`, version.AppName),
),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
queryClient := feegrant.NewQueryClient(clientCtx)
granterAddr, err := sdk.AccAddressFromBech32(args[0])
if err != nil {
return err
}
pageReq, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
return err
}
res, err := queryClient.AllowancesByGranter(
cmd.Context(),
&feegrant.QueryAllowancesByGranterRequest{
Granter: granterAddr.String(),
Pagination: pageReq,
},
)
if err != nil {
return err
}
return clientCtx.PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
flags.AddPaginationFlagsToCmd(cmd, "grants")
return cmd
}

View File

@ -1,3 +1,4 @@
//go:build norace
// +build norace // +build norace
package testutil package testutil

View File

@ -195,7 +195,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrant() {
} }
} }
func (s *IntegrationTestSuite) TestCmdGetFeeGrants() { func (s *IntegrationTestSuite) TestCmdGetFeeGrantsByGrantee() {
val := s.network.Validators[0] val := s.network.Validators[0]
grantee := s.addedGrantee grantee := s.addedGrantee
clientCtx := val.ClientCtx clientCtx := val.ClientCtx
@ -216,7 +216,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrants() {
true, nil, 0, true, nil, 0,
}, },
{ {
"non existed grantee", "non existent grantee",
[]string{ []string{
"cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl",
fmt.Sprintf("--%s=json", tmcli.OutputFlag), fmt.Sprintf("--%s=json", tmcli.OutputFlag),
@ -237,7 +237,63 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrants() {
tc := tc tc := tc
s.Run(tc.name, func() { s.Run(tc.name, func() {
cmd := cli.GetCmdQueryFeeGrants() cmd := cli.GetCmdQueryFeeGrantsByGrantee()
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.expectErr {
s.Require().Error(err)
} else {
s.Require().NoError(err)
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.resp), out.String())
s.Require().Len(tc.resp.Allowances, tc.expectLength)
}
})
}
}
func (s *IntegrationTestSuite) TestCmdGetFeeGrantsByGranter() {
val := s.network.Validators[0]
granter := s.addedGranter
clientCtx := val.ClientCtx
testCases := []struct {
name string
args []string
expectErr bool
resp *feegrant.QueryAllowancesByGranterResponse
expectLength int
}{
{
"wrong grantee",
[]string{
"wrong_grantee",
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
true, nil, 0,
},
{
"non existent grantee",
[]string{
"cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl",
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
false, &feegrant.QueryAllowancesByGranterResponse{}, 0,
},
{
"valid req",
[]string{
granter.String(),
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
false, &feegrant.QueryAllowancesByGranterResponse{}, 1,
},
}
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
cmd := cli.GetCmdQueryFeeGrantsByGranter()
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.expectErr { if tc.expectErr {

View File

@ -93,3 +93,42 @@ func (q Keeper) Allowances(c context.Context, req *feegrant.QueryAllowancesReque
return &feegrant.QueryAllowancesResponse{Allowances: grants, Pagination: pageRes}, nil return &feegrant.QueryAllowancesResponse{Allowances: grants, Pagination: pageRes}, nil
} }
// AllowancesByGranter queries all the allowances granted by the given granter
func (q Keeper) AllowancesByGranter(c context.Context, req *feegrant.QueryAllowancesByGranterRequest) (*feegrant.QueryAllowancesByGranterResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
granterAddr, err := sdk.AccAddressFromBech32(req.Granter)
if err != nil {
return nil, err
}
ctx := sdk.UnwrapSDKContext(c)
var grants []*feegrant.Grant
store := ctx.KVStore(q.storeKey)
pageRes, err := query.Paginate(store, req.Pagination, func(key []byte, value []byte) error {
var grant feegrant.Grant
granter, _ := feegrant.ParseAddressesFromFeeAllowanceKey(key)
if !granter.Equals(granterAddr) {
return nil
}
if err := q.cdc.Unmarshal(value, &grant); err != nil {
return err
}
grants = append(grants, &grant)
return nil
})
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
return &feegrant.QueryAllowancesByGranterResponse{Allowances: grants, Pagination: pageRes}, nil
}

View File

@ -148,6 +148,72 @@ func (suite *KeeperTestSuite) TestFeeAllowances() {
} }
} }
func (suite *KeeperTestSuite) TestFeeAllowancesByGranter() {
testCases := []struct {
name string
req *feegrant.QueryAllowancesByGranterRequest
expectErr bool
preRun func()
postRun func(_ *feegrant.QueryAllowancesByGranterResponse)
}{
{
"nil request",
nil,
true,
func() {},
func(*feegrant.QueryAllowancesByGranterResponse) {},
},
{
"fail: invalid grantee",
&feegrant.QueryAllowancesByGranterRequest{
Granter: "invalid_grantee",
},
true,
func() {},
func(*feegrant.QueryAllowancesByGranterResponse) {},
},
{
"no grants",
&feegrant.QueryAllowancesByGranterRequest{
Granter: suite.addrs[0].String(),
},
false,
func() {},
func(resp *feegrant.QueryAllowancesByGranterResponse) {
suite.Require().Equal(len(resp.Allowances), 0)
},
},
{
"valid query: expect single grant",
&feegrant.QueryAllowancesByGranterRequest{
Granter: suite.addrs[0].String(),
},
false,
func() {
grantFeeAllowance(suite)
},
func(resp *feegrant.QueryAllowancesByGranterResponse) {
suite.Require().Equal(len(resp.Allowances), 1)
suite.Require().Equal(resp.Allowances[0].Granter, suite.addrs[0].String())
suite.Require().Equal(resp.Allowances[0].Grantee, suite.addrs[1].String())
},
},
}
for _, tc := range testCases {
suite.Run(tc.name, func() {
tc.preRun()
resp, err := suite.keeper.AllowancesByGranter(suite.ctx, tc.req)
if tc.expectErr {
suite.Require().Error(err)
} else {
suite.Require().NoError(err)
tc.postRun(resp)
}
})
}
}
func grantFeeAllowance(suite *KeeperTestSuite) { func grantFeeAllowance(suite *KeeperTestSuite) {
exp := suite.sdkCtx.BlockTime().AddDate(1, 0, 0) exp := suite.sdkCtx.BlockTime().AddDate(1, 0, 0)
err := suite.app.FeeGrantKeeper.GrantAllowance(suite.sdkCtx, suite.addrs[0], suite.addrs[1], &feegrant.BasicAllowance{ err := suite.app.FeeGrantKeeper.GrantAllowance(suite.sdkCtx, suite.addrs[0], suite.addrs[1], &feegrant.BasicAllowance{

View File

@ -3,6 +3,7 @@ package feegrant
import ( import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address" "github.com/cosmos/cosmos-sdk/types/address"
"github.com/cosmos/cosmos-sdk/types/kv"
) )
const ( const (
@ -34,3 +35,17 @@ func FeeAllowanceKey(granter sdk.AccAddress, grantee sdk.AccAddress) []byte {
func FeeAllowancePrefixByGrantee(grantee sdk.AccAddress) []byte { func FeeAllowancePrefixByGrantee(grantee sdk.AccAddress) []byte {
return append(FeeAllowanceKeyPrefix, address.MustLengthPrefix(grantee.Bytes())...) return append(FeeAllowanceKeyPrefix, address.MustLengthPrefix(grantee.Bytes())...)
} }
func ParseAddressesFromFeeAllowanceKey(key []byte) (granter, grantee sdk.AccAddress) {
// key is of format:
// 0x00<granteeAddressLen (1 Byte)><granteeAddress_Bytes><granterAddressLen (1 Byte)><granterAddress_Bytes><msgType_Bytes>
kv.AssertKeyAtLeastLength(key, 2)
granteeAddrLen := key[1] // remove prefix key
kv.AssertKeyAtLeastLength(key, int(2+granteeAddrLen))
grantee = sdk.AccAddress(key[2 : 2+granteeAddrLen])
granterAddrLen := int(key[2+granteeAddrLen])
kv.AssertKeyAtLeastLength(key, 3+int(granteeAddrLen+byte(granterAddrLen)))
granter = sdk.AccAddress(key[3+granterAddrLen : 3+granteeAddrLen+byte(granterAddrLen)])
return granter, grantee
}

25
x/feegrant/key_test.go Normal file
View File

@ -0,0 +1,25 @@
package feegrant_test
import (
"testing"
"github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
)
func TestMarshalAndUnmarshalFeegrantKey(t *testing.T) {
grantee, err := sdk.AccAddressFromBech32("cosmos1qk93t4j0yyzgqgt6k5qf8deh8fq6smpn3ntu3x")
require.NoError(t, err)
granter, err := sdk.AccAddressFromBech32("cosmos1p9qh4ldfd6n0qehujsal4k7g0e37kel90rc4ts")
require.NoError(t, err)
key := feegrant.FeeAllowanceKey(granter, grantee)
require.Len(t, key, len(grantee.Bytes())+len(granter.Bytes())+3)
require.Equal(t, feegrant.FeeAllowancePrefixByGrantee(grantee), key[:len(grantee.Bytes())+2])
g1, g2 := feegrant.ParseAddressesFromFeeAllowanceKey(key)
require.Equal(t, granter, g1)
require.Equal(t, grantee, g2)
}

View File

@ -239,11 +239,122 @@ func (m *QueryAllowancesResponse) GetPagination() *query.PageResponse {
return nil return nil
} }
// QueryAllowancesByGranterRequest is the request type for the Query/AllowancesByGranter RPC method.
type QueryAllowancesByGranterRequest struct {
Granter string `protobuf:"bytes,1,opt,name=granter,proto3" json:"granter,omitempty"`
// pagination defines an pagination for the request.
Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
}
func (m *QueryAllowancesByGranterRequest) Reset() { *m = QueryAllowancesByGranterRequest{} }
func (m *QueryAllowancesByGranterRequest) String() string { return proto.CompactTextString(m) }
func (*QueryAllowancesByGranterRequest) ProtoMessage() {}
func (*QueryAllowancesByGranterRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_59efc303945de53f, []int{4}
}
func (m *QueryAllowancesByGranterRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *QueryAllowancesByGranterRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_QueryAllowancesByGranterRequest.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 *QueryAllowancesByGranterRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_QueryAllowancesByGranterRequest.Merge(m, src)
}
func (m *QueryAllowancesByGranterRequest) XXX_Size() int {
return m.Size()
}
func (m *QueryAllowancesByGranterRequest) XXX_DiscardUnknown() {
xxx_messageInfo_QueryAllowancesByGranterRequest.DiscardUnknown(m)
}
var xxx_messageInfo_QueryAllowancesByGranterRequest proto.InternalMessageInfo
func (m *QueryAllowancesByGranterRequest) GetGranter() string {
if m != nil {
return m.Granter
}
return ""
}
func (m *QueryAllowancesByGranterRequest) GetPagination() *query.PageRequest {
if m != nil {
return m.Pagination
}
return nil
}
// QueryAllowancesByGranterResponse is the response type for the Query/AllowancesByGranter RPC method.
type QueryAllowancesByGranterResponse struct {
// allowances that have been issued by the granter.
Allowances []*Grant `protobuf:"bytes,1,rep,name=allowances,proto3" json:"allowances,omitempty"`
// pagination defines an pagination for the response.
Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
}
func (m *QueryAllowancesByGranterResponse) Reset() { *m = QueryAllowancesByGranterResponse{} }
func (m *QueryAllowancesByGranterResponse) String() string { return proto.CompactTextString(m) }
func (*QueryAllowancesByGranterResponse) ProtoMessage() {}
func (*QueryAllowancesByGranterResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_59efc303945de53f, []int{5}
}
func (m *QueryAllowancesByGranterResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *QueryAllowancesByGranterResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_QueryAllowancesByGranterResponse.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 *QueryAllowancesByGranterResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_QueryAllowancesByGranterResponse.Merge(m, src)
}
func (m *QueryAllowancesByGranterResponse) XXX_Size() int {
return m.Size()
}
func (m *QueryAllowancesByGranterResponse) XXX_DiscardUnknown() {
xxx_messageInfo_QueryAllowancesByGranterResponse.DiscardUnknown(m)
}
var xxx_messageInfo_QueryAllowancesByGranterResponse proto.InternalMessageInfo
func (m *QueryAllowancesByGranterResponse) GetAllowances() []*Grant {
if m != nil {
return m.Allowances
}
return nil
}
func (m *QueryAllowancesByGranterResponse) GetPagination() *query.PageResponse {
if m != nil {
return m.Pagination
}
return nil
}
func init() { func init() {
proto.RegisterType((*QueryAllowanceRequest)(nil), "cosmos.feegrant.v1beta1.QueryAllowanceRequest") proto.RegisterType((*QueryAllowanceRequest)(nil), "cosmos.feegrant.v1beta1.QueryAllowanceRequest")
proto.RegisterType((*QueryAllowanceResponse)(nil), "cosmos.feegrant.v1beta1.QueryAllowanceResponse") proto.RegisterType((*QueryAllowanceResponse)(nil), "cosmos.feegrant.v1beta1.QueryAllowanceResponse")
proto.RegisterType((*QueryAllowancesRequest)(nil), "cosmos.feegrant.v1beta1.QueryAllowancesRequest") proto.RegisterType((*QueryAllowancesRequest)(nil), "cosmos.feegrant.v1beta1.QueryAllowancesRequest")
proto.RegisterType((*QueryAllowancesResponse)(nil), "cosmos.feegrant.v1beta1.QueryAllowancesResponse") proto.RegisterType((*QueryAllowancesResponse)(nil), "cosmos.feegrant.v1beta1.QueryAllowancesResponse")
proto.RegisterType((*QueryAllowancesByGranterRequest)(nil), "cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest")
proto.RegisterType((*QueryAllowancesByGranterResponse)(nil), "cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse")
} }
func init() { func init() {
@ -251,7 +362,7 @@ func init() {
} }
var fileDescriptor_59efc303945de53f = []byte{ var fileDescriptor_59efc303945de53f = []byte{
// 430 bytes of a gzipped FileDescriptorProto // 495 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4e, 0xce, 0x2f, 0xce, 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, 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, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17,
@ -268,17 +379,21 @@ var fileDescriptor_59efc303945de53f = []byte{
0x5c, 0x5c, 0x88, 0xa0, 0x00, 0x3b, 0x94, 0xdb, 0x48, 0x0d, 0x66, 0x25, 0x28, 0xdc, 0xf4, 0x20, 0x5c, 0x5c, 0x88, 0xa0, 0x00, 0x3b, 0x94, 0xdb, 0x48, 0x0d, 0x66, 0x25, 0x28, 0xdc, 0xf4, 0x20,
0x31, 0x02, 0xb3, 0x34, 0x20, 0x31, 0x1d, 0xe6, 0xf7, 0x20, 0x24, 0x9d, 0x4a, 0x8b, 0x18, 0xb9, 0x31, 0x02, 0xb3, 0x34, 0x20, 0x31, 0x1d, 0xe6, 0xf7, 0x20, 0x24, 0x9d, 0x4a, 0x8b, 0x18, 0xb9,
0xc4, 0x31, 0x2c, 0x87, 0xfa, 0xca, 0x8e, 0x8b, 0x0b, 0xee, 0xc8, 0x62, 0x09, 0x46, 0x05, 0x66, 0xc4, 0x31, 0x2c, 0x87, 0xfa, 0xca, 0x8e, 0x8b, 0x0b, 0xee, 0xc8, 0x62, 0x09, 0x46, 0x05, 0x66,
0x22, 0xbc, 0x85, 0xa4, 0x43, 0xc8, 0x1d, 0x8b, 0x1b, 0xd5, 0x09, 0xba, 0x11, 0x62, 0x39, 0xb2, 0x22, 0xbc, 0x85, 0xa4, 0x43, 0xc8, 0x1d, 0x8b, 0x1b, 0xd5, 0x09, 0xba, 0x11, 0x62, 0x39, 0x8a,
0x23, 0x8d, 0xee, 0x33, 0x71, 0xb1, 0x82, 0x1d, 0x29, 0xb4, 0x86, 0x91, 0x8b, 0x13, 0xee, 0x52, 0x23, 0x9b, 0x19, 0xb9, 0xe4, 0xd1, 0x1c, 0xe9, 0x54, 0xe9, 0x0e, 0x89, 0x2f, 0xc2, 0x11, 0x4a,
0x21, 0x3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x58, 0x5f, 0x48, 0x97, 0xb0, 0x8b, 0x8b,
0xb1, 0x1c, 0x43, 0x94, 0x7a, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0x2e, 0xcc, 0x91, 0x1c, 0xba, 0x97, 0x91, 0x4b, 0x18, 0x4b, 0x52, 0x10, 0xb2, 0x20, 0xd6, 0x01, 0xe8, 0x69,
0x48, 0x08, 0xa5, 0x5b, 0x9c, 0x92, 0xad, 0x5f, 0x01, 0x37, 0x3f, 0x89, 0x0d, 0x9c, 0xe3, 0x8c, 0x58, 0xca, 0x92, 0x0c, 0x9d, 0x50, 0x3f, 0x18, 0x82, 0xfd, 0xa0, 0x2d, 0xa4, 0x89, 0xd3, 0x0f,
0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x19, 0x08, 0xf0, 0xae, 0x23, 0x04, 0x00, 0x00, 0x99, 0xc5, 0xc5, 0xa5, 0xa9, 0x29, 0x88, 0x20, 0x77, 0x72, 0x3c, 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, 0xf5, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c,
0x98, 0x71, 0x10, 0x4a, 0xb7, 0x38, 0x25, 0x5b, 0xbf, 0x02, 0x6e, 0x76, 0x12, 0x1b, 0xb8, 0x94,
0x35, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x83, 0x57, 0xbe, 0x61, 0x17, 0x06, 0x00, 0x00,
} }
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
@ -297,6 +412,9 @@ type QueryClient interface {
Allowance(ctx context.Context, in *QueryAllowanceRequest, opts ...grpc.CallOption) (*QueryAllowanceResponse, error) Allowance(ctx context.Context, in *QueryAllowanceRequest, opts ...grpc.CallOption) (*QueryAllowanceResponse, error)
// Allowances returns all the grants for address. // Allowances returns all the grants for address.
Allowances(ctx context.Context, in *QueryAllowancesRequest, opts ...grpc.CallOption) (*QueryAllowancesResponse, error) Allowances(ctx context.Context, in *QueryAllowancesRequest, opts ...grpc.CallOption) (*QueryAllowancesResponse, error)
// AllowancesByGranter returns all the grants given by an address
// Since v0.46
AllowancesByGranter(ctx context.Context, in *QueryAllowancesByGranterRequest, opts ...grpc.CallOption) (*QueryAllowancesByGranterResponse, error)
} }
type queryClient struct { type queryClient struct {
@ -325,12 +443,24 @@ func (c *queryClient) Allowances(ctx context.Context, in *QueryAllowancesRequest
return out, nil return out, nil
} }
func (c *queryClient) AllowancesByGranter(ctx context.Context, in *QueryAllowancesByGranterRequest, opts ...grpc.CallOption) (*QueryAllowancesByGranterResponse, error) {
out := new(QueryAllowancesByGranterResponse)
err := c.cc.Invoke(ctx, "/cosmos.feegrant.v1beta1.Query/AllowancesByGranter", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// QueryServer is the server API for Query service. // QueryServer is the server API for Query service.
type QueryServer interface { type QueryServer interface {
// Allowance returns fee granted to the grantee by the granter. // Allowance returns fee granted to the grantee by the granter.
Allowance(context.Context, *QueryAllowanceRequest) (*QueryAllowanceResponse, error) Allowance(context.Context, *QueryAllowanceRequest) (*QueryAllowanceResponse, error)
// Allowances returns all the grants for address. // Allowances returns all the grants for address.
Allowances(context.Context, *QueryAllowancesRequest) (*QueryAllowancesResponse, error) Allowances(context.Context, *QueryAllowancesRequest) (*QueryAllowancesResponse, error)
// AllowancesByGranter returns all the grants given by an address
// Since v0.46
AllowancesByGranter(context.Context, *QueryAllowancesByGranterRequest) (*QueryAllowancesByGranterResponse, error)
} }
// UnimplementedQueryServer can be embedded to have forward compatible implementations. // UnimplementedQueryServer can be embedded to have forward compatible implementations.
@ -343,6 +473,9 @@ func (*UnimplementedQueryServer) Allowance(ctx context.Context, req *QueryAllowa
func (*UnimplementedQueryServer) Allowances(ctx context.Context, req *QueryAllowancesRequest) (*QueryAllowancesResponse, error) { func (*UnimplementedQueryServer) Allowances(ctx context.Context, req *QueryAllowancesRequest) (*QueryAllowancesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Allowances not implemented") return nil, status.Errorf(codes.Unimplemented, "method Allowances not implemented")
} }
func (*UnimplementedQueryServer) AllowancesByGranter(ctx context.Context, req *QueryAllowancesByGranterRequest) (*QueryAllowancesByGranterResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method AllowancesByGranter not implemented")
}
func RegisterQueryServer(s grpc1.Server, srv QueryServer) { func RegisterQueryServer(s grpc1.Server, srv QueryServer) {
s.RegisterService(&_Query_serviceDesc, srv) s.RegisterService(&_Query_serviceDesc, srv)
@ -384,6 +517,24 @@ func _Query_Allowances_Handler(srv interface{}, ctx context.Context, dec func(in
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _Query_AllowancesByGranter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(QueryAllowancesByGranterRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QueryServer).AllowancesByGranter(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.feegrant.v1beta1.Query/AllowancesByGranter",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QueryServer).AllowancesByGranter(ctx, req.(*QueryAllowancesByGranterRequest))
}
return interceptor(ctx, in, info, handler)
}
var _Query_serviceDesc = grpc.ServiceDesc{ var _Query_serviceDesc = grpc.ServiceDesc{
ServiceName: "cosmos.feegrant.v1beta1.Query", ServiceName: "cosmos.feegrant.v1beta1.Query",
HandlerType: (*QueryServer)(nil), HandlerType: (*QueryServer)(nil),
@ -396,6 +547,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{
MethodName: "Allowances", MethodName: "Allowances",
Handler: _Query_Allowances_Handler, Handler: _Query_Allowances_Handler,
}, },
{
MethodName: "AllowancesByGranter",
Handler: _Query_AllowancesByGranter_Handler,
},
}, },
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},
Metadata: "cosmos/feegrant/v1beta1/query.proto", Metadata: "cosmos/feegrant/v1beta1/query.proto",
@ -564,6 +719,97 @@ func (m *QueryAllowancesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
return len(dAtA) - i, nil return len(dAtA) - i, nil
} }
func (m *QueryAllowancesByGranterRequest) 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 *QueryAllowancesByGranterRequest) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *QueryAllowancesByGranterRequest) 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.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 *QueryAllowancesByGranterResponse) 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 *QueryAllowancesByGranterResponse) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *QueryAllowancesByGranterResponse) 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.Allowances) > 0 {
for iNdEx := len(m.Allowances) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.Allowances[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 { func encodeVarintQuery(dAtA []byte, offset int, v uint64) int {
offset -= sovQuery(v) offset -= sovQuery(v)
base := offset base := offset
@ -641,6 +887,42 @@ func (m *QueryAllowancesResponse) Size() (n int) {
return n return n
} }
func (m *QueryAllowancesByGranterRequest) 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))
}
if m.Pagination != nil {
l = m.Pagination.Size()
n += 1 + l + sovQuery(uint64(l))
}
return n
}
func (m *QueryAllowancesByGranterResponse) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if len(m.Allowances) > 0 {
for _, e := range m.Allowances {
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) { func sovQuery(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7 return (math_bits.Len64(x|1) + 6) / 7
} }
@ -1085,6 +1367,244 @@ func (m *QueryAllowancesResponse) Unmarshal(dAtA []byte) error {
} }
return nil return nil
} }
func (m *QueryAllowancesByGranterRequest) 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: QueryAllowancesByGranterRequest: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: QueryAllowancesByGranterRequest: 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 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) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthQuery
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *QueryAllowancesByGranterResponse) 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: QueryAllowancesByGranterResponse: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: QueryAllowancesByGranterResponse: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Allowances", 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.Allowances = append(m.Allowances, &Grant{})
if err := m.Allowances[len(m.Allowances)-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) || (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) { func skipQuery(dAtA []byte) (n int, err error) {
l := len(dAtA) l := len(dAtA)
iNdEx := 0 iNdEx := 0

View File

@ -179,6 +179,78 @@ func local_request_Query_Allowances_0(ctx context.Context, marshaler runtime.Mar
} }
var (
filter_Query_AllowancesByGranter_0 = &utilities.DoubleArray{Encoding: map[string]int{"granter": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
)
func request_Query_AllowancesByGranter_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryAllowancesByGranterRequest
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)
}
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AllowancesByGranter_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.AllowancesByGranter(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_AllowancesByGranter_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryAllowancesByGranterRequest
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)
}
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AllowancesByGranter_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.AllowancesByGranter(ctx, &protoReq)
return msg, metadata, err
}
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
// UnaryRPC :call QueryServer directly. // UnaryRPC :call QueryServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
@ -225,6 +297,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
}) })
mux.Handle("GET", pattern_Query_AllowancesByGranter_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_AllowancesByGranter_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_AllowancesByGranter_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil return nil
} }
@ -306,6 +398,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
}) })
mux.Handle("GET", pattern_Query_AllowancesByGranter_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_AllowancesByGranter_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_AllowancesByGranter_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil return nil
} }
@ -313,10 +425,14 @@ var (
pattern_Query_Allowance_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", "allowance", "granter", "grantee"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_Allowance_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", "allowance", "granter", "grantee"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_Allowances_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", "allowances", "grantee"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_Allowances_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", "allowances", "grantee"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_AllowancesByGranter_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", "issued", "granter"}, "", runtime.AssumeColonVerbOpt(false)))
) )
var ( var (
forward_Query_Allowance_0 = runtime.ForwardResponseMessage forward_Query_Allowance_0 = runtime.ForwardResponseMessage
forward_Query_Allowances_0 = runtime.ForwardResponseMessage forward_Query_Allowances_0 = runtime.ForwardResponseMessage
forward_Query_AllowancesByGranter_0 = runtime.ForwardResponseMessage
) )

View File

@ -4,10 +4,10 @@ package v040
import ( import (
"encoding/binary" "encoding/binary"
"fmt"
"time" "time"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/kv"
v040auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v040" v040auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v040"
) )
@ -113,9 +113,7 @@ func VoteKey(proposalID uint64, voterAddr sdk.AccAddress) []byte {
// SplitProposalKey split the proposal key and returns the proposal id // SplitProposalKey split the proposal key and returns the proposal id
func SplitProposalKey(key []byte) (proposalID uint64) { func SplitProposalKey(key []byte) (proposalID uint64) {
if len(key[1:]) != 8 { kv.AssertKeyLength(key[1:], 8)
panic(fmt.Sprintf("unexpected key length (%d ≠ 8)", len(key[1:])))
}
return GetProposalIDFromBytes(key[1:]) return GetProposalIDFromBytes(key[1:])
} }
@ -143,9 +141,7 @@ func SplitKeyVote(key []byte) (proposalID uint64, voterAddr sdk.AccAddress) {
// private functions // private functions
func splitKeyWithTime(key []byte) (proposalID uint64, endTime time.Time) { func splitKeyWithTime(key []byte) (proposalID uint64, endTime time.Time) {
if len(key[1:]) != 8+lenTime { kv.AssertKeyLength(key[1:], 8+lenTime)
panic(fmt.Sprintf("unexpected key length (%d ≠ %d)", len(key[1:]), lenTime+8))
}
endTime, err := sdk.ParseTimeBytes(key[1 : 1+lenTime]) endTime, err := sdk.ParseTimeBytes(key[1 : 1+lenTime])
if err != nil { if err != nil {
@ -157,10 +153,9 @@ func splitKeyWithTime(key []byte) (proposalID uint64, endTime time.Time) {
} }
func splitKeyWithAddress(key []byte) (proposalID uint64, addr sdk.AccAddress) { func splitKeyWithAddress(key []byte) (proposalID uint64, addr sdk.AccAddress) {
if len(key[1:]) != 8+v040auth.AddrLen { kv.AssertKeyLength(key[1:], 8+v040auth.AddrLen)
panic(fmt.Sprintf("unexpected key length (%d ≠ %d)", len(key), 8+v040auth.AddrLen))
}
kv.AssertKeyAtLeastLength(key, 10)
proposalID = GetProposalIDFromBytes(key[1:9]) proposalID = GetProposalIDFromBytes(key[1:9])
addr = sdk.AccAddress(key[9:]) addr = sdk.AccAddress(key[9:])
return return

View File

@ -2,11 +2,11 @@ package types
import ( import (
"encoding/binary" "encoding/binary"
"fmt"
"time" "time"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address" "github.com/cosmos/cosmos-sdk/types/address"
"github.com/cosmos/cosmos-sdk/types/kv"
) )
const ( const (
@ -111,9 +111,7 @@ func VoteKey(proposalID uint64, voterAddr sdk.AccAddress) []byte {
// SplitProposalKey split the proposal key and returns the proposal id // SplitProposalKey split the proposal key and returns the proposal id
func SplitProposalKey(key []byte) (proposalID uint64) { func SplitProposalKey(key []byte) (proposalID uint64) {
if len(key[1:]) != 8 { kv.AssertKeyLength(key[1:], 8)
panic(fmt.Sprintf("unexpected key length (%d ≠ 8)", len(key[1:])))
}
return GetProposalIDFromBytes(key[1:]) return GetProposalIDFromBytes(key[1:])
} }
@ -141,9 +139,7 @@ func SplitKeyVote(key []byte) (proposalID uint64, voterAddr sdk.AccAddress) {
// private functions // private functions
func splitKeyWithTime(key []byte) (proposalID uint64, endTime time.Time) { func splitKeyWithTime(key []byte) (proposalID uint64, endTime time.Time) {
if len(key[1:]) != 8+lenTime { kv.AssertKeyLength(key[1:], 8+lenTime)
panic(fmt.Sprintf("unexpected key length (%d ≠ %d)", len(key[1:]), lenTime+8))
}
endTime, err := sdk.ParseTimeBytes(key[1 : 1+lenTime]) endTime, err := sdk.ParseTimeBytes(key[1 : 1+lenTime])
if err != nil { if err != nil {
@ -157,7 +153,9 @@ func splitKeyWithTime(key []byte) (proposalID uint64, endTime time.Time) {
func splitKeyWithAddress(key []byte) (proposalID uint64, addr sdk.AccAddress) { func splitKeyWithAddress(key []byte) (proposalID uint64, addr sdk.AccAddress) {
// Both Vote and Deposit store keys are of format: // Both Vote and Deposit store keys are of format:
// <prefix (1 Byte)><proposalID (8 bytes)><addrLen (1 Byte)><addr_Bytes> // <prefix (1 Byte)><proposalID (8 bytes)><addrLen (1 Byte)><addr_Bytes>
kv.AssertKeyAtLeastLength(key, 10)
proposalID = GetProposalIDFromBytes(key[1:9]) proposalID = GetProposalIDFromBytes(key[1:9])
kv.AssertKeyAtLeastLength(key, 11)
addr = sdk.AccAddress(key[10:]) addr = sdk.AccAddress(key[10:])
return return
} }

View File

@ -6,6 +6,7 @@ import (
"encoding/binary" "encoding/binary"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/kv"
v040auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v040" v040auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v040"
) )
@ -44,10 +45,9 @@ func ValidatorSigningInfoKey(v sdk.ConsAddress) []byte {
// ValidatorSigningInfoAddress - extract the address from a validator signing info key // ValidatorSigningInfoAddress - extract the address from a validator signing info key
func ValidatorSigningInfoAddress(key []byte) (v sdk.ConsAddress) { func ValidatorSigningInfoAddress(key []byte) (v sdk.ConsAddress) {
kv.AssertKeyAtLeastLength(key, 2)
addr := key[1:] addr := key[1:]
if len(addr) != v040auth.AddrLen { kv.AssertKeyLength(addr, v040auth.AddrLen)
panic("unexpected key length")
}
return sdk.ConsAddress(addr) return sdk.ConsAddress(addr)
} }

View File

@ -5,6 +5,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address" "github.com/cosmos/cosmos-sdk/types/address"
"github.com/cosmos/cosmos-sdk/types/kv"
) )
const ( const (
@ -43,6 +44,7 @@ func ValidatorSigningInfoKey(v sdk.ConsAddress) []byte {
// ValidatorSigningInfoAddress - extract the address from a validator signing info key // ValidatorSigningInfoAddress - extract the address from a validator signing info key
func ValidatorSigningInfoAddress(key []byte) (v sdk.ConsAddress) { func ValidatorSigningInfoAddress(key []byte) (v sdk.ConsAddress) {
// Remove prefix and address length. // Remove prefix and address length.
kv.AssertKeyAtLeastLength(key, 3)
addr := key[2:] addr := key[2:]
return sdk.ConsAddress(addr) return sdk.ConsAddress(addr)

View File

@ -10,6 +10,7 @@ import (
"time" "time"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/kv"
v040auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v040" v040auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v040"
"github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/cosmos-sdk/x/staking/types"
) )
@ -66,6 +67,7 @@ func GetValidatorByConsAddrKey(addr sdk.ConsAddress) []byte {
// Get the validator operator address from LastValidatorPowerKey // Get the validator operator address from LastValidatorPowerKey
func AddressFromLastValidatorPowerKey(key []byte) []byte { func AddressFromLastValidatorPowerKey(key []byte) []byte {
kv.AssertKeyAtLeastLength(key, 2)
return key[1:] // remove prefix bytes return key[1:] // remove prefix bytes
} }
@ -112,9 +114,7 @@ func GetLastValidatorPowerKey(operator sdk.ValAddress) []byte {
// parse the validators operator address from power rank key // parse the validators operator address from power rank key
func ParseValidatorPowerRankKey(key []byte) (operAddr []byte) { func ParseValidatorPowerRankKey(key []byte) (operAddr []byte) {
powerBytesLen := 8 powerBytesLen := 8
if len(key) != 1+powerBytesLen+v040auth.AddrLen { kv.AssertKeyLength(key, 1+powerBytesLen+v040auth.AddrLen)
panic("Invalid validator power rank key length")
}
operAddr = sdk.CopyBytes(key[powerBytesLen+1:]) operAddr = sdk.CopyBytes(key[powerBytesLen+1:])
@ -196,11 +196,11 @@ func GetUBDByValIndexKey(delAddr sdk.AccAddress, valAddr sdk.ValAddress) []byte
// rearranges the ValIndexKey to get the UBDKey // rearranges the ValIndexKey to get the UBDKey
func GetUBDKeyFromValIndexKey(indexKey []byte) []byte { func GetUBDKeyFromValIndexKey(indexKey []byte) []byte {
kv.AssertKeyAtLeastLength(indexKey, 2)
addrs := indexKey[1:] // remove prefix bytes addrs := indexKey[1:] // remove prefix bytes
if len(addrs) != 2*v040auth.AddrLen { kv.AssertKeyLength(addrs, 2*v040auth.AddrLen)
panic("unexpected key length")
}
kv.AssertKeyAtLeastLength(addrs, v040auth.AddrLen+1)
valAddr := addrs[:v040auth.AddrLen] valAddr := addrs[:v040auth.AddrLen]
delAddr := addrs[v040auth.AddrLen:] delAddr := addrs[v040auth.AddrLen:]
@ -268,9 +268,7 @@ func GetREDByValDstIndexKey(delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.V
// GetREDKeyFromValSrcIndexKey rearranges the ValSrcIndexKey to get the REDKey // GetREDKeyFromValSrcIndexKey rearranges the ValSrcIndexKey to get the REDKey
func GetREDKeyFromValSrcIndexKey(indexKey []byte) []byte { func GetREDKeyFromValSrcIndexKey(indexKey []byte) []byte {
// note that first byte is prefix byte // note that first byte is prefix byte
if len(indexKey) != 3*v040auth.AddrLen+1 { kv.AssertKeyLength(indexKey, 3*v040auth.AddrLen+1)
panic("unexpected key length")
}
valSrcAddr := indexKey[1 : v040auth.AddrLen+1] valSrcAddr := indexKey[1 : v040auth.AddrLen+1]
delAddr := indexKey[v040auth.AddrLen+1 : 2*v040auth.AddrLen+1] delAddr := indexKey[v040auth.AddrLen+1 : 2*v040auth.AddrLen+1]
@ -282,9 +280,7 @@ func GetREDKeyFromValSrcIndexKey(indexKey []byte) []byte {
// GetREDKeyFromValDstIndexKey rearranges the ValDstIndexKey to get the REDKey // GetREDKeyFromValDstIndexKey rearranges the ValDstIndexKey to get the REDKey
func GetREDKeyFromValDstIndexKey(indexKey []byte) []byte { func GetREDKeyFromValDstIndexKey(indexKey []byte) []byte {
// note that first byte is prefix byte // note that first byte is prefix byte
if len(indexKey) != 3*v040auth.AddrLen+1 { kv.AssertKeyLength(indexKey, 3*v040auth.AddrLen+1)
panic("unexpected key length")
}
valDstAddr := indexKey[1 : v040auth.AddrLen+1] valDstAddr := indexKey[1 : v040auth.AddrLen+1]
delAddr := indexKey[v040auth.AddrLen+1 : 2*v040auth.AddrLen+1] delAddr := indexKey[v040auth.AddrLen+1 : 2*v040auth.AddrLen+1]

View File

@ -9,6 +9,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address" "github.com/cosmos/cosmos-sdk/types/address"
"github.com/cosmos/cosmos-sdk/types/kv"
) )
const ( const (
@ -63,11 +64,13 @@ func GetValidatorByConsAddrKey(addr sdk.ConsAddress) []byte {
// AddressFromValidatorsKey creates the validator operator address from ValidatorsKey // AddressFromValidatorsKey creates the validator operator address from ValidatorsKey
func AddressFromValidatorsKey(key []byte) []byte { func AddressFromValidatorsKey(key []byte) []byte {
kv.AssertKeyAtLeastLength(key, 3)
return key[2:] // remove prefix bytes and address length return key[2:] // remove prefix bytes and address length
} }
// AddressFromLastValidatorPowerKey creates the validator operator address from LastValidatorPowerKey // AddressFromLastValidatorPowerKey creates the validator operator address from LastValidatorPowerKey
func AddressFromLastValidatorPowerKey(key []byte) []byte { func AddressFromLastValidatorPowerKey(key []byte) []byte {
kv.AssertKeyAtLeastLength(key, 3)
return key[2:] // remove prefix bytes and address length return key[2:] // remove prefix bytes and address length
} }
@ -196,10 +199,13 @@ func GetUBDByValIndexKey(delAddr sdk.AccAddress, valAddr sdk.ValAddress) []byte
// GetUBDKeyFromValIndexKey rearranges the ValIndexKey to get the UBDKey // GetUBDKeyFromValIndexKey rearranges the ValIndexKey to get the UBDKey
func GetUBDKeyFromValIndexKey(indexKey []byte) []byte { func GetUBDKeyFromValIndexKey(indexKey []byte) []byte {
kv.AssertKeyAtLeastLength(indexKey, 2)
addrs := indexKey[1:] // remove prefix bytes addrs := indexKey[1:] // remove prefix bytes
valAddrLen := addrs[0] valAddrLen := addrs[0]
kv.AssertKeyAtLeastLength(addrs, 2+int(valAddrLen))
valAddr := addrs[1 : 1+valAddrLen] valAddr := addrs[1 : 1+valAddrLen]
kv.AssertKeyAtLeastLength(addrs, 3+int(valAddrLen))
delAddr := addrs[valAddrLen+2:] delAddr := addrs[valAddrLen+2:]
return GetUBDKey(delAddr, valAddr) return GetUBDKey(delAddr, valAddr)
@ -273,12 +279,16 @@ func GetREDByValDstIndexKey(delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.V
// GetREDKeyFromValSrcIndexKey rearranges the ValSrcIndexKey to get the REDKey // GetREDKeyFromValSrcIndexKey rearranges the ValSrcIndexKey to get the REDKey
func GetREDKeyFromValSrcIndexKey(indexKey []byte) []byte { func GetREDKeyFromValSrcIndexKey(indexKey []byte) []byte {
// note that first byte is prefix byte, which we remove // note that first byte is prefix byte, which we remove
kv.AssertKeyAtLeastLength(indexKey, 2)
addrs := indexKey[1:] addrs := indexKey[1:]
valSrcAddrLen := addrs[0] valSrcAddrLen := addrs[0]
kv.AssertKeyAtLeastLength(addrs, int(valSrcAddrLen)+2)
valSrcAddr := addrs[1 : valSrcAddrLen+1] valSrcAddr := addrs[1 : valSrcAddrLen+1]
delAddrLen := addrs[valSrcAddrLen+1] delAddrLen := addrs[valSrcAddrLen+1]
kv.AssertKeyAtLeastLength(addrs, int(valSrcAddrLen)+int(delAddrLen)+2)
delAddr := addrs[valSrcAddrLen+2 : valSrcAddrLen+2+delAddrLen] delAddr := addrs[valSrcAddrLen+2 : valSrcAddrLen+2+delAddrLen]
kv.AssertKeyAtLeastLength(addrs, int(valSrcAddrLen)+int(delAddrLen)+4)
valDstAddr := addrs[valSrcAddrLen+delAddrLen+3:] valDstAddr := addrs[valSrcAddrLen+delAddrLen+3:]
return GetREDKey(delAddr, valSrcAddr, valDstAddr) return GetREDKey(delAddr, valSrcAddr, valDstAddr)
@ -287,12 +297,16 @@ func GetREDKeyFromValSrcIndexKey(indexKey []byte) []byte {
// GetREDKeyFromValDstIndexKey rearranges the ValDstIndexKey to get the REDKey // GetREDKeyFromValDstIndexKey rearranges the ValDstIndexKey to get the REDKey
func GetREDKeyFromValDstIndexKey(indexKey []byte) []byte { func GetREDKeyFromValDstIndexKey(indexKey []byte) []byte {
// note that first byte is prefix byte, which we remove // note that first byte is prefix byte, which we remove
kv.AssertKeyAtLeastLength(indexKey, 2)
addrs := indexKey[1:] addrs := indexKey[1:]
valDstAddrLen := addrs[0] valDstAddrLen := addrs[0]
kv.AssertKeyAtLeastLength(addrs, int(valDstAddrLen)+2)
valDstAddr := addrs[1 : valDstAddrLen+1] valDstAddr := addrs[1 : valDstAddrLen+1]
delAddrLen := addrs[valDstAddrLen+1] delAddrLen := addrs[valDstAddrLen+1]
kv.AssertKeyAtLeastLength(addrs, int(valDstAddrLen)+int(delAddrLen)+3)
delAddr := addrs[valDstAddrLen+2 : valDstAddrLen+2+delAddrLen] delAddr := addrs[valDstAddrLen+2 : valDstAddrLen+2+delAddrLen]
kv.AssertKeyAtLeastLength(addrs, int(valDstAddrLen)+int(delAddrLen)+4)
valSrcAddr := addrs[valDstAddrLen+delAddrLen+3:] valSrcAddr := addrs[valDstAddrLen+delAddrLen+3:]
return GetREDKey(delAddr, valSrcAddr, valDstAddr) return GetREDKey(delAddr, valSrcAddr, valDstAddr)