Skip to content

Commit

Permalink
chore: smart-transactions code domain (#26948)
Browse files Browse the repository at this point in the history
## **Description**

This PR establishes the `ui/pages/smart-transactions` code domain,
following the guidance in [this
proposal](https://docs.google.com/document/d/1dzgWc1LCkYz2lZZ6X8SOaj23iaGYVQ2zJ1FVpOxsU-o/edit).


Moved | To ui/pages/smart-transactions/
-- | --

ui/components/app/smart-transactions/smart-transactions-opt-in-modal.tsx
| components/smart-transactions-opt-in-modal.tsx

The following files will be left in place.
| Left in place | Reason |

|---------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|
app/scripts/lib/transaction/smart-transactions.ts | background code
shared/constants/smartTransactions.ts | shared with background
|
`ui/components/app/transaction-list-item/smart-transaction-list-item.component.js`
| Specific to the transaction list. |
|
`ui/pages/confirmations/confirmation/templates/smart-transaction-status-page.js`
| Belongs with other confirmation templates. |
| `ui/pages/swaps/smart-transaction-status/smart-transaction-status.js`
| Swaps-focused. Will be replaced by regular STX status screen once
swaps moves to regular STX. |

### STX-related code in other files
The following files contain stx-related code, which may be extracted and
moved into the smart-transactions code domain at a later time.

| Path | STX-Related Code |

|------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
| `app/scripts/metamask-controller.js` | We use the STX controller there
`new SmartTransactionsController`. `*// Smart Transactions` section* |
| `ui/ducks/swaps/swaps.js` | A few functions related to STX:
`fetchSmartTransactionsLiveness`, `signAndSendSmartTransaction`,
`setSmartTransactionsRefreshInterval`, etc. |
| `ui/store/actions.ts` | `fetchSmartTransactionsLiveness` and other STX
functions |
|
`ui/pages/confirmations/confirm-transaction-base/confirm-transaction-base.container.js`
| STX is used from this component |
| `ui/pages/settings/advanced-tab/advanced-tab.component.js` | Advanced
Settings that include STX option |
| `ui/pages/swaps/swaps.util.ts` | `getFeeForSmartTransaction` |
| `ui/pages/swaps/prepare-swap-page/review-quote.js` | Uses STX in Swaps
|
| `ui/selectors/transactions.js` |
`allowedSwapsSmartTransactionStatusesForActivityList` |


<!--
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/26948?quickstart=1)

## **Related issues**

Fixes:

## **Manual testing steps**

1. Installed extension
2. Added account with crypto 
3. Verify STX opt-in-modal
4. Send a smart transaction

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**


![image](https://github.com/user-attachments/assets/6d610e0d-48b8-43e5-9dff-774481966e77)


![image](https://github.com/user-attachments/assets/4a8f5c17-4e2e-402b-84ca-61c95ed08948)


![image](https://github.com/user-attachments/assets/0eae012c-4cfe-4272-94c2-12b7519af1cb)


![image](https://github.com/user-attachments/assets/2cd232e6-d279-4894-b2df-5fcee0a8a0c9)

## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.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-extension/blob/develop/.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
dbrans authored Sep 18, 2024
1 parent 8d3e6ad commit 1a6f212
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 4 deletions.
1 change: 0 additions & 1 deletion ui/components/app/app-components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
@import 'recovery-phrase-reminder/index';
@import 'step-progress-bar/index.scss';
@import 'selected-account/index';
@import 'smart-transactions/index';
@import 'srp-input/srp-input';
@import 'snaps/snap-privacy-warning/index';
@import 'tab-bar/index';
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/home/home.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import TermsOfUsePopup from '../../components/app/terms-of-use-popup';
import RecoveryPhraseReminder from '../../components/app/recovery-phrase-reminder';
import WhatsNewPopup from '../../components/app/whats-new-popup';
import { FirstTimeFlowType } from '../../../shared/constants/onboarding';
import SmartTransactionsOptInModal from '../../components/app/smart-transactions/smart-transactions-opt-in-modal';
import SmartTransactionsOptInModal from '../smart-transactions/components/smart-transactions-opt-in-modal';
///: END:ONLY_INCLUDE_IF
import HomeNotification from '../../components/app/home-notification';
import MultipleNotifications from '../../components/app/multiple-notifications';
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/pages.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
@import 'onboarding-flow/index';
@import 'permissions-connect/index';
@import 'settings/index';
@import 'smart-transactions/index';
@import 'snaps/snaps-list/index';
@import 'snaps/snap-view/index';
@import 'create-snap-account/index';
@import 'smart-transactions/smart-transaction-status-page/index';
@import 'remove-snap-account/index';
@import 'swaps/index';
@import 'token-details/index';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
ButtonLinkSize,
Icon,
IconName,
} from '../../component-library';
} from '../../../components/component-library';
import { setSmartTransactionsOptInStatus } from '../../../store/actions';
import { SMART_TRANSACTIONS_LEARN_MORE_URL } from '../../../../shared/constants/smartTransactions';

Expand Down
2 changes: 2 additions & 0 deletions ui/pages/smart-transactions/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import './smart-transaction-status-page/index';
@import './components/index';

0 comments on commit 1a6f212

Please sign in to comment.