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

Ct queries #1927

Merged
merged 16 commits into from
Nov 12, 2024
Merged

Ct queries #1927

merged 16 commits into from
Nov 12, 2024

Conversation

dssei
Copy link
Contributor

@dssei dssei commented Nov 11, 2024

Describe your changes and provide context

Testing performed to validate your change

Copy link

codecov bot commented Nov 11, 2024

Codecov Report

Attention: Patch coverage is 69.81132% with 32 lines in your changes missing coverage. Please review.

Project coverage is 61.30%. Comparing base (32c89cd) to head (c9c0828).
Report is 33 commits behind head on feature/ct_types.

Files with missing lines Patch % Lines
x/confidentialtransfers/keeper/keeper.go 51.21% 19 Missing and 1 partial ⚠️
x/confidentialtransfers/keeper/grpc_query.go 76.00% 8 Missing and 4 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                  @@
##           feature/ct_types    #1927      +/-   ##
====================================================
- Coverage             61.36%   61.30%   -0.06%     
====================================================
  Files                   263      275      +12     
  Lines                 23306    24427    +1121     
====================================================
+ Hits                  14301    14976     +675     
- Misses                 8001     8357     +356     
- Partials               1004     1094      +90     
Files with missing lines Coverage Δ
app/app.go 66.66% <100.00%> (+0.31%) ⬆️
x/confidentialtransfers/keeper/genesis.go 75.75% <100.00%> (ø)
x/confidentialtransfers/types/keys.go 0.00% <ø> (ø)
x/confidentialtransfers/keeper/grpc_query.go 76.00% <76.00%> (ø)
x/confidentialtransfers/keeper/keeper.go 46.42% <51.21%> (ø)

... and 4 files with indirect coverage changes

Copy link
Contributor

@mj850 mj850 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall! With some small questions comments

message TestQueryResponse {
string test_field = 1;
message GetAllAccountsResponse {
repeated CtAccount accounts = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CtAccount itself does not have reference to the denom associated with the account - we should make sure this query responds with the names of the denoms that the address has accounts for

(actually that's probably the most important thing for this query, I think it's mostly useful to let users know what denoms some account has an confidential transfer accounts for, the user can then query that account directly to get the account details)

account, err := ctAccount.FromProto()
if err != nil {
return types.Account{}, false
}
return *account, true
}

func (k BaseKeeper) getCtAccount(ctx sdk.Context, address sdk.AccAddress, denom string) (types.CtAccount, bool) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to have both getAccount and getCtAccount?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was experimenting with the implementation a bit, will remove duplicate code

store := ctx.KVStore(k.storeKey)
key := types.GetAccountKey(address, denom)
if !store.Has(key) {
func (k BaseKeeper) getAccount(ctx sdk.Context, address sdk.AccAddress, denom string) (types.Account, bool) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to export this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I refactored it to be private, since the only usage rn is in the querier, and querier itself being a BaseKeeper has GetAccount method

account, err := ctAccount.FromProto()
if err != nil {
return types.Account{}, false
}
return *account, true
}

func (k BaseKeeper) getCtAccount(ctx sdk.Context, address sdk.AccAddress, denom string) (types.CtAccount, bool) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to export this method as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now it's only used in in getAccount so I would keep it as is for now.

@dssei dssei marked this pull request as ready for review November 12, 2024 19:34
@dssei dssei merged commit b6ed1a7 into feature/ct_types Nov 12, 2024
29 checks passed
@dssei dssei deleted the ct_queries branch November 12, 2024 23:04
mj850 pushed a commit that referenced this pull request Dec 7, 2024
* add genesis init/export tests

* refactor store

* confidential transfers queries

* working draft test

* more tests

* refactor tests

* all accounts query

* formatting

* add pagination to request/response

* update implementation to use paginated response instead

* formatting

* remove redundant param

* all accounts with denoms

* clean up commented code

* return GetAccount back to keeper

* formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants