Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: end point to get intents across all zones for a delegator address #466 #468

Merged
merged 36 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
3f9412a
front-port v1.2.13
Jun 2, 2023
c1056cd
fix delegation flush test
May 29, 2023
f59917a
add tests for HandleDepositTransaction
May 29, 2023
2637729
update tests for new error handling
May 30, 2023
cd44c38
remove superflous field in proto
Jun 2, 2023
f9a1f71
final v1.2.13 front-port and test fixes
Jun 2, 2023
c8f0205
s/s/suite/
Jun 2, 2023
be20f50
remove fmt.Printlns used for debugging
Jun 2, 2023
b18cd9f
update participation rewards and protocoldatas, to add validation, au…
Jun 2, 2023
6a77679
front-port v1.2.13
Jun 2, 2023
058bd08
remove balancerPoolPretty json marshal/unmarshal, as we deal with raw…
Jun 5, 2023
5502cb3
fix: allow support for multiple denoms from same zone in tvl calc
Jun 5, 2023
43f0dcf
lint
Jun 5, 2023
48ef8cc
fix: refactor utils/address.go to avoid import cycle when using in os…
Jun 8, 2023
a8333ed
add test for randomutils
Jun 8, 2023
08c6382
fix: remove potential non-det by iterating over maps using sorted keys
Jun 8, 2023
a8bc5eb
resolve outstanding nits
Jun 8, 2023
8f9c1a5
lint
Jun 8, 2023
27174c0
fix nits
Jun 9, 2023
87ed29e
bump go to 1.20.5
Jun 9, 2023
2a7d2c4
Merge branch 'develop' into pr-tvl-updates
Jun 9, 2023
729e5bf
Update x/interchainstaking/keeper/receipt.go
Jun 12, 2023
f69e7b9
Apply suggestions from code review
Jun 12, 2023
dcbb1fb
lint
Jun 12, 2023
ccf97e2
bump hermes to v1.5.0
Jun 12, 2023
974ea7f
update icq and relayer in test scripts
Jun 12, 2023
04df0fb
Merge remote-tracking branch 'origin/develop' into develop
muku314115 Jun 16, 2023
c7ad866
Merge remote-tracking branch 'origin/develop' into develop
muku314115 Jun 19, 2023
468fdfc
copying
muku314115 Jun 20, 2023
c07ca18
Merge branch 'develop' into mukund/delegatorintents
Jun 20, 2023
12092f6
Update x/interchainstaking/keeper/grpc_query.go
muku314115 Jun 21, 2023
4b6abfc
adding nil check
muku314115 Jun 21, 2023
b15e78e
Merge remote-tracking branch 'origin/mukund/delegatorintents' into mu…
muku314115 Jun 21, 2023
a5234f8
Merge branch 'develop' of https://github.com/ingenuity-build/quicksil…
muku314115 Jun 21, 2023
c311c50
proto format
muku314115 Jun 21, 2023
7b9d5ef
Merge branch 'develop' into mukund/delegatorintents
Jun 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions proto/quicksilver/interchainquery/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ option go_package = "github.com/ingenuity-build/quicksilver/x/interchainquery/ty
service QuerySrvr {
// Params returns the total set of minting parameters.
rpc Queries(QueryRequestsRequest) returns (QueryRequestsResponse) {
option (google.api.http).get = "/quicksilver/interchainquery/v1/queries/{chain_id}";
option (google.api.http).get =
"/quicksilver/interchainquery/v1/queries/{chain_id}";
}
}

Expand All @@ -29,7 +30,8 @@ message QueryRequestsRequest {
// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryRequestsResponse {
// params defines the parameters of the module.
repeated quicksilver.interchainquery.v1.Query queries = 1 [(gogoproto.nullable) = false];
repeated quicksilver.interchainquery.v1.Query queries = 1
[ (gogoproto.nullable) = false ];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

Expand Down
47 changes: 39 additions & 8 deletions proto/quicksilver/interchainstaking/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,20 @@ service Query {
rpc DepositAccount(QueryDepositAccountForChainRequest) returns (QueryDepositAccountForChainResponse) {
option (google.api.http).get = "/quicksilver/interchainstaking/v1/zones/{chain_id}/deposit_address";
}

// DelegatorIntent provides data on the intent of the delegator for the given
// zone.
rpc DelegatorIntent(QueryDelegatorIntentRequest) returns (QueryDelegatorIntentResponse) {
option (google.api.http).get =
"/quicksilver/interchainstaking/v1/zones/{chain_id}/delegator_intent/"
"{delegator_address}";
"/quicksilver/interchainstaking/v1/zones/{chain_id}/delegator_intent/"
"{delegator_address}";
}

// DelegatorIntents provides data on the intent of the delegator for all zones
rpc DelegatorIntents(QueryDelegatorIntentsRequest) returns (QueryDelegatorIntentsResponse) {
option (google.api.http).get =
"/quicksilver/interchainstaking/v1/delegator_intents/"
"{delegator_address}";
}

// Delegations provides data on the delegations for the given zone.
Expand All @@ -50,15 +58,20 @@ service Query {
// WithdrawalRecords provides data on the active withdrawals.
rpc ZoneWithdrawalRecords(QueryWithdrawalRecordsRequest) returns (QueryWithdrawalRecordsResponse) {
option (google.api.http).get =
"/quicksilver/interchainstaking/v1/zones/{chain_id}/withdrawal_records/"
"{delegator_address}";
"/quicksilver/interchainstaking/v1/zones/{chain_id}/withdrawal_records/"
"{delegator_address}";
}

// WithdrawalRecords provides data on the active withdrawals.
rpc WithdrawalRecords(QueryWithdrawalRecordsRequest) returns (QueryWithdrawalRecordsResponse) {
option (google.api.http).get = "/quicksilver/interchainstaking/v1/zones/{chain_id}/withdrawal_records";
}

// WithdrawalRecords provides data on the active withdrawals.
rpc UserWithdrawalRecords(QueryUserWithdrawalRecordsRequest) returns (QueryWithdrawalRecordsResponse) {
option (google.api.http).get = "/quicksilver/interchainstaking/v1/users/{user_address}/withdrawal_records";
}

// UnbondingRecords provides data on the active unbondings.
rpc UnbondingRecords(QueryUnbondingRecordsRequest) returns (QueryUnbondingRecordsResponse) {
option (google.api.http).get = "/quicksilver/interchainstaking/v1/zones/{chain_id}/unbonding_records";
Expand All @@ -67,8 +80,8 @@ service Query {
// RedelegationRecords provides data on the active unbondings.
rpc RedelegationRecords(QueryRedelegationRecordsRequest) returns (QueryRedelegationRecordsResponse) {
option (google.api.http).get =
"/quicksilver/interchainstaking/v1/zones/"
"{chain_id}/redelegation_records";
"/quicksilver/interchainstaking/v1/zones/"
"{chain_id}/redelegation_records";
}

// MappedAccounts provides data on the mapped accounts for a given user over different host chains.
Expand Down Expand Up @@ -138,6 +151,19 @@ message QueryDelegatorIntentResponse {
DelegatorIntent intent = 1;
}

message QueryDelegatorIntentsRequest {
string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

message DelegatorIntentsResponse {
string chain_id = 1;
DelegatorIntent intent = 2;
}

message QueryDelegatorIntentsResponse {
repeated DelegatorIntentsResponse intents = 1;
}

message QueryDelegationsRequest {
string chain_id = 1 [(gogoproto.moretags) = "yaml:\"chain_id\""];
cosmos.base.query.v1beta1.PageRequest pagination = 2;
Expand Down Expand Up @@ -170,9 +196,14 @@ message QueryWithdrawalRecordsResponse {
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

message QueryUserWithdrawalRecordsRequest {
string user_address = 1 [(gogoproto.moretags) = "cosmos.AddressString"];
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}

message QueryUnbondingRecordsRequest {
string chain_id = 1 [(gogoproto.moretags) = "yaml:\"chain_id\""];
cosmos.base.query.v1beta1.PageRequest pagination = 3;
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}

message QueryUnbondingRecordsResponse {
Expand All @@ -198,4 +229,4 @@ message QueryMappedAccountsRequest {
message QueryMappedAccountsResponse {
map<string, bytes> RemoteAddressMap = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ message Params {

// distribution_proportions defines the proportions of the minted
// participation rewards;
DistributionProportions distribution_proportions = 1 [(gogoproto.nullable) = false];
DistributionProportions distribution_proportions = 1
[ (gogoproto.nullable) = false ];
bool claims_enabled = 2;
}

Expand All @@ -48,7 +49,7 @@ message KeyedProtocolData {
// determination of rewards.
message ProtocolData {
string type = 1;
bytes data = 2 [(gogoproto.casttype) = "encoding/json.RawMessage"];
bytes data = 2 [ (gogoproto.casttype) = "encoding/json.RawMessage" ];
}

enum ProtocolDataType {
Expand Down
37 changes: 37 additions & 0 deletions x/interchainstaking/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,26 @@ func (k *Keeper) DelegatorIntent(c context.Context, req *types.QueryDelegatorInt
return &types.QueryDelegatorIntentResponse{Intent: &intent}, nil
}

// DelegatorIntents returns information about the delegation intent of the caller for all zones.
muku314115 marked this conversation as resolved.
Show resolved Hide resolved
func (k *Keeper) DelegatorIntents(c context.Context, req *types.QueryDelegatorIntentsRequest) (*types.QueryDelegatorIntentsResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}

ctx := sdk.UnwrapSDKContext(c)

intents := []*types.DelegatorIntentsResponse{}

k.IterateZones(ctx, func(_ int64, zone *types.Zone) bool {
intent, _ := k.GetDelegatorIntent(ctx, zone, req.DelegatorAddress, false)

intents = append(intents, &types.DelegatorIntentsResponse{ChainId: zone.ChainId, Intent: &intent})
return false
muku314115 marked this conversation as resolved.
Show resolved Hide resolved
})

return &types.QueryDelegatorIntentsResponse{Intents: intents}, nil
}

func (k *Keeper) Delegations(c context.Context, req *types.QueryDelegationsRequest) (*types.QueryDelegationsResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
Expand Down Expand Up @@ -230,6 +250,23 @@ func (k *Keeper) WithdrawalRecords(c context.Context, req *types.QueryWithdrawal
return &types.QueryWithdrawalRecordsResponse{Withdrawals: withdrawalrecords}, nil
}

func (k *Keeper) UserWithdrawalRecords(c context.Context, req *types.QueryUserWithdrawalRecordsRequest) (*types.QueryWithdrawalRecordsResponse, error) {
// TODO: implement pagination
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}

if _, err := addressutils.AddressFromBech32(req.UserAddress, ""); err != nil {
return nil, err
}

ctx := sdk.UnwrapSDKContext(c)

withdrawalrecords := k.AllUserWithdrawalRecords(ctx, req.UserAddress)

return &types.QueryWithdrawalRecordsResponse{Withdrawals: withdrawalrecords}, nil
}

func (k *Keeper) UnbondingRecords(c context.Context, req *types.QueryUnbondingRecordsRequest) (*types.QueryUnbondingRecordsResponse, error) {
// TODO: implement pagination
if req == nil {
Expand Down
Loading