Repository navigation
feat(transaction-pay-middleware): accept a zero amount for perpsWithdraw - #11114
Merged
Merged
Conversation
OGPoyraz
marked this pull request as ready for review
October 27, 2026 10:36
OGPoyraz
temporarily deployed
to
default-branch
October 27, 2026 10:36 — with
GitHub Actions
Inactive
dan437
approved these changes
Oct 27, 2026
gaohan1994
pushed a commit
to gaohan1994/core
that referenced
this pull request
Oct 28, 2026
## Explanation Release `1368.0.0` with a major version bump for: - **`@metamask/transaction-pay-middleware`** `1.0.0` → `2.0.0` ### `@metamask/transaction-pay-middleware@2.0.0` **Breaking:** `wallet_pay` now selects the requested account before adding the transaction, once the request has passed every check ([MetaMask#11109](MetaMask#11109)) - The messenger must now allow `AccountsController:getAccountByAddress`, `AccountsController:getSelectedAccount` and `AccountTreeController:setSelectedAccountGroupByAccountId`. - A request whose `from` is not a known account is rejected with `4100`. Other changes: - Add support for Node.js 26 ([MetaMask#10981](MetaMask#10981)) - Accept a zero `amount` for `perpsWithdraw`, which opens the confirmation without a prefilled amount; adds optional `allowZeroAmount` to `WalletPayFlow` ([MetaMask#11114](MetaMask#11114)) - Add dependencies `@metamask/accounts-controller` (`^40.1.0`) and `@metamask/account-tree-controller` (`^11.2.0`) ([MetaMask#11109](MetaMask#11109)) - Bump `@metamask/perps-controller` from `^21.0.0` to `^22.0.0` ([MetaMask#11029](MetaMask#11029)) - Bump `@metamask/utils` from `^12.0.0` to `^12.0.1` ([MetaMask#11107](MetaMask#11107)) ### Dependency updates No packages in the monorepo depend on `@metamask/transaction-pay-middleware`, so there are no downstream range updates. All upstream dependencies are already at their released versions and were marked `intentionally-skip`. ## References - [MetaMask#11109](MetaMask#11109) — select the requested account for `wallet_pay` - [MetaMask#11114](MetaMask#11114) — accept a zero amount for `perpsWithdraw` ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Version and changelog edits only; no application code changes in this diff. > > **Overview** > Cuts **monorepo release `1368.0.0`** and publishes **`@metamask/transaction-pay-middleware@2.0.0`** by bumping root and package versions and moving unreleased changelog entries into a **`[2.0.0]`** section with updated compare links. > > The documented **2.0.0** behavior (already merged elsewhere) includes a **breaking** change: `wallet_pay` selects the `from` account before enqueueing the transaction, with new messenger actions and `4100` for unknown accounts; plus Node 26 support, optional zero `amount` for `perpsWithdraw` via `allowZeroAmount`, and dependency bumps. No other monorepo packages declare a dependency on this middleware, so this PR does not update downstream version ranges. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit e9c6ee0. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
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
wallet_payonly accepts a positiveamount, or noamount. A dApp opening aperpsWithdrawwithout knowing the amount up front, and passing"0", was rejected with-32602. The in-wallet withdraw opens with no prefilled amount and lets the user enter it on the confirmation.This PR accepts a zero
amountforperpsWithdraw:AmountStructnow accepts any non-negative decimal with up to 6 decimals.WalletPayFlowgets an optionalallowZeroAmountproperty. After validating the params,walletPayrejects a zeroamountwith-32602unless the requested type's flow sets it.perpsWithdrawFlowsetsallowZeroAmount: true. A zero amount is encoded the same way as no amount (0x0), so the confirmation opens without a prefilled amount.perpsDepositstill requires a positiveamountwhen one is given.No
amountis still accepted for both types, as before.References
Checklist
Note
Low Risk
Narrows validation for one pay type behind an explicit flow flag; deposit rules unchanged and behavior for zero withdraw matches omitting amount.
Overview
wallet_payno longer rejects"0"forperpsWithdraw. Dapps that do not know the withdraw amount up front can pass a zeroamount(or omit it) and get the same confirmation UX as the in-wallet withdraw—no prefilled amount.Validation is split:
AmountStructnow allows any non-negative decimal (up to 6 places), andwalletPayaddsassertAmountAllowed, which returns-32602for a zeroamountunless the flow sets the new optionalallowZeroAmountonWalletPayFlow. OnlyperpsWithdrawFlowenables that flag;perpsDepositstill requires a positive amount whenamountis present. Zero amounts encode like a missing amount (zero USDC transfer data).README and changelog document the behavior; tests cover deposit rejection vs withdraw acceptance.
Reviewed by Cursor Bugbot for commit 5834e2d. Bugbot is set up for automated code reviews on this repo. Configure here.