Skip to content

Commit

Permalink
Merge branch 'develop' into fix-no-permission-state
Browse files Browse the repository at this point in the history
  • Loading branch information
NidhiKJha authored Oct 10, 2024
2 parents 75fed70 + 86525fd commit 48ffeba
Show file tree
Hide file tree
Showing 213 changed files with 5,015 additions and 3,251 deletions.
14 changes: 5 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,9 @@ workflows:
- prep-deps
- get-changed-files-with-git-diff:
filters:
branches:
ignore:
- master
requires:
- prep-deps
branches:
ignore:
- master
- test-deps-audit:
requires:
- prep-deps
Expand Down Expand Up @@ -360,11 +358,10 @@ workflows:
value: << pipeline.git.branch >>
jobs:
- prep-deps
- get-changed-files-with-git-diff:
requires:
- prep-deps
- get-changed-files-with-git-diff
- validate-locales-only:
requires:
- prep-deps
- get-changed-files-with-git-diff
- test-lint:
requires:
Expand Down Expand Up @@ -501,7 +498,6 @@ jobs:
- run: sudo corepack enable
- attach_workspace:
at: .
- gh/install
- run:
name: Get changed files with git diff
command: npx tsx .circleci/scripts/git-diff-develop.ts
Expand Down
101 changes: 64 additions & 37 deletions .circleci/scripts/git-diff-develop.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
import { hasProperty } from '@metamask/utils';
import { exec as execCallback } from 'child_process';
import fs from 'fs';
import path from 'path';
import { promisify } from 'util';

const exec = promisify(execCallback);

// The CIRCLE_PR_NUMBER variable is only available on forked Pull Requests
const PR_NUMBER =
process.env.CIRCLE_PR_NUMBER ||
process.env.CIRCLE_PULL_REQUEST?.split('/').pop();

const MAIN_BRANCH = 'develop';
const SOURCE_BRANCH = `refs/pull/${PR_NUMBER}/head`;

const CHANGED_FILES_DIR = 'changed-files';

type PRInfo = {
base: {
ref: string;
};
body: string;
};

/**
* Get the target branch for the given pull request.
* Get JSON info about the given pull request
*
* @returns The name of the branch targeted by the PR.
* @returns JSON info from GitHub
*/
async function getBaseRef(): Promise<string | null> {
if (!process.env.CIRCLE_PULL_REQUEST) {
async function getPrInfo(): Promise<PRInfo | null> {
if (!PR_NUMBER) {
return null;
}

// We're referencing the CIRCLE_PULL_REQUEST environment variable within the script rather than
// passing it in because this makes it easier to use Bash parameter expansion to extract the
// PR number from the URL.
const result = await exec(`gh pr view --json baseRefName "\${CIRCLE_PULL_REQUEST##*/}" --jq '.baseRefName'`);
const baseRef = result.stdout.trim();
return baseRef;
return await (
await fetch(
`https://api.github.com/repos/${process.env.CIRCLE_PROJECT_USERNAME}/${process.env.CIRCLE_PROJECT_REPONAME}/pulls/${PR_NUMBER}`,
)
).json();
}

/**
Expand All @@ -34,8 +47,10 @@ async function getBaseRef(): Promise<string | null> {
*/
async function fetchWithDepth(depth: number): Promise<boolean> {
try {
await exec(`git fetch --depth ${depth} origin develop`);
await exec(`git fetch --depth ${depth} origin ${process.env.CIRCLE_BRANCH}`);
await exec(`git fetch --depth ${depth} origin "${MAIN_BRANCH}"`);
await exec(
`git fetch --depth ${depth} origin "${SOURCE_BRANCH}:${SOURCE_BRANCH}"`,
);
return true;
} catch (error: unknown) {
console.error(`Failed to fetch with depth ${depth}:`, error);
Expand All @@ -59,18 +74,16 @@ async function fetchUntilMergeBaseFound() {
await exec(`git merge-base origin/HEAD HEAD`);
return;
} catch (error: unknown) {
if (
error instanceof Error &&
hasProperty(error, 'code') &&
error.code === 1
) {
console.error(`Error 'no merge base' encountered with depth ${depth}. Incrementing depth...`);
if (error instanceof Error && 'code' in error) {
console.error(
`Error 'no merge base' encountered with depth ${depth}. Incrementing depth...`,
);
} else {
throw error;
}
}
}
await exec(`git fetch --unshallow origin develop`);
await exec(`git fetch --unshallow origin "${MAIN_BRANCH}"`);
}

/**
Expand All @@ -82,55 +95,69 @@ async function fetchUntilMergeBaseFound() {
*/
async function gitDiff(): Promise<string> {
await fetchUntilMergeBaseFound();
const { stdout: diffResult } = await exec(`git diff --name-only origin/HEAD...${process.env.CIRCLE_BRANCH}`);
const { stdout: diffResult } = await exec(
`git diff --name-only "origin/HEAD...${SOURCE_BRANCH}"`,
);
if (!diffResult) {
throw new Error('Unable to get diff after full checkout.');
throw new Error('Unable to get diff after full checkout.');
}
return diffResult;
}

function writePrBodyToFile(prBody: string) {
const prBodyPath = path.resolve(CHANGED_FILES_DIR, 'pr-body.txt');
fs.writeFileSync(prBodyPath, prBody.trim());
console.log(`PR body saved to ${prBodyPath}`);
}

/**
* Stores the output of git diff to a file.
* Main run function, stores the output of git diff and the body of the matching PR to a file.
*
* @returns Returns a promise that resolves when the git diff output is successfully stored.
* @returns Returns a promise that resolves when the git diff output and PR body is successfully stored.
*/
async function storeGitDiffOutput() {
async function storeGitDiffOutputAndPrBody() {
try {
// Create the directory
// This is done first because our CirleCI config requires that this directory is present,
// even if we want to skip this step.
const outputDir = 'changed-files';
fs.mkdirSync(outputDir, { recursive: true });
fs.mkdirSync(CHANGED_FILES_DIR, { recursive: true });

console.log(`Determining whether this run is for a PR targetting ${MAIN_BRANCH}`)
if (!process.env.CIRCLE_PULL_REQUEST) {
console.log("Not a PR, skipping git diff");
console.log(
`Determining whether this run is for a PR targeting ${MAIN_BRANCH}`,
);
if (!PR_NUMBER) {
console.log('Not a PR, skipping git diff');
return;
}

const baseRef = await getBaseRef();
if (baseRef === null) {
console.log("Not a PR, skipping git diff");
const prInfo = await getPrInfo();

const baseRef = prInfo?.base.ref;
if (!baseRef) {
console.log('Not a PR, skipping git diff');
return;
} else if (baseRef !== MAIN_BRANCH) {
console.log(`This is for a PR targeting '${baseRef}', skipping git diff`);
writePrBodyToFile(prInfo.body);
return;
}

console.log("Attempting to get git diff...");
console.log('Attempting to get git diff...');
const diffOutput = await gitDiff();
console.log(diffOutput);

// Store the output of git diff
const outputPath = path.resolve(outputDir, 'changed-files.txt');
const outputPath = path.resolve(CHANGED_FILES_DIR, 'changed-files.txt');
fs.writeFileSync(outputPath, diffOutput.trim());

console.log(`Git diff results saved to ${outputPath}`);

writePrBodyToFile(prInfo.body);

process.exit(0);
} catch (error: any) {
console.error('An error occurred:', error.message);
process.exit(1);
}
}

storeGitDiffOutput();
storeGitDiffOutputAndPrBody();
12 changes: 5 additions & 7 deletions .github/workflows/update-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ on:
- cron: 0 0 * * *
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
run-tests:
name: Run tests
Expand All @@ -27,22 +23,24 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.LAVAMOAT_UPDATE_TOKEN }}

- name: Update coverage
run: |
echo "{ \"coverage\": $CURRENT_COVERAGE }" > coverage.json
- name: Checkout/create branch, commit, and force push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "MetaMask Bot"
git config user.email "metamaskbot@users.noreply.github.com"
git checkout -b metamaskbot/update-coverage
git add coverage.json
git commit -m "chore: Update coverage.json"
git push -f origin metamaskbot/update-coverage
- name: Create/update pull request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.LAVAMOAT_UPDATE_TOKEN }}
run: |
gh pr create --title "chore: Update coverage.json" --body "This PR is automatically opened to update the coverage.json file when test coverage increases. Coverage increased from $STORED_COVERAGE% to $CURRENT_COVERAGE%." --base develop --head metamaskbot/update-coverage || gh pr edit --body "This PR is automatically opened to update the coverage.json file when test coverage increases. Coverage increased from $STORED_COVERAGE% to $CURRENT_COVERAGE%."
5 changes: 5 additions & 0 deletions .storybook/test-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,11 @@ const state = {
currentLocale: 'en',
preferences: {
showNativeTokenAsMainBalance: true,
tokenSortConfig: {
key: 'token-sort-key',
order: 'dsc',
sortCallback: 'stringNumeric',
},
},
incomingTransactionsPreferences: {
[CHAIN_IDS.MAINNET]: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
diff --git a/dist/assetsUtil.cjs b/dist/assetsUtil.cjs
index e90a1b6767bc8ac54b7a4d580035cf5db6861dca..a5e0f03d2541b4e3540431ef2e6e4b60fb7ae9fe 100644
--- a/dist/assetsUtil.cjs
+++ b/dist/assetsUtil.cjs
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
+function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }
exports.fetchTokenContractExchangeRates = exports.reduceInBatchesSerially = exports.divideIntoBatches = exports.ethersBigNumberToBN = exports.addUrlProtocolPrefix = exports.getFormattedIpfsUrl = exports.getIpfsCIDv1AndPath = exports.removeIpfsProtocolPrefix = exports.isTokenListSupportedForNetwork = exports.isTokenDetectionSupportedForNetwork = exports.SupportedTokenDetectionNetworks = exports.formatIconUrlWithProxy = exports.formatAggregatorNames = exports.hasNewCollectionFields = exports.compareNftMetadata = exports.TOKEN_PRICES_BATCH_SIZE = void 0;
const controller_utils_1 = require("@metamask/controller-utils");
const utils_1 = require("@metamask/utils");
@@ -221,7 +222,7 @@ async function getIpfsCIDv1AndPath(ipfsUrl) {
const index = url.indexOf('/');
const cid = index !== -1 ? url.substring(0, index) : url;
const path = index !== -1 ? url.substring(index) : undefined;
- const { CID } = await import("multiformats");
+ const { CID } = _interopRequireWildcard(require("multiformats"));
// We want to ensure that the CID is v1 (https://docs.ipfs.io/concepts/content-addressing/#identifier-formats)
// because most cid v0s appear to be incompatible with IPFS subdomains
return {
diff --git a/dist/token-prices-service/codefi-v2.mjs b/dist/token-prices-service/codefi-v2.mjs
index e7eaad2cfa8b233c4fd42a51f745233a1cc5c387..b89849c0caf7e5db3b53cf03dd5746b6b1433543 100644
--- a/dist/token-prices-service/codefi-v2.mjs
+++ b/dist/token-prices-service/codefi-v2.mjs
@@ -12,8 +12,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
var _CodefiTokenPricesServiceV2_tokenPricePolicy;
import { handleFetch } from "@metamask/controller-utils";
import { hexToNumber } from "@metamask/utils";
-import $cockatiel from "cockatiel";
-const { circuitBreaker, ConsecutiveBreaker, ExponentialBackoff, handleAll, retry, wrap, CircuitState } = $cockatiel;
+import { circuitBreaker, ConsecutiveBreaker, ExponentialBackoff, handleAll, retry, wrap, CircuitState } from "cockatiel";
/**
* The list of currencies that can be supplied as the `vsCurrency` parameter to
* the `/spot-prices` endpoint, in lowercase form.
30 changes: 29 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [12.4.0]
### Added
- Added a receive button to the home screen, allowing users to easily get their address or QR-code for receiving cryptocurrency ([#26148](https://github.com/MetaMask/metamask-extension/pull/26148))
- Added smart transactions functionality for hardware wallet users ([#26251](https://github.com/MetaMask/metamask-extension/pull/26251))
- Added new custom UI components for Snaps developers ([#26675](https://github.com/MetaMask/metamask-extension/pull/26675))
- Add support for footers to Snap home pages ([#26463](https://github.com/MetaMask/metamask-extension/pull/26463))
- [FLASK] Added Account Watcher as a preinstalled snap and added it to the menu list ([#26402](https://github.com/MetaMask/metamask-extension/pull/26402))
- [FLASK] Added footers to Snap home pages ([#26463](https://github.com/MetaMask/metamask-extension/pull/26463))
- Added icons for IoTeX network ([#26723](https://github.com/MetaMask/metamask-extension/pull/26723))
- Added NEAR icon for chainId 397 and 398 ([#26459](https://github.com/MetaMask/metamask-extension/pull/26459))


### Changed
- Redesign contract deployment transaction screen ([#26382](https://github.com/MetaMask/metamask-extension/pull/26382))
- Improve performance, reliability and coverage of the phishing detection feature ([#25839](https://github.com/MetaMask/metamask-extension/pull/25839))
- Updated Moonbeam and Moonriver network and token logos ([#26677](https://github.com/MetaMask/metamask-extension/pull/26677))
- Updated UI for add network notification window ([#25777](https://github.com/MetaMask/metamask-extension/pull/25777))
- Update visual styling of token lists ([#26300](https://github.com/MetaMask/metamask-extension/pull/26300))
- Update spacing on Snap home page ([#26462](https://github.com/MetaMask/metamask-extension/pull/26462))
- [FLASK] Integrated Snaps into the redesigned confirmation pages ([#26435](https://github.com/MetaMask/metamask-extension/pull/26435))

### Fixed
- Fixed network change toast width in wide screen mode ([#26532](https://github.com/MetaMask/metamask-extension/pull/26532))
- Fixed missing deadline in swaps smart transaction status screen ([#25779](https://github.com/MetaMask/metamask-extension/pull/25779))
- Improved Snap Address component UI/UX; stop using petnames in custom Snaps UIs ([#26477](https://github.com/MetaMask/metamask-extension/pull/26477))
- Fixed bug that could prevent the Import NFT modal from closing after importing some tokens ([#26269](https://github.com/MetaMask/metamask-extension/pull/26269))

## [12.3.1]
### Fixed
- Fix duplicate network validation ([#27463](https://github.com/MetaMask/metamask-extension/pull/27463))
Expand Down Expand Up @@ -5112,7 +5139,8 @@ Update styles and spacing on the critical error page ([#20350](https://github.c
- Added the ability to restore accounts from seed words.


[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v12.3.1...HEAD
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v12.4.0...HEAD
[12.4.0]: https://github.com/MetaMask/metamask-extension/compare/v12.3.1...v12.4.0
[12.3.1]: https://github.com/MetaMask/metamask-extension/compare/v12.3.0...v12.3.1
[12.3.0]: https://github.com/MetaMask/metamask-extension/compare/v12.2.4...v12.3.0
[12.2.4]: https://github.com/MetaMask/metamask-extension/compare/v12.2.3...v12.2.4
Expand Down
15 changes: 0 additions & 15 deletions app/_locales/de/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 48ffeba

Please sign in to comment.