Skip to content

Commit

Permalink
Merge branch 'develop' into fix/mark-all-as-read-button
Browse files Browse the repository at this point in the history
  • Loading branch information
matteoscurati authored Jun 7, 2024
2 parents 3ff8b6b + 55f1a8e commit b8622ca
Show file tree
Hide file tree
Showing 23 changed files with 222 additions and 116 deletions.
2 changes: 1 addition & 1 deletion .github/pull-request-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Fixes:

## **Pre-merge author checklist**

- [ ] Ive followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] 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
Expand Down
13 changes: 13 additions & 0 deletions .yarn/patches/@metamask-assets-controllers-patch-26d4328777.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/dist/chunk-6W5EQ3JQ.js b/dist/chunk-6W5EQ3JQ.js
index 0dc70ec5f77484f8d4021bdfff7bca90dd87bd51..81c2d0d1e6a0ad6db8b361423774b9a843fb46f6 100644
--- a/dist/chunk-6W5EQ3JQ.js
+++ b/dist/chunk-6W5EQ3JQ.js
@@ -380,7 +380,7 @@ fetchAndMapExchangeRatesForSupportedNativeCurrency_fn = async function({
(obj, [tokenAddress, token]) => {
obj = {
...obj,
- [tokenAddress.toLowerCase()]: { ...token }
+ [tokenAddress]: { ...token }
};
return obj;
},
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ For up to the minute news, follow our [Twitter](https://twitter.com/metamask) or

To learn how to develop MetaMask-compatible applications, visit our [Developer Docs](https://metamask.github.io/metamask-docs/).

To learn how to contribute to the MetaMask project itself, visit our [Internal Docs](https://github.com/MetaMask/metamask-extension/tree/develop/docs).
To learn how to contribute to the MetaMask codebase, visit our [Contributor Docs](https://github.com/MetaMask/contributor-docs).

To learn how to contribute to the MetaMask Extension project itself, visit our [Extension Docs](https://github.com/MetaMask/metamask-extension/tree/develop/docs).

## GitHub Codespaces quickstart

Expand Down
8 changes: 4 additions & 4 deletions builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ buildTypes:
- SEGMENT_WRITE_KEY_REF: SEGMENT_PROD_WRITE_KEY
- ALLOW_LOCAL_SNAPS: false
- REQUIRE_SNAPS_ALLOWLIST: true
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/6.2.0/index.html
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/6.3.0/index.html
- ACCOUNT_SNAPS_DIRECTORY_URL: https://snaps.metamask.io/account-management
# Main build uses the default browser manifest
manifestOverrides: false
Expand Down Expand Up @@ -64,7 +64,7 @@ buildTypes:
- SEGMENT_FLASK_WRITE_KEY
- ALLOW_LOCAL_SNAPS: true
- REQUIRE_SNAPS_ALLOWLIST: false
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/6.2.0/index.html
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/6.3.0/index.html
- SUPPORT_LINK: https://metamask-flask.zendesk.com/hc
- SUPPORT_REQUEST_LINK: https://metamask-flask.zendesk.com/hc/en-us/requests/new
- INFURA_ENV_KEY_REF: INFURA_FLASK_PROJECT_ID
Expand All @@ -86,7 +86,7 @@ buildTypes:
- SEGMENT_FLASK_WRITE_KEY
- ALLOW_LOCAL_SNAPS: true
- REQUIRE_SNAPS_ALLOWLIST: false
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/6.2.0/index.html
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/6.3.0/index.html
- SUPPORT_LINK: https://metamask-flask.zendesk.com/hc
- SUPPORT_REQUEST_LINK: https://metamask-flask.zendesk.com/hc/en-us/requests/new
- INFURA_ENV_KEY_REF: INFURA_FLASK_PROJECT_ID
Expand All @@ -109,7 +109,7 @@ buildTypes:
- SEGMENT_WRITE_KEY_REF: SEGMENT_MMI_WRITE_KEY
- ALLOW_LOCAL_SNAPS: false
- REQUIRE_SNAPS_ALLOWLIST: true
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/6.2.0/index.html
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/6.3.0/index.html
- MMI_CONFIGURATION_SERVICE_URL: https://configuration.metamask-institutional.io/v2/configuration/default
- SUPPORT_LINK: https://mmi-support.metamask.io/hc/en-us
- SUPPORT_REQUEST_LINK: https://mmi-support.metamask.io/hc/en-us/requests/new
Expand Down
2 changes: 1 addition & 1 deletion development/sentry-upload-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function upload_sourcemaps {
local release="${1}"; shift
local dist_directory="${1}"; shift

sentry-cli releases files "${release}" upload-sourcemaps "${dist_directory}"/chrome/*.js "${dist_directory}"/sourcemaps/ --rewrite --url-prefix '/metamask'
sentry-cli releases files "${release}" upload-sourcemaps "${dist_directory}"/chrome/ "${dist_directory}"/sourcemaps/ --rewrite --url-prefix '/metamask'
}

function main {
Expand Down
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
"[email protected]": "^7.5.4",
"@trezor/schema-utils@npm:1.0.2": "patch:@trezor/schema-utils@npm%3A1.0.2#~/.yarn/patches/@trezor-schema-utils-npm-1.0.2-7dd48689b2.patch",
"lavamoat-core@npm:^15.1.1": "patch:lavamoat-core@npm%3A15.1.1#~/.yarn/patches/lavamoat-core-npm-15.1.1-51fbe39988.patch",
"@metamask/snaps-sdk": "^4.3.0",
"@metamask/snaps-sdk": "^4.4.2",
"@metamask/transaction-controller": "^32.0.0",
"@babel/runtime@npm:^7.7.6": "patch:@babel/runtime@npm%3A7.24.0#~/.yarn/patches/@babel-runtime-npm-7.24.0-7eb1dd11a2.patch",
"@babel/runtime@npm:^7.9.2": "patch:@babel/runtime@npm%3A7.24.0#~/.yarn/patches/@babel-runtime-npm-7.24.0-7eb1dd11a2.patch",
Expand Down Expand Up @@ -252,7 +252,8 @@
"sucrase@npm:3.34.0": "^3.35.0",
"@expo/config/glob": "^10.3.10",
"@expo/config-plugins/glob": "^10.3.10",
"@metamask/network-controller": "patch:@metamask/network-controller@npm%3A18.1.2#~/.yarn/patches/@metamask-network-controller-npm-18.1.2-1bcb8d8610.patch"
"@metamask/network-controller": "patch:@metamask/network-controller@npm%3A18.1.2#~/.yarn/patches/@metamask-network-controller-npm-18.1.2-1bcb8d8610.patch",
"@solana/web3.js/rpc-websockets": "^8.0.1"
},
"dependencies": {
"@babel/runtime": "patch:@babel/runtime@npm%3A7.24.0#~/.yarn/patches/@babel-runtime-npm-7.24.0-7eb1dd11a2.patch",
Expand Down Expand Up @@ -284,7 +285,7 @@
"@metamask/address-book-controller": "^4.0.1",
"@metamask/announcement-controller": "^6.1.0",
"@metamask/approval-controller": "^6.0.1",
"@metamask/assets-controllers": "patch:@metamask/assets-controllers@npm%3A30.0.0#~/.yarn/patches/@metamask-assets-controllers-npm-30.0.0-8747c20871.patch",
"@metamask/assets-controllers": "patch:@metamask/assets-controllers@patch%3A@metamask/assets-controllers@npm%253A30.0.0%23~/.yarn/patches/@metamask-assets-controllers-npm-30.0.0-8747c20871.patch%3A%3Aversion=30.0.0&hash=9269c8#~/.yarn/patches/@metamask-assets-controllers-patch-26d4328777.patch",
"@metamask/base-controller": "^4.1.0",
"@metamask/browser-passworder": "^4.3.0",
"@metamask/contract-metadata": "^2.5.0",
Expand Down Expand Up @@ -331,11 +332,11 @@
"@metamask/selected-network-controller": "^13.0.0",
"@metamask/signature-controller": "^14.0.1",
"@metamask/smart-transactions-controller": "^10.1.2",
"@metamask/snaps-controllers": "^8.2.0",
"@metamask/snaps-execution-environments": "^6.2.0",
"@metamask/snaps-rpc-methods": "^9.1.0",
"@metamask/snaps-sdk": "^4.3.0",
"@metamask/snaps-utils": "^7.4.0",
"@metamask/snaps-controllers": "^8.4.0",
"@metamask/snaps-execution-environments": "^6.3.0",
"@metamask/snaps-rpc-methods": "^9.1.2",
"@metamask/snaps-sdk": "^4.4.2",
"@metamask/snaps-utils": "^7.5.0",
"@metamask/transaction-controller": "^32.0.0",
"@metamask/user-operation-controller": "^10.0.0",
"@metamask/utils": "^8.2.1",
Expand Down
5 changes: 3 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { PlaywrightTestConfig } from '@playwright/test';
import { devices } from '@playwright/test';
import dotenv from 'dotenv';
import { isHeadless } from './test/helpers/env';

dotenv.config({ path: './test/e2e/mmi/.env' });
const logOutputFolder = './public/playwright/playwright-reports';
Expand Down Expand Up @@ -42,8 +43,8 @@ const config: PlaywrightTestConfig = {
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on',
video: 'off',
// Run tests headless in local
headless: process.env.HEADLESS === 'true',
/* Run tests headless in local */
headless: isHeadless('PLAYWRIGHT'),
},

/* Configure projects for major browsers */
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/mmi/helpers/extension-loader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import path from 'path';
import { test as base, chromium } from '@playwright/test';

import { isHeadless } from '../../../helpers/env';

const extensionPath = path.join(__dirname, '../../../../dist/chrome');

export const test = base.extend({
Expand All @@ -10,7 +12,7 @@ export const test = base.extend({
headless: false,
args: [`--disable-extensions-except=${extensionPath}`],
};
if (process.env.HEADLESS === 'true') {
if (isHeadless('PLAYWRIGHT')) {
launchOptions.args.push('--headless=new');
}
const context = await chromium.launchPersistentContext('', launchOptions);
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/webdriver/chrome.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { Builder } = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
const { ThenableWebDriver } = require('selenium-webdriver'); // eslint-disable-line no-unused-vars -- this is imported for JSDoc
const { isHeadless } = require('../../helpers/env');

/**
* Proxy host to use for HTTPS requests
Expand Down Expand Up @@ -42,7 +43,7 @@ class ChromeDriver {
args.push('--disable-gpu');
}

if (process.env.SELENIUM_HEADLESS) {
if (isHeadless('SELENIUM')) {
// TODO: Remove notice and consider non-experimental when results are consistent
console.warn(
'*** Running e2e tests in headless mode is experimental and some tests are known to fail for unknown reasons',
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/webdriver/firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const {
} = require('selenium-webdriver');
const firefox = require('selenium-webdriver/firefox');
const { retry } = require('../../../development/lib/retry');
const { isHeadless } = require('../../helpers/env');

/**
* The prefix for temporary Firefox profiles. All Firefox profiles used for e2e tests
Expand Down Expand Up @@ -58,7 +59,7 @@ class FirefoxDriver {
if (process.env.CI === 'true') {
options.setBinary('/opt/firefox/firefox');
}
if (process.env.SELENIUM_HEADLESS) {
if (isHeadless('SELENIUM')) {
// TODO: Remove notice and consider non-experimental when results are consistent
console.warn(
'*** Running e2e tests in headless mode is experimental and some tests are known to fail for unknown reasons',
Expand Down
36 changes: 36 additions & 0 deletions test/helpers/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { env } from 'process';

type HeadlessCapableServiceName = 'SELENIUM' | 'PLAYWRIGHT';

export function isHeadless(serviceName: HeadlessCapableServiceName): boolean {
if (serviceName) {
const serviceKey = `${serviceName}_HEADLESS`;
if (env[serviceKey]) {
return parseBoolean(env[serviceKey]);
}
}
return Boolean(env.HEADLESS) && parseBoolean(env.HEADLESS);
}

export function parseBoolean(value: undefined | string): boolean {
if (!value) {
return false;
}
if (typeof value === 'boolean') {
return value;
}
if (typeof value !== 'string') {
throw new Error(`Not-a-Boolean: '${value}'`);
}
switch (value.toLowerCase().trim()) {
case 'false':
case '0':
case '':
return false;
case 'true':
case '1':
return true;
default:
throw new Error(`Not-a-Boolean: '${value}'`);
}
}
8 changes: 6 additions & 2 deletions ui/components/app/snaps/snap-ui-renderer/components/bold.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { BoldElement } from '@metamask/snaps-sdk/jsx';
import { BoldElement, JSXElement } from '@metamask/snaps-sdk/jsx';
import { getJsxChildren } from '@metamask/snaps-utils';
import { NonEmptyArray } from '@metamask/utils';
import { mapTextToTemplate } from '../utils';
import {
TextVariant,
Expand All @@ -13,7 +14,10 @@ export const bold: UIComponentFactory<BoldElement> = ({
...params
}) => ({
element: 'Text',
children: mapTextToTemplate(getJsxChildren(element), params),
children: mapTextToTemplate(
getJsxChildren(element) as NonEmptyArray<string | JSXElement>,
params,
),
props: {
variant: TextVariant.bodyMd,
overflowWrap: OverflowWrap.Anywhere,
Expand Down
5 changes: 3 additions & 2 deletions ui/components/app/snaps/snap-ui-renderer/components/box.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { BoxElement, JSXElement, BoxProps } from '@metamask/snaps-sdk/jsx';
import { getJsxChildren } from '@metamask/snaps-utils';
import { NonEmptyArray } from '@metamask/utils';
import {
Display,
FlexDirection,
TextColor,
} from '../../../../../helpers/constants/design-system';
import { mapToTemplate } from '../utils';
import { UIComponentFactory } from './types';
import { UIComponent, UIComponentFactory } from './types';

function generateJustifyContent(alignment?: BoxProps['alignment']) {
switch (alignment) {
Expand Down Expand Up @@ -35,7 +36,7 @@ export const box: UIComponentFactory<BoxElement> = ({
element: 'Box',
children: getJsxChildren(element).map((children) =>
mapToTemplate({ ...params, element: children as JSXElement }),
),
) as NonEmptyArray<UIComponent>,
props: {
display: Display.Flex,
flexDirection:
Expand Down
5 changes: 3 additions & 2 deletions ui/components/app/snaps/snap-ui-renderer/components/form.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { FormElement, JSXElement } from '@metamask/snaps-sdk/jsx';
import { getJsxChildren } from '@metamask/snaps-utils';
import { NonEmptyArray } from '@metamask/utils';
import { mapToTemplate } from '../utils';
import { UIComponentFactory } from './types';
import { UIComponent, UIComponentFactory } from './types';

export const form: UIComponentFactory<FormElement> = ({
element,
Expand All @@ -14,7 +15,7 @@ export const form: UIComponentFactory<FormElement> = ({
form: element.props.name,
...params,
}),
),
) as NonEmptyArray<UIComponent>,
props: {
name: element.props.name,
},
Expand Down
8 changes: 6 additions & 2 deletions ui/components/app/snaps/snap-ui-renderer/components/italic.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ItalicElement } from '@metamask/snaps-sdk/jsx';
import { ItalicElement, JSXElement } from '@metamask/snaps-sdk/jsx';
import { getJsxChildren } from '@metamask/snaps-utils';
import { NonEmptyArray } from '@metamask/utils';
import { mapTextToTemplate } from '../utils';
import {
TextVariant,
Expand All @@ -13,7 +14,10 @@ export const italic: UIComponentFactory<ItalicElement> = ({
...params
}) => ({
element: 'Text',
children: mapTextToTemplate(getJsxChildren(element), params),
children: mapTextToTemplate(
getJsxChildren(element) as NonEmptyArray<string | JSXElement>,
params,
),
props: {
variant: TextVariant.bodyMd,
overflowWrap: OverflowWrap.Anywhere,
Expand Down
8 changes: 6 additions & 2 deletions ui/components/app/snaps/snap-ui-renderer/components/link.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { LinkElement } from '@metamask/snaps-sdk/jsx';
import { LinkElement, JSXElement } from '@metamask/snaps-sdk/jsx';
import { getJsxChildren } from '@metamask/snaps-utils';
import { NonEmptyArray } from '@metamask/utils';
import { mapTextToTemplate } from '../utils';
import { UIComponentFactory } from './types';

Expand All @@ -8,7 +9,10 @@ export const link: UIComponentFactory<LinkElement> = ({
...params
}) => ({
element: 'SnapUILink',
children: mapTextToTemplate(getJsxChildren(element), params),
children: mapTextToTemplate(
getJsxChildren(element) as NonEmptyArray<string | JSXElement>,
params,
),
props: {
href: element.props.href,
},
Expand Down
8 changes: 6 additions & 2 deletions ui/components/app/snaps/snap-ui-renderer/components/text.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { TextElement } from '@metamask/snaps-sdk/jsx';
import { JSXElement, TextElement } from '@metamask/snaps-sdk/jsx';
import { getJsxChildren } from '@metamask/snaps-utils';
import { NonEmptyArray } from '@metamask/utils';
import { mapTextToTemplate } from '../utils';
import {
TextVariant,
Expand All @@ -13,7 +14,10 @@ export const text: UIComponentFactory<TextElement> = ({
...params
}) => ({
element: 'Text',
children: mapTextToTemplate(getJsxChildren(element), params),
children: mapTextToTemplate(
getJsxChildren(element) as NonEmptyArray<string | JSXElement>,
params,
),
props: {
variant: TextVariant.bodyMd,
overflowWrap: OverflowWrap.Anywhere,
Expand Down
8 changes: 4 additions & 4 deletions ui/components/app/snaps/snap-ui-renderer/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { JSXElement, GenericSnapElement } from '@metamask/snaps-sdk/jsx';
import { hasChildren } from '@metamask/snaps-utils';
import { memoize } from 'lodash';
import { sha256 } from '@noble/hashes/sha256';
import { bytesToHex, remove0x } from '@metamask/utils';
import { NonEmptyArray, bytesToHex, remove0x } from '@metamask/utils';
import { unescape as unescapeEntities } from 'he';
import { COMPONENT_MAPPING } from './components';
import { UIComponent } from './components/types';
Expand Down Expand Up @@ -97,9 +97,9 @@ export const mapToTemplate = (params: MapToTemplateParams): UIComponent => {
};

export const mapTextToTemplate = (
elements: (JSXElement | string)[],
elements: NonEmptyArray<JSXElement | string>,
params: Pick<MapToTemplateParams, 'map'>,
): (UIComponent | string)[] =>
): NonEmptyArray<UIComponent | string> =>
elements.map((element) => {
// With the introduction of JSX elements here can be strings.
if (typeof element === 'string') {
Expand All @@ -108,4 +108,4 @@ export const mapTextToTemplate = (
}

return mapToTemplate({ ...params, element });
});
}) as NonEmptyArray<UIComponent | string>;
Loading

0 comments on commit b8622ca

Please sign in to comment.