Skip to content

Commit e39125e

Browse files
authored
fix: wrong stx chain id (#37461)
<!-- 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** Fixes #37194 <!-- 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? --> [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/37461?quickstart=1) ## **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: Fixed the smart transaction link ## **Related issues** Fixes: #37194 ## **Manual testing steps** 1. Make sure smart transactions are enabled 2. Perform a Send on Ethereum mainnet, BSC or Base 3. Make sure the "View transaction" link is displayed immediately after confirming the transaction (it should be instant) 4. Click on the link and make sure the transaction details are displayed ## **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** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/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 - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Pass `chainId` through smart transaction approval state and read it in the status page to build the correct Portfolio link; update test mocks accordingly. > > - **Smart Transactions Flow**: > - Include `chainId` in `requestState.smartTransaction` when adding the approval request in `app/scripts/lib/smart-transaction/smart-transactions.ts`. > - **UI**: > - `ui/pages/.../smart-transaction-status-page.tsx`: Stop using network selector; read `chainId` from `smartTransaction.chainId` to construct the Portfolio status URL. > - **Tests/Mocks**: > - `test/jest/mock-store.js`: Add `chainId` to mocked smart transaction entries. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 14d874c. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent c30ed30 commit e39125e

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

app/scripts/lib/smart-transaction/smart-transactions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ class SmartTransactionHook {
379379
status: SmartTransactionStatuses.PENDING,
380380
creationTime: Date.now(),
381381
uuid,
382+
chainId: this.#chainId,
382383
},
383384
isDapp: this.#isDapp,
384385
txId: this.#transactionMeta.id,

test/jest/mock-store.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ export const createSwapsMockStore = () => {
676676
'0x55ad39634ee10d417b6e190cfd3736098957e958879cffe78f1f00f4fd2654d6',
677677
minedTx: 'success',
678678
},
679+
chainId: CHAIN_IDS.MAINNET,
679680
},
680681
{
681682
uuid: 'uuid2',
@@ -689,6 +690,7 @@ export const createSwapsMockStore = () => {
689690
'0x55ad39634ee10d417b6e190cfd3736098957e958879cffe78f1f00f4fd2654d6',
690691
minedTx: 'success',
691692
},
693+
chainId: CHAIN_IDS.MAINNET,
692694
},
693695
],
694696
},

ui/pages/smart-transactions/smart-transaction-status-page/smart-transaction-status-page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {
2626
IconColor,
2727
} from '../../../helpers/constants/design-system';
2828
import { useI18nContext } from '../../../hooks/useI18nContext';
29-
import { getCurrentChainId } from '../../../../shared/modules/selectors/networks';
3029
import { getFullTxData } from '../../../selectors';
3130
import { BaseUrl } from '../../../../shared/constants/urls';
3231
import { hideLoadingIndication } from '../../../store/actions';
@@ -296,7 +295,7 @@ export const SmartTransactionStatusPage = ({
296295
smartTransaction?.status?.startsWith(SmartTransactionStatuses.CANCELLED),
297296
);
298297

299-
const chainId: string = useSelector(getCurrentChainId);
298+
const chainId: string | undefined = smartTransaction?.chainId;
300299
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
301300
// @ts-ignore: This same selector is used in the awaiting-swap component.
302301
const fullTxData = useSelector((state) => getFullTxData(state, txId)) || {};

0 commit comments

Comments
 (0)