Skip to content

Commit 937c7ad

Browse files
fix: stx on ramps missing origin (#10099) (#10102)
<!-- 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 is the cherry pick PR for #10099 This PR fixes an issue with Ramps and STX missing an origin. This will disable STX for all Ramps Send transactions. ## **Related issues** #10100 Fixes: ## **Manual testing steps** 1. Turn on STX 2. Start an off ramp 3. Should be a normal tx 4. You should only see 1 off ramp transaction ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] 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). - [ ] 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 - [ ] 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. <!-- 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? --> ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] 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). - [ ] 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 - [ ] 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 182ee88 commit 937c7ad

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

app/components/UI/Ramp/Views/SendTransaction/SendTransaction.test.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ describe('SendTransaction View', () => {
400400
},
401401
{
402402
"deviceConfirmedOn": "metamask_mobile",
403+
"origin": "RAMPS_SEND",
403404
},
404405
],
405406
]
@@ -444,6 +445,7 @@ describe('SendTransaction View', () => {
444445
},
445446
{
446447
"deviceConfirmedOn": "metamask_mobile",
448+
"origin": "RAMPS_SEND",
447449
},
448450
],
449451
]

app/components/UI/Ramp/Views/SendTransaction/SendTransaction.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { useDispatch, useSelector } from 'react-redux';
44
import { useNavigation } from '@react-navigation/native';
55
import { BN } from 'ethereumjs-util';
66
import { SellOrder } from '@consensys/on-ramp-sdk/dist/API';
7-
import { Transaction, WalletDevice } from '@metamask/transaction-controller';
7+
import {
8+
TransactionParams,
9+
WalletDevice,
10+
} from '@metamask/transaction-controller';
811

912
import Row from '../../components/Row';
1013
import ScreenLayout from '../../components/ScreenLayout';
@@ -54,6 +57,7 @@ import { safeToChecksumAddress } from '../../../../../util/address';
5457
import { generateTransferData } from '../../../../../util/transactions';
5558
import useAnalytics from '../../hooks/useAnalytics';
5659
import { toHex } from '@metamask/controller-utils';
60+
import { RAMPS_SEND } from '../../constants';
5761

5862
interface SendTransactionParams {
5963
orderId?: string;
@@ -118,7 +122,7 @@ function SendTransaction() {
118122
} catch {
119123
return;
120124
}
121-
let transactionParams: Transaction;
125+
let transactionParams: TransactionParams;
122126
const amount = addHexPrefix(
123127
new BN(
124128
toTokenMinimalUnit(
@@ -153,6 +157,7 @@ function SendTransaction() {
153157
);
154158
const response = await addTransaction(transactionParams, {
155159
deviceConfirmedOn: WalletDevice.MM_MOBILE,
160+
origin: RAMPS_SEND,
156161
});
157162
const hash = await response.result;
158163

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/* eslint-disable import/prefer-default-export */
2+
export const RAMPS_SEND = 'RAMPS_SEND';

app/util/smart-transactions/smart-publish-hook.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
import { v1 as random } from 'uuid';
2121
import { decimalToHex } from '../conversions';
2222
import { ApprovalTypes } from '../../core/RPCMethods/RPCMethodMiddleware';
23+
import { RAMPS_SEND } from '../../components/UI/Ramp/constants';
2324

2425
export declare type Hex = `0x${string}`;
2526

@@ -146,7 +147,10 @@ class SmartTransactionHook {
146147
this.#shouldUseSmartTransaction,
147148
);
148149
const useRegularTransactionSubmit = { transactionHash: undefined };
149-
if (!this.#shouldUseSmartTransaction) {
150+
if (
151+
!this.#shouldUseSmartTransaction ||
152+
this.#transactionMeta.origin === RAMPS_SEND
153+
) {
150154
return useRegularTransactionSubmit;
151155
}
152156

0 commit comments

Comments
 (0)