Skip to content

Conversation

@dan437
Copy link
Contributor

@dan437 dan437 commented Jan 29, 2026

Explanation

Add type definitions for the withdrawal-to-any-token feature:

  • Add isPostQuote and selectedToken to TransactionData
  • Add UpdateSelectedTokenRequest type
  • Add TransactionPayControllerSetIsPostQuoteAction action type
  • Add TransactionPayControllerUpdateSelectedTokenAction action type
  • Add isPostQuote to MetamaskPayMetadata in transaction-controller
  • Export new types from index.ts

These types enable withdrawal flows where users can select a destination token different from the withdrawal's native token.

References

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
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Low Risk
Type-only additions across transaction-controller and transaction-pay-controller; low runtime risk but may require downstream updates where paymentToken semantics are assumed.

Overview
Enables post-quote (withdrawal) flows by extending TransactionPayController state with TransactionData.isPostQuote and selectedToken, while marking paymentToken as deprecated for backward compatibility.

Adds new messenger action typings (TransactionPayController:setIsPostQuote, TransactionPayController:updateSelectedToken) plus UpdateSelectedTokenRequest, and exports these new types from transaction-pay-controller.

Extends transaction-controller’s MetamaskPayMetadata with an optional isPostQuote flag and updates both packages’ changelogs accordingly.

Written by Cursor Bugbot for commit 9dc045f. This will update automatically on new commits. Configure here.

@dan437 dan437 requested a review from a team as a code owner January 29, 2026 13:37
@dan437 dan437 force-pushed the withdrawal-to-any-token-pr-1 branch from 5160a5d to 3cbc8b4 Compare January 29, 2026 13:52
@dan437 dan437 requested a review from a team as a code owner January 29, 2026 13:52
Add type definitions for the withdrawal-to-any-token feature:

- Add `isPostQuote` and `selectedToken` to TransactionData
- Add `UpdateSelectedTokenRequest` type
- Add `TransactionPayControllerSetIsPostQuoteAction` action type
- Add `TransactionPayControllerUpdateSelectedTokenAction` action type
- Add `isPostQuote` to MetamaskPayMetadata in transaction-controller
- Export new types from index.ts

These types enable withdrawal flows where users can select a destination
token different from the withdrawal's native token.
@dan437 dan437 force-pushed the withdrawal-to-any-token-pr-1 branch from 3cbc8b4 to 9dc045f Compare January 29, 2026 13:58
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

export type TransactionPayControllerSetIsPostQuoteAction = {
type: `${typeof CONTROLLER_NAME}:setIsPostQuote`;
handler: (transactionId: string, isPostQuote: boolean) => void;
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New action types lack corresponding handler registrations

Medium Severity

The new action types TransactionPayControllerUpdateSelectedTokenAction and TransactionPayControllerSetIsPostQuoteAction are added to the TransactionPayControllerActions union and exported, but no handlers are registered in TransactionPayController. Existing actions like setIsMaxAmount and updatePaymentToken follow a pattern where they're defined in types, have corresponding controller methods, and handlers are registered via messenger.registerActionHandler. The new action types break this pattern — calling them via the messenger will fail at runtime.

Additional Locations (1)

Fix in Cursor Fix in Web

* - For deposits (isPostQuote=false): This is the SOURCE/payment token
* - For withdrawals (isPostQuote=true): This is the DESTINATION token
*/
selectedToken?: TransactionPaymentToken;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't bother renaming this yet until the entire feature is done, given the breaking change, and refactor needed in the clients.

Though we can still update the JSDoc to clarify it's broader use.

};

/** Request to update the selected token for a transaction (used for withdrawals). */
export type UpdateSelectedTokenRequest = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here, wouldn't bother with a new action type yet as we can refactor later with a dedicated breaking change PR.

/**
* Whether this is a post-quote transaction (e.g., withdrawal flow).
* When true, the selectedToken represents the destination token,
* and the quote source is derived from the transaction's native token.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't quite true, the source would be whatever the original transaction generated / it's output.

* Used for Predict/Perps withdrawals where funds flow:
* withdrawal → bridge/swap → destination token
*/
isPostQuote?: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd usually recommend against a type only PR as easier to judge it's value when it's being utilised in new logic.

@dan437
Copy link
Contributor Author

dan437 commented Jan 30, 2026

Closing in favor of #7783

@dan437 dan437 closed this Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants