Repository navigation
fix(proxy): require balance covering endpoint price before proxying - #1474
Open
lienhoatienphung-svg wants to merge 1 commit into
Open
lienhoatienphung-svg wants to merge 1 commit into
lienhoatienphung-svg wants to merge 1 commit into
Conversation
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.
Closes #1224
Summary
Resolves the matched endpoint's
priceUsdcbefore the pre-proxy balance check inhandleProxy(src/routes/proxyRoutes.ts), rejects requests with402 Payment Required(INSUFFICIENT_BALANCEin the standard error envelope) without contacting the upstream service whencurrentBalance < endpointPriceUsdc, and allows free endpoints (priceUsdc === 0) to proceed even when the caller's balance is zero.Acceptance Criteria Mapping
1calling a5-price endpoint receives402and the upstream is not called: Verified insrc/routes/gatewayRoutes.test.tsandsrc/__tests__/proxy.integration.test.ts.5calling a5-price endpoint succeeds and has5deducted: Verified insrc/routes/gatewayRoutes.test.tsandsrc/__tests__/proxy.integration.test.ts.0calling a0-price endpoint succeeds: Free endpoints skip the positive-balance requirement and proxy normally.new PaymentRequiredError('Payment Required: insufficient balance', 'INSUFFICIENT_BALANCE').Validation
npx jest src/routes/gatewayRoutes.test.ts --no-cacheandnpx jest src/__tests__/proxy.integration.test.ts -t "1224" --no-cache(all pass).Payout Wallet (Base Mainnet USDC / EVM):
0x3806cd592a508d1992Ed007C2F53de251C2E7452