Skip to content

Commit a80a3e9

Browse files
fix: cp-7.52.0 swaps mobile hw tx (#17574)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> This PR reenables Ledger hardware wallet support for Mobile Swaps/Bridges. ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** Fixes: #17475 Patch based off of: https://github.com/MetaMask/core/compare/patch/bridge-status-controller-v34-mobile-hardware?expand=1 ## **Manual testing steps** 1. Import a Ledger account 2. Go to Swaps 3. Swap native gas token 4. Swap ERC20 with approval 5. Txs should succeed ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> https://github.com/user-attachments/assets/9f72d5da-e8ae-4e3d-9089-260b6b1b20a4 ## **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 - [ ] I’ve included tests if applicable - [ ] 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. ## **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.
1 parent be548e4 commit a80a3e9

File tree

2 files changed

+42
-7
lines changed

2 files changed

+42
-7
lines changed

app/components/UI/Bridge/Views/BridgeView/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -394,14 +394,12 @@ const BridgeView = () => {
394394
activeQuote &&
395395
quotesLastFetched && (
396396
<Box style={styles.buttonContainer}>
397-
{isHardwareAddress && (
397+
{isHardwareAddress && isSolanaSourced && (
398398
<BannerAlert
399399
severity={BannerAlertSeverity.Error}
400-
description={
401-
isSolanaSourced
402-
? strings('bridge.hardware_wallet_not_supported_solana')
403-
: strings('bridge.hardware_wallet_not_supported')
404-
}
400+
description={strings(
401+
'bridge.hardware_wallet_not_supported_solana',
402+
)}
405403
/>
406404
)}
407405
<Button
@@ -410,7 +408,9 @@ const BridgeView = () => {
410408
onPress={handleContinue}
411409
style={styles.button}
412410
isDisabled={
413-
hasInsufficientBalance || isSubmittingTx || isHardwareAddress
411+
hasInsufficientBalance ||
412+
isSubmittingTx ||
413+
(isHardwareAddress && isSolanaSourced)
414414
}
415415
/>
416416
<Button
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
diff --git a/node_modules/@metamask/bridge-status-controller/dist/bridge-status-controller.cjs b/node_modules/@metamask/bridge-status-controller/dist/bridge-status-controller.cjs
2+
index 84e7c48..b43fd13 100644
3+
--- a/node_modules/@metamask/bridge-status-controller/dist/bridge-status-controller.cjs
4+
+++ b/node_modules/@metamask/bridge-status-controller/dist/bridge-status-controller.cjs
5+
@@ -317,7 +317,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
6+
}
7+
return finalTransactionMeta;
8+
});
9+
- _BridgeStatusController_handleApprovalTx.set(this, async (isBridgeTx, quoteResponse) => {
10+
+ _BridgeStatusController_handleApprovalTx.set(this, async (isBridgeTx, quoteResponse, requireApproval) => {
11+
const { approval } = quoteResponse;
12+
if (approval) {
13+
const approveTx = async () => {
14+
@@ -327,6 +327,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
15+
? transaction_controller_1.TransactionType.bridgeApproval
16+
: transaction_controller_1.TransactionType.swapApproval,
17+
trade: approval,
18+
+ requireApproval,
19+
});
20+
await (0, transaction_1.handleLineaDelay)(quoteResponse);
21+
return approvalTxMeta;
22+
@@ -521,8 +522,12 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
23+
return tradeMeta;
24+
}
25+
// Set approval time and id if an approval tx is needed
26+
- const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_handleApprovalTx, "f").call(this, isBridgeTx, quoteResponse);
27+
+ const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_handleApprovalTx, "f").call(this, isBridgeTx, quoteResponse, requireApproval);
28+
approvalTxId = approvalTxMeta?.id;
29+
+ if (requireApproval) {
30+
+ const mobileHardwareWalletDelay = new Promise((resolve) => setTimeout(resolve, 1000));
31+
+ await mobileHardwareWalletDelay;
32+
+ }
33+
return await __classPrivateFieldGet(this, _BridgeStatusController_handleEvmTransaction, "f").call(this, {
34+
transactionType: isBridgeTx
35+
? transaction_controller_1.TransactionType.bridge

0 commit comments

Comments
 (0)