Skip to content

Commit

Permalink
Merge branch 'MetaMask:develop' into Migrate-to-TS
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvv173 committed May 20, 2023
2 parents 2ed6e2b + 9d38e53 commit 0c5f7d9
Show file tree
Hide file tree
Showing 53 changed files with 3,092 additions and 1,019 deletions.
124 changes: 72 additions & 52 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,42 @@
const path = require('path');
const {
ProvidePlugin
} = require('webpack');
const { ProvidePlugin } = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const {
generateIconNames
} = require('../development/generate-icon-names');
module.exports = {
core: {
disableTelemetry: true
disableTelemetry: true,
},
features: {
buildStoriesJson: true
buildStoriesJson: true,
},
stories: ['../ui/**/*.stories.js', '../ui/**/*.stories.tsx', '../ui/**/*.stories.mdx', './*.stories.mdx'],
addons: ['@storybook/addon-essentials', '@storybook/addon-actions', '@storybook/addon-a11y', '@storybook/addon-knobs', './i18n-party-addon/register.js', 'storybook-dark-mode', '@whitespace/storybook-addon-html', '@storybook/addon-mdx-gfm'],
stories: [
'../ui/**/*.stories.js',
'../ui/**/*.stories.tsx',
'../ui/**/*.stories.mdx',
'./*.stories.mdx',
],
addons: [
'@storybook/addon-essentials',
'@storybook/addon-actions',
'@storybook/addon-a11y',
'@storybook/addon-knobs',
'./i18n-party-addon/register.js',
'storybook-dark-mode',
'@whitespace/storybook-addon-html',
'@storybook/addon-mdx-gfm',
],
staticDirs: ['../app', './images'],
// Uses babel.config.js settings and prevents "Missing class properties transform" error
babel: async options => ({
overrides: options.overrides
babel: async (options) => ({
overrides: options.overrides,
}),
// Sets env variables https://storybook.js.org/docs/react/configure/environment-variables/
env: async config => {
return {
...config,
// Creates the icon names environment variable for the component-library/icon/icon.js component
ICON_NAMES: generateIconNames()
};
},
webpackFinal: async config => {
webpackFinal: async (config) => {
config.context = process.cwd();
config.node = {
__filename: true
__filename: true,
};
config.resolve.alias['webextension-polyfill'] = require.resolve('../ui/__mocks__/webextension-polyfill.js');
config.resolve.alias['webextension-polyfill'] = require.resolve(
'../ui/__mocks__/webextension-polyfill.js',
);
config.resolve.fallback = {
child_process: false,
constants: false,
Expand All @@ -45,44 +48,61 @@ module.exports = {
path: false,
stream: require.resolve('stream-browserify'),
zlib: false,
_stream_transform: require.resolve('readable-stream/lib/_stream_transform.js'),
_stream_transform: require.resolve(
'readable-stream/lib/_stream_transform.js',
),
};
config.module.strictExportPresence = true;
config.module.rules.push({
test: /\.scss$/,
use: ['style-loader', {
loader: 'css-loader',
options: {
import: false,
url: false
}
}, {
loader: 'sass-loader',
options: {
sourceMap: true,
implementation: require('sass'),
sassOptions: {
includePaths: ['ui/css/']
}
}
}]
use: [
'style-loader',
{
loader: 'css-loader',
options: {
import: false,
url: false,
},
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
implementation: require('sass'),
sassOptions: {
includePaths: ['ui/css/'],
},
},
},
],
});
config.plugins.push(new CopyWebpackPlugin({
patterns: [{
from: path.join('node_modules', '@fortawesome', 'fontawesome-free', 'webfonts'),
to: path.join('fonts', 'fontawesome')
}]
}));
config.plugins.push(new ProvidePlugin({
Buffer: ['buffer', 'Buffer']
}));
config.plugins.push(
new CopyWebpackPlugin({
patterns: [
{
from: path.join(
'node_modules',
'@fortawesome',
'fontawesome-free',
'webfonts',
),
to: path.join('fonts', 'fontawesome'),
},
],
}),
);
config.plugins.push(
new ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
);
return config;
},
docs: {
autodocs: true
autodocs: true,
},
framework: {
name: '@storybook/react-webpack5',
options: {}
}
options: {},
},
};
2 changes: 0 additions & 2 deletions builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,6 @@ env:
# Also see DEBUG and NODE_DEBUG
- METAMASK_DEBUG: false
# Modified in <root>/development/build/scripts.js:@setEnvironmentVariables
- ICON_NAMES
# Modified in <root>/development/build/scripts.js:@setEnvironmentVariables
- IN_TEST
# Modified in <root>/development/build/scripts.js:@setEnvironmentVariables
- METAMASK_ENVIRONMENT
Expand Down
3 changes: 0 additions & 3 deletions development/build/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const bifyModuleGroups = require('bify-module-groups');

const phishingWarningManifest = require('@metamask/phishing-warning/package.json');
const { streamFlatMap } = require('../stream-flat-map');
const { generateIconNames } = require('../generate-icon-names');
const { BUILD_TARGETS, ENVIRONMENT } = require('./constants');
const { getConfig } = require('./config');
const {
Expand Down Expand Up @@ -1182,10 +1181,8 @@ async function setEnvironmentVariables({
}) {
const devMode = isDevBuild(buildTarget);
const testing = isTestBuild(buildTarget);
const iconNames = await generateIconNames();

variables.set({
ICON_NAMES: iconNames,
IN_TEST: testing,
INFURA_PROJECT_ID: getInfuraProjectId({
buildType,
Expand Down
42 changes: 0 additions & 42 deletions development/generate-icon-names.js

This file was deleted.

6 changes: 1 addition & 5 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ module.exports = {
// TODO: enable resetMocks
// resetMocks: true,
restoreMocks: true,
setupFiles: [
'<rootDir>/test/setup.js',
'<rootDir>/test/env.js',
'<rootDir>/test/jest/env.js', // jest specific env vars that break mocha tests
],
setupFiles: ['<rootDir>/test/setup.js', '<rootDir>/test/env.js'],
setupFilesAfterEnv: ['<rootDir>/test/jest/setup.js'],
testMatch: [
'<rootDir>/app/scripts/constants/error-utils.test.js',
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
"@metamask/address-book-controller": "^2.0.0",
"@metamask/announcement-controller": "^3.0.0",
"@metamask/approval-controller": "^2.1.0",
"@metamask/assets-controllers": "^6.0.0",
"@metamask/assets-controllers": "^7.0.0",
"@metamask/base-controller": "^2.0.0",
"@metamask/browser-passworder": "^4.1.0",
"@metamask/contract-metadata": "^2.3.1",
Expand All @@ -235,7 +235,7 @@
"@metamask/eth-token-tracker": "^4.0.0",
"@metamask/eth-trezor-keyring": "^1.0.0",
"@metamask/etherscan-link": "^2.2.0",
"@metamask/gas-fee-controller": "^4.0.0",
"@metamask/gas-fee-controller": "^5.0.0",
"@metamask/jazzicon": "^2.0.0",
"@metamask/key-tree": "^7.0.0",
"@metamask/logo": "^3.1.1",
Expand Down
9 changes: 0 additions & 9 deletions test/jest/env.js

This file was deleted.

4 changes: 2 additions & 2 deletions ui/components/app/dropdowns/network-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import {
ADD_POPULAR_CUSTOM_NETWORK,
ADVANCED_ROUTE,
} from '../../../helpers/constants/routes';
import { ButtonIcon } from '../../component-library/button-icon/deprecated';
import { Icon, IconName, IconSize } from '../../component-library';

import { Icon, IconName, IconSize, ButtonIcon } from '../../component-library';

import { Dropdown, DropdownMenuItem } from './dropdown';

Expand Down
10 changes: 7 additions & 3 deletions ui/components/app/wallet-overview/token-overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ import {
import { AssetType } from '../../../../shared/constants/transaction';
import useRamps from '../../../hooks/experiences/useRamps';

import { ButtonIcon, Icon, IconName } from '../../component-library';
import {
ButtonIcon,
ButtonIconSize,
Icon,
IconName,
} from '../../component-library';
import { IconColor } from '../../../helpers/constants/design-system';

import { BUTTON_ICON_SIZES } from '../../component-library/button-icon/deprecated';
import { getPortfolioUrl } from '../../../helpers/utils/portfolio';
import WalletOverview from './wallet-overview';

Expand Down Expand Up @@ -95,7 +99,7 @@ const TokenOverview = ({ className, token }) => {
color={IconColor.primaryDefault}
iconName={IconName.Diagram}
ariaLabel={t('portfolio')}
size={BUTTON_ICON_SIZES.LG}
size={ButtonIconSize.Lg}
onClick={() => {
const portfolioUrl = getPortfolioUrl('', 'ext', metaMetricsId);
global.platform.openTab({
Expand Down
15 changes: 7 additions & 8 deletions ui/components/component-library/banner-base/banner-base.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { ButtonIcon } from '../button-icon/deprecated';
import { ButtonLink, Text } from '..';
import { ICON_NAMES } from '../icon/deprecated';

import Box from '../../ui/box';

import {
BackgroundColor,
BorderRadius,
DISPLAY,
Display,
Size,
TextVariant,
} from '../../../helpers/constants/design-system';

import Box from '../../ui/box';

import { ButtonLink, Text, IconName, ButtonIcon } from '..';

export const BannerBase = ({
className,
title,
Expand All @@ -33,7 +32,7 @@ export const BannerBase = ({
return (
<Box
className={classnames('mm-banner-base', className)}
display={DISPLAY.FLEX}
display={Display.Flex}
gap={2}
backgroundColor={BackgroundColor.backgroundDefault}
borderRadius={BorderRadius.SM}
Expand Down Expand Up @@ -73,7 +72,7 @@ export const BannerBase = ({
<ButtonIcon
className="mm-banner-base__close-button"
marginLeft="auto"
iconName={ICON_NAMES.CLOSE}
iconName={IconName.Close}
size={Size.SM}
ariaLabel="Close" // TODO: i18n
onClick={onClose}
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 0c5f7d9

Please sign in to comment.