Skip to content

Commit

Permalink
Merge branch 'develop' into remove-unused-rpc-handler-hook
Browse files Browse the repository at this point in the history
  • Loading branch information
rekmarks committed May 10, 2024
2 parents 38cf3c7 + 3c2d792 commit 2c1d1a3
Show file tree
Hide file tree
Showing 37 changed files with 788 additions and 208 deletions.
2 changes: 1 addition & 1 deletion app/scripts/controllers/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default class PreferencesController {
useNativeCurrencyAsPrimaryCurrency: true,
hideZeroBalanceTokens: false,
petnamesEnabled: true,
redesignedConfirmationsEnabled: false,
redesignedConfirmationsEnabled: true,
featureNotificationsEnabled: false,
},
// ENS decentralized website resolution
Expand Down
8 changes: 3 additions & 5 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,7 @@ export default class MetamaskController extends EventEmitter {
},
},
provider: this.provider,
testGasFeeFlows: process.env.TEST_GAS_FEE_FLOWS,
hooks: {
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
afterSign: (txMeta, signedEthTx) =>
Expand Down Expand Up @@ -4896,11 +4897,8 @@ export default class MetamaskController extends EventEmitter {
///: END:ONLY_INCLUDE_IF

const isConfirmationRedesignEnabled = () => {
return (
process.env.ENABLE_CONFIRMATION_REDESIGN &&
this.preferencesController.store.getState().preferences
.redesignedConfirmations
);
return this.preferencesController.store.getState().preferences
.redesignedConfirmations;
};

engine.push(
Expand Down
4 changes: 3 additions & 1 deletion builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ env:
- MULTICHAIN: ''
# Determines if feature flagged Multichain Transactions should be used
- TRANSACTION_MULTICHAIN: ''
# Enables use of test gas fee flow to debug gas fee estimation
- TEST_GAS_FEE_FLOWS: false

# Enables the notifications feature within the build:
- NOTIFICATIONS: ''
Expand All @@ -308,4 +310,4 @@ env:
# Account Abstraction (EIP-4337)
###

- EIP_4337_ENTRYPOINT: null
- EIP_4337_ENTRYPOINT: null
2 changes: 2 additions & 0 deletions development/build/set-environment-variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ module.exports.setEnvironmentVariables = function setEnvironmentVariables({
variables,
environment,
}),
TEST_GAS_FEE_FLOWS:
isDevBuild && variables.getMaybe('TEST_GAS_FEE_FLOWS') === true,
});
};

Expand Down
1 change: 0 additions & 1 deletion lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,6 @@
"@metamask/assets-controllers>@metamask/polling-controller": true,
"@metamask/controller-utils": true,
"@metamask/eth-query": true,
"@metamask/ethjs>@metamask/ethjs-unit": true,
"bn.js": true,
"browserify>buffer": true,
"uuid": true
Expand Down
1 change: 0 additions & 1 deletion lavamoat/browserify/desktop/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,6 @@
"@metamask/assets-controllers>@metamask/polling-controller": true,
"@metamask/controller-utils": true,
"@metamask/eth-query": true,
"@metamask/ethjs>@metamask/ethjs-unit": true,
"bn.js": true,
"browserify>buffer": true,
"uuid": true
Expand Down
1 change: 0 additions & 1 deletion lavamoat/browserify/flask/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,6 @@
"@metamask/assets-controllers>@metamask/polling-controller": true,
"@metamask/controller-utils": true,
"@metamask/eth-query": true,
"@metamask/ethjs>@metamask/ethjs-unit": true,
"bn.js": true,
"browserify>buffer": true,
"uuid": true
Expand Down
1 change: 0 additions & 1 deletion lavamoat/browserify/main/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,6 @@
"@metamask/assets-controllers>@metamask/polling-controller": true,
"@metamask/controller-utils": true,
"@metamask/eth-query": true,
"@metamask/ethjs>@metamask/ethjs-unit": true,
"bn.js": true,
"browserify>buffer": true,
"uuid": true
Expand Down
1 change: 0 additions & 1 deletion lavamoat/browserify/mmi/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,6 @@
"@metamask/assets-controllers>@metamask/polling-controller": true,
"@metamask/controller-utils": true,
"@metamask/eth-query": true,
"@metamask/ethjs>@metamask/ethjs-unit": true,
"bn.js": true,
"browserify>buffer": true,
"uuid": true
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@
"@metamask/snaps-rpc-methods": "^8.0.0",
"@metamask/snaps-sdk": "^4.0.1",
"@metamask/snaps-utils": "^7.1.1",
"@metamask/transaction-controller": "^28.1.1",
"@metamask/transaction-controller": "^29.0.0",
"@metamask/user-operation-controller": "^8.0.1",
"@metamask/utils": "^8.2.1",
"@ngraveio/bc-ur": "^1.1.12",
Expand Down
4 changes: 0 additions & 4 deletions test/e2e/tests/confirmations/header.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ const WALLET_ADDRESS = '0x5CfE73b6021E818B776b421B1c4Db2474086a7e1';
const WALLET_ETH_BALANCE = '25';

describe('Confirmation Header Component', function () {
if (!process.env.ENABLE_CONFIRMATION_REDESIGN) {
return;
}

SIGNATURE_CONFIRMATIONS.forEach((confirmation) => {
it(`${confirmation.name} component includes header with balance`, async function () {
await withFixtures(
Expand Down
74 changes: 74 additions & 0 deletions test/e2e/tests/transaction/change-assets.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const {
} = require('../../helpers');
const FixtureBuilder = require('../../fixture-builder');
const { SMART_CONTRACTS } = require('../../seeder/smart-contracts');
const { tEn } = require('../../../lib/i18n-helpers');

describe('Change assets', function () {
if (!process.env.MULTICHAIN) {
Expand Down Expand Up @@ -237,4 +238,77 @@ describe('Change assets', function () {
},
);
});

it('changes to native currency when switching accounts during a NFT send', async function () {
const smartContract = SMART_CONTRACTS.NFTS;
await withFixtures(
{
dapp: true,
fixtures: new FixtureBuilder().withNftControllerERC721().build(),
ganacheOptions: defaultGanacheOptions,
smartContract,
title: this.test.fullTitle(),
},
async ({ driver, ganacheServer }) => {
await logInWithBalanceValidation(driver, ganacheServer);

// Create second account
await driver.clickElement('[data-testid="account-menu-icon"]');
await driver.clickElement(
'[data-testid="multichain-account-menu-popover-action-button"]',
);
await driver.clickElement(
'[data-testid="multichain-account-menu-popover-add-account"]',
);
await driver.fill('[placeholder="Account 2"]', 'Account 2');
await driver.clickElement({ text: tEn('create'), tag: 'button' });

// Go back to Account 1
await driver.clickElement('[data-testid="account-menu-icon"]');
await driver.clickElement({
css: `.multichain-account-list-item .multichain-account-list-item__account-name__button`,
text: 'Account 1',
});

// Choose the nft
await driver.clickElement('[data-testid="home__nfts-tab"]');
await driver.clickElement('[data-testid="nft-default-image"]');
await driver.clickElement('[data-testid="nft-send-button"]');

// Chose a recipient
await driver.clickElement('.multichain-account-list-item');

// Validate that an NFT is chosen in the AssetAmountPicker
await driver.waitForSelector({
css: '.asset-picker__symbol',
text: 'TDN',
});
await driver.waitForSelector({ css: 'p', text: '#1' });

// Switch to Account 2
await driver.clickElement('[data-testid="send-page-account-picker"]');
await driver.clickElement({
css: `.multichain-account-list-item .multichain-account-list-item__account-name__button`,
text: 'Account 2',
});

// Ensure that the AssetPicker shows native currency and 0 value
await driver.waitForSelector({
css: '.asset-picker__symbol',
text: 'ETH',
});

// Populate an amount, continue
await driver.clickElement('[data-testid="currency-input"]');
await driver.press('[data-testid="currency-input"]', '2');
await driver.clickElement({ text: 'Continue', css: 'button' });

// Validate the send amount
await driver.waitForSelector({
css: '.currency-display-component__text',
text: '2.000042',
});
},
);
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`AlertRow should match snapshot with no alert 1`] = `
exports[`AlertRow matches snapshot with no alert 1`] = `
<div>
<div
class="mm-box confirm-info-row mm-box--margin-top-2 mm-box--margin-bottom-2 mm-box--padding-right-2 mm-box--padding-left-2 mm-box--display-flex mm-box--flex-direction-row mm-box--flex-wrap-wrap mm-box--justify-content-space-between mm-box--color-text-default mm-box--rounded-lg"
Expand Down
42 changes: 32 additions & 10 deletions ui/components/app/confirm/info/row/alert-row/alert-row.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import React from 'react';
import { ConfirmInfoRow, ConfirmInfoRowVariant } from '../row';
import { AlertRow, AlertRowProps } from './alert-row';
import { ConfirmInfoRowVariant } from '../row';
import { AlertRow } from './alert-row';
import { Severity } from '../../../../../../helpers/constants/design-system';
import { Alert } from '../../../../../../ducks/confirm-alerts/confirm-alerts';
import configureStore from '../../../../../../store/store';
import { Provider } from 'react-redux';
import { Meta } from '@storybook/react';

const LABEL_FROM_MOCK = 'From';
const DATA_FROM_MOCK = 'Data';
const CONTRACT_FROM_MOCK = 'Contract';
const alertsMock: Alert[] = [
{
key: LABEL_FROM_MOCK,
Expand All @@ -21,12 +23,32 @@ const alertsMock: Alert[] = [
'Operator is untrusted according to previous activity',
],
},
{
key: 'Data',
field: 'Data',
severity: Severity.Warning,
message: 'Alert 2',
alertDetails: ['detail 1 warning', 'detail 2 warning'],
},
{
key: 'Contract',
field: 'Contract',
severity: Severity.Info,
message: 'Alert Info',
alertDetails: ['detail 1 info', 'detail info'],
},
];
const OWNER_ID_MOCK = '123';
const storeMock = configureStore({
confirmAlerts: {
alerts: { [OWNER_ID_MOCK]: alertsMock },
confirmed: { [OWNER_ID_MOCK]: { [LABEL_FROM_MOCK]: false, 'data': false, 'contract': false } },
confirmed: {
[OWNER_ID_MOCK]: {
[LABEL_FROM_MOCK]: false,
[DATA_FROM_MOCK]: false,
[CONTRACT_FROM_MOCK]: false,
},
},
},
confirm: {
currentConfirmation: {
Expand Down Expand Up @@ -76,7 +98,7 @@ AlertRowCritical.args = {
label: LABEL_FROM_MOCK,
children: 'Value',
alertKey: LABEL_FROM_MOCK,
alertOwnerId: OWNER_ID_MOCK,
ownerId: OWNER_ID_MOCK,
variant: ConfirmInfoRowVariant.Critical,
};

Expand All @@ -85,10 +107,10 @@ AlertRowCritical.args = {
*/
export const AlertRowWarning = DefaultStory.bind({});
AlertRowWarning.args = {
label: LABEL_FROM_MOCK,
label: DATA_FROM_MOCK,
children: 'Value',
alertKey: LABEL_FROM_MOCK,
alertOwnerId: OWNER_ID_MOCK,
alertKey: DATA_FROM_MOCK,
ownerId: OWNER_ID_MOCK,
variant: ConfirmInfoRowVariant.Warning,
};

Expand All @@ -97,9 +119,9 @@ AlertRowWarning.args = {
*/
export const AlertRowInformative = DefaultStory.bind({});
AlertRowInformative.args = {
label: LABEL_FROM_MOCK,
label: CONTRACT_FROM_MOCK,
children: 'Value',
alertKey: LABEL_FROM_MOCK,
alertOwnerId: OWNER_ID_MOCK,
alertKey: CONTRACT_FROM_MOCK,
ownerId: OWNER_ID_MOCK,
variant: ConfirmInfoRowVariant.Default,
};
Loading

0 comments on commit 2c1d1a3

Please sign in to comment.