-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Use x/auth/client for querying Txs #8732
Conversation
Codecov Report
@@ Coverage Diff @@
## release/v0.41.x #8732 +/- ##
=================================================
Coverage 61.93% 61.93%
=================================================
Files 611 612 +1
Lines 35250 35408 +158
=================================================
+ Hits 21831 21930 +99
- Misses 11136 11167 +31
- Partials 2283 2311 +28
|
x/auth/tx/xauthclient.go
Outdated
// Package tx 's xauthclient.go file is copy-pasted from | ||
// https://github.com/cosmos/cosmos-sdk/blob/v0.41.3/x/auth/client/query.go | ||
// It is duplicated as to not introduce any breaking change in 0.41.4, see PR: | ||
// TODO | ||
// It is refactored and removed in the following PR: | ||
// TODO |
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.
This PR fixes query Txs (by hash or by event) GRPC handlers, by filling out all required fields.
The thing is, all this logic is already implemented in x/auth/client/query.go
, so the GRPC handlers could just call that file. Unfortunately, that creates an import cycle, see #8732 (comment)
To not introduce breaking changes, I copy-pasted the relevant functions from x/auth/client/query.go
to this folder. We have duplicate code, and will have it on 0.41.4.
I also created #8734, which is the correct way imo to solve things, which will be on master and on 0.42+.
x/auth/tx/service.go
Outdated
query := strings.Join(tmEvents, " AND ") | ||
|
||
result, err := s.clientCtx.Client.TxSearch(ctx, query, false, &page, &limit, "") | ||
result, err := queryTxsByEvents(s.clientCtx, req.Events, page, limit, "") |
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.
Calling authclient.QueryTxsByEvents
is the correct way to do things, but it introduces an import cycle, so I just copy/pasted queryTxsByEvents
to this package :(
e905f61
to
2c8b241
Compare
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.
Overall looks good. Left few comments.
@@ -194,7 +194,7 @@ func (s IntegrationTestSuite) TestGetTxEvents_GRPC() { | |||
{ | |||
"with multi events", | |||
&tx.GetTxsEventRequest{ | |||
Events: []string{"message.action=send", "message.module=bank"}, | |||
Events: []string{"message.action='send'", "message.module='bank'"}, |
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.
is '
required?
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.
If i'm not mistaken, it's required by tendermint.
Somehow, in the gRPC handler, we added a logic saying that "if there's no '
, we add a '
". I think people are used to '
, so I'm proposing to do exactly what tendermint expects, and remove the "add '
automatically" logic.
} | ||
any := p.AsAny() | ||
return sdk.NewResponseResultTx(resTx, any, resBlock.Block.Time.Format(time.RFC3339)), nil | ||
} |
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.
this is just code copy, right? Maybe you can add a source in a comment at the top of the file?
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.
it's there already!
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
…into am/8680-missing
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.
Approved. Maybe we can also check the documentation and update it to mention that Apostrophe in event values is required?
OK, I can make sure about that, #8736 |
Description
companion PR of #8734.
#8734 solves the issue in the correct way, but introduces breaking changes. This PR solves the same issue, without intoroducing breaking changes, but with some duplicate code.
Closes: #8680
Closes: #8681
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes