-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix: yaci query #35
fix: yaci query #35
Conversation
WalkthroughThe changes involve modifications to the Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #35 +/- ##
==========================================
+ Coverage 59.39% 59.40% +0.01%
==========================================
Files 148 148
Lines 13830 13826 -4
==========================================
Hits 8214 8214
+ Misses 5616 5612 -4 ☔ View full report in Codecov by Sentry. |
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.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (1)
hooks/useQueries.ts (1)
Line range hint
787-841
: Add test coverage for the updated queries.The changes involve critical query functionality but lack test coverage. Consider adding tests that verify:
- Direct MsgSend transactions
- Nested group proposal MsgSend transactions
- Different address scenarios (sender/receiver)
- Edge cases and error handling
Would you like me to help create a test suite for these scenarios?
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 787-787: hooks/useQueries.ts#L787
Added line #L787 was not covered by tests
[warning] 789-792: hooks/useQueries.ts#L789-L792
Added lines #L789 - L792 were not covered by tests
[warning] 794-798: hooks/useQueries.ts#L794-L798
Added lines #L794 - L798 were not covered by tests
[warning] 800-801: hooks/useQueries.ts#L800-L801
Added lines #L800 - L801 were not covered by tests
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
hooks/useQueries.ts
(2 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
hooks/useQueries.ts
[warning] 787-787: hooks/useQueries.ts#L787
Added line #L787 was not covered by tests
[warning] 789-792: hooks/useQueries.ts#L789-L792
Added lines #L789 - L792 were not covered by tests
[warning] 794-798: hooks/useQueries.ts#L794-L798
Added lines #L794 - L798 were not covered by tests
[warning] 800-801: hooks/useQueries.ts#L800-L801
Added lines #L800 - L801 were not covered by tests
[warning] 841-841: hooks/useQueries.ts#L841
Added line #L841 was not covered by tests
@@ -842,7 +838,7 @@ | |||
export const useSendTxQuery = () => { | |||
const fetchTransactions = async () => { | |||
const baseUrl = 'https://testnet-indexer.liftedinit.tech/transactions'; | |||
const query = `data->tx->body->messages->0->>@type=eq./cosmos.bank.v1beta1.MsgSend`; | |||
const query = `data->tx->body->messages.cs.[{"@type": "/cosmos.bank.v1beta1.MsgSend"}]`; |
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.
🛠️ Refactor suggestion
Consider handling nested messages consistently.
While the query works for direct MsgSend messages, it might miss transactions within group proposals. Consider updating it to match the pattern used in useSendTxIncludingAddressQuery
for consistency.
- const query = `data->tx->body->messages.cs.[{"@type": "/cosmos.bank.v1beta1.MsgSend"}]`;
+ const query = `or(
+ data->tx->body->messages.cs.[{"@type": "/cosmos.bank.v1beta1.MsgSend"}],
+ data->tx->body->messages.cs.[{"messages": [{"@type": "/cosmos.bank.v1beta1.MsgSend"}]}]
+ )`;
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const query = `data->tx->body->messages.cs.[{"@type": "/cosmos.bank.v1beta1.MsgSend"}]`; | |
const query = `or( | |
data->tx->body->messages.cs.[{"@type": "/cosmos.bank.v1beta1.MsgSend"}], | |
data->tx->body->messages.cs.[{"messages": [{"@type": "/cosmos.bank.v1beta1.MsgSend"}]}] | |
)`; |
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 841-841: hooks/useQueries.ts#L841
Added line #L841 was not covered by tests
// Build query for both direct MsgSend and nested (1 level) group proposal MsgSend | ||
const query = ` | ||
or=( | ||
and( | ||
data->tx->body->messages->0->>@type.eq./cosmos.bank.v1beta1.MsgSend, | ||
or( | ||
data->tx->body->messages->0->>fromAddress.eq.${address}, | ||
data->tx->body->messages->0->>toAddress.eq.${address} | ||
) | ||
and=( | ||
or( | ||
data->tx->body->messages.cs.[{"@type": "/cosmos.bank.v1beta1.MsgSend"}], | ||
data->tx->body->messages.cs.[{"messages": [{"@type": "/cosmos.bank.v1beta1.MsgSend"}]}] | ||
), | ||
and( | ||
data->tx->body->messages->0->>@type.eq./cosmos.group.v1.MsgSubmitProposal, | ||
data->tx->body->messages->0->messages->0->>@type.eq./cosmos.bank.v1beta1.MsgSend, | ||
or( | ||
data->tx->body->messages->0->messages->0->>fromAddress.eq.${address}, | ||
data->tx->body->messages->0->messages->0->>toAddress.eq.${address} | ||
) | ||
or( | ||
data->tx->body->messages.cs.[{"fromAddress": "${address}"}], | ||
data->tx->body->messages.cs.[{"toAddress": "${address}"}], | ||
data->tx->body->messages.cs.[{"messages": [{"fromAddress": "${address}"}]}], | ||
data->tx->body->messages.cs.[{"messages": [{"toAddress": "${address}"}]}] | ||
) | ||
)`; | ||
) | ||
`; |
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.
💡 Codebase verification
Test coverage is missing for the updated query.
The changes in hooks/useQueries.ts
do not have corresponding tests to verify the new query logic.
🔗 Analysis chain
Query implementation looks good but needs test coverage.
The updated query correctly handles both direct MsgSend and nested group proposal MsgSend messages, aligning with the PR objective. The implementation uses PostgreSQL's containment operator efficiently.
Let's verify the query structure:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for existing test files and patterns
# Look for test files
echo "Searching for test files..."
fd -e test.ts -e spec.ts
# Look for similar query patterns
echo "Searching for similar query patterns..."
rg -A 2 'data->tx->body->messages\.cs\.'
Length of output: 1186
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 787-787: hooks/useQueries.ts#L787
Added line #L787 was not covered by tests
[warning] 789-792: hooks/useQueries.ts#L789-L792
Added lines #L789 - L792 were not covered by tests
[warning] 794-798: hooks/useQueries.ts#L794-L798
Added lines #L794 - L798 were not covered by tests
[warning] 800-801: hooks/useQueries.ts#L800-L801
Added lines #L800 - L801 were not covered by tests
This PR fixes the YACI query so all messages (up to 1 level deep) get processed, not only the first one.
Relates: #34
Fixes #33
Summary by CodeRabbit
MsgSend
types.