feat(transaction-pay): add Across strategy support#7886
feat(transaction-pay): add Across strategy support#7886pedronfigueiredo wants to merge 1 commit intomainfrom
Conversation
packages/transaction-pay-controller/src/strategy/across/across-submit.ts
Show resolved
Hide resolved
packages/transaction-pay-controller/src/strategy/across/across-submit.ts
Outdated
Show resolved
Hide resolved
665488f to
8be8f8c
Compare
packages/transaction-pay-controller/src/strategy/across/across-quotes.ts
Outdated
Show resolved
Hide resolved
8be8f8c to
3f52702
Compare
packages/transaction-pay-controller/src/strategy/across/across-submit.ts
Outdated
Show resolved
Hide resolved
packages/transaction-pay-controller/src/strategy/across/across-submit.ts
Show resolved
Hide resolved
3f52702 to
789a704
Compare
packages/transaction-pay-controller/src/strategy/across/across-submit.ts
Outdated
Show resolved
Hide resolved
789a704 to
6953629
Compare
packages/transaction-pay-controller/src/strategy/across/across-quotes.ts
Outdated
Show resolved
Hide resolved
6953629 to
8c1c7e5
Compare
9cd0f37 to
a6c9af9
Compare
| return getFeatureFlags(messenger).relayFallbackGas; | ||
| } | ||
|
|
||
| export async function estimateGasWithBufferOrFallback({ |
| }; | ||
| } | ||
|
|
||
| export function getFallbackGas(messenger: TransactionPayControllerMessenger): { |
There was a problem hiding this comment.
Should this be in feature-flags.ts?
| error = caughtError; | ||
| } | ||
|
|
||
| const fallbackGas = getFallbackGas(messenger); |
There was a problem hiding this comment.
Debatable whether we should have fallback gas or throw as it implies the transaction would revert?
There was a problem hiding this comment.
fallback is now option but off by default
| across?: PayStrategyConfigRaw; | ||
| relay?: { | ||
| enabled?: boolean; | ||
| relayQuoteUrl?: string; |
There was a problem hiding this comment.
Is this redundant as we already have the top level value?
| slippage: number; | ||
| }; | ||
|
|
||
| export type PayStrategyConfigRaw = { |
There was a problem hiding this comment.
Should this be AcrossConfig?
| messenger, | ||
| }); | ||
|
|
||
| const max = calculateGasCost({ |
There was a problem hiding this comment.
We also need gas station support here, but can do that in a future PR and re-use the Relay logic.
There was a problem hiding this comment.
added a ticket for this
| request: QuoteRequest, | ||
| ): Promise<TransactionPayQuote<AcrossQuote>['fees']['sourceNetwork']> { | ||
| const { from } = request; | ||
| const { swapTx } = quote; |
There was a problem hiding this comment.
Do we also need to include gas cost of approvalTxns?
| const chainId = toHex(params.chainId); | ||
| const value = toHex(params.value ?? '0x0'); | ||
|
|
||
| const gas = await estimateGasWithBuffer( |
There was a problem hiding this comment.
We don't want to duplicate the gas logic again, but store the gas limits in the quote to use during submit, so we know the network fees will match.
| data: params.data, | ||
| from, | ||
| gas: toHex(gas), | ||
| maxFeePerGas: normalizeOptionalHex(params.maxFeePerGas), |
There was a problem hiding this comment.
Can they not return gas fee properties?
There was a problem hiding this comment.
not sure I understand the question here, it's simply normalising to hex if needed.
| } | ||
|
|
||
| await Promise.all( | ||
| transactionIds.map((txId) => waitForTransactionConfirmed(txId, messenger)), |
There was a problem hiding this comment.
We're waiting for the deposit transactions to succeed, but we also need to poll the Across API to verify the status of their transactions on the target chain.
Looks like /deposit/status?
08bac6a to
26c090a
Compare
8c1c7e5 to
68679f6
Compare
packages/transaction-pay-controller/src/strategy/across/across-quotes.ts
Show resolved
Hide resolved
packages/transaction-pay-controller/src/strategy/across/across-submit.ts
Show resolved
Hide resolved
packages/transaction-pay-controller/src/strategy/across/across-quotes.ts
Show resolved
Hide resolved
0df61f2 to
43816bc
Compare
packages/transaction-pay-controller/src/strategy/across/across-quotes.ts
Outdated
Show resolved
Hide resolved
d7d7490 to
b6a43e3
Compare
bee7414 to
ca79a44
Compare
packages/transaction-pay-controller/src/strategy/across/across-quotes.ts
Show resolved
Hide resolved
packages/transaction-pay-controller/src/strategy/across/across-quotes.ts
Show resolved
Hide resolved
packages/transaction-pay-controller/src/strategy/across/across-submit.ts
Show resolved
Hide resolved
ca79a44 to
44f5e5a
Compare
packages/transaction-pay-controller/src/strategy/across/across-quotes.ts
Show resolved
Hide resolved
b6a43e3 to
7908026
Compare
44f5e5a to
0217b80
Compare
packages/transaction-pay-controller/src/strategy/across/across-quotes.ts
Outdated
Show resolved
Hide resolved
0217b80 to
e9f21d7
Compare
packages/transaction-pay-controller/src/strategy/across/across-quotes.ts
Outdated
Show resolved
Hide resolved
packages/transaction-pay-controller/src/strategy/across/across-submit.ts
Outdated
Show resolved
Hide resolved
e9f21d7 to
bc1b4fe
Compare
packages/transaction-pay-controller/src/strategy/across/across-quotes.ts
Show resolved
Hide resolved
bc1b4fe to
a2cec3d
Compare
packages/transaction-pay-controller/src/strategy/across/across-submit.ts
Outdated
Show resolved
Hide resolved
a2cec3d to
4e7659a
Compare
packages/transaction-pay-controller/src/strategy/across/across-quotes.ts
Show resolved
Hide resolved
packages/transaction-pay-controller/src/strategy/across/AcrossStrategy.ts
Show resolved
Hide resolved
4e7659a to
3c6deb7
Compare
packages/transaction-pay-controller/src/strategy/across/across-quotes.ts
Show resolved
Hide resolved
3c6deb7 to
d514937
Compare
|
|
||
| export type AcrossActionRequestBody = { | ||
| actions: AcrossAction[]; | ||
| }; |
There was a problem hiding this comment.
Unused exported types are dead code
Low Severity
AcrossActionArg, AcrossAction, and AcrossActionRequestBody are exported from this file but never imported or referenced anywhere in the codebase. These types appear to be scaffolding for future delegation support (per PR discussion), but they are currently dead code that adds maintenance surface area without being used.


Explanation
This PR extracts the Across strategy work on top of the provider-fallback baseline.
It adds:
acrossstrategy type + registration)transaction-controllerandtransaction-pay-controllerReferences
Addresses: https://github.com/MetaMask/MetaMask-planning/issues/6997
Checklist
Note
Medium Risk
Adds a new transaction submission path (including batched approvals and on-chain gas estimation/fallback) and new transaction types, which could impact how pay transactions are created and tracked if misconfigured.
Overview
Adds an Across-based pay strategy to
transaction-pay-controller, including quote fetching/normalization and a submission flow that can execute approval + deposit (batched) or deposit-only transactions and optionally poll Across for completion.Extends configuration and utilities to support this: introduces
TransactionPayStrategy.Across, feature-flag-drivenpayStrategiesconfig (incl. default Across API base), validated optionalmetaMaskFeeparams, sharedamountshelpers, and a newestimateGasLimitWithBufferOrFallbackhelper used by Across;RelayStrategynow has an explicitsupports()gate.Updates
transaction-controllertransaction typing withperpsAcrossDeposit/predictAcrossDepositfor attribution, and adds comprehensive tests plus changelog entries.Written by Cursor Bugbot for commit d514937. This will update automatically on new commits. Configure here.