fix: do not override comments#1414
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThe pull request updates the enclave configuration file with new contract deploy block values and expanded node configuration, while refactoring the config updater script to use a line-oriented state machine instead of YAML parsing, thereby preserving comments and formatting. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
packages/enclave-contracts/scripts/utils.ts (2)
331-351: Partial field updates not handled.If an existing contract has
addressbut is missingdeploy_block, the current logic marks the contract as "found" (line 277) but won't add the missingdeploy_blockfield. The contract would be skipped by the "missing contracts" logic since it's infoundKeys.This is likely acceptable if all existing contracts have both fields, but worth noting as a potential edge case.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/enclave-contracts/scripts/utils.ts` around lines 331 - 351, Existing contracts that are marked as found (foundKeys) but are missing specific fields (e.g., deploy_block) are not updated; modify the logic that processes found keys so it checks each found contract's existing lines for missing fields and inserts only the missing fields (address and/or deploy_block) instead of treating the whole contract as complete. Use the existing variables and structures (foundKeys, updates, lines, contractEntryIndent, contractsKeyIndent, lastContractsLine) to locate the contract block in lines, detect whether "address:" and "deploy_block:" exist for a given configKey, and push or splice the necessary line(s) with correct indentation and values from updates.get(configKey) when a field is absent. Ensure you still avoid duplicating fields and preserve indenting using contractEntryIndent/valIndent.
317-330: Hardcoded indentation assumes 2-space YAML style.The new chain entry uses hardcoded 2-space indentation. This works for the current configs but could produce inconsistent formatting if a config file uses different indentation. Consider deriving the indentation from the existing
chains:section structure for better robustness.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/enclave-contracts/scripts/utils.ts` around lines 317 - 330, The newLines creation hardcodes 2-space indentation; change it to derive indentation from the surrounding YAML by detecting the leading whitespace of the existing "chains:" section (or the line at insertIdx) and compute per-level indent, then build the entry using that indent for the chain name, rpc_url, contracts, and nested contract fields (use the same indent variable when pushing strings instead of literal two spaces); update the code that constructs newLines (referencing newLines, chainToConfig, rpcUrl, updates, insertIdx, and lines) to use the computed indent so added entries match the file's existing indentation style.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/enclave-contracts/scripts/utils.ts`:
- Around line 331-351: Existing contracts that are marked as found (foundKeys)
but are missing specific fields (e.g., deploy_block) are not updated; modify the
logic that processes found keys so it checks each found contract's existing
lines for missing fields and inserts only the missing fields (address and/or
deploy_block) instead of treating the whole contract as complete. Use the
existing variables and structures (foundKeys, updates, lines,
contractEntryIndent, contractsKeyIndent, lastContractsLine) to locate the
contract block in lines, detect whether "address:" and "deploy_block:" exist for
a given configKey, and push or splice the necessary line(s) with correct
indentation and values from updates.get(configKey) when a field is absent.
Ensure you still avoid duplicating fields and preserve indenting using
contractEntryIndent/valIndent.
- Around line 317-330: The newLines creation hardcodes 2-space indentation;
change it to derive indentation from the surrounding YAML by detecting the
leading whitespace of the existing "chains:" section (or the line at insertIdx)
and compute per-level indent, then build the entry using that indent for the
chain name, rpc_url, contracts, and nested contract fields (use the same indent
variable when pushing strings instead of literal two spaces); update the code
that constructs newLines (referencing newLines, chainToConfig, rpcUrl, updates,
insertIdx, and lines) to use the computed indent so added entries match the
file's existing indentation style.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 08dcf991-3ac4-43cd-9596-a4fe9ffae6ec
📒 Files selected for processing (2)
examples/CRISP/enclave.config.yamlpackages/enclave-contracts/scripts/utils.ts
fix #1051
Summary by CodeRabbit