feat(transaction-pay-controller): add subsidized Relay submit via /relay/subsidize#9298
Draft
matthewwalsh0 wants to merge 1 commit into
Draft
feat(transaction-pay-controller): add subsidized Relay submit via /relay/subsidize#9298matthewwalsh0 wants to merge 1 commit into
matthewwalsh0 wants to merge 1 commit into
Conversation
…lay/subsidize Subsidized Relay quotes (non-zero fees.subsidized.amountUsd) now bypass /execute and submit through the intents-API POST /relay/subsidize endpoint instead. The client signs two ERC20BalanceChange + LimitedCalls delegations server-side; the server JIT-fetches a fresh Relay quote, pairs each delegation with a step, builds redeemDelegations calldata, and submits to Relay — returning a new request ID for status polling. Key changes: - utils/delegation.ts: buildAndSignSubsidizedDelegation with ERC20BalanceChange and LimitedCalls caveats, ANY_BENEFICIARY delegate, 20% amount buffer - relay-api.ts: submitRelaySubsidize() calling POST /relay/subsidize - relay-submit.ts: submitViaRelaySubsidize signs 2 delegations in parallel and sends delegations:[ctx0,ctx1] matching server schema; isSubsidizedRelayQuote detects subsidized quotes from fees.subsidized.amountUsd - types.ts: RelaySubsidizeRequest / RelaySubsidizeResponse - feature-flags.ts: relaySubsidizeUrl flag with DEFAULT_RELAY_SUBSIDIZE_URL default; fix localhost hardcoded URLs for relayQuoteUrl and relaySubsidizeUrl Fix crash when subsidized preview quotes have steps: undefined — server toSafeSubsidizedQuote() strips steps entirely; submitTransactions now uses quote.original.steps ?? [] and submitViaRelaySubsidize initialises quote.original.steps ??= [] before element access.
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.
Explanation
Subsidized Relay quotes currently flow through the same
/executepath as non-subsidized quotes. This exposes Relay quote internals (request IDs, exact calldata) to clients and couples the sponsorship model to specific Relay steps decided at quote time.This PR introduces a dedicated subsidized submit path. When a Relay quote carries a non-zero
fees.subsidized.amountUsd, the client signs two ERC20BalanceChange + LimitedCalls delegations (one per possible Relay step) instead of committing to exact step calldata. These delegations are sent toPOST /relay/subsidizeon the intents-API. The server JIT-fetches a fresh Relay quote server-side, pairs each delegation with a step, buildsredeemDelegationscalldata entirely on the server, and submits to Relay — returning a new request ID used for status polling.Key design decisions:
delegations.length >= steps.lengthand ignores extras.waitForRelayCompletionpolling loop polls the correct Relay request.isSubsidizedRelayQuote()returns true.Also fixes a crash introduced by the server's
toSafeSubsidizedQuote()function, which stripsstepsfrom subsidized preview quotes entirely (field absent, not empty array). Two sites inrelay-submit.tsthat accessedstepswithout guarding againstundefinedwould throwTypeErroron every subsidized submit attempt.References
Checklist