Skip to content

Commit 4344f8c

Browse files
authored
Merge branch 'main' into feat/srp-flow-review
2 parents 9d98e29 + 257fe93 commit 4344f8c

File tree

53 files changed

+1882
-184
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1882
-184
lines changed

.github/workflows/cla.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2424
with:
2525
path-to-signatures: 'cla.json'
26-
url-to-cladocument: 'https://metamask.io/cla.html'
26+
url-to-cladocument: 'https://metamask.io/cla'
2727
# This branch can't have protections, commits are made directly to the specified branch.
2828
branch: 'cla-signatures'
2929
allowlist: 'dependabot[bot],metamaskbot,crowdin-bot,runway-github[bot]'

app/_locales/en/messages.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/en_GB/messages.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/scripts/metamask-controller.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,10 @@ export const METAMASK_CONTROLLER_EVENTS = {
428428
'NotificationServicesController:markNotificationsAsRead',
429429
};
430430

431+
/**
432+
* @typedef {import('../../ui/store/store').MetaMaskReduxState} MetaMaskReduxState
433+
*/
434+
431435
// Types of APIs
432436
const API_TYPE = {
433437
EIP1193: 'eip-1193',
@@ -3338,7 +3342,7 @@ export default class MetamaskController extends EventEmitter {
33383342
/**
33393343
* The metamask-state of the various controllers, made available to the UI
33403344
*
3341-
* @returns {object} status
3345+
* @returns {MetaMaskReduxState["metamask"]} status
33423346
*/
33433347
getState() {
33443348
const { vault } = this.keyringController.state;

app/scripts/platforms/extension.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ export default class ExtensionPlatform {
5858
return browser.runtime.getManifest().version;
5959
}
6060

61+
/**
62+
* Returns the absolute URL of the extension's home.html page, optionally with
63+
* a route and query string.
64+
*
65+
* @param {string | null} route
66+
* @param {string | null} queryString
67+
* @returns { string }
68+
*/
6169
getExtensionURL(route = null, queryString = null) {
6270
let extensionURL = browser.runtime.getURL('home.html');
6371

@@ -72,6 +80,12 @@ export default class ExtensionPlatform {
7280
return extensionURL;
7381
}
7482

83+
/**
84+
*
85+
* @param {string | null} route
86+
* @param {string | null} queryString
87+
* @param {boolean} [keepWindowOpen] - defaults to false
88+
*/
7589
openExtensionInBrowser(
7690
route = null,
7791
queryString = null,

test/e2e/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const DAPP_ONE_URL = `http://${DAPP_ONE_ADDRESS}`;
5555
export const DEFAULT_BTC_ADDRESS = 'bc1qg6whd6pc0cguh6gpp3ewujm53hv32ta9hdp252';
5656

5757
/* Default BTC Account name */
58-
export const DEFAULT_ACCOUNT_NAME = 'Bitcoin Account 1';
58+
export const DEFAULT_BTC_ACCOUNT_NAME = 'Bitcoin Account 1';
5959

6060
/* Default (mocked) BTC balance used by the Bitcoin RPC provider */
6161
export const DEFAULT_BTC_BALANCE = 1; // BTC
Lines changed: 13 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,29 @@
11
import { strict as assert } from 'assert';
22
import { Suite } from 'mocha';
3-
import { DEFAULT_ACCOUNT_NAME, DEFAULT_BTC_BALANCE } from '../../constants';
3+
import { DEFAULT_BTC_ACCOUNT_NAME, DEFAULT_BTC_BALANCE } from '../../constants';
4+
import AssetListPage from '../../page-objects/pages/home/asset-list';
45
import BitcoinHomepage from '../../page-objects/pages/home/bitcoin-homepage';
56
import { withBtcAccountSnap } from './common-btc';
67

78
describe('BTC Account - Overview', function (this: Suite) {
89
it('has balance displayed and has portfolio button enabled for BTC accounts', async function () {
910
await withBtcAccountSnap(async (driver) => {
10-
await driver.findElement({
11-
css: '[data-testid="account-menu-icon"]',
12-
text: DEFAULT_ACCOUNT_NAME,
13-
});
14-
15-
await driver.waitForSelector({
16-
text: 'Send',
17-
tag: 'button',
18-
css: '[data-testid="coin-overview-send"]',
19-
});
20-
21-
await driver.waitForSelector({
22-
text: 'Swap',
23-
tag: 'button',
24-
css: '[disabled]',
25-
});
26-
27-
await driver.waitForSelector({
28-
text: 'Bridge',
29-
tag: 'button',
30-
css: '[disabled]',
31-
});
32-
33-
// buy sell button
34-
await driver.findClickableElement('[data-testid="coin-overview-buy"]');
35-
36-
// portfolio button
37-
await driver.findClickableElement('[data-testid="portfolio-link"]');
38-
}, this.test?.fullTitle());
39-
});
40-
41-
it('has balance', async function () {
42-
await withBtcAccountSnap(async (driver) => {
43-
await driver.waitForSelector({
44-
testId: 'account-value-and-suffix',
45-
text: `${DEFAULT_BTC_BALANCE}`,
46-
});
47-
48-
await driver.waitForSelector({
49-
testId: 'multichain-token-list-item-value',
50-
text: `${DEFAULT_BTC_BALANCE} BTC`,
51-
});
5211
const homePage = new BitcoinHomepage(driver);
5312
await homePage.check_pageIsLoaded();
54-
await homePage.headerNavbar.check_accountLabel(DEFAULT_ACCOUNT_NAME);
55-
await homePage.check_isExpectedBitcoinBalanceDisplayed(
56-
DEFAULT_BTC_BALANCE,
57-
);
58-
assert.equal(await homePage.check_isBridgeButtonEnabled(), false);
13+
await homePage.headerNavbar.check_accountLabel(DEFAULT_BTC_ACCOUNT_NAME);
14+
5915
assert.equal(await homePage.check_isSwapButtonEnabled(), false);
16+
assert.equal(await homePage.check_isBridgeButtonEnabled(), false);
6017
assert.equal(await homePage.check_isBuySellButtonEnabled(), true);
6118
assert.equal(await homePage.check_isReceiveButtonEnabled(), true);
19+
await homePage.check_portfolioLinkIsDisplayed();
20+
21+
await homePage.check_isExpectedBitcoinBalanceDisplayed(
22+
DEFAULT_BTC_BALANCE,
23+
);
24+
await new AssetListPage(driver).check_tokenAmountIsDisplayed(
25+
`${DEFAULT_BTC_BALANCE} BTC`,
26+
);
6227
}, this.test?.fullTitle());
6328
});
6429
});

test/e2e/flask/btc/btc-create-account.spec.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import LoginPage from '../../page-objects/pages/login-page';
88
import PrivacySettings from '../../page-objects/pages/settings/privacy-settings';
99
import ResetPasswordPage from '../../page-objects/pages/reset-password-page';
1010
import SettingsPage from '../../page-objects/pages/settings/settings-page';
11-
import { ACCOUNT_TYPE, DEFAULT_ACCOUNT_NAME } from '../../constants';
11+
import { ACCOUNT_TYPE, DEFAULT_BTC_ACCOUNT_NAME } from '../../constants';
1212
import { withBtcAccountSnap } from './common-btc';
1313

1414
describe('Create BTC Account', function (this: Suite) {
1515
it('create BTC account from the menu', async function () {
1616
await withBtcAccountSnap(async (driver) => {
1717
const headerNavbar = new HeaderNavbar(driver);
1818
await headerNavbar.check_pageIsLoaded();
19-
await headerNavbar.check_accountLabel(DEFAULT_ACCOUNT_NAME);
19+
await headerNavbar.check_accountLabel(DEFAULT_BTC_ACCOUNT_NAME);
2020
}, this.test?.fullTitle());
2121
});
2222

@@ -25,7 +25,7 @@ describe('Create BTC Account', function (this: Suite) {
2525
// check that we have one BTC account
2626
const headerNavbar = new HeaderNavbar(driver);
2727
await headerNavbar.check_pageIsLoaded();
28-
await headerNavbar.check_accountLabel(DEFAULT_ACCOUNT_NAME);
28+
await headerNavbar.check_accountLabel(DEFAULT_BTC_ACCOUNT_NAME);
2929

3030
// check user cannot create second BTC account
3131
await headerNavbar.openAccountMenu();
@@ -45,14 +45,14 @@ describe('Create BTC Account', function (this: Suite) {
4545
// check that we have one BTC account
4646
const headerNavbar = new HeaderNavbar(driver);
4747
await headerNavbar.check_pageIsLoaded();
48-
await headerNavbar.check_accountLabel(DEFAULT_ACCOUNT_NAME);
48+
await headerNavbar.check_accountLabel(DEFAULT_BTC_ACCOUNT_NAME);
4949

5050
// check user can cancel the removal of the BTC account
5151
await headerNavbar.openAccountMenu();
5252
const accountListPage = new AccountListPage(driver);
5353
await accountListPage.check_pageIsLoaded();
54-
await accountListPage.removeAccount(DEFAULT_ACCOUNT_NAME, false);
55-
await headerNavbar.check_accountLabel(DEFAULT_ACCOUNT_NAME);
54+
await accountListPage.removeAccount(DEFAULT_BTC_ACCOUNT_NAME, false);
55+
await headerNavbar.check_accountLabel(DEFAULT_BTC_ACCOUNT_NAME);
5656

5757
// check the number of accounts. it should be 2.
5858
await headerNavbar.openAccountMenu();
@@ -66,19 +66,19 @@ describe('Create BTC Account', function (this: Suite) {
6666
// check that we have one BTC account
6767
const headerNavbar = new HeaderNavbar(driver);
6868
await headerNavbar.check_pageIsLoaded();
69-
await headerNavbar.check_accountLabel(DEFAULT_ACCOUNT_NAME);
69+
await headerNavbar.check_accountLabel(DEFAULT_BTC_ACCOUNT_NAME);
7070

7171
// get the address of the BTC account and remove it
7272
await headerNavbar.openAccountMenu();
7373
const accountListPage = new AccountListPage(driver);
7474
await accountListPage.check_pageIsLoaded();
75-
await accountListPage.openAccountDetailsModal(DEFAULT_ACCOUNT_NAME);
75+
await accountListPage.openAccountDetailsModal(DEFAULT_BTC_ACCOUNT_NAME);
7676

7777
const accountDetailsModal = new AccountDetailsModal(driver);
7878
await accountDetailsModal.check_pageIsLoaded();
7979
const accountAddress = await accountDetailsModal.getAccountAddress();
8080
await headerNavbar.openAccountMenu();
81-
await accountListPage.removeAccount(DEFAULT_ACCOUNT_NAME);
81+
await accountListPage.removeAccount(DEFAULT_BTC_ACCOUNT_NAME);
8282

8383
// Recreate account and check that the address is the same
8484
await headerNavbar.openAccountMenu();
@@ -90,11 +90,11 @@ describe('Create BTC Account', function (this: Suite) {
9090
await accountListPage.closeAccountModal();
9191
await headerNavbar.openAccountMenu();
9292
await accountListPage.addAccount({ accountType: ACCOUNT_TYPE.Bitcoin });
93-
await headerNavbar.check_accountLabel(DEFAULT_ACCOUNT_NAME);
93+
await headerNavbar.check_accountLabel(DEFAULT_BTC_ACCOUNT_NAME);
9494

9595
await headerNavbar.openAccountMenu();
9696
await accountListPage.check_pageIsLoaded();
97-
await accountListPage.openAccountDetailsModal(DEFAULT_ACCOUNT_NAME);
97+
await accountListPage.openAccountDetailsModal(DEFAULT_BTC_ACCOUNT_NAME);
9898
await accountDetailsModal.check_pageIsLoaded();
9999
const recreatedAccountAddress =
100100
await accountDetailsModal.getAccountAddress();
@@ -108,12 +108,12 @@ describe('Create BTC Account', function (this: Suite) {
108108
// check that we have one BTC account
109109
const headerNavbar = new HeaderNavbar(driver);
110110
await headerNavbar.check_pageIsLoaded();
111-
await headerNavbar.check_accountLabel(DEFAULT_ACCOUNT_NAME);
111+
await headerNavbar.check_accountLabel(DEFAULT_BTC_ACCOUNT_NAME);
112112

113113
await headerNavbar.openAccountMenu();
114114
const accountListPage = new AccountListPage(driver);
115115
await accountListPage.check_pageIsLoaded();
116-
await accountListPage.openAccountDetailsModal(DEFAULT_ACCOUNT_NAME);
116+
await accountListPage.openAccountDetailsModal(DEFAULT_BTC_ACCOUNT_NAME);
117117
const accountDetailsModal = new AccountDetailsModal(driver);
118118
await accountDetailsModal.check_pageIsLoaded();
119119
const accountAddress = await accountDetailsModal.getAccountAddress();
@@ -141,7 +141,7 @@ describe('Create BTC Account', function (this: Suite) {
141141
// check discovered account address is the same
142142
await headerNavbar.openAccountMenu();
143143
await accountListPage.check_pageIsLoaded();
144-
await accountListPage.openAccountDetailsModal(DEFAULT_ACCOUNT_NAME);
144+
await accountListPage.openAccountDetailsModal(DEFAULT_BTC_ACCOUNT_NAME);
145145
await accountDetailsModal.check_pageIsLoaded();
146146
const discoveredAccountAddress =
147147
await accountDetailsModal.getAccountAddress();

test/e2e/flask/btc/btc-send.spec.ts

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,12 @@ describe('BTC Account - Send', function (this: Suite) {
3232

3333
const bitcoinReviewTxPage = new BitcoinReviewTxPage(driver);
3434
await bitcoinReviewTxPage.check_pageIsLoaded();
35-
await driver.waitForSelector({
36-
text: `Sending ${sendAmount} BTC`,
37-
tag: 'h2',
38-
});
39-
await driver.waitForSelector({
40-
text: `${expectedFee} sats`,
41-
tag: 'p',
42-
});
43-
await driver.waitForSelector({
44-
text: `${Math.floor(DEFAULT_BTC_FEE_RATE)} sat/vB`,
45-
tag: 'p',
46-
});
47-
await driver.waitForSelector({
48-
text: `${expectedTotal} BTC`,
49-
tag: 'p',
50-
});
35+
await bitcoinReviewTxPage.check_sendAmountIsDisplayed(sendAmount);
36+
await bitcoinReviewTxPage.check_networkFeeIsDisplayed(expectedFee);
37+
await bitcoinReviewTxPage.check_feeRateIsDisplayed(
38+
Math.floor(DEFAULT_BTC_FEE_RATE).toString(),
39+
);
40+
await bitcoinReviewTxPage.check_totalAmountIsDisplayed(expectedTotal);
5141
await bitcoinReviewTxPage.clickSendButton();
5242

5343
// TODO: Test that the transaction appears in the activity tab once activity tab is implemented for Bitcoin
@@ -77,14 +67,12 @@ describe('BTC Account - Send', function (this: Suite) {
7767

7868
const bitcoinReviewTxPage = new BitcoinReviewTxPage(driver);
7969
await bitcoinReviewTxPage.check_pageIsLoaded();
80-
await driver.waitForSelector({
81-
text: `Sending ${DEFAULT_BTC_BALANCE - expectedFee} BTC`,
82-
tag: 'h2',
83-
});
84-
await driver.waitForSelector({
85-
text: `${DEFAULT_BTC_BALANCE} BTC`,
86-
tag: 'p',
87-
});
70+
await bitcoinReviewTxPage.check_sendAmountIsDisplayed(
71+
(DEFAULT_BTC_BALANCE - expectedFee).toString(),
72+
);
73+
await bitcoinReviewTxPage.check_totalAmountIsDisplayed(
74+
DEFAULT_BTC_BALANCE.toString(),
75+
);
8876
await bitcoinReviewTxPage.clickSendButton();
8977

9078
// TODO: Test that the transaction appears in the activity tab once activity tab is implemented for Bitcoin

test/e2e/mock-e2e-allowlist.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ const ALLOWLISTED_URLS = [
4646
'https://metamask.github.io/vault-decryptor/bundle.js',
4747
];
4848

49-
const ALLOWLISTED_HOSTS = [
50-
'accounts.api.cx.metamask.io',
51-
'token.api.cx.metamask.io',
52-
];
49+
const ALLOWLISTED_HOSTS = ['token.api.cx.metamask.io'];
5350

5451
module.exports = { ALLOWLISTED_HOSTS, ALLOWLISTED_URLS };

0 commit comments

Comments
 (0)