1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Merge remote-tracking branch 'origin/develop' into master-sync

This commit is contained in:
ryanml 2021-10-09 16:46:28 -07:00
commit 018095691f
254 changed files with 7951 additions and 1177 deletions

View File

@ -391,7 +391,7 @@ jobs:
destination: test-artifacts
test-e2e-firefox:
executor: node-browsers
executor: node-browsers-medium-plus
steps:
- checkout
- run:

View File

@ -11,7 +11,7 @@ BUILD_DEST="./build-artifacts/build-viz/"
mkdir -p "${BUILD_DEST}"
# generate lavamoat debug config
yarn lavamoat:debug
yarn lavamoat:debug:build
# generate viz
npx lavamoat-viz --dest "${BUILD_DEST}"

View File

@ -6,7 +6,7 @@ set -o pipefail
yarn allow-scripts auto
if git diff --exit-code --quiet
if git diff --exit-code
then
echo "allow-scripts configuration is up-to-date"
else

View File

@ -6,7 +6,7 @@ set -o pipefail
yarn lavamoat:auto
if git diff --exit-code --quiet
if git diff --exit-code
then
echo "LavaMoat policy is up-to-date"
else

View File

@ -183,6 +183,7 @@ module.exports = {
'nyc.config.js',
'stylelint.config.js',
'app/scripts/lockdown-run.js',
'app/scripts/lockdown-more.js',
'development/**/*.js',
'test/e2e/**/*.js',
'test/lib/wait-until-called.js',
@ -197,6 +198,7 @@ module.exports = {
{
files: [
'app/scripts/lockdown-run.js',
'app/scripts/lockdown-more.js',
'test/unit-global/protect-intrinsics.test.js',
],
globals: {

View File

@ -0,0 +1,9 @@
export const updateSendAsset = (type) => ({
type: 'send/updateSendAsset',
payload: type,
});
export const updateSendStage = (stage) => ({
type: 'send/updateSendStage',
payload: stage,
});

View File

@ -1,65 +1,83 @@
export const suggestedTokens = {
"0x6b175474e89094c44da98b954eedeac495271d0f": {
"address": "0x6b175474e89094c44da98b954eedeac495271d0f",
"symbol": "META",
"decimals": 18,
"image": "metamark.svg",
"unlisted": false
export const suggestedAssets = [
{
asset: {
address: '0x6b175474e89094c44da98b954eedeac495271d0f',
symbol: 'META',
decimals: 18,
image: 'metamark.svg',
unlisted: false
},
"0xB8c77482e45F1F44dE1745F52C74426C631bDD52": {
"address": "0xB8c77482e45F1F44dE1745F52C74426C631bDD52",
"symbol": "0X",
"decimals": 18,
"image": "0x.svg",
"unlisted": false
},
"0x1f9840a85d5af5bf1d1762f925bdaddc4201f984": {
"address": "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984",
"symbol": "AST",
"decimals": 18,
"image": "ast.png",
"unlisted": false
{
asset: {
'address': '0xB8c77482e45F1F44dE1745F52C74426C631bDD52',
'symbol': '0X',
'decimals': 18,
'image': '0x.svg',
'unlisted': false
},
"0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2": {
"address": "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2",
"symbol": "BAT",
"decimals": 18,
"image": "BAT_icon.svg",
"unlisted": false
},
"0xe83cccfabd4ed148903bf36d4283ee7c8b3494d1": {
"address": "0xe83cccfabd4ed148903bf36d4283ee7c8b3494d1",
"symbol": "CVL",
"decimals": 18,
"image": "CVL_token.svg",
"unlisted": false
{
asset: {
'address': '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984',
'symbol': 'AST',
'decimals': 18,
'image': 'ast.png',
'unlisted': false
},
"0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e": {
"address": "0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e",
"symbol": "GLA",
"decimals": 18,
"image": "gladius.svg",
"unlisted": false
},
"0x467Bccd9d29f223BcE8043b84E8C8B282827790F": {
"address": "0x467Bccd9d29f223BcE8043b84E8C8B282827790F",
"symbol": "GNO",
"decimals": 18,
"image": "gnosis.svg",
"unlisted": false
{
asset: {
'address': '0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2',
'symbol': 'BAT',
'decimals': 18,
'image': 'BAT_icon.svg',
'unlisted': false
},
"0xff20817765cb7f73d4bde2e66e067e58d11095c2": {
"address": "0xff20817765cb7f73d4bde2e66e067e58d11095c2",
"symbol": "OMG",
"decimals": 18,
"image": "omg.jpg",
"unlisted": false
},
"0x8e870d67f660d95d5be530380d0ec0bd388289e1": {
"address": "0x8e870d67f660d95d5be530380d0ec0bd388289e1",
"symbol": "WED",
"decimals": 18,
"image": "wed.png",
"unlisted": false
{
asset: {
'address': '0xe83cccfabd4ed148903bf36d4283ee7c8b3494d1',
'symbol': 'CVL',
'decimals': 18,
'image': 'CVL_token.svg',
'unlisted': false
},
}
},
{
asset: {
'address': '0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e',
'symbol': 'GLA',
'decimals': 18,
'image': 'gladius.svg',
'unlisted': false
},
},
{
asset: {
'address': '0x467Bccd9d29f223BcE8043b84E8C8B282827790F',
'symbol': 'GNO',
'decimals': 18,
'image': 'gnosis.svg',
'unlisted': false
},
},
{
asset: {
'address': '0xff20817765cb7f73d4bde2e66e067e58d11095c2',
'symbol': 'OMG',
'decimals': 18,
'image': 'omg.jpg',
'unlisted': false
},
},
{
asset: {
'address': '0x8e870d67f660d95d5be530380d0ec0bd388289e1',
'symbol': 'WED',
'decimals': 18,
'image': 'wed.png',
'unlisted': false
},
},
]

View File

@ -0,0 +1,9 @@
import testData from '../test-data';
const initialState = { ...testData.history };
export default function historySBReducer(state = initialState, action) {
switch (action.type) {
default:
return state;
}
}

View File

@ -0,0 +1,19 @@
import testData from '../test-data';
const initialState = { ...testData.send };
export default function sendSBReducer(state = initialState, action) {
switch (action.type) {
case 'send/updateSendStage':
return {
...state,
stage: action.payload,
};
case 'send/updateSendAsset':
return {
...state,
asset: { ...state.asset, type: action.payload },
};
default:
return state;
}
}

View File

@ -1,5 +1,3 @@
import { TRANSACTION_STATUSES } from '../shared/constants/transaction';
const state = {
invalidCustomNetwork: {
state: 'CLOSED',
@ -16,11 +14,109 @@ const state = {
url: 'https://metamask.github.io/test-dapp/',
},
metamask: {
tokenList: {
'0x6b175474e89094c44da98b954eedeac495271d0f': {
address: '0x6b175474e89094c44da98b954eedeac495271d0f',
symbol: 'META',
decimals: 18,
image: 'metamark.svg',
unlisted: false
},
'0xB8c77482e45F1F44dE1745F52C74426C631bDD52': {
address: '0xB8c77482e45F1F44dE1745F52C74426C631bDD52',
symbol: '0X',
decimals: 18,
image: '0x.svg',
unlisted: false
},
'0x1f9840a85d5af5bf1d1762f925bdaddc4201f984': {
address: '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984',
symbol: 'AST',
decimals: 18,
image: 'ast.png',
unlisted: false
},
'0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2': {
address: '0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2',
symbol: 'BAT',
decimals: 18,
image: 'BAT_icon.svg',
unlisted: false
},
'0xe83cccfabd4ed148903bf36d4283ee7c8b3494d1': {
address: '0xe83cccfabd4ed148903bf36d4283ee7c8b3494d1',
symbol: 'CVL',
decimals: 18,
image: 'CVL_token.svg',
unlisted: false
},
'0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e': {
address: '0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e',
symbol: 'GLA',
decimals: 18,
image: 'gladius.svg',
unlisted: false
},
'0x467Bccd9d29f223BcE8043b84E8C8B282827790F': {
address: '0x467Bccd9d29f223BcE8043b84E8C8B282827790F',
symbol: 'GNO',
decimals: 18,
image: 'gnosis.svg',
unlisted: false
},
'0xff20817765cb7f73d4bde2e66e067e58d11095c2': {
address: '0xff20817765cb7f73d4bde2e66e067e58d11095c2',
symbol: 'OMG',
decimals: 18,
image: 'omg.jpg',
unlisted: false
},
'0x8e870d67f660d95d5be530380d0ec0bd388289e1': {
address: '0x8e870d67f660d95d5be530380d0ec0bd388289e1',
symbol: 'WED',
decimals: 18,
image: 'wed.png',
unlisted: false
},
},
networkDetails: {
EIPS: {
1559: true,
},
},
gasFeeEstimates: '0x5208',
swapsState: {
quotes: {},
fetchParams: null,
tokens: null,
tradeTxId: null,
approveTxId: null,
quotesLastFetched: null,
customMaxGas: '',
customGasPrice: null,
selectedAggId: null,
customApproveTxData: '',
errorKey: '',
topAggId: null,
routeState: '',
swapsFeatureIsLive: false,
swapsQuoteRefreshTime: 60000,
},
accountArray: [
{
name: 'This is a Really Long Account Name',
address: '0x64a845a5b02460acf8a3d84503b0d68d028b4bb4',
index: 0,
balance: '0x176e5b6f173ebe66',
},
{
name: 'Account 2',
address: '0xb19ac54efa18cc3a14a5b821bfec73d284bf0c5e',
index: 1,
balance: '0x2d3142f5000',
},
],
connectedAccounts: ['0x64a845a5b02460acf8a3d84503b0d68d028b4bb4'],
isInitialized: true,
isUnlocked: true,
isAccountMenuOpen: false,
@ -103,12 +199,6 @@ const state = {
},
},
},
recipient: {
address: '0x39a4e4Af7cCB654dB9500F258c64781c8FbD39F0',
nickname: 'John Doe',
error: '',
warning: '',
},
addresses: [
{
address: '0x39a4e4Af7cCB654dB9500F258c64781c8FbD39F0',
@ -366,6 +456,15 @@ const state = {
value: '0x9c2686',
},
],
[
{
note: 'txStateManager: setting status to confirmed',
op: 'replace',
path: '/status',
timestamp: 1629582721178,
value: 'confirmed',
},
],
[
{
note: 'txStateManager: setting status to confirmed',
@ -794,7 +893,7 @@ const state = {
'0xaD6D458402F60fD3Bd25163575031ACDce07538D': './sai.svg',
},
hiddenTokens: [],
suggestedTokens: {},
suggestedAssets: {},
useNonceField: false,
usePhishDetect: true,
lostIdentities: {},
@ -1165,6 +1264,11 @@ const state = {
balance: '0x0',
details: null,
},
stage: 'ADD_RECIPIENT',
amount: '3782dace9d900000',
gas: {
price: null,
},
},
confirmTransaction: {
txData: {

View File

@ -1124,15 +1124,6 @@
"viewContact": {
"message": "ዕውቂያን ይመልከቱ"
},
"viewOnCustomBlockExplorer": {
"message": "በ $1ይመልከቱ"
},
"viewOnEtherscan": {
"message": "በ Etherscan ላይ ይመልከቱ"
},
"viewinExplorer": {
"message": "በኤክስፕሎረር ተመልከት"
},
"visitWebSite": {
"message": "ድረ ገጻችንን ይጎብኙ"
},

View File

@ -1120,15 +1120,6 @@
"viewContact": {
"message": "عرض جهة الاتصال"
},
"viewOnCustomBlockExplorer": {
"message": "عرض في $1"
},
"viewOnEtherscan": {
"message": "عرضه على Etherscan"
},
"viewinExplorer": {
"message": "عرض في متصفح Explorer"
},
"visitWebSite": {
"message": "قم بزيارة موقعنا على الإنترنت"
},

View File

@ -1123,15 +1123,6 @@
"viewContact": {
"message": "Преглед на контакта"
},
"viewOnCustomBlockExplorer": {
"message": "Преглед на $1"
},
"viewOnEtherscan": {
"message": "Преглед на Etherscan"
},
"viewinExplorer": {
"message": "Преглед в Explorer"
},
"visitWebSite": {
"message": "Посетете нашият уеб сайт"
},

View File

@ -1127,15 +1127,6 @@
"viewContact": {
"message": "পরিচিতি দেখুন"
},
"viewOnCustomBlockExplorer": {
"message": "$1 এ দেখুন"
},
"viewOnEtherscan": {
"message": "Etherscan দেখুন"
},
"viewinExplorer": {
"message": "এক্সপ্লোরারে দেখুন"
},
"visitWebSite": {
"message": "আমাদের ওয়েবসাইট দেখুন"
},

View File

@ -1096,15 +1096,6 @@
"viewContact": {
"message": "Veure Contacte"
},
"viewOnCustomBlockExplorer": {
"message": "Mostra a $1"
},
"viewOnEtherscan": {
"message": "Veure a Etherscan"
},
"viewinExplorer": {
"message": "Mostra a Explorer"
},
"visitWebSite": {
"message": "Visita el nostre lloc web"
},

View File

@ -1096,15 +1096,6 @@
"viewContact": {
"message": "Vis kontakt"
},
"viewOnCustomBlockExplorer": {
"message": "Se på $1"
},
"viewOnEtherscan": {
"message": "Se på Etherscan"
},
"viewinExplorer": {
"message": "Vis i stifinder"
},
"visitWebSite": {
"message": "Besøg vores webside"
},

View File

@ -1087,15 +1087,6 @@
"viewContact": {
"message": "Kontakt anzeigen"
},
"viewOnCustomBlockExplorer": {
"message": "Für $1 ansehen"
},
"viewOnEtherscan": {
"message": "Auf Etherscan ansehen"
},
"viewinExplorer": {
"message": "Im Explorer anzeigen"
},
"visitWebSite": {
"message": "Gehe zu unserer Webseite"
},

View File

@ -1121,15 +1121,6 @@
"viewContact": {
"message": "Εμφάνιση Επαφής"
},
"viewOnCustomBlockExplorer": {
"message": "Προβολή σε $1"
},
"viewOnEtherscan": {
"message": "Προβολή στο Etherscan"
},
"viewinExplorer": {
"message": "Προβολή στον Εξερευνητή"
},
"visitWebSite": {
"message": "Επισκεφθείτε τον ιστότοπό μας"
},

View File

@ -259,6 +259,22 @@
"betaWelcome": {
"message": "Welcome to MetaMask Beta"
},
"blockExplorerAccountAction": {
"message": "Account",
"description": "This is used with viewOnEtherscan and viewInExplorer e.g View Account in Explorer"
},
"blockExplorerAssetAction": {
"message": "Asset",
"description": "This is used with viewOnEtherscan and viewInExplorer e.g View Asset in Explorer"
},
"blockExplorerSwapAction": {
"message": "Swap",
"description": "This is used with viewOnEtherscan e.g View Swap on Etherscan"
},
"blockExplorerTransactionAction": {
"message": "Transaction",
"description": "This is used with viewOnCustomBlockExplorer and viewOnEtherscan e.g View Transaction on Etherscan"
},
"blockExplorerUrl": {
"message": "Block Explorer URL"
},
@ -405,7 +421,7 @@
"message": "You have 1 account connected to this site."
},
"connectedAccountsEmptyDescription": {
"message": "MetaMask is not connected this site. To connect to a web3 site, find the connect button on their site."
"message": "MetaMask is not connected to this site. To connect to a web3 site, find and click the connect button."
},
"connectedSites": {
"message": "Connected sites"
@ -1026,6 +1042,9 @@
"getStarted": {
"message": "Get Started"
},
"goBack": {
"message": "Go Back"
},
"goerli": {
"message": "Goerli Test Network"
},
@ -1191,6 +1210,9 @@
"ipfsGatewayDescription": {
"message": "Enter the URL of the IPFS CID gateway to use for ENS content resolution."
},
"jsDeliver": {
"message": "jsDeliver"
},
"jsonFile": {
"message": "JSON File",
"description": "format for importing an account"
@ -1601,6 +1623,14 @@
"message": "\"$1\" will close this tab and direct back to $2",
"description": "Return the user to the site that initiated onboarding"
},
"onboardingShowIncomingTransactionsDescription": {
"message": "Showing incoming transactions in your wallet relies on communication with $1. Etherscan will have access to your Ethereum address and your IP address. View $2.",
"description": "$1 is a clickable link with text defined by the 'etherscan' key. $2 is a clickable link with text defined by the 'privacyMsg' key."
},
"onboardingUsePhishingDetectionDescription": {
"message": "Phishing detection alerts rely on communication with $1. jsDeliver will have access to your IP address. View $2.",
"description": "The $1 is the word 'jsDeliver', from key 'jsDeliver' and $2 is the words Privacy Policy from key 'privacyMsg', both separated here so that it can be wrapped as a link"
},
"onlyAddTrustedNetworks": {
"message": "A malicious network provider can lie about the state of the blockchain and record your network activity. Only add custom networks you trust."
},
@ -1884,6 +1914,12 @@
"seedPhraseEnterMissingWords": {
"message": "Confirm Secret Recovery Phrase"
},
"seedPhraseIntroNotRecommendedButtonCopy": {
"message": "Remind me later (not recommended)"
},
"seedPhraseIntroRecommendedButtonCopy": {
"message": "Secure my wallet (recommended)"
},
"seedPhraseIntroSidebarBulletFour": {
"message": "Write down and store in multiple secret places."
},
@ -1897,13 +1933,13 @@
"message": "Store in a bank vault."
},
"seedPhraseIntroSidebarCopyOne": {
"message": "Your Secret Recovery Phrase is the “master key” to your wallet and funds."
"message": "Your Secret Recovery Phrase is a 12-word phrase that is the “master key” to your wallet and your funds"
},
"seedPhraseIntroSidebarCopyThree": {
"message": "If someone asks for your Secret Recovery Phrase, they are most likely trying to scam you."
"message": "If someone asks for your recovery phrase they are likely trying to scam you and steal your wallet funds"
},
"seedPhraseIntroSidebarCopyTwo": {
"message": "Never, ever share your Secret Recovery Phrase, even with MetaMask!"
"message": "Never, ever share your Secret Recovery Phrase, not even with MetaMask!"
},
"seedPhraseIntroSidebarTitleOne": {
"message": "What is a Secret Recovery Phrase?"
@ -1995,6 +2031,12 @@
"separateEachWord": {
"message": "Separate each word with a single space"
},
"setAdvancedPrivacySettings": {
"message": "Set advanced privacy settings"
},
"setAdvancedPrivacySettingsDetails": {
"message": "MetaMask uses these trusted third-party services to enhance product usability and safety."
},
"settings": {
"message": "Settings"
},
@ -2055,6 +2097,15 @@
"signed": {
"message": "Signed"
},
"skip": {
"message": "Skip"
},
"skipAccountSecurity": {
"message": "Skip Account Security?"
},
"skipAccountSecurityDetails": {
"message": "I understand that until I back up my Secret Recovery Phrase, I may lose my accounts and all of their assets."
},
"slow": {
"message": "Slow"
},
@ -2684,6 +2735,9 @@
"tryAgain": {
"message": "Try again"
},
"turnOnTokenDetection": {
"message": "Turn on Token Detection"
},
"typePassword": {
"message": "Type your MetaMask password"
},
@ -2784,13 +2838,16 @@
"message": "View More"
},
"viewOnCustomBlockExplorer": {
"message": "View at $1"
"message": "View $1 at $2",
"description": "$1 is the action type. e.g (Account, Transaction, Swap) and $2 is the Custom Block Exporer URL"
},
"viewOnEtherscan": {
"message": "View on Etherscan"
"message": "View $1 on Etherscan",
"description": "$1 is the action type. e.g (Account, Transaction, Swap)"
},
"viewinExplorer": {
"message": "View in Explorer"
"message": "View $1 in Explorer",
"description": "$1 is the action type. e.g (Account, Transaction, Swap)"
},
"visitWebSite": {
"message": "Visit our web site"

View File

@ -2386,15 +2386,6 @@
"viewMore": {
"message": "Ver más"
},
"viewOnCustomBlockExplorer": {
"message": "Ver en $1"
},
"viewOnEtherscan": {
"message": "Ver en Etherscan"
},
"viewinExplorer": {
"message": "Ver en el explorador"
},
"visitWebSite": {
"message": "Visite nuestro sitio web"
},

View File

@ -2386,15 +2386,6 @@
"viewMore": {
"message": "Ver más"
},
"viewOnCustomBlockExplorer": {
"message": "Ver en $1"
},
"viewOnEtherscan": {
"message": "Ver en Etherscan"
},
"viewinExplorer": {
"message": "Ver en el explorador"
},
"visitWebSite": {
"message": "Visite nuestro sitio web"
},

View File

@ -1117,15 +1117,6 @@
"viewContact": {
"message": "Kuva kontakt"
},
"viewOnCustomBlockExplorer": {
"message": "Vaata $1"
},
"viewOnEtherscan": {
"message": "Kuva Etherscanil"
},
"viewinExplorer": {
"message": "Kuva Exploreris"
},
"visitWebSite": {
"message": "Külastage meie veebilehte"
},

View File

@ -1127,15 +1127,6 @@
"viewContact": {
"message": "مشاهده تماس"
},
"viewOnCustomBlockExplorer": {
"message": "مشاهده در 1$1"
},
"viewOnEtherscan": {
"message": "مشاهده در ایترسکن"
},
"viewinExplorer": {
"message": "مشاهده در براوزر"
},
"visitWebSite": {
"message": "از وب سایت ما دیدن نمایید"
},

View File

@ -1124,15 +1124,6 @@
"viewContact": {
"message": "Näytä yhteyshenkilö"
},
"viewOnCustomBlockExplorer": {
"message": "Tarkastele kohdassa $1"
},
"viewOnEtherscan": {
"message": "Näytä Etherscanissa"
},
"viewinExplorer": {
"message": "Tarkastele Explorerissa"
},
"visitWebSite": {
"message": "Vieraile verkkosivustollamme"
},

View File

@ -1021,15 +1021,6 @@
"viewContact": {
"message": "Tingnan ang Contact"
},
"viewOnCustomBlockExplorer": {
"message": "Tingnan sa $1"
},
"viewOnEtherscan": {
"message": "Tingnan sa Etherscan"
},
"viewinExplorer": {
"message": "Tingnan sa Explorer"
},
"visitWebSite": {
"message": "Bisitahin ang aming web site"
},

View File

@ -1103,15 +1103,6 @@
"viewContact": {
"message": "Voir contact"
},
"viewOnCustomBlockExplorer": {
"message": "Afficher sur $1"
},
"viewOnEtherscan": {
"message": "Voir sur Etherscan"
},
"viewinExplorer": {
"message": "Afficher dans Explorer"
},
"visitWebSite": {
"message": "Visitez notre site web"
},

View File

@ -1121,15 +1121,6 @@
"viewContact": {
"message": "הצג איש קשר"
},
"viewOnCustomBlockExplorer": {
"message": "הצג ב- $1"
},
"viewOnEtherscan": {
"message": "הצג ב-Etherscan"
},
"viewinExplorer": {
"message": "הצג באקספלורר"
},
"visitWebSite": {
"message": "בקר/י באתר שלנו"
},

View File

@ -2386,15 +2386,6 @@
"viewMore": {
"message": "और देखें"
},
"viewOnCustomBlockExplorer": {
"message": "$1 पर देखें"
},
"viewOnEtherscan": {
"message": "Etherscan पर देखें"
},
"viewinExplorer": {
"message": "एक्सप्लोरर में देखें"
},
"visitWebSite": {
"message": "हमारी वेबसाइट पर जाएँ"
},

View File

@ -1117,15 +1117,6 @@
"viewContact": {
"message": "Prikaži kontakt"
},
"viewOnCustomBlockExplorer": {
"message": "Prikaži u $1"
},
"viewOnEtherscan": {
"message": "Prikaži na Etherscanu"
},
"viewinExplorer": {
"message": "Prikaži u Exploreru"
},
"visitWebSite": {
"message": "Posjetite naše mrežno mjesto"
},

View File

@ -688,9 +688,6 @@
"viewAccount": {
"message": "Wè Kont"
},
"viewOnEtherscan": {
"message": "Wè sou Etherscan"
},
"visitWebSite": {
"message": "Vizite sit entènèt nou an"
},

View File

@ -1117,15 +1117,6 @@
"viewContact": {
"message": "Névjegy megtekintése"
},
"viewOnCustomBlockExplorer": {
"message": "Megtekintés $1-kor"
},
"viewOnEtherscan": {
"message": "Nézze meg Etherscanen"
},
"viewinExplorer": {
"message": "Megtekintés Explorerben"
},
"visitWebSite": {
"message": "Látogass el weboldalunkra"
},

View File

@ -2386,15 +2386,6 @@
"viewMore": {
"message": "Lihat Selengkapnya"
},
"viewOnCustomBlockExplorer": {
"message": "Lihat di $1"
},
"viewOnEtherscan": {
"message": "Lihat di Etherscan"
},
"viewinExplorer": {
"message": "Lihat di Explorer"
},
"visitWebSite": {
"message": "Kunjungi situs web kami"
},

View File

@ -1947,15 +1947,6 @@
"viewContact": {
"message": "Visualizza contatto"
},
"viewOnCustomBlockExplorer": {
"message": "Vedi su $1"
},
"viewOnEtherscan": {
"message": "Vedi su Etherscan"
},
"viewinExplorer": {
"message": "Vista in Explorer"
},
"visitWebSite": {
"message": "Visita il nostro sito web"
},

View File

@ -2386,15 +2386,6 @@
"viewMore": {
"message": "詳細を表示"
},
"viewOnCustomBlockExplorer": {
"message": "$1 に表示"
},
"viewOnEtherscan": {
"message": "Etherscan で表示"
},
"viewinExplorer": {
"message": "Explorer で表示"
},
"visitWebSite": {
"message": "当社の Web サイトにアクセス"
},

View File

@ -1127,15 +1127,6 @@
"viewContact": {
"message": "ಸಂಪರ್ಕವನ್ನು ವೀಕ್ಷಿಸಿ"
},
"viewOnCustomBlockExplorer": {
"message": "$1 ನಲ್ಲಿ ವೀಕ್ಷಿಸಿ"
},
"viewOnEtherscan": {
"message": "ಎಥೆರ್‌ಸ್ಕ್ಯಾನ್‌ನಲ್ಲಿ ವೀಕ್ಷಿಸಿ"
},
"viewinExplorer": {
"message": "ಎಕ್ಸ್‌ಪ್ಲೋರರ್‌ನಲ್ಲಿ ವೀಕ್ಷಿಸಿ"
},
"visitWebSite": {
"message": "ನಮ್ಮ ವೆಬ್ ಸೈಟ್ ಅನ್ನು ಭೇಟಿ ಮಾಡಿ"
},

View File

@ -2386,15 +2386,6 @@
"viewMore": {
"message": "더 보기"
},
"viewOnCustomBlockExplorer": {
"message": "$1에서 보기"
},
"viewOnEtherscan": {
"message": "Etherscan에서 보기"
},
"viewinExplorer": {
"message": "탐색기에서 보기"
},
"visitWebSite": {
"message": "당사 웹사이트 방문하기"
},

View File

@ -1127,15 +1127,6 @@
"viewContact": {
"message": "Peržiūrėti kontaktą"
},
"viewOnCustomBlockExplorer": {
"message": "Peržiūrėti $1"
},
"viewOnEtherscan": {
"message": "Peržiūrėti „Etherscan“"
},
"viewinExplorer": {
"message": "Peržiūrėti naršyklėje"
},
"visitWebSite": {
"message": "Apsilankykite mūsų svetainėje"
},

View File

@ -1123,15 +1123,6 @@
"viewContact": {
"message": "Skatīt līgumu"
},
"viewOnCustomBlockExplorer": {
"message": "Skatīt $1"
},
"viewOnEtherscan": {
"message": "Skatīt Etherscan"
},
"viewinExplorer": {
"message": "Skatīt Explorer"
},
"visitWebSite": {
"message": "Apmeklējiet mūsu tīmekļa vietni"
},

View File

@ -1101,15 +1101,6 @@
"viewContact": {
"message": "Lihat Kenalan"
},
"viewOnCustomBlockExplorer": {
"message": "Lihat pada $1"
},
"viewOnEtherscan": {
"message": "Lihat di Etherscan"
},
"viewinExplorer": {
"message": "Lihat di Explorer"
},
"visitWebSite": {
"message": "Kunjungi laman web kami"
},

View File

@ -1102,15 +1102,6 @@
"viewContact": {
"message": "Se kontrakt"
},
"viewOnCustomBlockExplorer": {
"message": "Vis ved $1 "
},
"viewOnEtherscan": {
"message": "Vis på Etherscan "
},
"viewinExplorer": {
"message": "Se i Explorer"
},
"visitWebSite": {
"message": "Besøk nettsiden vår "
},

View File

@ -2386,15 +2386,6 @@
"viewMore": {
"message": "Tumingin Pa"
},
"viewOnCustomBlockExplorer": {
"message": "Tingnan sa $1"
},
"viewOnEtherscan": {
"message": "Tingnan sa Etherscan"
},
"viewinExplorer": {
"message": "Tingnan sa Explorer"
},
"visitWebSite": {
"message": "Bisitahin ang aming website"
},

View File

@ -1115,15 +1115,6 @@
"viewContact": {
"message": "Wyświetl kontakt"
},
"viewOnCustomBlockExplorer": {
"message": "Wyświetl w $1"
},
"viewOnEtherscan": {
"message": "Zobacz na Etherscan"
},
"viewinExplorer": {
"message": "Wyświetl w przeglądarce"
},
"visitWebSite": {
"message": "Odwiedź naszą stronę"
},

View File

@ -2386,15 +2386,6 @@
"viewMore": {
"message": "Exibir Mais"
},
"viewOnCustomBlockExplorer": {
"message": "Exibir em $1"
},
"viewOnEtherscan": {
"message": "Exibir no Etherscan"
},
"viewinExplorer": {
"message": "Exibir no Explorer"
},
"visitWebSite": {
"message": "Visite nosso website"
},

View File

@ -1108,15 +1108,6 @@
"viewContact": {
"message": "Vizualizare contact"
},
"viewOnCustomBlockExplorer": {
"message": "Vizualizați la $1"
},
"viewOnEtherscan": {
"message": "Vizualizați pe Etherscan"
},
"viewinExplorer": {
"message": "Vizualizare în Explorator"
},
"visitWebSite": {
"message": "Accesați site-ul nostru"
},

View File

@ -2386,15 +2386,6 @@
"viewMore": {
"message": "Посмотреть больше"
},
"viewOnCustomBlockExplorer": {
"message": "Посмотреть на $1"
},
"viewOnEtherscan": {
"message": "Посмотреть на Etherscan"
},
"viewinExplorer": {
"message": "Проводник в проводнике"
},
"visitWebSite": {
"message": "Посетите наш веб-сайт"
},

View File

@ -1084,15 +1084,6 @@
"viewContact": {
"message": "Zobraziť kontakt"
},
"viewOnCustomBlockExplorer": {
"message": "Zobraziť na $1"
},
"viewOnEtherscan": {
"message": "Zobraziť na Etherscan"
},
"viewinExplorer": {
"message": "Zobraziť v Exploreri"
},
"visitWebSite": {
"message": "Navštivte naši stránku"
},

View File

@ -1112,15 +1112,6 @@
"viewContact": {
"message": "Ogled stika"
},
"viewOnCustomBlockExplorer": {
"message": "Ogled na $1 "
},
"viewOnEtherscan": {
"message": "Poglej na Etherscan"
},
"viewinExplorer": {
"message": "Ogled v Explorerju"
},
"visitWebSite": {
"message": "Obiščite našo spletno stran"
},

View File

@ -1112,15 +1112,6 @@
"viewContact": {
"message": "Pogledaj kontakt"
},
"viewOnCustomBlockExplorer": {
"message": "Pogledaj na $1"
},
"viewOnEtherscan": {
"message": "Pogledaj na Etherscan-u"
},
"viewinExplorer": {
"message": "Pogledati u Explorer-u"
},
"visitWebSite": {
"message": "Posetite našu veb lokaciju"
},

View File

@ -1102,15 +1102,6 @@
"viewContact": {
"message": "Visa kontakt"
},
"viewOnCustomBlockExplorer": {
"message": "Visa vid $1"
},
"viewOnEtherscan": {
"message": "Visa på Etherscan"
},
"viewinExplorer": {
"message": "Visa i Utforskaren"
},
"visitWebSite": {
"message": "Besök vår hemsida"
},

View File

@ -1105,15 +1105,6 @@
"viewContact": {
"message": "Tazama Mawasiliano"
},
"viewOnCustomBlockExplorer": {
"message": "Tazama kwenye $1"
},
"viewOnEtherscan": {
"message": "Tazama kwenye Etherscan"
},
"viewinExplorer": {
"message": "Tazama kwenye Explorer"
},
"visitWebSite": {
"message": "Tembelea Tovuti yetu"
},

View File

@ -1900,15 +1900,6 @@
"viewContact": {
"message": "Tingnan ang Contact"
},
"viewOnCustomBlockExplorer": {
"message": "Tingnan sa $1"
},
"viewOnEtherscan": {
"message": "Tingnan sa Etherscan"
},
"viewinExplorer": {
"message": "Tingnan sa Explorer"
},
"visitWebSite": {
"message": "Bisitahin ang aming website"
},

View File

@ -1127,15 +1127,6 @@
"viewContact": {
"message": "Переглянути контакт"
},
"viewOnCustomBlockExplorer": {
"message": "Дивитись на $1"
},
"viewOnEtherscan": {
"message": "Дивитись на Etherscan"
},
"viewinExplorer": {
"message": "Дивитись в Explorer"
},
"visitWebSite": {
"message": "Відвідайте наш веб-сайт"
},

View File

@ -2386,15 +2386,6 @@
"viewMore": {
"message": "Xem thêm"
},
"viewOnCustomBlockExplorer": {
"message": "Xem tại $1"
},
"viewOnEtherscan": {
"message": "Xem trên Etherscan"
},
"viewinExplorer": {
"message": "Xem trên trình khám phá"
},
"visitWebSite": {
"message": "Truy cập trang web của chúng tôi"
},

View File

@ -1924,15 +1924,6 @@
"viewContact": {
"message": "查看联系人"
},
"viewOnCustomBlockExplorer": {
"message": "在 $1 查看"
},
"viewOnEtherscan": {
"message": "在 Etherscan以太坊浏览器上查看"
},
"viewinExplorer": {
"message": "在浏览器中查看"
},
"visitWebSite": {
"message": "访问我们的网站"
},

View File

@ -1115,15 +1115,6 @@
"viewContact": {
"message": "觀看聯絡資訊"
},
"viewOnCustomBlockExplorer": {
"message": "在 $1 瀏覽"
},
"viewOnEtherscan": {
"message": "在 Etherscan 上瀏覽"
},
"viewinExplorer": {
"message": "在 Explorer 上瀏覽"
},
"visitWebSite": {
"message": "造訪我們的網站"
},

View File

@ -6,9 +6,16 @@
<body>
<script src="./globalthis.js" type="text/javascript" charset="utf-8"></script>
<script src="./sentry-install.js" type="text/javascript" charset="utf-8"></script>
{{@if(it.useLavamoat)}}
<script src="./runtime-lavamoat.js" type="text/javascript" charset="utf-8"></script>
<script src="./lockdown-more.js" type="text/javascript" charset="utf-8"></script>
<script src="./policy-load.js" type="text/javascript" charset="utf-8"></script>
{{#else}}
<script src="./lockdown-install.js" type="text/javascript" charset="utf-8"></script>
<script src="./lockdown-run.js" type="text/javascript" charset="utf-8"></script>
<script src="./lockdown-more.js" type="text/javascript" charset="utf-8"></script>
<script src="./runtime-cjs.js" type="text/javascript" charset="utf-8"></script>
{{/if}}
{{@each(it.jsBundles) => val}}
<script src="{{val}}" type="text/javascript" charset="utf-8"></script>
{{/each}}

View File

@ -12,9 +12,16 @@
<div id="popover-content"></div>
<script src="./globalthis.js" type="text/javascript" charset="utf-8"></script>
<script src="./sentry-install.js" type="text/javascript" charset="utf-8"></script>
{{@if(it.useLavamoat)}}
<script src="./runtime-lavamoat.js" type="text/javascript" charset="utf-8"></script>
<script src="./lockdown-more.js" type="text/javascript" charset="utf-8"></script>
<script src="./policy-load.js" type="text/javascript" charset="utf-8"></script>
{{#else}}
<script src="./lockdown-install.js" type="text/javascript" charset="utf-8"></script>
<script src="./lockdown-run.js" type="text/javascript" charset="utf-8"></script>
<script src="./lockdown-more.js" type="text/javascript" charset="utf-8"></script>
<script src="./runtime-cjs.js" type="text/javascript" charset="utf-8"></script>
{{/if}}
{{@each(it.jsBundles) => val}}
<script src="{{val}}" type="text/javascript" charset="utf-8"></script>
{{/each}}

BIN
app/images/warning-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -35,6 +35,7 @@
"globalthis.js",
"lockdown-install.js",
"lockdown-run.js",
"lockdown-more.js",
"contentscript.js"
],
"run_at": "document_start",

View File

@ -22,6 +22,5 @@
"512": "images/icon-512.png"
},
"name": "__MSG_appName__ Beta",
"short_name": "__MSG_appName__ Beta",
"version": ""
"short_name": "__MSG_appName__ Beta"
}

View File

@ -35,9 +35,16 @@
<div id="popover-content"></div>
<script src="./globalthis.js" type="text/javascript" charset="utf-8"></script>
<script src="./sentry-install.js" type="text/javascript" charset="utf-8"></script>
{{@if(it.useLavamoat)}}
<script src="./runtime-lavamoat.js" type="text/javascript" charset="utf-8"></script>
<script src="./lockdown-more.js" type="text/javascript" charset="utf-8"></script>
<script src="./policy-load.js" type="text/javascript" charset="utf-8"></script>
{{#else}}
<script src="./lockdown-install.js" type="text/javascript" charset="utf-8"></script>
<script src="./lockdown-run.js" type="text/javascript" charset="utf-8"></script>
<script src="./lockdown-more.js" type="text/javascript" charset="utf-8"></script>
<script src="./runtime-cjs.js" type="text/javascript" charset="utf-8"></script>
{{/if}}
{{@each(it.jsBundles) => val}}
<script src="{{val}}" type="text/javascript" charset="utf-8"></script>
{{/each}}

View File

@ -5,6 +5,7 @@
<script src="./globalthis.js" type="text/javascript" charset="utf-8"></script>
<script src="./lockdown-install.js" type="text/javascript" charset="utf-8"></script>
<script src="./lockdown-run.js" type="text/javascript" charset="utf-8"></script>
<script src="./lockdown-more.js" type="text/javascript" charset="utf-8"></script>
<script src="./phishing-detect.js"></script>
<link rel="stylesheet" type="text/css" href="./index.css" title="ltr">
<link rel="stylesheet" type="text/css" href="./index-rtl.css" title="rtl" disabled>

View File

@ -12,9 +12,16 @@
<div id="popover-content"></div>
<script src="./globalthis.js" type="text/javascript" charset="utf-8"></script>
<script src="./sentry-install.js" type="text/javascript" charset="utf-8"></script>
{{@if(it.useLavamoat)}}
<script src="./runtime-lavamoat.js" type="text/javascript" charset="utf-8"></script>
<script src="./lockdown-more.js" type="text/javascript" charset="utf-8"></script>
<script src="./policy-load.js" type="text/javascript" charset="utf-8"></script>
{{#else}}
<script src="./lockdown-install.js" type="text/javascript" charset="utf-8"></script>
<script src="./lockdown-run.js" type="text/javascript" charset="utf-8"></script>
<script src="./lockdown-more.js" type="text/javascript" charset="utf-8"></script>
<script src="./runtime-cjs.js" type="text/javascript" charset="utf-8"></script>
{{/if}}
{{@each(it.jsBundles) => val}}
<script src="{{val}}" type="text/javascript" charset="utf-8"></script>
{{/each}}

View File

@ -405,8 +405,9 @@ export default class TransactionController extends EventEmitter {
* @returns {Promise<object>} resolves with txMeta
*/
async addTxGasDefaults(txMeta, getCodeResponse) {
const eip1559Compatibility = await this.getEIP1559Compatibility();
const eip1559Compatibility =
txMeta.txParams.type !== TRANSACTION_ENVELOPE_TYPES.LEGACY &&
(await this.getEIP1559Compatibility());
const {
gasPrice: defaultGasPrice,
maxFeePerGas: defaultMaxFeePerGas,

View File

@ -525,6 +525,58 @@ describe('Transaction Controller', function () {
stub2.restore();
});
it('should not add maxFeePerGas and maxPriorityFeePerGas to type-0 transactions', async function () {
const TEST_GASPRICE = '0x12a05f200';
const stub1 = sinon
.stub(txController, 'getEIP1559Compatibility')
.returns(true);
const stub2 = sinon
.stub(txController, '_getDefaultGasFees')
.callsFake(() => ({ gasPrice: TEST_GASPRICE }));
txController.txStateManager._addTransactionsToState([
{
id: 1,
status: TRANSACTION_STATUSES.UNAPPROVED,
metamaskNetworkId: currentNetworkId,
txParams: {
to: VALID_ADDRESS,
from: VALID_ADDRESS_TWO,
type: '0x0',
},
history: [{}],
},
]);
const txMeta = {
id: 1,
txParams: {
from: '0xc684832530fcbddae4b4230a47e991ddcec2831d',
to: '0xc684832530fcbddae4b4230a47e991ddcec2831d',
type: '0x0',
},
history: [{}],
};
providerResultStub.eth_getBlockByNumber = { gasLimit: '47b784' };
providerResultStub.eth_estimateGas = '5209';
const txMetaWithDefaults = await txController.addTxGasDefaults(txMeta);
assert.equal(
txMetaWithDefaults.txParams.maxFeePerGas,
undefined,
'should not have maxFeePerGas',
);
assert.equal(
txMetaWithDefaults.txParams.maxPriorityFeePerGas,
undefined,
'should not have max priority fee per gas',
);
stub1.restore();
stub2.restore();
});
it('should not add gasPrice if the fee data is available from the dapp', async function () {
const TEST_GASPRICE = '0x12a05f200';
const TEST_MAX_FEE_PER_GAS = '0x12a05f200';

View File

@ -0,0 +1,91 @@
// Make all "object" and "function" own properties of globalThis
// non-configurable and non-writable, when possible.
// We call a property that is non-configurable and non-writable,
// "non-modifiable".
try {
/**
* `lockdown` only hardens the properties enumerated by the
* universalPropertyNames constant specified in 'ses/src/whitelist'. This
* function makes all function and object properties on the start compartment
* global non-configurable and non-writable, unless they are already
* non-configurable.
*
* It is critical that this function runs at the right time during
* initialization, which should always be immediately after `lockdown` has been
* called. At the time of writing, the modifications this function makes to the
* runtime environment appear to be non-breaking, but that could change with
* the addition of dependencies, or the order of our scripts in our HTML files.
* Exercise caution.
*
* See inline comments for implementation details.
*
* We write this function in IIFE format to avoid polluting global scope.
*/
(function protectIntrinsics() {
const namedIntrinsics = Reflect.ownKeys(new Compartment().globalThis);
// These named intrinsics are not automatically hardened by `lockdown`
const shouldHardenManually = new Set(['eval', 'Function']);
const globalProperties = new Set([
// universalPropertyNames is a constant added by lockdown to global scope
// at the time of writing, it is initialized in 'ses/src/whitelist'.
// These properties tend to be non-enumerable.
...namedIntrinsics,
// TODO: Also include the named platform globals
// This grabs every enumerable property on globalThis.
// ...Object.keys(globalThis),
]);
globalProperties.forEach((propertyName) => {
const descriptor = Reflect.getOwnPropertyDescriptor(
globalThis,
propertyName,
);
if (descriptor) {
if (descriptor.configurable) {
// If the property on globalThis is configurable, make it
// non-configurable. If it has no accessor properties, also make it
// non-writable.
if (hasAccessor(descriptor)) {
Object.defineProperty(globalThis, propertyName, {
configurable: false,
});
} else {
Object.defineProperty(globalThis, propertyName, {
configurable: false,
writable: false,
});
}
}
if (shouldHardenManually.has(propertyName)) {
harden(globalThis[propertyName]);
}
}
});
/**
* Checks whether the given propertyName descriptor has any accessors, i.e. the
* properties `get` or `set`.
*
* We want to make globals non-writable, and we can't set the `writable`
* property and accessor properties at the same time.
*
* @param {Object} descriptor - The propertyName descriptor to check.
* @returns {boolean} Whether the propertyName descriptor has any accessors.
*/
function hasAccessor(descriptor) {
return 'set' in descriptor || 'get' in descriptor;
}
})();
} catch (error) {
console.error('Protecting intrinsics failed:', error);
if (globalThis?.sentry.captureException) {
globalThis.sentry.captureException(
new Error(`Protecting intrinsics failed: ${error.message}`),
);
}
}

View File

@ -20,95 +20,3 @@ try {
);
}
}
// Make all "object" and "function" own properties of globalThis
// non-configurable and non-writable, when possible.
// We call the a property that is non-configurable and non-writable,
// "non-modifiable".
try {
/**
* `lockdown` only hardens the properties enumerated by the
* universalPropertyNames constant specified in 'ses/src/whitelist'. This
* function makes all function and object properties on the start compartment
* global non-configurable and non-writable, unless they are already
* non-configurable.
*
* It is critical that this function runs at the right time during
* initialization, which should always be immediately after `lockdown` has been
* called. At the time of writing, the modifications this function makes to the
* runtime environment appear to be non-breaking, but that could change with
* the addition of dependencies, or the order of our scripts in our HTML files.
* Exercise caution.
*
* See inline comments for implementation details.
*
* We write this function in IIFE format to avoid polluting global scope.
*/
(function protectIntrinsics() {
const namedIntrinsics = Reflect.ownKeys(new Compartment().globalThis);
// These named intrinsics are not automatically hardened by `lockdown`
const shouldHardenManually = new Set(['eval', 'Function']);
const globalProperties = new Set([
// universalPropertyNames is a constant added by lockdown to global scope
// at the time of writing, it is initialized in 'ses/src/whitelist'.
// These properties tend to be non-enumerable.
...namedIntrinsics,
// TODO: Also include the named platform globals
// This grabs every enumerable property on globalThis.
// ...Object.keys(globalThis),
]);
globalProperties.forEach((propertyName) => {
const descriptor = Reflect.getOwnPropertyDescriptor(
globalThis,
propertyName,
);
if (descriptor) {
if (descriptor.configurable) {
// If the property on globalThis is configurable, make it
// non-configurable. If it has no accessor properties, also make it
// non-writable.
if (hasAccessor(descriptor)) {
Object.defineProperty(globalThis, propertyName, {
configurable: false,
});
} else {
Object.defineProperty(globalThis, propertyName, {
configurable: false,
writable: false,
});
}
}
if (shouldHardenManually.has(propertyName)) {
harden(globalThis[propertyName]);
}
}
});
/**
* Checks whether the given propertyName descriptor has any accessors, i.e. the
* properties `get` or `set`.
*
* We want to make globals non-writable, and we can't set the `writable`
* property and accessor properties at the same time.
*
* @param {Object} descriptor - The propertyName descriptor to check.
* @returns {boolean} Whether the propertyName descriptor has any accessors.
*/
function hasAccessor(descriptor) {
return 'set' in descriptor || 'get' in descriptor;
}
})();
} catch (error) {
console.error('Protecting intrinsics failed:', error);
if (globalThis.sentry && globalThis.sentry.captureException) {
globalThis.sentry.captureException(
new Error(`Protecting intrinsics failed: ${error.message}`),
);
}
}

View File

@ -32,6 +32,7 @@ import { TRANSACTION_STATUSES } from '../../shared/constants/transaction';
import {
GAS_API_BASE_URL,
GAS_DEV_API_BASE_URL,
SWAPS_CLIENT_ID,
} from '../../shared/constants/swaps';
import { MAINNET_CHAIN_ID } from '../../shared/constants/network';
import { KEYRING_TYPES } from '../../shared/constants/hardware-wallets';
@ -201,6 +202,7 @@ export default class MetamaskController extends EventEmitter {
this.gasFeeController = new GasFeeController({
interval: 10000,
messenger: gasFeeMessenger,
clientId: SWAPS_CLIENT_ID,
getProvider: () =>
this.networkController.getProviderAndBlockTracker().provider,
onNetworkStateChange: this.networkController.on.bind(

View File

@ -40,8 +40,6 @@ Commands:
e2e tests.
Options:
--beta-version If the build type is "beta", the beta version number.
[number] [default: 0]
--build-type The "type" of build to create. One of: "beta", "main"
[string] [default: "main"]
--lint-fence-files Whether files with code fences should be linted after

View File

@ -5,17 +5,12 @@ const del = require('del');
const pify = require('pify');
const pump = pify(require('pump'));
const { version } = require('../../package.json');
const { createTask, composeParallel } = require('./task');
const { BuildTypes } = require('./utils');
module.exports = createEtcTasks;
function createEtcTasks({
betaVersionsMap,
browserPlatforms,
isBeta,
livereload,
}) {
function createEtcTasks({ browserPlatforms, buildType, livereload }) {
const clean = createTask('clean', async function clean() {
await del(['./dist/*']);
await Promise.all(
@ -33,20 +28,19 @@ function createEtcTasks({
const zip = createTask(
'zip',
composeParallel(
...browserPlatforms.map((platform) =>
createZipTask(platform, isBeta ? betaVersionsMap[platform] : undefined),
),
...browserPlatforms.map((platform) => createZipTask(platform, buildType)),
),
);
return { clean, reload, zip };
}
function createZipTask(platform, betaVersion) {
function createZipTask(platform, buildType) {
return async () => {
const path = betaVersion
? `metamask-BETA-${platform}-${betaVersion}`
: `metamask-${platform}-${version}`;
const path =
buildType === BuildTypes.main
? `metamask-${platform}-${version}`
: `metamask-${buildType}-${platform}-${version}`;
await pump(
gulp.src(`dist/${platform}/**`),
gulpZip(`${path}.zip`),

View File

@ -5,7 +5,6 @@
//
const livereload = require('gulp-livereload');
const minimist = require('minimist');
const { version } = require('../../package.json');
const {
createTask,
composeSeries,
@ -17,7 +16,7 @@ const createScriptTasks = require('./scripts');
const createStyleTasks = require('./styles');
const createStaticAssetTasks = require('./static');
const createEtcTasks = require('./etc');
const { BuildTypes, getNextBetaVersionMap } = require('./utils');
const { BuildTypes, getBrowserVersionMap } = require('./utils');
// packages required dynamically via browserify configuration in dependencies
require('loose-envify');
@ -34,10 +33,8 @@ defineAndRunBuildTasks();
function defineAndRunBuildTasks() {
const {
betaVersion,
buildType,
entryTask,
isBeta,
isLavaMoat,
shouldIncludeLockdown,
shouldLintFenceFiles,
@ -46,26 +43,19 @@ function defineAndRunBuildTasks() {
const browserPlatforms = ['firefox', 'chrome', 'brave', 'opera'];
let betaVersionsMap;
if (isBeta) {
betaVersionsMap = getNextBetaVersionMap(
version,
betaVersion,
browserPlatforms,
);
}
const browserVersionMap = getBrowserVersionMap(browserPlatforms);
const staticTasks = createStaticAssetTasks({
livereload,
browserPlatforms,
shouldIncludeLockdown,
isBeta,
buildType,
});
const manifestTasks = createManifestTasks({
browserPlatforms,
betaVersionsMap,
isBeta,
browserVersionMap,
buildType,
});
const styleTasks = createStyleTasks({ livereload });
@ -81,8 +71,7 @@ function defineAndRunBuildTasks() {
const { clean, reload, zip } = createEtcTasks({
livereload,
browserPlatforms,
betaVersionsMap,
isBeta,
buildType,
});
// build for development (livereload)
@ -146,7 +135,6 @@ function defineAndRunBuildTasks() {
function parseArgv() {
const NamedArgs = {
BetaVersion: 'beta-version',
BuildType: 'build-type',
LintFenceFiles: 'lint-fence-files',
OmitLockdown: 'omit-lockdown',
@ -161,7 +149,6 @@ function parseArgv() {
],
string: [NamedArgs.BuildType],
default: {
[NamedArgs.BetaVersion]: 0,
[NamedArgs.BuildType]: BuildTypes.main,
[NamedArgs.LintFenceFiles]: true,
[NamedArgs.OmitLockdown]: false,
@ -180,11 +167,6 @@ function parseArgv() {
throw new Error('MetaMask build: No entry task specified.');
}
const betaVersion = argv[NamedArgs.BetaVersion];
if (!Number.isInteger(betaVersion) || betaVersion < 0) {
throw new Error(`MetaMask build: Invalid beta version: "${betaVersion}"`);
}
const buildType = argv[NamedArgs.BuildType];
if (!(buildType in BuildTypes)) {
throw new Error(`MetaMask build: Invalid build type: "${buildType}"`);
@ -198,10 +180,8 @@ function parseArgv() {
: !/dev/iu.test(entryTask);
return {
betaVersion: String(betaVersion),
buildType,
entryTask,
isBeta: argv[NamedArgs.BuildType] === BuildTypes.beta,
isLavaMoat: process.argv[0].includes('lavamoat'),
shouldIncludeLockdown: argv[NamedArgs.OmitLockdown],
shouldLintFenceFiles,

View File

@ -3,14 +3,18 @@ const path = require('path');
const { merge, cloneDeep } = require('lodash');
const baseManifest = require('../../app/manifest/_base.json');
const { version } = require('../../package.json');
const betaManifestModifications = require('../../app/manifest/_beta_modifications.json');
const { createTask, composeSeries } = require('./task');
const { BuildTypes } = require('./utils');
module.exports = createManifestTasks;
function createManifestTasks({ betaVersionsMap, browserPlatforms, isBeta }) {
function createManifestTasks({
browserPlatforms,
browserVersionMap,
buildType,
}) {
// merge base manifest with per-platform manifests
const prepPlatforms = async () => {
return Promise.all(
@ -28,9 +32,8 @@ function createManifestTasks({ betaVersionsMap, browserPlatforms, isBeta }) {
const result = merge(
cloneDeep(baseManifest),
platformModifications,
isBeta
? getBetaModifications(platform, betaVersionsMap)
: { version },
browserVersionMap[platform],
getBuildModifications(buildType),
);
const dir = path.join('.', 'dist', platform);
await fs.mkdir(dir, { recursive: true });
@ -109,16 +112,10 @@ async function writeJson(obj, file) {
return fs.writeFile(file, JSON.stringify(obj, null, 2));
}
function getBetaModifications(platform, betaVersionsMap) {
if (!betaVersionsMap || typeof betaVersionsMap !== 'object') {
throw new Error('MetaMask build: Expected object beta versions map.');
function getBuildModifications(buildType) {
const buildModifications = {};
if (buildType === BuildTypes.beta) {
Object.assign(buildModifications, betaManifestModifications);
}
const betaVersion = betaVersionsMap[platform];
return {
...betaManifestModifications,
version: betaVersion,
...(platform === 'firefox' ? {} : { version_name: 'beta' }),
};
return buildModifications;
}

View File

@ -4,6 +4,7 @@ const { writeFileSync, readFileSync } = require('fs');
const EventEmitter = require('events');
const gulp = require('gulp');
const watch = require('gulp-watch');
const Vinyl = require('vinyl');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const log = require('fancy-log');
@ -20,13 +21,15 @@ const endOfStream = pify(require('end-of-stream'));
const labeledStreamSplicer = require('labeled-stream-splicer').obj;
const wrapInStream = require('pumpify').obj;
const Sqrl = require('squirrelly');
const lavaPack = require('@lavamoat/lavapack');
const lavapack = require('@lavamoat/lavapack');
const lavamoatBrowserify = require('lavamoat-browserify');
const terser = require('terser');
const bifyModuleGroups = require('bify-module-groups');
const metamaskrc = require('rc')('metamask', {
INFURA_PROJECT_ID: process.env.INFURA_PROJECT_ID,
ONBOARDING_V2: process.env.ONBOARDING_V2,
SEGMENT_HOST: process.env.SEGMENT_HOST,
SEGMENT_WRITE_KEY: process.env.SEGMENT_WRITE_KEY,
SEGMENT_LEGACY_WRITE_KEY: process.env.SEGMENT_LEGACY_WRITE_KEY,
@ -259,7 +262,22 @@ function createFactoredBuild({
// set bundle entries
bundlerOpts.entries = [...entryFiles];
// setup lavamoat
// lavamoat will add lavapack but it will be removed by bify-module-groups
// we will re-add it later by installing a lavapack runtime
const lavamoatOpts = {
policy: path.resolve(__dirname, '../../lavamoat/browserify/policy.json'),
policyOverride: path.resolve(
__dirname,
'../../lavamoat/browserify/policy-override.json',
),
writeAutoPolicy: process.env.WRITE_AUTO_POLICY,
};
Object.assign(bundlerOpts, lavamoatBrowserify.args);
bundlerOpts.plugin.push([lavamoatBrowserify, lavamoatOpts]);
// setup bundle factoring with bify-module-groups plugin
// note: this will remove lavapack, but its ok bc we manually readd it later
Object.assign(bundlerOpts, bifyModuleGroups.plugin.args);
bundlerOpts.plugin = [...bundlerOpts.plugin, [bifyModuleGroups.plugin]];
@ -281,18 +299,24 @@ function createFactoredBuild({
groupingMap: sizeGroupMap,
}),
);
pipeline.get('vinyl').unshift(
// convert each module group into a stream with a single vinyl file
streamFlatMap((moduleGroup) => {
// converts each module group into a single vinyl file containing its bundle
const moduleGroupPackerStream = streamFlatMap((moduleGroup) => {
const filename = `${moduleGroup.label}.js`;
const childStream = wrapInStream(
moduleGroup.stream,
lavaPack({ raw: true, hasExports: true, includePrelude: false }),
// we manually readd lavapack here bc bify-module-groups removes it
lavapack({ raw: true, hasExports: true, includePrelude: false }),
source(filename),
);
return childStream;
});
pipeline.get('vinyl').unshift(moduleGroupPackerStream, buffer());
// add lavamoat policy loader file to packer output
moduleGroupPackerStream.push(
new Vinyl({
path: 'policy-load.js',
contents: lavapack.makePolicyLoaderStream(lavamoatOpts),
}),
buffer(),
);
// setup bundle destination
browserPlatforms.forEach((platform) => {
@ -306,36 +330,58 @@ function createFactoredBuild({
const commonSet = sizeGroupMap.get('common');
// create entry points for each file
for (const [groupLabel, groupSet] of sizeGroupMap.entries()) {
// skip "common" group, they are added tp all other groups
// skip "common" group, they are added to all other groups
if (groupSet === commonSet) continue;
switch (groupLabel) {
case 'ui': {
renderHtmlFile('popup', groupSet, commonSet, browserPlatforms);
renderHtmlFile(
'notification',
renderHtmlFile({
htmlName: 'popup',
groupSet,
commonSet,
browserPlatforms,
);
renderHtmlFile('home', groupSet, commonSet, browserPlatforms);
useLavamoat: false,
});
renderHtmlFile({
htmlName: 'notification',
groupSet,
commonSet,
browserPlatforms,
useLavamoat: false,
});
renderHtmlFile({
htmlName: 'home',
groupSet,
commonSet,
browserPlatforms,
useLavamoat: false,
});
break;
}
case 'background': {
renderHtmlFile('background', groupSet, commonSet, browserPlatforms);
break;
}
case 'content-script': {
renderHtmlFile(
'trezor-usb-permissions',
renderHtmlFile({
htmlName: 'background',
groupSet,
commonSet,
browserPlatforms,
);
useLavamoat: false,
});
break;
}
case 'content-script': {
renderHtmlFile({
htmlName: 'trezor-usb-permissions',
groupSet,
commonSet,
browserPlatforms,
useLavamoat: false,
});
break;
}
default: {
throw new Error(`buildsys - unknown groupLabel "${groupLabel}"`);
throw new Error(
`build/scripts - unknown groupLabel "${groupLabel}"`,
);
}
}
}
@ -612,6 +658,7 @@ function getEnvironmentVariables({ buildType, devMode, testing }) {
? process.env.SEGMENT_PROD_LEGACY_WRITE_KEY
: metamaskrc.SEGMENT_LEGACY_WRITE_KEY,
SWAPS_USE_DEV_APIS: process.env.SWAPS_USE_DEV_APIS === '1',
ONBOARDING_V2: metamaskrc.ONBOARDING_V2 === '1',
};
}
@ -635,13 +682,24 @@ function getEnvironment({ devMode, testing }) {
return 'other';
}
function renderHtmlFile(htmlName, groupSet, commonSet, browserPlatforms) {
function renderHtmlFile({
htmlName,
groupSet,
commonSet,
browserPlatforms,
useLavamoat,
}) {
if (useLavamoat === undefined) {
throw new Error(
'build/scripts/renderHtmlFile - must specify "useLavamoat" option',
);
}
const htmlFilePath = `./app/${htmlName}.html`;
const htmlTemplate = readFileSync(htmlFilePath, 'utf8');
const jsBundles = [...commonSet.values(), ...groupSet.values()].map(
(label) => `./${label}.js`,
);
const htmlOutput = Sqrl.render(htmlTemplate, { jsBundles });
const htmlOutput = Sqrl.render(htmlTemplate, { jsBundles, useLavamoat });
browserPlatforms.forEach((platform) => {
const dest = `./dist/${platform}/${htmlName}.html`;
// we dont have a way of creating async events atm

View File

@ -6,6 +6,7 @@ const glob = require('fast-glob');
const locales = require('../../app/_locales/index.json');
const { createTask, composeSeries } = require('./task');
const { BuildTypes } = require('./utils');
const EMPTY_JS_FILE = './development/empty.js';
@ -13,26 +14,30 @@ module.exports = function createStaticAssetTasks({
livereload,
browserPlatforms,
shouldIncludeLockdown = true,
isBeta,
buildType,
}) {
const [copyTargetsProd, copyTargetsDev] = getCopyTargets(
shouldIncludeLockdown,
);
const copyTargetsBeta = [
...copyTargetsProd,
const additionalBuildTargets = {
[BuildTypes.beta]: [
{
src: './app/build-types/beta/',
dest: `images`,
},
];
],
};
const targets = isBeta ? copyTargetsBeta : copyTargetsProd;
if (Object.keys(additionalBuildTargets).includes(buildType)) {
copyTargetsProd.push(...additionalBuildTargets[buildType]);
copyTargetsDev.push(...additionalBuildTargets[buildType]);
}
const prod = createTask(
'static:prod',
composeSeries(
...targets.map((target) => {
...copyTargetsProd.map((target) => {
return async function copyStaticAssets() {
await performCopy(target);
};
@ -143,11 +148,22 @@ function getCopyTargets(shouldIncludeLockdown) {
: EMPTY_JS_FILE,
dest: `lockdown-run.js`,
},
{
src: shouldIncludeLockdown
? `./app/scripts/lockdown-more.js`
: EMPTY_JS_FILE,
dest: `lockdown-more.js`,
},
{
// eslint-disable-next-line node/no-extraneous-require
src: require.resolve('@lavamoat/lavapack/src/runtime-cjs.js'),
dest: `runtime-cjs.js`,
},
{
// eslint-disable-next-line node/no-extraneous-require
src: require.resolve('@lavamoat/lavapack/src/runtime.js'),
dest: `runtime-lavamoat.js`,
},
{
src: `./app/phishing.html`,
dest: `phishing.html`,

View File

@ -1,24 +1,5 @@
/**
* @returns {Object} An object with browser as key and next version of beta
* as the value. E.g. { firefox: '9.6.0.beta0', chrome: '9.6.0.1' }
*/
function getNextBetaVersionMap(currentVersion, betaVersion, platforms) {
const [major, minor] = currentVersion.split('.');
return platforms.reduce((platformMap, platform) => {
platformMap[platform] = [
// Keeps the current major
major,
// Bump the minor version
Number(minor) + 1,
// This isn't typically used
0,
// The beta number
`${platform === 'firefox' ? 'beta' : ''}${betaVersion}`,
].join('.');
return platformMap;
}, {});
}
const semver = require('semver');
const { version } = require('../../package.json');
const BuildTypes = {
beta: 'beta',
@ -26,7 +7,57 @@ const BuildTypes = {
main: 'main',
};
/**
* Map the current version to a format that is compatible with each browser.
*
* The given version number is assumed to be a SemVer version number. Additionally, if the version
* has a prerelease component, it is assumed to have the format "<build type>.<build version",
* where the build version is a positive integer.
*
* @param {string} currentVersion - The current version.
* @param {string[]} platforms - A list of browsers to generate versions for.
* @returns {Object} An object with the browser as the key and the browser-specific version object
* as the value. For example, the version `9.6.0-beta.1` would return the object
* `{ firefox: { version: '9.6.0.beta1' }, chrome: { version: '9.6.0.1', version_name: 'beta' } }`.
*/
function getBrowserVersionMap(platforms) {
const major = semver.major(version);
const minor = semver.minor(version);
const patch = semver.patch(version);
const prerelease = semver.prerelease(version);
let buildType;
let buildVersion;
if (prerelease) {
if (prerelease.length !== 2) {
throw new Error(`Invalid prerelease version: '${prerelease.join('.')}'`);
}
[buildType, buildVersion] = prerelease;
if (!String(buildVersion).match(/^\d+$/u)) {
throw new Error(`Invalid prerelease build version: '${buildVersion}'`);
} else if (buildType !== BuildTypes.beta) {
throw new Error(`Invalid prerelease build type: ${buildType}`);
}
}
return platforms.reduce((platformMap, platform) => {
const versionParts = [major, minor, patch];
const browserSpecificVersion = {};
if (prerelease) {
if (platform === 'firefox') {
versionParts.push(`${buildType}${buildVersion}`);
} else {
versionParts.push(buildVersion);
browserSpecificVersion.version_name = buildType;
}
}
browserSpecificVersion.version = versionParts.join('.');
platformMap[platform] = browserSpecificVersion;
return platformMap;
}, {});
}
module.exports = {
BuildTypes,
getNextBetaVersionMap,
getBrowserVersionMap,
};

View File

@ -0,0 +1,55 @@
{
"resources": {
"browser-resolve": {
"packages": {
"core-js": true
}
},
"babel-runtime": {
"packages": {
"@babel/runtime": true
}
},
"node-fetch": {
"globals": {
"fetch": true
}
},
"lodash": {
"globals": {
"setTimeout": true,
"clearTimeout": true
}
},
"@ethersproject/random": {
"globals": {
"crypto.getRandomValues": true
}
},
"browser-passworder": {
"globals": {
"crypto": true
}
},
"randombytes": {
"globals": {
"crypto.getRandomValues": true
}
},
"extensionizer": {
"globals": {
"console": true
}
},
"web3": {
"globals": {
"XMLHttpRequest": true
}
},
"storage": {
"globals": {
"localStorage": true
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -824,8 +824,8 @@
"@gulp-sourcemaps/identity-map": {
"packages": {
"acorn": true,
"css": true,
"normalize-path": true,
"postcss": true,
"source-map": true,
"through2": true
}
@ -840,18 +840,22 @@
"builtin": {
"assert": true,
"buffer.Buffer.from": true,
"fs.readFileSync": true,
"path.join": true,
"path.relative": true
},
"globals": {
"__dirname": true,
"process.cwd": true
"process.cwd": true,
"setTimeout": true
},
"packages": {
"JSONStream": true,
"combine-source-map": true,
"convert-source-map": true,
"json-stable-stringify": true,
"lavamoat-core": true,
"readable-stream": true,
"through2": true,
"umd": true
}
@ -962,15 +966,6 @@
"uri-js": true
}
},
"amdefine": {
"builtin": {
"path.dirname": true
},
"globals": {
"__filename": true,
"process.nextTick": true
}
},
"ansi-colors": {
"packages": {
"ansi-wrap": true
@ -1407,6 +1402,15 @@
"buffer.Buffer": true
}
},
"clone-deep": {
"packages": {
"for-own": true,
"is-plain-object": true,
"kind-of": true,
"lazy-cache": true,
"shallow-clone": true
}
},
"clone-regexp": {
"packages": {
"is-regexp": true
@ -1465,6 +1469,7 @@
"concat-stream": {
"globals": {
"Buffer.concat": true,
"Buffer.from": true,
"Buffer.isBuffer": true
},
"packages": {
@ -1481,7 +1486,7 @@
"path.resolve": true
},
"globals": {
"Buffer": true
"Buffer.from": true
},
"packages": {
"safe-buffer": true
@ -1540,13 +1545,13 @@
"css": {
"builtin": {
"fs.readFileSync": true,
"path.dirname": true
"path.dirname": true,
"path.sep": true
},
"packages": {
"inherits": true,
"source-map": true,
"source-map-resolve": true,
"urix": true
"source-map-resolve": true
}
},
"d": {
@ -2436,7 +2441,8 @@
"path.sep": true
},
"globals": {
"Buffer": true
"Buffer.concat": true,
"Buffer.from": true
},
"packages": {
"@gulp-sourcemaps/identity-map": true,
@ -2595,7 +2601,7 @@
},
"inline-source-map": {
"globals": {
"Buffer": true
"Buffer.from": true
},
"packages": {
"source-map": true
@ -2820,6 +2826,70 @@
"es6-weak-map": true
}
},
"lavamoat-browserify": {
"builtin": {
"fs.existsSync": true,
"fs.mkdirSync": true,
"fs.readFileSync": true,
"fs.writeFileSync": true,
"path.dirname": true,
"path.extname": true,
"path.resolve": true,
"util.callbackify": true
},
"globals": {
"console.warn": true,
"process.cwd": true
},
"packages": {
"@lavamoat/lavapack": true,
"concat-stream": true,
"duplexify": true,
"json-stable-stringify": true,
"lavamoat-core": true,
"readable-stream": true,
"through2": true
}
},
"lavamoat-core": {
"builtin": {
"events": true,
"fs.existsSync": true,
"fs.readFileSync": true,
"module.createRequire": true,
"module.createRequireFromPath": true,
"path.extname": true,
"path.join": true,
"path.sep": true
},
"globals": {
"__dirname": true,
"console.warn": true,
"define": true
},
"packages": {
"fromentries": true,
"json-stable-stringify": true,
"lavamoat-tofu": true,
"merge-deep": true,
"resolve": true
}
},
"lavamoat-tofu": {
"globals": {
"console.log": true
},
"packages": {
"@babel/parser": true,
"@babel/traverse": true
}
},
"lazy-cache": {
"globals": {
"process.env.TRAVIS": true,
"process.env.UNLAZY": true
}
},
"lazystream": {
"builtin": {
"util.inherits": true
@ -2870,6 +2940,11 @@
"js-tokens": true
}
},
"lru-cache": {
"packages": {
"yallist": true
}
},
"lru-queue": {
"packages": {
"es5-ext": true
@ -2936,6 +3011,13 @@
"timers-ext": true
}
},
"merge-deep": {
"packages": {
"arr-union": true,
"clone-deep": true,
"kind-of": true
}
},
"merge-source-map": {
"packages": {
"source-map": true
@ -3000,6 +3082,12 @@
"is-extendable": true
}
},
"mixin-object": {
"packages": {
"for-in": true,
"is-extendable": true
}
},
"mkdirp": {
"builtin": {
"fs": true,
@ -3732,6 +3820,9 @@
"globals": {
"console": true,
"process": true
},
"packages": {
"lru-cache": true
}
},
"set-value": {
@ -3742,6 +3833,14 @@
"split-string": true
}
},
"shallow-clone": {
"packages": {
"is-extendable": true,
"kind-of": true,
"lazy-cache": true,
"mixin-object": true
}
},
"shasum": {
"builtin": {
"buffer.Buffer.isBuffer": true,
@ -3816,16 +3915,15 @@
"console.time": true,
"console.timeEnd": true,
"fetch": true
},
"packages": {
"amdefine": true
}
},
"source-map-resolve": {
"builtin": {
"path.sep": true,
"url.resolve": true
},
"globals": {
"TextDecoder": true,
"setImmediate": true
},
"packages": {

View File

@ -24,9 +24,10 @@
"dapp-chain": "GANACHE_ARGS='-b 2' concurrently -k -n ganache,dapp -p '[{time}][{name}]' 'yarn ganache:start' 'sleep 5 && yarn dapp'",
"forwarder": "node ./development/static-server.js ./node_modules/@metamask/forwarder/dist/ --port 9010",
"dapp-forwarder": "concurrently -k -n forwarder,dapp -p '[{time}][{name}]' 'yarn forwarder' 'yarn dapp'",
"test:unit": "mocha --exit --require test/env.js --require test/setup.js --recursive './app/**/*.test.js'",
"test:unit": "./test/test-unit-combined.sh",
"test:unit:jest": "./test/test-unit-jest.sh",
"test:unit:global": "mocha --exit --require test/env.js --require test/setup.js --recursive test/unit-global/*.test.js",
"test:unit:jest": "./test/run-jest.sh",
"test:unit:mocha": "mocha --exit --require test/env.js --require test/setup.js --ignore './app/scripts/migrations/*.test.js' --recursive './app/**/*.test.js'",
"test:unit:lax": "mocha --exit --require test/env.js --require test/setup.js --ignore './app/scripts/controllers/permissions/*.test.js' --ignore './app/scripts/migrations/*.test.js' --recursive './app/**/*.test.js'",
"test:unit:strict": "mocha --exit --require test/env.js --require test/setup.js --recursive './app/scripts/controllers/permissions/*.test.js'",
"test:unit:path": "mocha --exit --require test/env.js --require test/setup.js --recursive",
@ -64,11 +65,14 @@
"storybook:deploy": "storybook-to-ghpages --existing-output-dir storybook-build --remote storybook --branch master",
"update-changelog": "auto-changelog update",
"generate:migration": "./development/generate-migration.sh",
"lavamoat:auto": "lavamoat ./development/build/index.js --writeAutoPolicy",
"lavamoat:debug": "lavamoat ./development/build/index.js --writeAutoPolicyDebug"
"lavamoat:build:auto": "lavamoat ./development/build/index.js --writeAutoPolicy",
"lavamoat:debug:build": "lavamoat ./development/build/index.js --writeAutoPolicyDebug",
"lavamoat:background:auto": "WRITE_AUTO_POLICY=1 yarn build prod",
"lavamoat:auto": "yarn lavamoat:build:auto && yarn lavamoat:background:auto"
},
"resolutions": {
"**/regenerator-runtime": "^0.13.7",
"**/caniuse-lite": "1.0.30001265",
"**/configstore/dot-prop": "^5.1.1",
"**/ethers/elliptic": "^6.5.4",
"**/knex/minimist": "^1.2.5",
@ -102,7 +106,7 @@
"@fortawesome/fontawesome-free": "^5.13.0",
"@material-ui/core": "^4.11.0",
"@metamask/contract-metadata": "^1.28.0",
"@metamask/controllers": "^16.0.0",
"@metamask/controllers": "^17.0.0",
"@metamask/eth-ledger-bridge-keyring": "^0.7.0",
"@metamask/eth-token-tracker": "^3.0.1",
"@metamask/etherscan-link": "^2.1.0",
@ -216,7 +220,7 @@
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.5.5",
"@lavamoat/allow-scripts": "^1.0.6",
"@lavamoat/lavapack": "^1.0.4",
"@lavamoat/lavapack": "^2.0.3",
"@metamask/auto-changelog": "^2.1.0",
"@metamask/eslint-config": "^6.0.0",
"@metamask/eslint-config-jest": "^6.0.0",
@ -278,7 +282,7 @@
"gulp-livereload": "4.0.0",
"gulp-rename": "^2.0.0",
"gulp-rtlcss": "^1.4.0",
"gulp-sourcemaps": "^2.6.0",
"gulp-sourcemaps": "^3.0.0",
"gulp-stylelint": "^13.0.0",
"gulp-watch": "^5.0.1",
"gulp-zip": "^4.0.0",
@ -287,7 +291,8 @@
"jest": "^26.6.3",
"jsdom": "^11.2.0",
"koa": "^2.7.0",
"lavamoat": "^5.3.1",
"lavamoat": "^5.3.4",
"lavamoat-browserify": "^14.0.3",
"lavamoat-viz": "^6.0.9",
"lockfile-lint": "^4.0.0",
"loose-envify": "^1.4.0",
@ -312,6 +317,7 @@
"sass": "^1.32.4",
"sass-loader": "^10.1.1",
"selenium-webdriver": "4.0.0-alpha.7",
"semver": "^7.3.5",
"serve-handler": "^6.1.2",
"sinon": "^9.0.0",
"source-map": "^0.7.2",
@ -323,6 +329,7 @@
"terser": "^5.7.0",
"through2": "^4.0.2",
"ttest": "^2.1.1",
"vinyl": "^2.2.1",
"vinyl-buffer": "^1.0.1",
"vinyl-source-stream": "^2.0.0",
"vinyl-sourcemaps-apply": "^0.2.1",

View File

@ -0,0 +1,18 @@
diff --git a/node_modules/abort-controller/browser.js b/node_modules/abort-controller/browser.js
index b0c5ec3..c8c8018 100644
--- a/node_modules/abort-controller/browser.js
+++ b/node_modules/abort-controller/browser.js
@@ -2,12 +2,7 @@
"use strict"
/*eslint-disable @mysticatea/prettier */
-const { AbortController, AbortSignal } =
- typeof self !== "undefined" ? self :
- typeof window !== "undefined" ? window :
- /* otherwise */ undefined
+const { AbortController } = globalThis;
/*eslint-enable @mysticatea/prettier */
module.exports = AbortController
-module.exports.AbortSignal = AbortSignal
-module.exports.default = AbortController

View File

@ -0,0 +1,22 @@
diff --git a/node_modules/combine-source-map/node_modules/convert-source-map/index.js b/node_modules/combine-source-map/node_modules/convert-source-map/index.js
index bfe92d1..bee1ffe 100644
--- a/node_modules/combine-source-map/node_modules/convert-source-map/index.js
+++ b/node_modules/combine-source-map/node_modules/convert-source-map/index.js
@@ -9,7 +9,7 @@ var mapFileCommentRx =
/(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/){1}[ \t]*$)/mg
function decodeBase64(base64) {
- return new Buffer(base64, 'base64').toString();
+ return Buffer.from(base64, 'base64').toString();
}
function stripComment(sm) {
@@ -60,7 +60,7 @@ Converter.prototype.toJSON = function (space) {
Converter.prototype.toBase64 = function () {
var json = this.toJSON();
- return new Buffer(json).toString('base64');
+ return Buffer.from(json).toString('base64');
};
Converter.prototype.toComment = function (options) {

View File

@ -0,0 +1,44 @@
diff --git a/node_modules/gulp-sourcemaps/src/init/index.internals.js b/node_modules/gulp-sourcemaps/src/init/index.internals.js
index 7104555..7dfe218 100644
--- a/node_modules/gulp-sourcemaps/src/init/index.internals.js
+++ b/node_modules/gulp-sourcemaps/src/init/index.internals.js
@@ -72,7 +72,7 @@ module.exports = function(options, file, fileContent) {
});
// remove source map comment from source
- file.contents = new Buffer(sources.content, 'utf8');
+ file.contents = Buffer.from(sources.content, 'utf8');
}
}
diff --git a/node_modules/gulp-sourcemaps/src/write/index.internals.js b/node_modules/gulp-sourcemaps/src/write/index.internals.js
index 89cee60..adfe8d1 100644
--- a/node_modules/gulp-sourcemaps/src/write/index.internals.js
+++ b/node_modules/gulp-sourcemaps/src/write/index.internals.js
@@ -99,7 +99,7 @@ module.exports = function(destPath, options) {
if (destPath === undefined || destPath === null) {
// encode source map into comment
- var base64Map = new Buffer(JSON.stringify(sourceMap)).toString('base64');
+ var base64Map = Buffer.from(JSON.stringify(sourceMap)).toString('base64');
comment = commentFormatter('data:application/json;charset=' + options.charset + ';base64,' + base64Map);
} else {
var mapFile = path.join(destPath, file.relative) + '.map';
@@ -130,7 +130,7 @@ module.exports = function(destPath, options) {
var sourceMapFile = file.clone(options.clone || { deep: false, contents: false });
sourceMapFile.path = sourceMapPath;
- sourceMapFile.contents = new Buffer(JSON.stringify(sourceMap));
+ sourceMapFile.contents = Buffer.from(JSON.stringify(sourceMap));
sourceMapFile.stat = {
isFile: function() { return true; },
isDirectory: function() { return false; },
@@ -164,7 +164,7 @@ module.exports = function(destPath, options) {
// append source map comment
if (options.addComment) {
- file.contents = Buffer.concat([file.contents, new Buffer(comment)]);
+ file.contents = Buffer.concat([file.contents, Buffer.from(comment)]);
}
}

View File

@ -0,0 +1,13 @@
diff --git a/node_modules/inline-source-map/index.js b/node_modules/inline-source-map/index.js
index df74d61..7641aad 100644
--- a/node_modules/inline-source-map/index.js
+++ b/node_modules/inline-source-map/index.js
@@ -91,7 +91,7 @@ Generator.prototype.addSourceContent = function (sourceFile, sourcesContent) {
*/
Generator.prototype.base64Encode = function () {
var map = this.toString();
- return new Buffer(map).toString('base64');
+ return Buffer.from(map).toString('base64');
};
/**

View File

@ -1,5 +1,5 @@
diff --git a/node_modules/regenerator-runtime/runtime.js b/node_modules/regenerator-runtime/runtime.js
index 547b8c6..c53a471 100644
index 547b8c6..885626e 100644
--- a/node_modules/regenerator-runtime/runtime.js
+++ b/node_modules/regenerator-runtime/runtime.js
@@ -5,7 +5,7 @@
@ -65,3 +65,12 @@ index 547b8c6..c53a471 100644
function pushTryEntry(locs) {
var entry = { tryLoc: locs[0] };
@@ -733,7 +734,7 @@ var runtime = (function (exports) {
));
try {
- regeneratorRuntime = runtime;
+ globalThis.regeneratorRuntime = runtime;
} catch (accidentalStrictMode) {
// This module should not be running in strict mode, so the above
// assignment should always work unless something is misconfigured. Just

View File

@ -177,3 +177,5 @@ export const ETHEREUM = 'ethereum';
export const POLYGON = 'polygon';
export const BSC = 'bsc';
export const RINKEBY = 'rinkeby';
export const SWAPS_CLIENT_ID = 'extension';

View File

@ -31,6 +31,11 @@
"name": "Test Account 2"
}
},
"networkDetails": {
"EIPS": {
"1559": true
}
},
"cachedBalances": {},
"incomingTransactions": {},
"unapprovedTxs": {

View File

@ -130,7 +130,7 @@ async function withFixtures(options, testSuite) {
if (webDriver) {
await webDriver.quit();
}
if (dappServer) {
if (dappServer && dappServer.listening) {
await new Promise((resolve, reject) => {
dappServer.close((error) => {
if (error) {

View File

@ -100,7 +100,7 @@ describe('MetaMask', function () {
});
it('clicks the "No thanks" option on the metametrics opt-in screen', async function () {
await driver.clickElement('.btn-default');
await driver.clickElement('.btn-secondary');
await driver.delay(largeDelayMs);
});

View File

@ -1,15 +0,0 @@
#!/usr/bin/env bash
set -x
set -e
set -u
set -o pipefail
readonly __DIR__=$( cd "${BASH_SOURCE[0]%/*}" && pwd )
for spec in "${__DIR__}"/tests/*.spec.js
do
node "${__DIR__}/run-e2e-test.js" "${spec}"
done
node "${__DIR__}/run-e2e-test.js" "${__DIR__}/metamask-ui.spec.js"

View File

@ -1,5 +1,5 @@
const { strict: assert } = require('assert');
const { withFixtures } = require('../helpers');
const { withFixtures, regularDelayMs } = require('../helpers');
describe('Deploy contract and call contract methods', function () {
let windowHandles;
@ -32,6 +32,7 @@ describe('Deploy contract and call contract methods', function () {
await driver.openNewPage('http://127.0.0.1:8080/');
await driver.clickElement({ text: 'Connect', tag: 'button' });
await driver.waitUntilXWindowHandles(3);
await driver.delay(5000);
windowHandles = await driver.getAllWindowHandles();
extension = windowHandles[0];
dapp = await driver.switchToWindowWithTitle(
@ -86,11 +87,13 @@ describe('Deploy contract and call contract methods', function () {
await driver.switchToWindow(dapp);
await driver.clickElement('#depositButton');
await driver.waitUntilXWindowHandles(3);
await driver.delay(5000);
windowHandles = await driver.getAllWindowHandles();
await driver.switchToWindowWithTitle(
'MetaMask Notification',
windowHandles,
);
await driver.delay(regularDelayMs);
await driver.clickElement({ text: 'Confirm', tag: 'button' });
await driver.waitUntilXWindowHandles(2);
await driver.switchToWindow(extension);
@ -110,11 +113,13 @@ describe('Deploy contract and call contract methods', function () {
await driver.switchToWindow(dapp);
await driver.clickElement('#withdrawButton');
await driver.waitUntilXWindowHandles(3);
await driver.delay(5000);
windowHandles = await driver.getAllWindowHandles();
await driver.switchToWindowWithTitle(
'MetaMask Notification',
windowHandles,
);
await driver.delay(regularDelayMs);
await driver.clickElement({ text: 'Confirm', tag: 'button' });
await driver.waitUntilXWindowHandles(2);
await driver.switchToWindow(extension);

View File

@ -48,7 +48,7 @@ describe('Stores custom RPC history', function () {
await chainIdInput.clear();
await chainIdInput.sendKeys(chainId.toString());
await driver.clickElement('.network-form__footer .btn-secondary');
await driver.clickElement('.network-form__footer .btn-primary');
await driver.findElement({ text: networkName, tag: 'span' });
},
);
@ -192,7 +192,7 @@ describe('Stores custom RPC history', function () {
await driver.clickElement({ text: 'Custom RPC', tag: 'span' });
// cancel new custom rpc
await driver.clickElement('.network-form__footer button.btn-default');
await driver.clickElement('.network-form__footer button.btn-secondary');
const networkListItems = await driver.findClickableElements(
'.networks-tab__networks-list-name',
@ -209,7 +209,7 @@ describe('Stores custom RPC history', function () {
);
await driver.clickElement(
'.button.btn-danger.modal-container__footer-button',
'.button.btn-danger-primary.modal-container__footer-button',
);
// wait for confirm delete modal to be removed from DOM.

View File

@ -38,7 +38,7 @@ describe('Metamask Import UI', function () {
await driver.clickElement({ text: 'Import wallet', tag: 'button' });
// clicks the "No thanks" option on the metametrics opt-in screen
await driver.clickElement('.btn-default');
await driver.clickElement('.btn-secondary');
// Import Secret Recovery Phrase
await driver.fill(

View File

@ -42,7 +42,7 @@ describe('Incremental Security', function () {
await driver.clickElement({ text: 'Create a Wallet', tag: 'button' });
// clicks the "No thanks" option on the metametrics opt-in screen
await driver.clickElement('.btn-default');
await driver.clickElement('.btn-secondary');
// accepts a secure password
await driver.fill(

View File

@ -16,13 +16,10 @@ class ChromeDriver {
.setChromeOptions(options);
const service = new chrome.ServiceBuilder();
// Enables Chrome logging.
// Enables Chrome logging. Default: enabled
// Especially useful for discovering why Chrome has crashed, but can also
// be useful for revealing console errors (from the page or background).
if (
process.env.ENABLE_CHROME_LOGGING &&
process.env.ENABLE_CHROME_LOGGING !== 'false'
) {
if (process.env.ENABLE_CHROME_LOGGING !== 'false') {
service.setStdio('inherit').enableChromeLogging();
}
if (port) {

View File

@ -277,13 +277,13 @@ class Driver {
async switchToWindowWithTitle(
title,
windowHandles,
initialWindowHandles,
delayStep = 1000,
timeout = 5000,
) {
let windowHandles =
initialWindowHandles || (await this.driver.getAllWindowHandles());
let timeElapsed = 0;
// eslint-disable-next-line no-param-reassign
windowHandles = windowHandles || (await this.driver.getAllWindowHandles());
while (timeElapsed <= timeout) {
for (const handle of windowHandles) {
await this.driver.switchTo().window(handle);
@ -294,6 +294,8 @@ class Driver {
}
await this.delay(delayStep);
timeElapsed += delayStep;
// refresh the window handles
windowHandles = await this.driver.getAllWindowHandles();
}
throw new Error(`No window with title: ${title}`);

11
test/test-unit-combined.sh Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -x
set -e
set -u
set -o pipefail
concurrently --raw -n mocha,jest,global \
"yarn test:unit:mocha" \
"yarn test:unit:jest" \
"yarn test:unit:global"

View File

@ -5,6 +5,6 @@ set -e
set -u
set -o pipefail
concurrently \
concurrently -n production,development \
"jest --config=./jest.config.js $*" \
"jest --config=./development/jest.config.js $*"

View File

@ -1,5 +1,6 @@
import 'ses/lockdown';
import '../../app/scripts/lockdown-run';
import '../../app/scripts/lockdown-more';
import { strict as assert } from 'assert';
// These are Agoric inventions, and we don't care about them.

View File

@ -19,6 +19,7 @@ import {
} from '../../../helpers/constants/routes';
import TextField from '../../ui/text-field';
import SearchIcon from '../../ui/search-icon';
import Button from '../../ui/button';
import { isBeta } from '../../../helpers/utils/build-types';
@ -324,7 +325,7 @@ export default class AccountMenu extends Component {
<div className="account-menu__close-area" onClick={toggleAccountMenu} />
<AccountMenuItem className="account-menu__header">
{t('myAccounts')}
<button
<Button
className="account-menu__lock-button"
onClick={() => {
lockMetamask();
@ -332,7 +333,7 @@ export default class AccountMenu extends Component {
}}
>
{t('lock')}
</button>
</Button>
</AccountMenuItem>
<div className="account-menu__divider" />
<div className="account-menu__accounts-container">

View File

@ -3,6 +3,7 @@ import sinon from 'sinon';
import configureMockStore from 'redux-mock-store';
import { Provider } from 'react-redux';
import { mountWithRouter } from '../../../../test/lib/render-helpers';
import Button from '../../ui/button';
import AccountMenu from '.';
describe('Account Menu', () => {
@ -103,7 +104,7 @@ describe('Account Menu', () => {
let logout;
it('logout', () => {
logout = wrapper.find('.account-menu__lock-button');
logout = wrapper.find(Button);
expect(logout).toHaveLength(1);
});

Some files were not shown because too many files have changed in this diff Show More