-
Notifications
You must be signed in to change notification settings - Fork 1
chore: migrate-to-envio-query #28
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
base: master
Are you sure you want to change the base?
Conversation
WalkthroughAdds parsing and numeric validation of Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant App as Application
participant Env as Environment
participant SG as Subgraph
Note over App,Env #F8FBFF: Read and validate GTCR_SUBGRAPH_CHAIN_ID
App->>Env: GET GTCR_SUBGRAPH_CHAIN_ID
Env-->>App: chainId (string / undefined)
alt chainId invalid
App-->>App: log error and return
else chainId valid
App->>SG: query lrequests: LRequest(where:{resolved:{_eq:false},disputed:{_eq:false},chainId:{_eq:chainId}}, limit:1000) { ... }
SG-->>App: LRequest results
App->>SG: query lcontributions: LContribution(where:{withdrawable:{_eq:true},chainId:{_eq:chainId}}, limit:1000) { ... }
SG-->>App: LContribution results
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (2)
Comment |
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: 0
🧹 Nitpick comments (2)
src/light-gtcr-withdrawal.ts (1)
12-16
: Add an explicit limit to avoid unbounded responsesParity with execution (limit: 1000) and defensive querying. Also normalize spacing around _eq.
Apply this diff:
- lcontributions: LContribution(where: { withdrawable: {_eq :true} }) { + lcontributions: LContribution(where: { withdrawable: { _eq: true } }, limit: 1000) {src/light-gtcr-execution.ts (1)
13-21
: Consider stable ordering and pagination follow-upIf the result set can exceed 1000, consider adding an explicit ordering (if supported by your schema) and a looped pagination strategy to avoid skipping or reprocessing items between runs.
If the API supports it, a typical pattern (adjust names per schema) is:
- lrequests: LRequest(where: { resolved: {_eq: false}, disputed: {_eq: false} }, limit: 1000) { + lrequests: LRequest( + where: { resolved: { _eq: false }, disputed: { _eq: false } } + order_by: { submissionTime: asc } # or desc, depending on processing + limit: 1000 + ) {Pair this with cursor/offset handling in subsequent calls to cover all pages.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
src/light-gtcr-execution.ts
(1 hunks)src/light-gtcr-withdrawal.ts
(1 hunks)
🔇 Additional comments (4)
src/light-gtcr-withdrawal.ts (2)
12-16
: Alias migration and _eq filter look correctThe alias keeps downstream access via parsed.data.lcontributions intact, and switching to withdrawable: {_eq: true} matches the new schema’s boolean filter style.
12-16
: Verify GraphQL root field casing
File:src/light-gtcr-withdrawal.ts
(lines 12–16)We attempted to validate the root fields against your subgraph endpoint, but
GTCR_SUBGRAPH_URL
was not set, so no checks could be performed. Please setGTCR_SUBGRAPH_URL
to your GTCR_SUBGRAPH_URL and either re-run the script below or manually introspect the schema to confirm that the root queriesLContribution
andLRequest
exist (with the correct casing) on your subgraph.
- To re-run the automated check, export your endpoint and execute:
export GTCR_SUBGRAPH_URL="https://your.subgraph.url" curl -sS "$GTCR_SUBGRAPH_URL" \ -H 'content-type: application/json' \ --data-binary @- <<'JSON' | jq '.errors // "no errors"' {"query":"{ lcontributions: LContribution(where: { withdrawable: { _eq: true } }, limit: 1) { id contributor } }"} JSON- For manual verification, run an introspection query (e.g., in GraphiQL):
and look for{ __schema { queryType { fields { name } } } }LContribution
(or its lowercase variant, if your server normalizes names) andLRequest
.src/light-gtcr-execution.ts (2)
13-21
: LGTM: alias + _eq filters + limitThe aliased root field lrequests maps cleanly to parsed.data.lrequests, and the switch to _eq filters with limit: 1000 aligns with the new query style.
13-21
: Double-check root field casing (LRequest) on the endpointEnsure LRequest is the correct root field for your GTCR_SUBGRAPH_URL; otherwise, switch to the server’s expected collection field name.
Use the validation script included in the withdrawal file comment to confirm the schema accepts this query without errors.
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.
not sure how to test this one. @salgozino ? but looks good
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: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/light-gtcr-withdrawal.ts (1)
74-77
: Validate required environment variableGTCR_SUBGRAPH_CHAIN_ID
.The code checks for
GTCR_SUBGRAPH_URL
andLBATCH_WITHDRAW_ADDRESS
but does not validate the newly requiredGTCR_SUBGRAPH_CHAIN_ID
. If this variable is not set, the GraphQL query on line 12 will be malformed, causing runtime errors.Apply this diff:
- if (!process.env.GTCR_SUBGRAPH_URL || !process.env.LBATCH_WITHDRAW_ADDRESS) { - console.warn("No subgraph URL detected. Aborting lightGTCRWithdrawal bot"); + if (!process.env.GTCR_SUBGRAPH_URL || !process.env.LBATCH_WITHDRAW_ADDRESS || !process.env.GTCR_SUBGRAPH_CHAIN_ID) { + console.warn("Missing required environment variables. Aborting lightGTCRWithdrawal bot"); return; }src/light-gtcr-execution.ts (1)
115-118
: Validate required environment variableGTCR_SUBGRAPH_CHAIN_ID
.The code checks for
GTCR_SUBGRAPH_URL
but does not validate the newly requiredGTCR_SUBGRAPH_CHAIN_ID
. If this variable is not set, the GraphQL query on line 13 will be malformed, causing runtime errors.Apply this diff:
- if (!process.env.GTCR_SUBGRAPH_URL) { - console.warn("No subgraph URL detected. Aborting lightGTCRExecution bot"); + if (!process.env.GTCR_SUBGRAPH_URL || !process.env.GTCR_SUBGRAPH_CHAIN_ID) { + console.warn("Missing required environment variables. Aborting lightGTCRExecution bot"); return; }
🧹 Nitpick comments (2)
.env.example (1)
6-6
: Consider ordering the environment variable alphabetically.For consistency and easier navigation, place
GTCR_SUBGRAPH_CHAIN_ID
beforeGTCR_SUBGRAPH_URL
.As per static analysis hints.
src/light-gtcr-withdrawal.ts (1)
12-12
: Fix spacing inconsistency in GraphQL filter.There's an extra space before
true
in{_eq :true}
. Use consistent spacing for readability.Apply this diff:
- lcontributions: LContribution(where: { withdrawable: {_eq :true}, chainId: {_eq: ${process.env.GTCR_SUBGRAPH_CHAIN_ID}} }) { + lcontributions: LContribution(where: { withdrawable: {_eq: true}, chainId: {_eq: ${process.env.GTCR_SUBGRAPH_CHAIN_ID}} }) {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.env.example
(1 hunks)src/light-gtcr-execution.ts
(1 hunks)src/light-gtcr-withdrawal.ts
(1 hunks)
🧰 Additional context used
🪛 dotenv-linter (3.3.0)
.env.example
[warning] 6-6: [UnorderedKey] The GTCR_SUBGRAPH_CHAIN_ID key should go before the GTCR_SUBGRAPH_URL key
(UnorderedKey)
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.
LGTM. Just some minnor comments from CodeRabbit that are good things to have I think.
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: 1
🧹 Nitpick comments (2)
src/light-gtcr-withdrawal.ts (1)
10-14
: Consider extracting chainId validation to a shared helper.The chainId validation logic (lines 10-14) is duplicated in
src/light-gtcr-execution.ts
(lines 11-15). Extracting this to a shared utility function would improve maintainability..env.example (1)
3-8
: Consider alphabetical ordering of environment variables (optional).The static analysis tool suggests ordering keys alphabetically for consistency. While this is purely a style preference and doesn't affect functionality, it can improve readability in larger configuration files.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.env.example
(1 hunks)src/light-gtcr-execution.ts
(1 hunks)src/light-gtcr-withdrawal.ts
(1 hunks)
🧰 Additional context used
🪛 dotenv-linter (3.3.0)
.env.example
[warning] 4-4: [UnorderedKey] The LBATCH_WITHDRAW_ADDRESS key should go before the PROVIDER_URL key
(UnorderedKey)
[warning] 6-6: [UnorderedKey] The GTCR_SUBGRAPH_URL key should go before the LBATCH_WITHDRAW_ADDRESS key
(UnorderedKey)
[warning] 8-8: [UnorderedKey] The GTCR_SUBGRAPH_CHAIN_ID key should go before the GTCR_SUBGRAPH_URL key
(UnorderedKey)
🔇 Additional comments (5)
src/light-gtcr-withdrawal.ts (1)
10-14
: ChainId validation properly implemented.The validation logic correctly addresses the previous review concern by parsing and validating
GTCR_SUBGRAPH_CHAIN_ID
before using it in the query. The early return on invalid input prevents the bot from running with misconfigured environment variables..env.example (2)
3-8
: Configuration now consistent with Gnosis chain.The previous chain ID mismatch concern has been resolved. All configuration values (provider URL, subgraph URL, and chain ID) now align with Gnosis chain (chain ID 100).
6-6
: Verify the subgraph URL placeholder.The subgraph URL contains
abcabc
which appears to be a placeholder. Please confirm this is intentional for the example file, or update it with the actual indexer endpoint if this represents a real deployment.src/light-gtcr-execution.ts (2)
11-15
: ChainId validation properly implemented.The validation logic correctly addresses the previous review concern by parsing and validating
GTCR_SUBGRAPH_CHAIN_ID
before using it in the query. The implementation is consistent with the pattern used insrc/light-gtcr-withdrawal.ts
.
20-20
: Query syntax correctly updated for Envio.The GraphQL query has been properly updated to use Envio/Hasura-style syntax with
_eq
comparisons andlimit
instead offirst
. The chainId filter is correctly applied with the validated value.
Summary by CodeRabbit
Refactor
Chores