-
-
Notifications
You must be signed in to change notification settings - Fork 252
feat: transaction pay controller #6820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
0e50e56 to
4c6b861
Compare
f286d34 to
1854460
Compare
f319b5c to
ab1550f
Compare
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
6bf4b22 to
77daf0c
Compare
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
fa44f49 to
1d50e78
Compare
bbdeed2 to
b7ddd1f
Compare
|
@metamaskbot publish-preview |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CODEOWNERS LGTM
packages/transaction-pay-controller/src/TransactionPayController.ts
Outdated
Show resolved
Hide resolved
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
a4e3b6c
a4e3b6c to
4d0ac75
Compare
|
@metamaskbot publish-preview |
| decimals: number, | ||
| fiatRates: FiatRates, | ||
| ) { | ||
| const amountRawValue = new BigNumber(amountRawInput); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to pass 16 here to denote a hexadecimal value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the value starts with 0x, it should be automatic.
|
|
||
| const sourceAmounts = tokens | ||
| .map((t) => calculateSourceAmount(paymentToken, t, messenger)) | ||
| .filter(Boolean) as TransactionPaySourceAmount[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This filter changes the length of the sourceAmounts array compared to the initial tokens array, this could cause issues on quotes.ts when relying on tokens[i] to select a certain token.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good spot, this is probably okay for now since it's the second gas fee token that is most likely to be removed if the user has balance, but safer to lookup by the token address on the source amount.
Explanation
Add the initial version of the
TransactionPayController.This intends to migrate the majority of the MetaMask Pay functionality from the mobile client, so it can be used without duplication in the extension.
For an architecture overview, see ARCHITECTURE.md.
Includes:
TransactionControllerto submit and wait for quotes.updatePaymentTokenaction / method.References
Checklist
Note
Adds @metamask/transaction-pay-controller to power MetaMask Pay with bridge/relay strategies, automatic required-token detection, quote orchestration, and a TransactionController publish hook.
@metamask/transaction-pay-controller0xa9059cbb, gas fees), selects payment token, computes source amounts, fetches quotes, and aggregates totals.BridgeStrategy: fetches viaBridgeController, submits viaBridgeStatusController, supports batch txs and configurable refresh intervals.RelayStrategy: fetches from Relay API, submits txs directly; supports Hyperliquid/Polygon-native normalization and skip-original-tx flow.TransactionPayPublishHookexecutes strategy quotes on publish and awaits completion.README.md(package list + dependency graph),CODEOWNERS,teams.json.Written by Cursor Bugbot for commit 83d6977. This will update automatically on new commits. Configure here.