Skip to content

Commit

Permalink
Merge branch 'develop' into feat/mmassets-356_sort-import-tokens-exte…
Browse files Browse the repository at this point in the history
…nsion--persistence-telemetry
  • Loading branch information
gambinish authored Oct 8, 2024
2 parents 0cd3e25 + 83455b8 commit c8467f6
Show file tree
Hide file tree
Showing 44 changed files with 560 additions and 588 deletions.
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%."
6 changes: 0 additions & 6 deletions app/_locales/de/messages.json

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

6 changes: 0 additions & 6 deletions app/_locales/el/messages.json

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

6 changes: 0 additions & 6 deletions app/_locales/en/messages.json

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

6 changes: 0 additions & 6 deletions app/_locales/en_GB/messages.json

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

6 changes: 0 additions & 6 deletions app/_locales/es/messages.json

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

6 changes: 0 additions & 6 deletions app/_locales/fr/messages.json

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

6 changes: 0 additions & 6 deletions app/_locales/hi/messages.json

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

6 changes: 0 additions & 6 deletions app/_locales/id/messages.json

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

6 changes: 0 additions & 6 deletions app/_locales/ja/messages.json

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

6 changes: 0 additions & 6 deletions app/_locales/ko/messages.json

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

6 changes: 0 additions & 6 deletions app/_locales/pt/messages.json

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

6 changes: 0 additions & 6 deletions app/_locales/ru/messages.json

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

6 changes: 0 additions & 6 deletions app/_locales/tl/messages.json

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

6 changes: 0 additions & 6 deletions app/_locales/tr/messages.json

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

6 changes: 0 additions & 6 deletions app/_locales/vi/messages.json

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

6 changes: 0 additions & 6 deletions app/_locales/zh_CN/messages.json

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

2 changes: 1 addition & 1 deletion coverage.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "coverage": 0 }
{ "coverage": 71 }
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@
"base32-encode": "^1.2.0",
"base64-js": "^1.5.1",
"bignumber.js": "^4.1.0",
"bitcoin-address-validation": "^2.2.3",
"blo": "1.2.0",
"bn.js": "^5.2.1",
"bowser": "^2.11.0",
Expand Down
17 changes: 11 additions & 6 deletions shared/lib/multichain.test.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,51 @@
import { isBtcMainnetAddress, isBtcTestnetAddress } from './multichain';

const MAINNET_ADDRESSES = [
const BTC_MAINNET_ADDRESSES = [
// P2WPKH
'bc1qwl8399fz829uqvqly9tcatgrgtwp3udnhxfq4k',
// P2PKH
'1P5ZEDWTKTFGxQjZphgWPQUpe554WKDfHQ',
];

const TESTNET_ADDRESSES = [
const BTC_TESTNET_ADDRESSES = [
// P2WPKH
'tb1q6rmsq3vlfdhjdhtkxlqtuhhlr6pmj09y6w43g8',
];

const ETH_ADDRESSES = ['0x6431726EEE67570BF6f0Cf892aE0a3988F03903F'];

const SOL_ADDRESSES = [
'7EcDhSYGxXyscszYEp35KHN8vvw3svAuLKTzXwCFLtV',
'DpNXPNWvWoHaZ9P3WtfGCb2ZdLihW8VW1w1Ph4KDH9iG',
];

describe('multichain', () => {
// @ts-expect-error This is missing from the Mocha type definitions
it.each(MAINNET_ADDRESSES)(
it.each(BTC_MAINNET_ADDRESSES)(
'returns true if address is compatible with BTC mainnet: %s',
(address: string) => {
expect(isBtcMainnetAddress(address)).toBe(true);
},
);

// @ts-expect-error This is missing from the Mocha type definitions
it.each([...TESTNET_ADDRESSES, ...ETH_ADDRESSES])(
it.each([...BTC_TESTNET_ADDRESSES, ...ETH_ADDRESSES, ...SOL_ADDRESSES])(
'returns false if address is not compatible with BTC mainnet: %s',
(address: string) => {
expect(isBtcMainnetAddress(address)).toBe(false);
},
);

// @ts-expect-error This is missing from the Mocha type definitions
it.each(TESTNET_ADDRESSES)(
it.each(BTC_TESTNET_ADDRESSES)(
'returns true if address is compatible with BTC testnet: %s',
(address: string) => {
expect(isBtcTestnetAddress(address)).toBe(true);
},
);

// @ts-expect-error This is missing from the Mocha type definitions
it.each([...MAINNET_ADDRESSES, ...ETH_ADDRESSES])(
it.each([...BTC_MAINNET_ADDRESSES, ...ETH_ADDRESSES, ...SOL_ADDRESSES])(
'returns false if address is compatible with BTC testnet: %s',
(address: string) => {
expect(isBtcTestnetAddress(address)).toBe(false);
Expand Down
11 changes: 3 additions & 8 deletions shared/lib/multichain.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// TODO: Remove restricted import
// eslint-disable-next-line import/no-restricted-paths
import { isEthAddress } from '../../app/scripts/lib/multichain/address';
import { validate, Network } from 'bitcoin-address-validation';

/**
* Returns whether an address is on the Bitcoin mainnet.
Expand All @@ -14,10 +12,7 @@ import { isEthAddress } from '../../app/scripts/lib/multichain/address';
* @returns `true` if the address is on the Bitcoin mainnet, `false` otherwise.
*/
export function isBtcMainnetAddress(address: string): boolean {
return (
!isEthAddress(address) &&
(address.startsWith('bc1') || address.startsWith('1'))
);
return validate(address, Network.mainnet);
}

/**
Expand All @@ -29,5 +24,5 @@ export function isBtcMainnetAddress(address: string): boolean {
* @returns `true` if the address is on the Bitcoin testnet, `false` otherwise.
*/
export function isBtcTestnetAddress(address: string): boolean {
return !isEthAddress(address) && !isBtcMainnetAddress(address);
return validate(address, Network.testnet);
}
9 changes: 4 additions & 5 deletions test/e2e/flask/btc/create-btc-account.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,10 @@ describe('Create BTC Account', function (this: Suite) {
await driver.clickElement(
'[data-testid="account-options-menu-button"]',
);
const lockButton = await driver.findClickableElement(
'[data-testid="global-menu-lock"]',
);
assert.equal(await lockButton.getText(), 'Lock MetaMask');
await lockButton.click();
await driver.clickElement({
css: '[data-testid="global-menu-lock"]',
text: 'Lock MetaMask',
});

await driver.clickElement({
text: 'Forgot password?',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ describe('Malicious Confirmation Signature - Bad Domain @no-mmi', function (this
}: TestSuiteArguments) => {
await openDappAndTriggerSignature(driver, SignatureType.SIWE_BadDomain);

await driver.clickElement(
await driver.clickElementAndWaitForWindowToClose(
'[data-testid="confirm-footer-cancel-button"]',
);

await driver.waitUntilXWindowHandles(2);
await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp);

const rejectionResult = await driver.waitForSelector({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,10 @@ describe('Confirmation Signature - Personal Sign @no-mmi', function (this: Suite
}: TestSuiteArguments) => {
await openDappAndTriggerSignature(driver, SignatureType.PersonalSign);

await driver.clickElement(
await driver.clickElementAndWaitForWindowToClose(
'[data-testid="confirm-footer-cancel-button"]',
);

await driver.waitUntilXWindowHandles(2);
await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp);

const rejectionResult = await driver.waitForSelector({
Expand Down
Loading

0 comments on commit c8467f6

Please sign in to comment.