Skip to content

Commit

Permalink
feat: add feegrant query to see allowances from a given granter (back…
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored and JeancarloBarrios committed Sep 28, 2024
1 parent 2beadc3 commit 5f8efef
Show file tree
Hide file tree
Showing 22 changed files with 3,089 additions and 460 deletions.
2,687 changes: 2,349 additions & 338 deletions CHANGELOG.md

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions proto/cosmos/base/tendermint/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ message GetNodeInfoResponse {

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

// Module is the type for VersionInfo
Expand Down
3 changes: 1 addition & 2 deletions proto/cosmos/store/snapshots/v1/snapshot.proto
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ message SnapshotIAVLItem {
// version is block height
int64 version = 3;
// height is depth of the tree.
int32 height = 4;
option (cosmos_proto.message_added_in) = "cosmos-sdk 0.46";
int32 height = 4;
}

// SnapshotExtensionMeta contains metadata about an external snapshotter.
Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/tx/signing/v1beta1/signing.proto
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ enum SignMode {

// 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
Expand Down
6 changes: 3 additions & 3 deletions proto/cosmos/tx/v1beta1/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ message GetBlockWithTxsRequest {
// Since: cosmos-sdk 0.45.2
message GetBlockWithTxsResponse {
// txs are the transactions in the block.
repeated cosmos.tx.v1beta1.Tx txs = 1;
.tendermint.types.BlockID block_id = 2;
.tendermint.types.Block block = 3;
repeated cosmos.tx.v1beta1.Tx txs = 1;
.tendermint.types.BlockID block_id = 2;
.tendermint.types.Block block = 3;
// pagination defines a pagination for the response.
cosmos.base.query.v1beta1.PageResponse pagination = 4;
}
82 changes: 44 additions & 38 deletions types/tx/signing/signing.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions x/authz/authz.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions x/authz/keeper/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
"github.com/cosmos/cosmos-sdk/types/kv"
"github.com/cosmos/cosmos-sdk/x/authz"
)

// Keys for store prefixes
Expand Down Expand Up @@ -49,6 +50,13 @@ func granterStoreKey(granter sdk.AccAddress) []byte {
func parseGrantStoreKey(key []byte) (granterAddr, granteeAddr sdk.AccAddress, msgType string) {
// key is of format:
// 0x01<granterAddressLen (1 Byte)><granterAddress_Bytes><granteeAddressLen (1 Byte)><granteeAddress_Bytes><msgType_Bytes>
kv.AssertKeyAtLeastLength(key, 2)
granterAddrLen := key[1] // remove prefix key
kv.AssertKeyAtLeastLength(key, int(3+granterAddrLen))
granterAddr = sdk.AccAddress(key[2 : 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)])

granterAddrLen, granterAddrLenEndIndex := sdk.ParseLengthPrefixedBytes(key, 1, 1) // ignore key[0] since it is a prefix key
granterAddr, granterAddrEndIndex := sdk.ParseLengthPrefixedBytes(key, granterAddrLenEndIndex+1, int(granterAddrLen[0]))
Expand Down
8 changes: 4 additions & 4 deletions x/authz/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

85 changes: 81 additions & 4 deletions x/distribution/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,87 @@ var (
ParamsKey = collections.NewPrefix(9) // key for distribution module params
)

// Reserved prefixes
var (
DeprecatedProposerKey = collections.NewPrefix(1) // key for the proposer operator address
)
// GetValidatorOutstandingRewardsAddress creates an address from a validator's outstanding rewards key.
func GetValidatorOutstandingRewardsAddress(key []byte) (valAddr sdk.ValAddress) {
// key is in the format:
// 0x02<valAddrLen (1 Byte)><valAddr_Bytes>

// Remove prefix and address length.
kv.AssertKeyAtLeastLength(key, 3)
addr := key[2:]
kv.AssertKeyLength(addr, int(key[1]))

return sdk.ValAddress(addr)
}

// GetDelegatorWithdrawInfoAddress creates an address from a delegator's withdraw info key.
func GetDelegatorWithdrawInfoAddress(key []byte) (delAddr sdk.AccAddress) {
// key is in the format:
// 0x03<accAddrLen (1 Byte)><accAddr_Bytes>

// Remove prefix and address length.
kv.AssertKeyAtLeastLength(key, 3)
addr := key[2:]
kv.AssertKeyLength(addr, int(key[1]))

return sdk.AccAddress(addr)
}

// GetDelegatorStartingInfoAddresses creates the addresses from a delegator starting info key.
func GetDelegatorStartingInfoAddresses(key []byte) (valAddr sdk.ValAddress, delAddr sdk.AccAddress) {
// key is in the format:
// 0x04<valAddrLen (1 Byte)><valAddr_Bytes><accAddrLen (1 Byte)><accAddr_Bytes>
kv.AssertKeyAtLeastLength(key, 2)
valAddrLen := int(key[1])
kv.AssertKeyAtLeastLength(key, 3+valAddrLen)
valAddr = sdk.ValAddress(key[2 : 2+valAddrLen])
delAddrLen := int(key[2+valAddrLen])
kv.AssertKeyAtLeastLength(key, 4+valAddrLen)
delAddr = sdk.AccAddress(key[3+valAddrLen:])
kv.AssertKeyLength(delAddr.Bytes(), delAddrLen)

return
}

// GetValidatorHistoricalRewardsAddressPeriod creates the address & period from a validator's historical rewards key.
func GetValidatorHistoricalRewardsAddressPeriod(key []byte) (valAddr sdk.ValAddress, period uint64) {
// key is in the format:
// 0x05<valAddrLen (1 Byte)><valAddr_Bytes><period_Bytes>
kv.AssertKeyAtLeastLength(key, 2)
valAddrLen := int(key[1])
kv.AssertKeyAtLeastLength(key, 3+valAddrLen)
valAddr = sdk.ValAddress(key[2 : 2+valAddrLen])
b := key[2+valAddrLen:]
kv.AssertKeyLength(b, 8)
period = binary.LittleEndian.Uint64(b)
return
}

// GetValidatorCurrentRewardsAddress creates the address from a validator's current rewards key.
func GetValidatorCurrentRewardsAddress(key []byte) (valAddr sdk.ValAddress) {
// key is in the format:
// 0x06<valAddrLen (1 Byte)><valAddr_Bytes>: ValidatorCurrentRewards

// Remove prefix and address length.
kv.AssertKeyAtLeastLength(key, 3)
addr := key[2:]
kv.AssertKeyLength(addr, int(key[1]))

return sdk.ValAddress(addr)
}

// GetValidatorAccumulatedCommissionAddress creates the address from a validator's accumulated commission key.
func GetValidatorAccumulatedCommissionAddress(key []byte) (valAddr sdk.ValAddress) {
// key is in the format:
// 0x07<valAddrLen (1 Byte)><valAddr_Bytes>: ValidatorCurrentRewards

// Remove prefix and address length.
kv.AssertKeyAtLeastLength(key, 3)
addr := key[2:]
kv.AssertKeyLength(addr, int(key[1]))

return sdk.ValAddress(addr)
}

// GetValidatorSlashEventAddressHeight creates the height from a validator's slash event key.
func GetValidatorSlashEventAddressHeight(key []byte) (valAddr sdk.ValAddress, height uint64) {
Expand Down
Loading

0 comments on commit 5f8efef

Please sign in to comment.