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

Add missing queries CLI #1233

Merged
merged 24 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ce9eda3
add placeholder code
tuantran1702 Mar 5, 2024
63453af
Merge branch 'main' of github.com:quicksilver-zone/quicksilver into t…
tuantran1702 Mar 6, 2024
3a34bbb
refactor based on function names
tuantran1702 Mar 7, 2024
783d067
add queries to CLI
tuantran1702 Mar 7, 2024
e3e2314
remove redundant code
tuantran1702 Mar 7, 2024
47caf05
Merge branch 'main' into tuan/add-query-cli
tuantran1702 Mar 7, 2024
69f5bf8
Add missing chain-id check
tuantran1702 Mar 7, 2024
17e6edb
Merge branch 'tuan/add-query-cli' of github.com:quicksilver-zone/quic…
tuantran1702 Mar 7, 2024
0e6b1b8
Merge branch 'main' into tuan/add-query-cli
faddat Mar 8, 2024
36c1714
add test and refactor query
tuantran1702 Mar 8, 2024
c7ad1fb
Merge branch 'tuan/add-query-cli' of github.com:quicksilver-zone/quic…
tuantran1702 Mar 8, 2024
a6d3490
Add some notes
tuantran1702 Mar 8, 2024
e6ce40b
linting
tuantran1702 Mar 8, 2024
730daf7
refactor tests
tuantran1702 Mar 8, 2024
7373432
add test for get unbonding
tuantran1702 Mar 8, 2024
e2f56f2
add test for get zone
tuantran1702 Mar 8, 2024
e0ae89b
Merge branch 'main' into tuan/add-query-cli
tuantran1702 Mar 10, 2024
dd639e5
Merge branch 'main' into tuan/add-query-cli
faddat Mar 16, 2024
ded73b9
Merge branch 'main' into tuan/add-query-cli
tuantran1702 Mar 16, 2024
6a201f5
add UserZoneWithdrawalRecords and test
tuantran1702 Mar 16, 2024
adee560
remove TODO
tuantran1702 Mar 17, 2024
6223679
Merge branch 'main' into tuan/add-query-cli
tuantran1702 Mar 21, 2024
89a83ad
Merge remote-tracking branch 'origin/main' into tuan/add-query-cli
tuantran1702 Mar 26, 2024
f1b7c11
test(ics): add valid test case for query delegator intent integration…
tuantran1702 Mar 26, 2024
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
312 changes: 312 additions & 0 deletions x/interchainstaking/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@
GetDelegatorIntentCmd(),
GetDepositAccountCmd(),
GetMappedAccountsCmd(),
GetWithdrawalRecordsCmd(),
GetUserWithdrawalRecordsCmd(),
GetZoneWithdrawalRecords(),
GetUnbondingRecordsCmd(),
GetReceiptsCmd(),
GetTxStatusCmd(),
GetZoneRedelegationRecordsCmd(),
GetZoneValidatorsCmd(),
GetZoneCmd(),

Check warning on line 41 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L33-L41

Added lines #L33 - L41 were not covered by tests
)

return cmd
Expand Down Expand Up @@ -180,3 +189,306 @@

return cmd
}

func GetWithdrawalRecordsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "withdrawal-records",
Short: "Query all withdrawal records",
Example: strings.TrimSpace(
fmt.Sprintf(`$ %s query interchainstaking withdrawal-records`,
version.AppName,
)),
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, _ []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err

Check warning on line 205 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L193-L205

Added lines #L193 - L205 were not covered by tests
}
queryClient := types.NewQueryClient(clientCtx)

Check warning on line 207 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L207

Added line #L207 was not covered by tests

pageReq, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
return err

Check warning on line 211 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L209-L211

Added lines #L209 - L211 were not covered by tests
}

req := &types.QueryWithdrawalRecordsRequest{
Pagination: pageReq,

Check warning on line 215 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L214-L215

Added lines #L214 - L215 were not covered by tests
}

res, err := queryClient.WithdrawalRecords(cmd.Context(), req)
if err != nil {
return err

Check warning on line 220 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L218-L220

Added lines #L218 - L220 were not covered by tests
}

return clientCtx.PrintProto(res)

Check warning on line 223 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L223

Added line #L223 was not covered by tests
},
}
flags.AddQueryFlagsToCmd(cmd)

Check warning on line 226 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L226

Added line #L226 was not covered by tests

return cmd

Check warning on line 228 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L228

Added line #L228 was not covered by tests
}

func GetUserWithdrawalRecordsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "user-withdrawal-record [user-address]",
Short: "Query withdrawal record for a given address.",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err

Check warning on line 239 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L231-L239

Added lines #L231 - L239 were not covered by tests
}

// args
address := args[0]

Check warning on line 243 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L243

Added line #L243 was not covered by tests

queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryUserWithdrawalRecordsRequest{
UserAddress: address,

Check warning on line 247 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L245-L247

Added lines #L245 - L247 were not covered by tests
}

res, err := queryClient.UserWithdrawalRecords(cmd.Context(), req)
if err != nil {
return err

Check warning on line 252 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L250-L252

Added lines #L250 - L252 were not covered by tests
}

return clientCtx.PrintProto(res)

Check warning on line 255 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L255

Added line #L255 was not covered by tests
},
}

flags.AddQueryFlagsToCmd(cmd)
return cmd

Check warning on line 260 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L259-L260

Added lines #L259 - L260 were not covered by tests
}

func GetZoneWithdrawalRecords() *cobra.Command {
cmd := &cobra.Command{
Use: "zone-withdrawal-records [chain-id]",
Short: "Query withdrawal records for a given zone.",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err

Check warning on line 271 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L263-L271

Added lines #L263 - L271 were not covered by tests
}

// args
chainID := args[0]

Check warning on line 275 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L275

Added line #L275 was not covered by tests

queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryWithdrawalRecordsRequest{
ChainId: chainID,

Check warning on line 279 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L277-L279

Added lines #L277 - L279 were not covered by tests
}

res, err := queryClient.ZoneWithdrawalRecords(cmd.Context(), req)
if err != nil {
return err

Check warning on line 284 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L282-L284

Added lines #L282 - L284 were not covered by tests
}

return clientCtx.PrintProto(res)

Check warning on line 287 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L287

Added line #L287 was not covered by tests
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd

Check warning on line 291 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L290-L291

Added lines #L290 - L291 were not covered by tests
}

func GetUnbondingRecordsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "unbonding-records",
Short: "Query all unbonding records",
Example: strings.TrimSpace(
fmt.Sprintf(`$ %s query interchainstaking unbonding-records`,
version.AppName,
)),
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, _ []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err

Check warning on line 306 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L294-L306

Added lines #L294 - L306 were not covered by tests
}
queryClient := types.NewQueryClient(clientCtx)

Check warning on line 308 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L308

Added line #L308 was not covered by tests

pageReq, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
return err

Check warning on line 312 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L310-L312

Added lines #L310 - L312 were not covered by tests
}

req := &types.QueryUnbondingRecordsRequest{
Pagination: pageReq,

Check warning on line 316 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L315-L316

Added lines #L315 - L316 were not covered by tests
}

res, err := queryClient.UnbondingRecords(cmd.Context(), req)
if err != nil {
return err

Check warning on line 321 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L319-L321

Added lines #L319 - L321 were not covered by tests
}

return clientCtx.PrintProto(res)

Check warning on line 324 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L324

Added line #L324 was not covered by tests
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd

Check warning on line 328 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L327-L328

Added lines #L327 - L328 were not covered by tests
}

func GetReceiptsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "recepts",
Short: "Query all receipts",
Example: strings.TrimSpace(
fmt.Sprintf(`$ %s query interchainstaking receipts`,
version.AppName,
)),
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, _ []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err

Check warning on line 343 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L331-L343

Added lines #L331 - L343 were not covered by tests
}
queryClient := types.NewQueryClient(clientCtx)

Check warning on line 345 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L345

Added line #L345 was not covered by tests

pageReq, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
return err

Check warning on line 349 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L347-L349

Added lines #L347 - L349 were not covered by tests
}

req := &types.QueryReceiptsRequest{
Pagination: pageReq,

Check warning on line 353 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L352-L353

Added lines #L352 - L353 were not covered by tests
}

res, err := queryClient.Receipts(cmd.Context(), req)
if err != nil {
return err

Check warning on line 358 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L356-L358

Added lines #L356 - L358 were not covered by tests
}

return clientCtx.PrintProto(res)

Check warning on line 361 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L361

Added line #L361 was not covered by tests
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd

Check warning on line 365 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L364-L365

Added lines #L364 - L365 were not covered by tests
}

func GetTxStatusCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "tx-status [chain-id] [tx-hash]",
Short: "Query the status of a transaction",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err

Check warning on line 376 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L368-L376

Added lines #L368 - L376 were not covered by tests
}

chainID := args[0]
txHash := args[1]

Check warning on line 380 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L379-L380

Added lines #L379 - L380 were not covered by tests

queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryTxStatusRequest{
ChainId: chainID,
TxHash: txHash,

Check warning on line 385 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L382-L385

Added lines #L382 - L385 were not covered by tests
}

res, err := queryClient.TxStatus(cmd.Context(), req)
if err != nil {
return err

Check warning on line 390 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L388-L390

Added lines #L388 - L390 were not covered by tests
}

return clientCtx.PrintProto(res)

Check warning on line 393 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L393

Added line #L393 was not covered by tests
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd

Check warning on line 397 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L396-L397

Added lines #L396 - L397 were not covered by tests
}

func GetZoneRedelegationRecordsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "zone-redelegation-records",
Short: "Query re-delegation records for a given zone.",
Example: strings.TrimSpace(
fmt.Sprintf(`$ %s query interchainstaking zone-redelegation-records`,
version.AppName,
)),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err

Check warning on line 412 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L400-L412

Added lines #L400 - L412 were not covered by tests
}
queryClient := types.NewQueryClient(clientCtx)

Check warning on line 414 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L414

Added line #L414 was not covered by tests

chainID := args[0]
req := &types.QueryRedelegationRecordsRequest{
ChainId: chainID,

Check warning on line 418 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L416-L418

Added lines #L416 - L418 were not covered by tests
}

// TODO: refactor this. Should be RedelegationRecords
Fixed Show fixed Hide fixed
res, err := queryClient.RedelegationRecords(cmd.Context(), req)
if err != nil {
return err

Check warning on line 424 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L422-L424

Added lines #L422 - L424 were not covered by tests
}

return clientCtx.PrintProto(res)

Check warning on line 427 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L427

Added line #L427 was not covered by tests
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd

Check warning on line 431 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L430-L431

Added lines #L430 - L431 were not covered by tests
}

// GetZoneValidatorCmd returns the validators for the given zone.
func GetZoneValidatorsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "zone-validators",
Short: "Query validators for a given zone.",
Example: strings.TrimSpace(
fmt.Sprintf(`$ %s query interchainstaking zone-validators`,
version.AppName,
)),
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, _ []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err

Check warning on line 447 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L435-L447

Added lines #L435 - L447 were not covered by tests
}
queryClient := types.NewQueryClient(clientCtx)

Check warning on line 449 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L449

Added line #L449 was not covered by tests

req := &types.QueryZoneValidatorsRequest{}

Check warning on line 451 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L451

Added line #L451 was not covered by tests

res, err := queryClient.ZoneValidators(cmd.Context(), req)
if err != nil {
return err

Check warning on line 455 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L453-L455

Added lines #L453 - L455 were not covered by tests
}

return clientCtx.PrintProto(res)

Check warning on line 458 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L458

Added line #L458 was not covered by tests
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd

Check warning on line 462 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L461-L462

Added lines #L461 - L462 were not covered by tests
}

// GetZoneCmd returns the information about the zone.
func GetZoneCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "zone [chain-id]",
Short: "Query zone information for a given chain.",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err

Check warning on line 474 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L466-L474

Added lines #L466 - L474 were not covered by tests
}

chainID := args[0]

Check warning on line 477 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L477

Added line #L477 was not covered by tests

queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryZoneRequest{
ChainId: chainID,

Check warning on line 481 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L479-L481

Added lines #L479 - L481 were not covered by tests
}

res, err := queryClient.Zone(cmd.Context(), req)
if err != nil {
return err

Check warning on line 486 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L484-L486

Added lines #L484 - L486 were not covered by tests
}

return clientCtx.PrintProto(res)

Check warning on line 489 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L489

Added line #L489 was not covered by tests
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd

Check warning on line 493 in x/interchainstaking/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/interchainstaking/client/cli/query.go#L492-L493

Added lines #L492 - L493 were not covered by tests
}
14 changes: 4 additions & 10 deletions x/interchainstaking/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,19 +244,12 @@
}

ctx := sdk.UnwrapSDKContext(c)

zone, found := k.GetZone(ctx, req.GetChainId())
_, found := k.GetZone(ctx, req.ChainId)
if !found {
return nil, status.Error(codes.NotFound, fmt.Sprintf("no zone found matching %s", req.GetChainId()))
}

withdrawalrecords := make([]types.WithdrawalRecord, 0)
k.IterateZoneWithdrawalRecords(ctx, zone.ChainId, func(index int64, record types.WithdrawalRecord) (stop bool) {
if record.Delegator == req.DelegatorAddress {
withdrawalrecords = append(withdrawalrecords, record)
}
return false
})
withdrawalrecords := k.AllZoneWithdrawalRecords(ctx, req.ChainId)

return &types.QueryWithdrawalRecordsResponse{Withdrawals: withdrawalrecords}, nil
}
Expand All @@ -269,7 +262,7 @@

ctx := sdk.UnwrapSDKContext(c)

withdrawalrecords := k.AllZoneWithdrawalRecords(ctx, req.ChainId)
withdrawalrecords := k.AllWithdrawalRecords(ctx)

return &types.QueryWithdrawalRecordsResponse{Withdrawals: withdrawalrecords}, nil
}
Expand Down Expand Up @@ -304,6 +297,7 @@
return &types.QueryUnbondingRecordsResponse{Unbondings: unbondings}, nil
}

// TODO: refactor this. Should be ZoneRedelegationRecords since it's only for a specific zone
Fixed Show fixed Hide fixed
tuantran1702 marked this conversation as resolved.
Show resolved Hide resolved
func (k *Keeper) RedelegationRecords(c context.Context, req *types.QueryRedelegationRecordsRequest) (*types.QueryRedelegationRecordsResponse, error) {
// TODO: implement pagination
if req == nil {
Expand Down
2 changes: 1 addition & 1 deletion x/interchainstaking/keeper/redelegation_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (k *Keeper) IterateRedelegationRecords(ctx sdk.Context, fn func(index int64
k.IteratePrefixedRedelegationRecords(ctx, nil, fn)
}

// AllRedelegationRecords returns every record in the store for the specified zone.
// AllRedelegationRecords returns every record in the store
func (k *Keeper) AllRedelegationRecords(ctx sdk.Context) []types.RedelegationRecord {
records := []types.RedelegationRecord{}
k.IterateRedelegationRecords(ctx, func(_ int64, _ []byte, record types.RedelegationRecord) (stop bool) {
Expand Down
Loading