Skip to content

Commit

Permalink
fix: stx on ramps missing origin (#10099) (#10102)
Browse files Browse the repository at this point in the history
<!--
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.
  • Loading branch information
infiniteflower authored Jun 25, 2024
1 parent 182ee88 commit 937c7ad
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ describe('SendTransaction View', () => {
},
{
"deviceConfirmedOn": "metamask_mobile",
"origin": "RAMPS_SEND",
},
],
]
Expand Down Expand Up @@ -444,6 +445,7 @@ describe('SendTransaction View', () => {
},
{
"deviceConfirmedOn": "metamask_mobile",
"origin": "RAMPS_SEND",
},
],
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { useDispatch, useSelector } from 'react-redux';
import { useNavigation } from '@react-navigation/native';
import { BN } from 'ethereumjs-util';
import { SellOrder } from '@consensys/on-ramp-sdk/dist/API';
import { Transaction, WalletDevice } from '@metamask/transaction-controller';
import {
TransactionParams,
WalletDevice,
} from '@metamask/transaction-controller';

import Row from '../../components/Row';
import ScreenLayout from '../../components/ScreenLayout';
Expand Down Expand Up @@ -54,6 +57,7 @@ import { safeToChecksumAddress } from '../../../../../util/address';
import { generateTransferData } from '../../../../../util/transactions';
import useAnalytics from '../../hooks/useAnalytics';
import { toHex } from '@metamask/controller-utils';
import { RAMPS_SEND } from '../../constants';

interface SendTransactionParams {
orderId?: string;
Expand Down Expand Up @@ -118,7 +122,7 @@ function SendTransaction() {
} catch {
return;
}
let transactionParams: Transaction;
let transactionParams: TransactionParams;
const amount = addHexPrefix(
new BN(
toTokenMinimalUnit(
Expand Down Expand Up @@ -153,6 +157,7 @@ function SendTransaction() {
);
const response = await addTransaction(transactionParams, {
deviceConfirmedOn: WalletDevice.MM_MOBILE,
origin: RAMPS_SEND,
});
const hash = await response.result;

Expand Down
2 changes: 2 additions & 0 deletions app/components/UI/Ramp/constants/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* eslint-disable import/prefer-default-export */
export const RAMPS_SEND = 'RAMPS_SEND';
6 changes: 5 additions & 1 deletion app/util/smart-transactions/smart-publish-hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
import { v1 as random } from 'uuid';
import { decimalToHex } from '../conversions';
import { ApprovalTypes } from '../../core/RPCMethods/RPCMethodMiddleware';
import { RAMPS_SEND } from '../../components/UI/Ramp/constants';

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

Expand Down Expand Up @@ -146,7 +147,10 @@ class SmartTransactionHook {
this.#shouldUseSmartTransaction,
);
const useRegularTransactionSubmit = { transactionHash: undefined };
if (!this.#shouldUseSmartTransaction) {
if (
!this.#shouldUseSmartTransaction ||
this.#transactionMeta.origin === RAMPS_SEND
) {
return useRegularTransactionSubmit;
}

Expand Down

0 comments on commit 937c7ad

Please sign in to comment.