Repository navigation
fix: fall back to public RPCs behind the free-plan Alchemy key and bundle only the env it reads - #321
Merged
Merged
Conversation
…ndle only the env it reads
|
Visit the preview URL for this PR (updated for commit 595bcf8): https://apps-lts--pr321-fix-rpc-public-fallb-wewpmo3q.web.app (expires Thu, 10 Dec 2026 14:53:48 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 8debd0062e03d9ce09ac2458f17da263c61e4b71 |
|
Visit the preview URL for this PR (updated for commit 595bcf8): https://dhedge-v1-withdraw--pr321-fix-rpc-public-fallb-w8xm995q.web.app (expires Thu, 10 Dec 2026 14:54:48 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 2157533cdfb02b956c33a37a482e9873c6f9154b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
No Trello card. The "mStable dApp Main" Alchemy key in the withdraw sites' bundle was found and used by a bot at up to 38M CU a day, billed to the paid account.
Description
withdraw.dhedge.org (
dhedge) and withdraw.mstable.org (lts) ship their Alchemy keys in the bundle, and Alchemy has no per-key cap. Both sites move to one key from a separate free-plan Alchemy account. That account stops at 30M CU a month and never bills, and once the month is used up it errors. Until now both providers were Alchemy keys, so nothing stood behind them.NX_ALCHEMY_MAIN_API_KEY) first and to public RPCs when it errors or stalls: PublicNode for Ethereum, Arbitrum and Optimism, Tenderly for Polygon. The second Alchemy key,NX_ALCHEMY_FALLBACK_API_KEY, is gone.NX*variable from the build env into the page, which putNX_CLOUD_ACCESS_TOKENinto both live bundles. It now builds in onlyNODE_ENV,NX_ALCHEMY_MAIN_API_KEYandNX_WALLET_CONNECT_PROJECT_ID, the variables these two apps read.ALCHEMY_FALLBACK_API_KEYin both key slots. All six workflows now useALCHEMY_MAIN_API_KEY.Verifying
Before the previews build, set the
ALCHEMY_MAIN_API_KEYsecret to the free-plan key.Steps to verify
*.g.alchemy.comwith the free key.*.g.alchemy.comand reload.NX_CLOUD.Expected results
NX_CLOUDis not found.Both apps lint and build locally. In a local build run with an extra
NX_*variable set, the bundles contained only the three listed names.Implementation details
getPublicRpcProvider()inlibs/shared/utils/src/web3.tsfollowsgetAlchemyRpcProvider(). wagmi'sconfigureChainsturns the two providers into an ethersFallbackProvider, which starts the second provider when the first errors or stalls.Todos (if a PR is in work in progress state)
After merging:
NX_CLOUD_ACCESS_TOKENsecret.ALCHEMY_FALLBACK_API_KEYsecret, and rotate the key it held where it lives.