Skip to content

Commit 1919f0f

Browse files
authored
feat(perps): align PerpsController with core PR MetaMask#8633 (isInternal flag) (MetaMask#30413)
## **Description** Mirrors the change from [MetaMask/core#8633](MetaMask/core#8633) into mobile ahead of the full migration to core, so the mobile copy of `PerpsController` stays in sync with the upstream controller. The single substantive change forwards `isInternal: true` in the `options` payload when `PerpsController` submits a transaction via the `TransactionController` messenger, matching the new core behavior that flags controller-originated transactions as internal. This keeps both codebases behaviorally identical until mobile retires its local `PerpsController` in favor of the core package. ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: ## **Manual testing steps** ```gherkin Feature: Perps internal transaction flag parity Scenario: user submits a perps transaction routed through PerpsController Given the Perps feature is enabled and the wallet is unlocked When user initiates a perps action that triggers PerpsController to submit a transaction Then the resulting TransactionController entry is marked as an internal transaction (isInternal: true) And the transaction completes with the same UX as before this change ``` ## **Screenshots/Recordings** ### **Before** N/A — behavioral parity change, no user-visible UI difference. ### **After** N/A — behavioral parity change, no user-visible UI difference. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I've included tests if applicable - [x] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. #### Performance checks (if applicable) - [x] I've tested on Android - [x] I've tested with a power user scenario - [x] I've instrumented key operations with Sentry traces for production performance metrics ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes the options passed to `TransactionController:addTransaction` for perps flows, which could affect how transactions are classified/handled downstream (e.g., UI filtering or telemetry). Scope is small and covered by updated unit tests. > > **Overview** > Perps transactions submitted via `PerpsController` now always forward `isInternal: true` when calling `TransactionController:addTransaction`, aligning mobile behavior with the upstream core controller. > > Tests for `depositWithConfirmation` (including the `perpsDeposit` and `perpsDepositAndOrder` paths) are updated to assert the new `isInternal` flag in the messenger call options. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 93a877e. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 3bc2d99 commit 1919f0f

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

app/controllers/perps/PerpsController.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2715,6 +2715,7 @@ describe('PerpsController', () => {
27152715
origin: 'metamask',
27162716
type: 'perpsDeposit',
27172717
skipInitialGasEstimate: true,
2718+
isInternal: true,
27182719
},
27192720
);
27202721
});
@@ -3106,6 +3107,7 @@ describe('PerpsController', () => {
31063107
origin: 'metamask',
31073108
type: 'perpsDepositAndOrder',
31083109
skipInitialGasEstimate: true,
3110+
isInternal: true,
31093111
},
31103112
);
31113113
// Should NOT also call with perpsDeposit type

app/controllers/perps/PerpsController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ export class PerpsController extends BaseController<
13651365
// eslint-disable-next-line @typescript-eslint/no-explicit-any
13661366
txParams as any,
13671367
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1368-
options as any,
1368+
{ ...(options as any), isInternal: true },
13691369
);
13701370
}
13711371

0 commit comments

Comments
 (0)