-
Notifications
You must be signed in to change notification settings - Fork 828
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
Ct queries #1927
Changes from 8 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
20aa35d
add genesis init/export tests
dssei b0b9752
refactor store
dssei 81e4a02
confidential transfers queries
dssei 4832cb6
working draft test
dssei 821ef7e
more tests
dssei 16c70b8
refactor tests
dssei c36af29
all accounts query
dssei ec491ec
formatting
dssei 865b8ee
add pagination to request/response
dssei 3cda115
update implementation to use paginated response instead
dssei 30b38fd
formatting
dssei 2f54260
remove redundant param
dssei ab47caa
all accounts with denoms
dssei 7e5d66e
clean up commented code
dssei 0901dc5
return GetAccount back to keeper
dssei c9c0828
formatting
dssei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package keeper | ||
|
||
import ( | ||
"context" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/sei-protocol/sei-chain/x/confidentialtransfers/types" | ||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/status" | ||
) | ||
|
||
var _ types.QueryServer = BaseKeeper{} | ||
|
||
func (k BaseKeeper) GetAccount(ctx context.Context, req *types.GetAccountRequest) (*types.GetAccountResponse, error) { | ||
if req == nil { | ||
return nil, status.Error(codes.InvalidArgument, "empty request") | ||
} | ||
|
||
if req.Address == "" { | ||
return nil, status.Error(codes.InvalidArgument, "address cannot be empty") | ||
} | ||
|
||
address, err := sdk.AccAddressFromBech32(req.Address) | ||
if err != nil { | ||
return nil, status.Errorf(codes.InvalidArgument, "invalid address: %s", err.Error()) | ||
} | ||
|
||
if req.Denom == "" { | ||
return nil, status.Error(codes.InvalidArgument, "invalid denom") | ||
} | ||
|
||
sdkCtx := sdk.UnwrapSDKContext(ctx) | ||
|
||
ctAccount, found := k.getCtAccount(sdkCtx, address, req.Denom) | ||
if !found { | ||
return nil, status.Errorf(codes.NotFound, "account not found for account %s and denom %s", | ||
req.Address, req.Denom) | ||
} | ||
|
||
return &types.GetAccountResponse{Account: &ctAccount}, nil | ||
} | ||
|
||
func (k BaseKeeper) GetAllAccounts(ctx context.Context, req *types.GetAllAccountsRequest) (*types.GetAllAccountsResponse, error) { | ||
if req == nil { | ||
return nil, status.Error(codes.InvalidArgument, "empty request") | ||
} | ||
|
||
if req.Address == "" { | ||
return nil, status.Error(codes.InvalidArgument, "address cannot be empty") | ||
} | ||
|
||
address, err := sdk.AccAddressFromBech32(req.Address) | ||
if err != nil { | ||
return nil, status.Errorf(codes.InvalidArgument, "invalid address: %s", err.Error()) | ||
} | ||
|
||
sdkCtx := sdk.UnwrapSDKContext(ctx) | ||
|
||
accounts, err := k.getCtAccountsForAddress(sdkCtx, address) | ||
|
||
if err != nil { | ||
return nil, status.Errorf(codes.Internal, "failed to fetch accounts: %s", err.Error()) | ||
} | ||
|
||
return &types.GetAllAccountsResponse{Accounts: accounts}, nil | ||
|
||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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)