feat: allow users to add custom RPC endpoints#2170
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Warning Review limit reached
Your plan includes 1 review of capacity. Refill in 46 minutes and 54 seconds. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more review capacity refills, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughThis PR adds custom RPC endpoint configuration per chain: persistent storage and types, a per-genesis hook, UI for adding/editing/removing endpoints with wss:// validation and genesis-hash verification, integration into fullscreen and popup endpoint lists, and translations for the new UI strings. ChangesCustom RPC Endpoint Management
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/extension-polkagate/src/hooks/useCustomEndpoint.ts`:
- Around line 41-46: The deletion currently copies in-memory customEndpoints and
persists the whole map which can overwrite concurrent updates; update
useCustomEndpoint to first read the latest storage snapshot for
STORAGE_KEY.CUSTOM_ENDPOINTS (via setStorage's backing read or the storage
getter used elsewhere), remove only the entry for genesisHash from that fresh
snapshot, and then call setStorage(STORAGE_KEY.CUSTOM_ENDPOINTS,
updatedSnapshot); reference the existing symbols customEndpoints, genesisHash,
setStorage and STORAGE_KEY.CUSTOM_ENDPOINTS when making the change to ensure you
don't rely on possibly stale in-memory customEndpoints.
In `@packages/extension-polkagate/src/hooks/useEndpoints.ts`:
- Line 94: Replace the hardcoded label in useEndpoints.ts where you return
[...baseEndpoints, { text: 'Custom RPC', value: customEndpoint }] with the i18n
translation call using the previously added translation key for this feature
(use the file's translation helper, e.g., t('<existing_key>')). In short: find
the return that appends the customEndpoint option and swap the literal 'Custom
RPC' for the translated string (via the module's t/useTranslation helper) so the
option label uses the existing translation key.
In `@packages/extension/public/locales/de/translation.json`:
- Around line 959-970: The German locale is missing the new translation key
"{{mode}} enabled" which causes fallback to English; add an entry for the
"{{mode}} enabled" key in the existing translation JSON
(packages/extension/public/locales/de/translation.json) with an appropriate
German string (e.g., "{{mode}} aktiviert") ensuring the key matches exactly
including braces and spacing so that whatever code uses "{{mode}} enabled" will
resolve to the German text.
In `@packages/extension/public/locales/es/translation.json`:
- Around line 959-970: Add the missing translation key "{{mode}} enabled" to the
Spanish localization by inserting an entry for the exact key "{{mode}} enabled"
with an appropriate Spanish value (e.g., "Modo {{mode}} habilitado" or similar)
in the same JSON block where RPC-related keys like "Edit Custom RPC" and "Saved"
are defined so the runtime will use the localized string instead of the
untranslated key.
In `@packages/extension/public/locales/fr/translation.json`:
- Around line 959-970: Missing translation key "{{mode}} enabled": add the same
key to the French translation JSON and provide a localized value that preserves
the placeholder (for example "{{mode}} activé" or appropriate gendered form),
ensuring the JSON key is exactly "{{mode}} enabled" and the value keeps the
{{mode}} token intact; place it near the related RPC/endpoint keys (e.g., near
"Saved" / "Checking") and validate the JSON remains well-formed after insertion.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0da0b0fd-8c36-4952-9e05-433f615ff058
📒 Files selected for processing (19)
packages/extension-polkagate/src/components/MyTextField.tsxpackages/extension-polkagate/src/fullscreen/settings/partials/Endpoints.tsxpackages/extension-polkagate/src/fullscreen/settings/partials/useEndpointsSetting.tspackages/extension-polkagate/src/hooks/index.tspackages/extension-polkagate/src/hooks/useChainSelectionSettings.tspackages/extension-polkagate/src/hooks/useCustomEndpoint.tspackages/extension-polkagate/src/hooks/useEndpoints.tspackages/extension-polkagate/src/popup/settings/extensionSettings/CustomEndpoint.tsxpackages/extension-polkagate/src/popup/settings/extensionSettings/Endpoints.tsxpackages/extension-polkagate/src/util/constants.tspackages/extension-polkagate/src/util/types.tspackages/extension/public/locales/de/translation.jsonpackages/extension/public/locales/en/translation.jsonpackages/extension/public/locales/es/translation.jsonpackages/extension/public/locales/fr/translation.jsonpackages/extension/public/locales/hi/translation.jsonpackages/extension/public/locales/pt/translation.jsonpackages/extension/public/locales/ru/translation.jsonpackages/extension/public/locales/zh/translation.json
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/extension-polkagate/src/hooks/useCustomEndpoint.ts`:
- Around line 41-47: The removeCustomEndpoint flow can throw if getStorage or
setStorage rejects, breaking the Promise<boolean> contract; update the
removeCustomEndpoint implementation (the block that reads
STORAGE_KEY.CUSTOM_ENDPOINTS, creates updated = { ...(latestCustomEndpoints ??
{}) }, deletes updated[genesisHash], then calls setStorage) to wrap the async
storage calls in a try/catch and return false on any error; on success return
the boolean result from setStorage (or true) so callers always receive a
resolved Promise<boolean> and storage errors are swallowed/handled gracefully.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a6ad7b66-6540-4d62-840b-f3892691d654
📒 Files selected for processing (1)
packages/extension-polkagate/src/hooks/useCustomEndpoint.ts
… Promise<boolean> contract
close #2166, #2167
Summary by CodeRabbit
New Features
UI Improvements
Documentation