From acc9a931e599dd2a796c1ee5ee34970e68cac287 Mon Sep 17 00:00:00 2001 From: ImanH <63911931+ImanH@users.noreply.github.com> Date: Thu, 14 Jan 2021 14:20:44 +0100 Subject: [PATCH 01/29] drop the fox in about (#10174) --- ui/app/pages/settings/info-tab/index.scss | 5 ++++- ui/app/pages/settings/info-tab/info-tab.component.js | 10 +++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ui/app/pages/settings/info-tab/index.scss b/ui/app/pages/settings/info-tab/index.scss index 88216c64a..41187cc37 100644 --- a/ui/app/pages/settings/info-tab/index.scss +++ b/ui/app/pages/settings/info-tab/index.scss @@ -6,7 +6,10 @@ &__logo { max-height: 100%; - max-width: 100%; + max-width: 50%; + display: block; + margin-left: auto; + margin-right: auto; } &__item { diff --git a/ui/app/pages/settings/info-tab/info-tab.component.js b/ui/app/pages/settings/info-tab/info-tab.component.js index 0e8118910..08e4777df 100644 --- a/ui/app/pages/settings/info-tab/info-tab.component.js +++ b/ui/app/pages/settings/info-tab/info-tab.component.js @@ -95,13 +95,6 @@ export default class InfoTab extends PureComponent {
-
- -
{t('metamaskVersion')} @@ -116,6 +109,9 @@ export default class InfoTab extends PureComponent {
{this.renderInfoLinks()}
+
+ +
) } From 9d224b72a7a732a21f2562dcc747538bb54a665f Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Thu, 14 Jan 2021 10:00:53 -0330 Subject: [PATCH 02/29] Add hiring note to the README (#10190) * Add hiring note to the README * Update README.md * Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 83b90ae1c..af6dd92d5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # MetaMask Browser Extension +Hey! We are hiring JavaScript Engineers! Apply here: https://boards.greenhouse.io/consensys/jobs/2572388 +--- + You can find the latest version of MetaMask on [our official website](https://metamask.io/). For help using MetaMask, visit our [User Support Site](https://metamask.zendesk.com/hc/en-us). For [general questions](https://metamask.zendesk.com/hc/en-us/community/topics/360000682532-General), [feature requests](https://metamask.zendesk.com/hc/en-us/community/topics/360000682552-Feature-Requests-Ideas), or [developer questions](https://metamask.zendesk.com/hc/en-us/community/topics/360001751291-Developer-Questions), visit our [Community Forum](https://metamask.zendesk.com/hc/en-us/community/topics). From 87d181b347c740699fcf12c4d76d1b42f7699949 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Mon, 18 Jan 2021 12:46:24 -0330 Subject: [PATCH 03/29] Fix hardware account selection (#10198) Fixes #9244 When trying to connect a Trezor account on a fresh install of MetaMask, the radio buttons on the account selection page would not respond to being clicked. When debugging this, it looks like the `onChange` event was never triggered. A radio `` element should trigger `onChange` whenever the selection state change, but seemingly this wouldn't happen if the change in selection state was undone during the same render cycle. If I paused at a breakpoint during the render, I could see the checkbox get selected then unselected again without triggering `onChange`. The simplest fix was to use `onClick` instead of `onChange`. This seems more appropriate anyway because we're treating the radio button as a controlled component here, so the state of the underlying element isn't really of any concern. --- ui/app/pages/create-account/connect-hardware/account-list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/pages/create-account/connect-hardware/account-list.js b/ui/app/pages/create-account/connect-hardware/account-list.js index b819c81be..2cf315ae7 100644 --- a/ui/app/pages/create-account/connect-hardware/account-list.js +++ b/ui/app/pages/create-account/connect-hardware/account-list.js @@ -90,7 +90,7 @@ class AccountList extends Component { name="selectedAccount" id={`address-${idx}`} value={account.index} - onChange={(e) => this.props.onAccountChange(e.target.value)} + onClick={(e) => this.props.onAccountChange(e.target.value)} checked={ this.props.selectedAccount === account.index.toString() } From b0bb190b5e753878502ec54d834480e21c620984 Mon Sep 17 00:00:00 2001 From: gasolin Date: Tue, 19 Jan 2021 05:18:27 +0800 Subject: [PATCH 04/29] =?UTF-8?q?Update=20TW=20=08term=20=E4=B9=99?= =?UTF-8?q?=E5=A4=AA=20->=20=E4=BB=A5=E5=A4=AA=20(#10191)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/_locales/zh_TW/messages.json | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/app/_locales/zh_TW/messages.json b/app/_locales/zh_TW/messages.json index c58f87eea..5f5d3c2a0 100644 --- a/app/_locales/zh_TW/messages.json +++ b/app/_locales/zh_TW/messages.json @@ -69,7 +69,7 @@ "message": "數量" }, "appDescription": { - "message": "乙太坊瀏覽器擴充插件", + "message": "以太坊瀏覽器擴充插件", "description": "The description of the application" }, "appName": { @@ -279,7 +279,7 @@ "message": "小數點後位數至少為0, 最多為36." }, "defaultNetwork": { - "message": "預設乙太幣交易網路為主網路" + "message": "預設以太幣交易網路為主網路" }, "delete": { "message": "刪除" @@ -294,16 +294,16 @@ "message": "你確定要刪除網路嗎?" }, "depositEther": { - "message": "存入乙太幣" + "message": "存入以太幣" }, "details": { "message": "詳情" }, "directDepositEther": { - "message": "直接存入乙太幣" + "message": "直接存入以太幣" }, "directDepositEtherExplainer": { - "message": "如果您已經擁有乙太幣,直接存入功能是讓新錢包最快取得乙太幣的方式。" + "message": "如果您已經擁有以太幣,直接存入功能是讓新錢包最快取得以太幣的方式。" }, "done": { "message": "完成" @@ -440,10 +440,10 @@ "message": "貨幣轉換,主要貨幣,語言,區塊鏈哈希頭像" }, "getEther": { - "message": "取得乙太幣" + "message": "取得以太幣" }, "getEtherFromFaucet": { - "message": "從水管取得 $1 乙太幣。", + "message": "從水管取得 $1 以太幣。", "description": "Displays network name for Ether faucet" }, "getHelp": { @@ -586,7 +586,7 @@ "message": "鎖定" }, "mainnet": { - "message": "乙太坊 主網路" + "message": "以太坊 主網路" }, "max": { "message": "最大值" @@ -601,7 +601,7 @@ "message": "訊息" }, "metamaskDescription": { - "message": "MetaMask 是乙太坊安全身份識別金庫" + "message": "MetaMask 是以太坊安全身份識別金庫" }, "metamaskVersion": { "message": "MetaMask 版本" @@ -622,14 +622,14 @@ "message": "所有你在 MetaMask 創建的帳號將自動新增到此區塊。" }, "needEtherInWallet": { - "message": "要使用 MetaMask 存取去中心化應用服務時,您的錢包中需要有乙太幣。" + "message": "要使用 MetaMask 存取去中心化應用服務時,您的錢包中需要有以太幣。" }, "needImportFile": { "message": "您必須選擇一個檔案來匯入", "description": "User is important an account and needs to add a file to continue" }, "negativeETH": { - "message": "不能送出負值的乙太幣" + "message": "不能送出負值的以太幣" }, "networkName": { "message": "網路名稱" @@ -748,7 +748,7 @@ "message": "主要顯示" }, "primaryCurrencySettingDescription": { - "message": "選擇使用乙太幣(ETH)或是法定貨幣(例如:美金)為主要錢幣顯示單位" + "message": "選擇使用以太幣(ETH)或是法定貨幣(例如:美金)為主要錢幣顯示單位" }, "privacyMsg": { "message": "隱私政策" @@ -890,7 +890,7 @@ "message": "助憶詞將可協助您用更簡單的方式備份帳戶資訊。" }, "secretBackupPhraseWarning": { - "message": "警告: 絕對不要洩漏您的助憶詞。任何人只要得知助憶詞代表他可以竊取您所有的乙太幣和代幣。" + "message": "警告: 絕對不要洩漏您的助憶詞。任何人只要得知助憶詞代表他可以竊取您所有的以太幣和代幣。" }, "secretPhrase": { "message": "輸入您的12個助憶詞以回復金庫" @@ -935,13 +935,13 @@ "message": "發送數量" }, "sendETH": { - "message": "發送乙太幣" + "message": "發送以太幣" }, "sendTokens": { "message": "發送代幣" }, "sentEther": { - "message": "發送乙太幣" + "message": "發送以太幣" }, "separateEachWord": { "message": "單詞之間請以空白間隔" @@ -1025,7 +1025,7 @@ "message": "3. 開始使用!" }, "step3HardwareWalletMsg": { - "message": "使用您硬體錢包中的帳戶,與去中心化應用服務交易乙太幣、ERC20代幣、或迷戀貓等數位資產。" + "message": "使用您硬體錢包中的帳戶,與去中心化應用服務交易以太幣、ERC20代幣、或迷戀貓等數位資產。" }, "storePhrase": { "message": "您可以用密碼管理系統例如 1Password 等軟體儲存助憶詞。" From 1007f4b6f21cae87d81b5a7c1f0978bb87f4e847 Mon Sep 17 00:00:00 2001 From: Yahsin Huang Date: Tue, 19 Jan 2021 05:29:01 +0800 Subject: [PATCH 05/29] zh_TW: Translate buy, assets, activity (#10207) --- app/_locales/zh_TW/messages.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/_locales/zh_TW/messages.json b/app/_locales/zh_TW/messages.json index 5f5d3c2a0..8f6d78b4a 100644 --- a/app/_locales/zh_TW/messages.json +++ b/app/_locales/zh_TW/messages.json @@ -26,6 +26,9 @@ "accountSelectionRequired": { "message": "必須先選擇一個帳戶!" }, + "activity": { + "message": "交易紀錄" + }, "activityLog": { "message": "活動紀錄" }, @@ -85,6 +88,9 @@ "asset": { "message": "資產" }, + "assets": { + "message": "資產" + }, "attemptToCancel": { "message": "嘗試取消?" }, @@ -146,6 +152,9 @@ "builtInCalifornia": { "message": "MetaMask 是在加州設計製造" }, + "buy": { + "message": "買" + }, "buyWithWyre": { "message": "用 Wyre 購買 ETH" }, From 4f66af606ed2b1837c6dea6cc36dd09f14981a40 Mon Sep 17 00:00:00 2001 From: Brad Decker Date: Tue, 19 Jan 2021 10:30:29 -0600 Subject: [PATCH 06/29] improve design system scss (#10193) --- .prettierignore | 1 + ui/app/css/design-system/colors.scss | 63 ++++++++++++++ ui/app/css/design-system/typography.scss | 101 ++++++++++------------ ui/app/helpers/constants/design-system.js | 41 +++++++++ 4 files changed, 151 insertions(+), 55 deletions(-) create mode 100644 ui/app/helpers/constants/design-system.js diff --git a/.prettierignore b/.prettierignore index 5428362b5..f1835d8dc 100644 --- a/.prettierignore +++ b/.prettierignore @@ -7,3 +7,4 @@ app/vendor/** .nyc_output/** .vscode/** test/e2e/send-eth-with-private-key-test/** +*.scss diff --git a/ui/app/css/design-system/colors.scss b/ui/app/css/design-system/colors.scss index c945c0de1..a1383b661 100644 --- a/ui/app/css/design-system/colors.scss +++ b/ui/app/css/design-system/colors.scss @@ -74,3 +74,66 @@ $accent-pink: #ff45d8; $neutral-white: #fff; $neutral-black: $Black-100; $neutral-grey: $Grey-500; + +// Everything below this line is part of the new color system +$primary-1: #037dd6; +$primary-2: #eaf6ff; +$primary-3: #0260a4; + +$secondary-1: #f66a0a; +$secondary-2: #fef5ef; +$secondary-3: #c65507; + +$error-1: #d73a49; +$error-2: #fcf2f3; +$error-3: #b92534; + +$alert-1: #ffd33d; +$alert-2: #fefcde; +$alert-3: #f8c000; + +$success-1: #4cd964; +$success-2: #caf4d1; +$success-3: #219e37; + +$ui-black: #24292e; +$ui-white: #fff; +$ui-1: #f2f3f4; +$ui-2: #d6d9dc; +$ui-3: #bbc0c5; +$ui-4: #6a737d; + +$mainnet: #29b6af; +$ropsten: #ff4a8d; +$kovan: #9064ff; +$rinkeby: #f6c343; +$goerli: #3099f2; + +$color-map: ( + 'ui-1': $ui-1, + 'ui-2': $ui-2, + 'ui-3': $ui-3, + 'ui-4': $ui-4, + 'white': $ui-white, + 'black': $ui-black, + 'primary-1': $primary-1, + 'primary-2': $primary-2, + 'primary-3': $primary-3, + 'secondary-1': $secondary-1, + 'secondary-2': $secondary-2, + 'secondary-3': $secondary-3, + 'alert-1': $alert-1, + 'alert-2': $alert-2, + 'alert-3': $alert-3, + 'error-1': $error-1, + 'error-2': $error-2, + 'error-3': $error-3, + 'success-1': $success-1, + 'success-2': $success-2, + 'success-3': $success-3, + 'mainnet': $mainnet, + 'ropsten': $ropsten, + 'kovan': $kovan, + 'rinkeby': $rinkeby, + 'goerli': $goerli, +); diff --git a/ui/app/css/design-system/typography.scss b/ui/app/css/design-system/typography.scss index 1d6e1a522..ff0725ea8 100644 --- a/ui/app/css/design-system/typography.scss +++ b/ui/app/css/design-system/typography.scss @@ -69,89 +69,80 @@ $fa-font-path: 'fonts/fontawesome'; $font-family: Euclid, Roboto, Helvetica, Arial, sans-serif; -$font-size-h1: 2.5rem; -$font-size-h2: 2rem; -$font-size-h3: 1.5rem; -$font-size-h4: 1.125rem; -$font-size-h5: 1rem; -$font-size-h6: 0.875rem; -$font-size-paragraph: 1rem; -$font-size-h7: 0.75rem; -$font-size-h8: 0.625rem; -$font-size-h9: 0.5rem; - -// Typography -@mixin H1 { - font-style: normal; - font-weight: normal; - font-size: $font-size-h1; +$typography-variants: ( + 'h1': 2.5rem, + 'h2': 2rem, + 'h3': 1.5rem, + 'h4': 1.125rem, + 'h5': 1rem, + 'h6': 0.875rem, + 'paragraph': 1rem, + 'h7': 0.75rem, + 'h8': 0.625rem, + 'h9': 0.5rem, +); + +$typography-font-weights: ( + 'bold': 700, + 'normal': 400, +); + +$font-size-h1: map-get($typography-variants, 'h1'); +$font-size-h2: map-get($typography-variants, 'h2'); +$font-size-h3: map-get($typography-variants, 'h3'); +$font-size-h4: map-get($typography-variants, 'h4'); +$font-size-h5: map-get($typography-variants, 'h5'); +$font-size-h6: map-get($typography-variants, 'h6'); +$font-size-paragraph: map-get($typography-variants, 'paragraph'); +$font-size-h7: map-get($typography-variants, 'h7'); +$font-size-h8: map-get($typography-variants, 'h8'); +$font-size-h9: map-get($typography-variants, 'h9'); + +@mixin typography($variant) { + font-size: map-get($typography-variants, $variant); font-family: $font-family; line-height: 140%; + font-style: normal; + font-weight: normal; } +// Typography +@mixin H1 { + @include typography('h1'); +} @mixin H2 { - font-style: normal; - font-weight: normal; - font-size: $font-size-h2; - font-family: $font-family; - line-height: 140%; + @include typography('h2'); } @mixin H3 { - font-style: normal; - font-weight: normal; - font-size: $font-size-h3; - font-family: $font-family; - line-height: 140%; + @include typography('h3'); } @mixin H4 { - font-style: normal; - font-weight: normal; - font-size: $font-size-h4; - font-family: $font-family; - line-height: 140%; + @include typography('h4'); } @mixin H5 { - font-style: normal; - font-weight: normal; - font-size: $font-size-h5; - line-height: 140%; + @include typography('h5'); } @mixin H6 { - font-style: normal; - font-weight: normal; - font-size: $font-size-h6; // 14px @default - line-height: 140%; + @include typography('h6'); } @mixin Paragraph { - font-style: normal; - font-weight: normal; - font-size: $font-size-paragraph; - line-height: 140%; + @include typography('paragraph'); } @mixin H7 { - font-style: normal; - font-weight: normal; - font-size: $font-size-h7; - line-height: 140%; + @include typography('h7'); } @mixin H8 { - font-style: normal; - font-weight: normal; - font-size: $font-size-h8; - line-height: 140%; + @include typography('h8'); } @mixin H9 { - font-style: normal; - font-weight: normal; - font-size: $font-size-h9; - line-height: 140%; + @include typography('h9'); } diff --git a/ui/app/helpers/constants/design-system.js b/ui/app/helpers/constants/design-system.js new file mode 100644 index 000000000..6d6512eba --- /dev/null +++ b/ui/app/helpers/constants/design-system.js @@ -0,0 +1,41 @@ +export const COLORS = { + UI1: 'ui-1', + UI2: 'ui-2', + UI3: 'ui-3', + UI4: 'ui-4', + BLACK: 'black', + WHITE: 'white', + PRIMARY1: 'primary-1', + PRIMARY2: 'primary-2', + PRIMARY3: 'primary-3', + SECONDARY1: 'secondary-1', + SECONDARY2: 'secondary-2', + SECONDARY3: 'secondary-3', + SUCCESS1: 'success-1', + SUCCESS2: 'success-2', + SUCCESS3: 'success-3', + ERROR1: 'error1', + ERROR2: 'error2', + ERROR3: 'error3', + ALERT1: 'alert-1', + ALERT2: 'alert-2', + ALERT3: 'alert-3', + MAINNET: 'mainnet', + ROPSTEN: 'ropsten', + KOVAN: 'kovan', + RINKEBY: 'rinkeby', + GOERLI: 'goerli', +} + +export const TYPOGRAPHY = { + H1: 'h1', + H2: 'h2', + H3: 'h3', + H4: 'h4', + H5: 'h5', + H6: 'h6', + H7: 'h7', + H8: 'h8', + H9: 'h9', + Paragraph: 'paragraph', +} From 28078bf81ca50da9eedb84b64533c5a42c5f7447 Mon Sep 17 00:00:00 2001 From: Dan Finlay <542863+danfinlay@users.noreply.github.com> Date: Tue, 19 Jan 2021 08:32:05 -0800 Subject: [PATCH 07/29] Make hiring link a link on text (#10206) To avoid repelling the neurotic JS developer. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index af6dd92d5..545f1218c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MetaMask Browser Extension -Hey! We are hiring JavaScript Engineers! Apply here: https://boards.greenhouse.io/consensys/jobs/2572388 +Hey! We are hiring JavaScript Engineers! [Apply here](https://boards.greenhouse.io/consensys/jobs/2572388)! --- You can find the latest version of MetaMask on [our official website](https://metamask.io/). For help using MetaMask, visit our [User Support Site](https://metamask.zendesk.com/hc/en-us). From 7159dd68679b427cb62ad96eb984a7b6fa5b642f Mon Sep 17 00:00:00 2001 From: Erik Marks <25517051+rekmarks@users.noreply.github.com> Date: Tue, 19 Jan 2021 08:41:57 -0800 Subject: [PATCH 08/29] Fetch with a timeout everywhere (#10101) * Use fetchWithTimeout everywhere * Memoize getFetchWithTimeout * Require specified timeout --- .../controllers/incoming-transactions.js | 8 ++--- app/scripts/controllers/token-rates.js | 5 +++- app/scripts/lib/ens-ipfs/setup.js | 7 ++++- app/scripts/lib/network-store.js | 5 +++- .../modules}/fetch-with-timeout.js | 12 ++++++-- test/unit/app/fetch-with-timeout.test.js | 29 +++++++++++-------- ui/app/ducks/gas/gas.duck.js | 6 ++-- ui/app/helpers/utils/fetch-with-cache.js | 6 ++-- ui/app/helpers/utils/i18n-helper.js | 9 ++++-- ui/app/helpers/utils/util.js | 27 ++++++++--------- 10 files changed, 70 insertions(+), 44 deletions(-) rename {app/scripts/lib => shared/modules}/fetch-with-timeout.js (64%) diff --git a/app/scripts/controllers/incoming-transactions.js b/app/scripts/controllers/incoming-transactions.js index 58a059dd2..625272740 100644 --- a/app/scripts/controllers/incoming-transactions.js +++ b/app/scripts/controllers/incoming-transactions.js @@ -3,7 +3,7 @@ import log from 'loglevel' import BN from 'bn.js' import createId from '../lib/random-id' import { bnToHex } from '../lib/util' -import fetchWithTimeout from '../lib/fetch-with-timeout' +import getFetchWithTimeout from '../../../shared/modules/fetch-with-timeout' import { TRANSACTION_CATEGORIES, @@ -24,9 +24,7 @@ import { ROPSTEN_CHAIN_ID, } from './network/enums' -const fetch = fetchWithTimeout({ - timeout: 30000, -}) +const fetchWithTimeout = getFetchWithTimeout(30000) /** * This controller is responsible for retrieving incoming transactions. Etherscan is polled once every block to check @@ -227,7 +225,7 @@ export default class IncomingTransactionsController { if (fromBlock) { url += `&startBlock=${parseInt(fromBlock, 10)}` } - const response = await fetch(url) + const response = await fetchWithTimeout(url) const parsedResponse = await response.json() return { diff --git a/app/scripts/controllers/token-rates.js b/app/scripts/controllers/token-rates.js index 9011b1d01..031017c83 100644 --- a/app/scripts/controllers/token-rates.js +++ b/app/scripts/controllers/token-rates.js @@ -2,6 +2,9 @@ import { ObservableStore } from '@metamask/obs-store' import log from 'loglevel' import { normalize as normalizeAddress } from 'eth-sig-util' import ethUtil from 'ethereumjs-util' +import getFetchWithTimeout from '../../../shared/modules/fetch-with-timeout' + +const fetchWithTimeout = getFetchWithTimeout(30000) // By default, poll every 3 minutes const DEFAULT_INTERVAL = 180 * 1000 @@ -34,7 +37,7 @@ export default class TokenRatesController { const query = `contract_addresses=${pairs}&vs_currencies=${nativeCurrency}` if (this._tokens.length > 0) { try { - const response = await window.fetch( + const response = await fetchWithTimeout( `https://api.coingecko.com/api/v3/simple/token_price/ethereum?${query}`, ) const prices = await response.json() diff --git a/app/scripts/lib/ens-ipfs/setup.js b/app/scripts/lib/ens-ipfs/setup.js index ab4cec023..9ec6e1492 100644 --- a/app/scripts/lib/ens-ipfs/setup.js +++ b/app/scripts/lib/ens-ipfs/setup.js @@ -1,6 +1,9 @@ import extension from 'extensionizer' +import getFetchWithTimeout from '../../../../shared/modules/fetch-with-timeout' import resolveEnsToIpfsContentId from './resolver' +const fetchWithTimeout = getFetchWithTimeout(30000) + const supportedTopLevelDomains = ['eth'] export default function setupEnsIpfsResolver({ @@ -55,7 +58,9 @@ export default function setupEnsIpfsResolver({ )}.${ipfsGateway}${pathname}${search || ''}${fragment || ''}` try { // check if ipfs gateway has result - const response = await window.fetch(resolvedUrl, { method: 'HEAD' }) + const response = await fetchWithTimeout(resolvedUrl, { + method: 'HEAD', + }) if (response.status === 200) { url = resolvedUrl } diff --git a/app/scripts/lib/network-store.js b/app/scripts/lib/network-store.js index cc2898292..bfa7a8ba4 100644 --- a/app/scripts/lib/network-store.js +++ b/app/scripts/lib/network-store.js @@ -1,4 +1,7 @@ import log from 'loglevel' +import getFetchWithTimeout from '../../../shared/modules/fetch-with-timeout' + +const fetchWithTimeout = getFetchWithTimeout(30000) const FIXTURE_SERVER_HOST = 'localhost' const FIXTURE_SERVER_PORT = 12345 @@ -24,7 +27,7 @@ export default class ReadOnlyNetworkStore { */ async _init() { try { - const response = await window.fetch(FIXTURE_SERVER_URL) + const response = await fetchWithTimeout(FIXTURE_SERVER_URL) if (response.ok) { this._state = await response.json() } diff --git a/app/scripts/lib/fetch-with-timeout.js b/shared/modules/fetch-with-timeout.js similarity index 64% rename from app/scripts/lib/fetch-with-timeout.js rename to shared/modules/fetch-with-timeout.js index a9e895b12..e97ae3402 100644 --- a/app/scripts/lib/fetch-with-timeout.js +++ b/shared/modules/fetch-with-timeout.js @@ -1,4 +1,10 @@ -const fetchWithTimeout = ({ timeout = 120000 } = {}) => { +import { memoize } from 'lodash' + +const getFetchWithTimeout = memoize((timeout) => { + if (!Number.isInteger(timeout) || timeout < 1) { + throw new Error('Must specify positive integer timeout.') + } + return async function _fetch(url, opts) { const abortController = new window.AbortController() const { signal } = abortController @@ -18,6 +24,6 @@ const fetchWithTimeout = ({ timeout = 120000 } = {}) => { throw e } } -} +}) -export default fetchWithTimeout +export default getFetchWithTimeout diff --git a/test/unit/app/fetch-with-timeout.test.js b/test/unit/app/fetch-with-timeout.test.js index 89ea2fec9..dd91ff58b 100644 --- a/test/unit/app/fetch-with-timeout.test.js +++ b/test/unit/app/fetch-with-timeout.test.js @@ -1,14 +1,16 @@ import assert from 'assert' import nock from 'nock' -import fetchWithTimeout from '../../../app/scripts/lib/fetch-with-timeout' +import getFetchWithTimeout from '../../../shared/modules/fetch-with-timeout' -describe('fetchWithTimeout', function () { +describe('getFetchWithTimeout', function () { it('fetches a url', async function () { nock('https://api.infura.io').get('/money').reply(200, '{"hodl": false}') - const fetch = fetchWithTimeout() - const response = await (await fetch('https://api.infura.io/money')).json() + const fetchWithTimeout = getFetchWithTimeout(30000) + const response = await ( + await fetchWithTimeout('https://api.infura.io/money') + ).json() assert.deepEqual(response, { hodl: false, }) @@ -20,12 +22,10 @@ describe('fetchWithTimeout', function () { .delay(2000) .reply(200, '{"moon": "2012-12-21T11:11:11Z"}') - const fetch = fetchWithTimeout({ - timeout: 123, - }) + const fetchWithTimeout = getFetchWithTimeout(123) try { - await fetch('https://api.infura.io/moon').then((r) => r.json()) + await fetchWithTimeout('https://api.infura.io/moon').then((r) => r.json()) assert.fail('Request should throw') } catch (e) { assert.ok(e) @@ -38,15 +38,20 @@ describe('fetchWithTimeout', function () { .delay(2000) .reply(200, '{"moon": "2012-12-21T11:11:11Z"}') - const fetch = fetchWithTimeout({ - timeout: 123, - }) + const fetchWithTimeout = getFetchWithTimeout(123) try { - await fetch('https://api.infura.io/moon').then((r) => r.json()) + await fetchWithTimeout('https://api.infura.io/moon').then((r) => r.json()) assert.fail('Request should be aborted') } catch (e) { assert.deepEqual(e.message, 'Aborted') } }) + + it('throws on invalid timeout', async function () { + assert.throws(() => getFetchWithTimeout(), 'should throw') + assert.throws(() => getFetchWithTimeout(-1), 'should throw') + assert.throws(() => getFetchWithTimeout({}), 'should throw') + assert.throws(() => getFetchWithTimeout(true), 'should throw') + }) }) diff --git a/ui/app/ducks/gas/gas.duck.js b/ui/app/ducks/gas/gas.duck.js index 83b15ecf1..1bcc5d417 100644 --- a/ui/app/ducks/gas/gas.duck.js +++ b/ui/app/ducks/gas/gas.duck.js @@ -1,8 +1,10 @@ import { cloneDeep } from 'lodash' import BigNumber from 'bignumber.js' import { getStorageItem, setStorageItem } from '../../../lib/storage-helpers' - import { decGWEIToHexWEI } from '../../helpers/utils/conversions.util' +import getFetchWithTimeout from '../../../../shared/modules/fetch-with-timeout' + +const fetchWithTimeout = getFetchWithTimeout(30000) // Actions const BASIC_GAS_ESTIMATE_LOADING_FINISHED = @@ -97,7 +99,7 @@ export function basicGasEstimatesLoadingFinished() { async function basicGasPriceQuery() { const url = `https://api.metaswap.codefi.network/gasPrices` - return await window.fetch(url, { + return await fetchWithTimeout(url, { headers: {}, referrer: 'https://api.metaswap.codefi.network/gasPrices', referrerPolicy: 'no-referrer-when-downgrade', diff --git a/ui/app/helpers/utils/fetch-with-cache.js b/ui/app/helpers/utils/fetch-with-cache.js index ca2bbd7f0..a903680c4 100644 --- a/ui/app/helpers/utils/fetch-with-cache.js +++ b/ui/app/helpers/utils/fetch-with-cache.js @@ -1,5 +1,5 @@ import { getStorageItem, setStorageItem } from '../../../lib/storage-helpers' -import fetchWithTimeout from '../../../../app/scripts/lib/fetch-with-timeout' +import getFetchWithTimeout from '../../../../shared/modules/fetch-with-timeout' const fetchWithCache = async ( url, @@ -29,8 +29,8 @@ const fetchWithCache = async ( return cachedResponse } fetchOptions.headers.set('Content-Type', 'application/json') - const _fetch = timeout ? fetchWithTimeout({ timeout }) : window.fetch - const response = await _fetch(url, { + const fetchWithTimeout = getFetchWithTimeout(timeout) + const response = await fetchWithTimeout(url, { referrerPolicy: 'no-referrer-when-downgrade', body: null, method: 'GET', diff --git a/ui/app/helpers/utils/i18n-helper.js b/ui/app/helpers/utils/i18n-helper.js index 140a12fff..bb8932683 100644 --- a/ui/app/helpers/utils/i18n-helper.js +++ b/ui/app/helpers/utils/i18n-helper.js @@ -1,9 +1,12 @@ // cross-browser connection to extension i18n API import React from 'react' import log from 'loglevel' - import * as Sentry from '@sentry/browser' +import getFetchWithTimeout from '../../../../shared/modules/fetch-with-timeout' + +const fetchWithTimeout = getFetchWithTimeout(30000) + const warned = {} const missingMessageErrors = {} const missingSubstitutionErrors = {} @@ -95,7 +98,7 @@ export const getMessage = (localeCode, localeMessages, key, substitutions) => { export async function fetchLocale(localeCode) { try { - const response = await window.fetch( + const response = await fetchWithTimeout( `./_locales/${localeCode}/messages.json`, ) return await response.json() @@ -120,7 +123,7 @@ export async function loadRelativeTimeFormatLocaleData(localeCode) { } async function fetchRelativeTimeFormatData(languageTag) { - const response = await window.fetch( + const response = await fetchWithTimeout( `./intl/${languageTag}/relative-time-format-data.json`, ) return await response.json() diff --git a/ui/app/helpers/utils/util.js b/ui/app/helpers/utils/util.js index 020ed9325..b88abc876 100644 --- a/ui/app/helpers/utils/util.js +++ b/ui/app/helpers/utils/util.js @@ -4,6 +4,9 @@ import BigNumber from 'bignumber.js' import ethUtil from 'ethereumjs-util' import { DateTime } from 'luxon' import { addHexPrefix } from '../../../../app/scripts/lib/util' +import getFetchWithTimeout from '../../../../shared/modules/fetch-with-timeout' + +const fetchWithTimeout = getFetchWithTimeout(30000) // formatData :: ( date: ) -> String export function formatDate(date, format = "M/d/y 'at' T") { @@ -478,19 +481,17 @@ export async function jsonRpcRequest(rpcUrl, rpcMethod, rpcParams = []) { headers.Authorization = `Basic ${encodedAuth}` fetchUrl = `${origin}${pathname}${search}` } - const jsonRpcResponse = await window - .fetch(fetchUrl, { - method: 'POST', - body: JSON.stringify({ - id: Date.now().toString(), - jsonrpc: '2.0', - method: rpcMethod, - params: rpcParams, - }), - headers, - cache: 'default', - }) - .then((httpResponse) => httpResponse.json()) + const jsonRpcResponse = await fetchWithTimeout(fetchUrl, { + method: 'POST', + body: JSON.stringify({ + id: Date.now().toString(), + jsonrpc: '2.0', + method: rpcMethod, + params: rpcParams, + }), + headers, + cache: 'default', + }).then((httpResponse) => httpResponse.json()) if ( !jsonRpcResponse || From acbe38c26007bf63fe2495e4676ef0a327876756 Mon Sep 17 00:00:00 2001 From: Brad Decker Date: Tue, 19 Jan 2021 10:54:32 -0600 Subject: [PATCH 09/29] use dart sass, and update related modules (#10208) --- .storybook/main.js | 26 ++++++---- development/build/styles.js | 2 +- package.json | 6 +-- ui/app/css/design-system/index.scss | 10 ++-- yarn.lock | 76 ++++++++++++++++++++--------- 5 files changed, 80 insertions(+), 40 deletions(-) diff --git a/.storybook/main.js b/.storybook/main.js index 2411f2066..bc4b01678 100644 --- a/.storybook/main.js +++ b/.storybook/main.js @@ -7,7 +7,7 @@ module.exports = { addons: [ '@storybook/addon-knobs', '@storybook/addon-actions', - '@storybook/addon-backgrounds' + '@storybook/addon-backgrounds', ], webpackFinal: async (config) => { config.module.strictExportPresence = true @@ -27,18 +27,26 @@ module.exports = { loader: 'sass-loader', options: { sourceMap: true, + implementation: require('sass'), }, }, ], }) - config.plugins.push(new CopyWebpackPlugin({ - patterns: [ - { - from: path.join('node_modules', '@fortawesome', 'fontawesome-free', 'webfonts'), - to: path.join('fonts', 'fontawesome'), - }, - ], - })) + config.plugins.push( + new CopyWebpackPlugin({ + patterns: [ + { + from: path.join( + 'node_modules', + '@fortawesome', + 'fontawesome-free', + 'webfonts', + ), + to: path.join('fonts', 'fontawesome'), + }, + ], + }), + ) return config }, } diff --git a/development/build/styles.js b/development/build/styles.js index 966b2c818..c8b9e6718 100644 --- a/development/build/styles.js +++ b/development/build/styles.js @@ -1,7 +1,7 @@ const pify = require('pify') const gulp = require('gulp') const sass = require('gulp-sass') -sass.compiler = require('node-sass') +sass.compiler = require('sass') const autoprefixer = require('gulp-autoprefixer') const gulpStylelint = require('gulp-stylelint') const watch = require('gulp-watch') diff --git a/package.json b/package.json index ba59f09d3..39d6ea073 100644 --- a/package.json +++ b/package.json @@ -246,7 +246,7 @@ "gulp-rename": "^2.0.0", "gulp-replace": "^1.0.0", "gulp-rtlcss": "^1.4.0", - "gulp-sass": "^4.0.0", + "gulp-sass": "^4.1.0", "gulp-sourcemaps": "^2.6.0", "gulp-stylelint": "^13.0.0", "gulp-terser-js": "^5.2.2", @@ -259,7 +259,6 @@ "mocha": "^7.2.0", "nock": "^9.0.14", "node-fetch": "^2.6.1", - "node-sass": "^4.14.1", "nyc": "^15.0.0", "polyfill-crypto.getrandomvalues": "^1.0.0", "prettier": "^2.1.1", @@ -275,7 +274,8 @@ "remote-redux-devtools": "^0.5.16", "remotedev-server": "^0.3.1", "resolve-url-loader": "^3.1.2", - "sass-loader": "^7.0.1", + "sass": "^1.32.4", + "sass-loader": "^10.1.1", "selenium-webdriver": "4.0.0-alpha.7", "serve-handler": "^6.1.2", "ses": "0.11.0", diff --git a/ui/app/css/design-system/index.scss b/ui/app/css/design-system/index.scss index 2d85fcae3..d4f8980b9 100644 --- a/ui/app/css/design-system/index.scss +++ b/ui/app/css/design-system/index.scss @@ -1,5 +1,5 @@ -@import 'breakpoints'; -@import 'colors'; -@import 'deprecated-colors'; -@import 'typography'; -@import 'z-index'; +@forward 'breakpoints'; +@forward 'colors'; +@forward 'deprecated-colors'; +@forward 'typography'; +@forward 'z-index'; diff --git a/yarn.lock b/yarn.lock index 126c52d11..714252227 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6708,6 +6708,21 @@ chokidar@3.3.0: optionalDependencies: fsevents "~2.1.1" +"chokidar@>=2.0.0 <4.0.0": + version "3.5.1" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.1.tgz#ee9ce7bbebd2b79f49f304799d5468e31e14e68a" + integrity sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw== + dependencies: + anymatch "~3.1.1" + braces "~3.0.2" + glob-parent "~5.1.0" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.5.0" + optionalDependencies: + fsevents "~2.3.1" + chokidar@^2.0.0, chokidar@^2.1.1, chokidar@^2.1.8: version "2.1.8" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.1.8.tgz#804b3a7b6a99358c3c5c61e71d8728f041cff917" @@ -11633,6 +11648,11 @@ fsevents@~2.1.1, fsevents@~2.1.2: resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e" integrity sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ== +fsevents@~2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.1.tgz#b209ab14c61012636c8863507edf7fb68cc54e9f" + integrity sha512-YR47Eg4hChJGAB1O3yEAOkGO+rlzutoICGqGo9EZ4lKWokzZRSyIW1QmTzqjtw8MJdj9srP869CuWw/hyzSiBw== + fsm-event@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/fsm-event/-/fsm-event-2.1.0.tgz#d385716ed38f9c92feab2ba601e2aac6c0ba5a92" @@ -12586,13 +12606,13 @@ gulp-rtlcss@^1.4.0: through2 "^2.0.5" vinyl-sourcemaps-apply "^0.2.1" -gulp-sass@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/gulp-sass/-/gulp-sass-4.0.1.tgz#7f43d117eb2d303524968a1b48494af1bc64d1d9" - integrity sha512-OMQEgWNggpog8Tc5v1MuI6eo+5iiPkVeLL76iBhDoEEScLUPfZlpvzmgTnLkpcqdrNodZxpz5qcv6mS2rulk3g== +gulp-sass@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/gulp-sass/-/gulp-sass-4.1.0.tgz#486d7443c32d42bf31a6b1573ebbdaa361de7427" + integrity sha512-xIiwp9nkBLcJDpmYHbEHdoWZv+j+WtYaKD6Zil/67F3nrAaZtWYN5mDwerdo7EvcdBenSAj7Xb2hx2DqURLGdA== dependencies: chalk "^2.3.0" - lodash.clonedeep "^4.3.2" + lodash "^4.17.11" node-sass "^4.8.3" plugin-error "^1.0.1" replace-ext "^1.0.0" @@ -15644,6 +15664,11 @@ klaw@^1.0.0: optionalDependencies: graceful-fs "^4.1.9" +klona@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/klona/-/klona-2.0.4.tgz#7bb1e3affb0cb8624547ef7e8f6708ea2e39dfc0" + integrity sha512-ZRbnvdg/NxqzC7L9Uyqzf4psi1OM4Cuc+sJAkQPjO6XkQIJTNbfK2Rsmbw8fx1p2mkZdp2FZYo2+LwXYY/uwIA== + knex@^0.15.2: version "0.15.2" resolved "https://registry.yarnpkg.com/knex/-/knex-0.15.2.tgz#6059b87489605f4cc87599a6d2a9d265709e9340" @@ -16545,7 +16570,7 @@ loader-runner@^2.4.0: resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.4.0.tgz#ed47066bfe534d7e84c4c7b9998c2a75607d9357" integrity sha512-Jsmr89RcXGIwivFY21FcRrisYZfvLMTWx5kOLc+JTxtpBOG6xML0vzbc6SEQG2FO9/4Fc3wW4LVcB5DmGflaRw== -loader-utils@1.2.3, loader-utils@^1.0.1, loader-utils@^1.0.2, loader-utils@^1.1.0, loader-utils@^1.2.3: +loader-utils@1.2.3, loader-utils@^1.0.2, loader-utils@^1.1.0, loader-utils@^1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.2.3.tgz#1ff5dc6911c9f0a062531a4c04b609406108c2c7" integrity sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA== @@ -16646,7 +16671,7 @@ lodash.assign@^4.2.0: resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-4.2.0.tgz#0d99f3ccd7a6d261d19bdaeb9245005d285808e7" integrity sha1-DZnzzNem0mHRm9rrkkUAXShYCOc= -lodash.clonedeep@4.5.0, lodash.clonedeep@^4.3.2: +lodash.clonedeep@4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8= @@ -16746,11 +16771,6 @@ lodash.sortby@^4.7.0: resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg= -lodash.tail@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/lodash.tail/-/lodash.tail-4.1.1.tgz#d2333a36d9e7717c8ad2f7cacafec7c32b444664" - integrity sha1-0jM6NtnncXyK0vfKyv7HwytERmQ= - lodash.throttle@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4" @@ -18025,6 +18045,11 @@ neo-async@^2.5.0, neo-async@^2.6.1: resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.1.tgz#ac27ada66167fa8849a6addd837f6b189ad2081c" integrity sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw== +neo-async@^2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" + integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== + nested-error-stacks@^2.0.0, nested-error-stacks@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/nested-error-stacks/-/nested-error-stacks-2.1.0.tgz#0fbdcf3e13fe4994781280524f8b96b0cdff9c61" @@ -18255,7 +18280,7 @@ node-releases@^1.1.52, node-releases@^1.1.66: resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.67.tgz#28ebfcccd0baa6aad8e8d4d8fe4cbc49ae239c12" integrity sha512-V5QF9noGFl3EymEwUYzO+3NTDpGfQB4ve6Qfnzf3UNydMhjQRVPR1DZTuvWiLzaFJYw2fmDwAfnRNEVb64hSIg== -node-sass@^4.14.1, node-sass@^4.8.3: +node-sass@^4.8.3: version "4.14.1" resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.14.1.tgz#99c87ec2efb7047ed638fb4c9db7f3a42e2217b5" integrity sha512-sjCuOlvGyCJS40R8BscF5vhVlQjNN069NtQ1gSxyK1u9iqvn6tf7O1R4GNowVZfiZUCRt5MmMs1xd+4V/7Yr0g== @@ -22428,16 +22453,23 @@ sass-graph@2.2.5: scss-tokenizer "^0.2.3" yargs "^13.3.2" -sass-loader@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/sass-loader/-/sass-loader-7.0.1.tgz#fd937259ccba3a9cfe0d5f8a98746d48adfcc261" - integrity sha512-MeVVJFejJELlAbA7jrRchi88PGP6U9yIfqyiG+bBC4a9s2PX+ulJB9h8bbEohtPBfZmlLhNZ0opQM9hovRXvlw== +sass-loader@^10.1.1: + version "10.1.1" + resolved "https://registry.yarnpkg.com/sass-loader/-/sass-loader-10.1.1.tgz#4ddd5a3d7638e7949065dd6e9c7c04037f7e663d" + integrity sha512-W6gVDXAd5hR/WHsPicvZdjAWHBcEJ44UahgxcIE196fW2ong0ZHMPO1kZuI5q0VlvMQZh32gpv69PLWQm70qrw== dependencies: - clone-deep "^2.0.1" - loader-utils "^1.0.1" - lodash.tail "^4.1.1" - neo-async "^2.5.0" - pify "^3.0.0" + klona "^2.0.4" + loader-utils "^2.0.0" + neo-async "^2.6.2" + schema-utils "^3.0.0" + semver "^7.3.2" + +sass@^1.32.4: + version "1.32.4" + resolved "https://registry.yarnpkg.com/sass/-/sass-1.32.4.tgz#308bf29dd7f53d44ae4f06580e9a910ad9aa411e" + integrity sha512-N0BT0PI/t3+gD8jKa83zJJUb7ssfQnRRfqN+GIErokW6U4guBpfYl8qYB+OFLEho+QvnV5ZH1R9qhUC/Z2Ch9w== + dependencies: + chokidar ">=2.0.0 <4.0.0" sax@^1.2.1, sax@^1.2.4, sax@~1.2.4: version "1.2.4" From 5b6e524c901ce23e838f56e4b11e8c57552380b9 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Tue, 19 Jan 2021 13:35:58 -0330 Subject: [PATCH 10/29] Remove default to 18 decimals in quotesToRenderableData method (#10212) --- ui/app/pages/swaps/swaps.util.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/ui/app/pages/swaps/swaps.util.js b/ui/app/pages/swaps/swaps.util.js index 81876d947..0fcc5d8a2 100644 --- a/ui/app/pages/swaps/swaps.util.js +++ b/ui/app/pages/swaps/swaps.util.js @@ -467,11 +467,11 @@ export function quotesToRenderableData( } = quote const sourceValue = calcTokenAmount( sourceAmount, - sourceTokenInfo.decimals || 18, + sourceTokenInfo.decimals, ).toString(10) const destinationValue = calcTokenAmount( destinationAmount, - destinationTokenInfo.decimals || 18, + destinationTokenInfo.decimals, ).toPrecision(8) const { @@ -501,14 +501,11 @@ export function quotesToRenderableData( destinationTokenInfo.symbol === 'ETH' ? calcTokenAmount( destinationAmount, - destinationTokenInfo.decimals || 18, + destinationTokenInfo.decimals, ).minus(rawEthFee, 10) : new BigNumber(tokenConversionRate || 0, 10) .times( - calcTokenAmount( - destinationAmount, - destinationTokenInfo.decimals || 18, - ), + calcTokenAmount(destinationAmount, destinationTokenInfo.decimals), 10, ) .minus(rawEthFee, 10) From 36ef9a228a6ef6020236626ab78e87a20bff5d73 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Tue, 19 Jan 2021 13:42:02 -0330 Subject: [PATCH 11/29] Disable the swaps submit button after the first time it is clicked (#10162) --- ui/app/pages/swaps/view-quote/view-quote.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ui/app/pages/swaps/view-quote/view-quote.js b/ui/app/pages/swaps/view-quote/view-quote.js index bdceee91f..6a9ab838f 100644 --- a/ui/app/pages/swaps/view-quote/view-quote.js +++ b/ui/app/pages/swaps/view-quote/view-quote.js @@ -83,6 +83,7 @@ export default function ViewQuote() { const metaMetricsEvent = useContext(MetaMetricsContext) const [dispatchedSafeRefetch, setDispatchedSafeRefetch] = useState(false) + const [submitClicked, setSubmitClicked] = useState(false) const [selectQuotePopoverShown, setSelectQuotePopoverShown] = useState(false) const [warningHidden, setWarningHidden] = useState(false) const [originalApproveAmount, setOriginalApproveAmount] = useState(null) @@ -570,6 +571,7 @@ export default function ViewQuote() {
{ + setSubmitClicked(true) if (!balanceError) { dispatch(signAndSendTransactions(history, metaMetricsEvent)) } else if (destinationToken.symbol === 'ETH') { @@ -580,7 +582,12 @@ export default function ViewQuote() { }} submitText={t('swap')} onCancel={async () => await dispatch(navigateBackToBuildQuote(history))} - disabled={balanceError || gasPrice === null || gasPrice === undefined} + disabled={ + submitClicked || + balanceError || + gasPrice === null || + gasPrice === undefined + } className={isShowingWarning && 'view-quote__thin-swaps-footer'} showTopBorder /> From a3de54d86d618610245985e0e83348db3c7908c7 Mon Sep 17 00:00:00 2001 From: Brad Decker Date: Wed, 20 Jan 2021 09:58:03 -0600 Subject: [PATCH 12/29] add includePaths to sass-loader in storybook (#10213) --- .storybook/main.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.storybook/main.js b/.storybook/main.js index bc4b01678..8b1860ee5 100644 --- a/.storybook/main.js +++ b/.storybook/main.js @@ -28,6 +28,9 @@ module.exports = { options: { sourceMap: true, implementation: require('sass'), + sassOptions: { + includePaths: ['ui/app/css/'], + }, }, }, ], From 90289ec22a02aefc1da3518c93ea65b1d9cf6407 Mon Sep 17 00:00:00 2001 From: Erik Marks <25517051+rekmarks@users.noreply.github.com> Date: Wed, 20 Jan 2021 08:13:14 -0800 Subject: [PATCH 13/29] Further improve organization of constants (#10200) --- app/scripts/background.js | 12 +++---- .../contracts.js} | 0 app/scripts/controllers/detect-tokens.js | 5 ++- .../controllers/incoming-transactions.js | 2 +- app/scripts/controllers/metametrics.js | 2 +- .../controllers/network/createInfuraClient.js | 2 +- app/scripts/controllers/network/network.js | 9 +++-- app/scripts/controllers/network/util.js | 2 +- app/scripts/controllers/permissions/enums.js | 5 --- app/scripts/controllers/permissions/index.js | 9 +++-- .../controllers/permissions/permissionsLog.js | 2 +- app/scripts/controllers/preferences.js | 2 +- app/scripts/lib/account-tracker.js | 4 +-- app/scripts/lib/decrypt-message-manager.js | 2 +- .../lib/encryption-public-key-manager.js | 2 +- app/scripts/lib/message-manager.js | 2 +- app/scripts/lib/personal-message-manager.js | 2 +- .../handlers/get-provider-state.js | 2 +- .../handlers/log-web3-shim-usage.js | 2 +- .../handlers/watch-asset.js | 2 +- app/scripts/lib/typed-message-manager.js | 2 +- app/scripts/lib/util.js | 2 +- app/scripts/migrations/051.js | 2 +- app/scripts/platforms/extension.js | 2 +- app/scripts/ui.js | 6 ++-- .../lib/enums.js => shared/constants/app.js | 34 ++++++------------- shared/constants/metametrics.js | 2 +- .../enums.js => shared/constants/network.js | 0 shared/constants/permissions.js | 4 +++ .../app/controllers/detect-tokens-test.js | 5 +-- .../controllers/incoming-transactions-test.js | 2 +- test/unit/app/controllers/metametrics-test.js | 2 +- .../unit/app/controllers/permissions/mocks.js | 2 +- test/unit/app/controllers/swaps-test.js | 2 +- test/unit/app/util-test.js | 2 +- test/unit/migrations/051-test.js | 2 +- .../account-menu/account-menu.component.js | 2 +- ...confirm-page-container-header.component.js | 2 +- .../app/dropdowns/network-dropdown.js | 2 +- .../app/menu-bar/account-options-menu.js | 2 +- ui/app/components/app/menu-bar/menu-bar.js | 2 +- ui/app/components/app/modals/modal.js | 2 +- .../modals/qr-scanner/qr-scanner.component.js | 2 +- .../network-display.component.js | 2 +- .../signature-request-original.component.js | 2 +- .../signature-request-original.container.js | 2 +- .../signature-request.constants.js | 2 +- .../signature-request.container.js | 2 +- .../app/wallet-overview/eth-overview.js | 2 +- .../app/wallet-overview/token-overview.js | 2 +- .../confirm-add-suggested-token.component.js | 2 +- .../confirm-decrypt-message.component.js | 2 +- ...confirm-encryption-public-key.component.js | 2 +- .../confirm-transaction-base.component.js | 2 +- .../confirm-transaction-switch.component.js | 2 +- ui/app/pages/confirm-transaction/conf-tx.js | 2 +- ui/app/pages/error/error.component.js | 2 +- ui/app/pages/home/home.container.js | 2 +- .../permissions-connect.component.js | 2 +- ui/app/pages/routes/routes.component.js | 2 +- .../add-recipient/ens-input.component.js | 2 +- .../contact-list-tab.container.js | 2 +- .../networks-tab/networks-tab.constants.js | 2 +- .../networks-tab/networks-tab.container.js | 2 +- ui/app/pages/settings/settings.container.js | 2 +- ui/app/pages/swaps/index.js | 2 +- .../unlock-page/unlock-page.container.js | 2 +- ui/app/selectors/permissions.js | 2 +- ui/app/store/actions.js | 2 +- ui/index.js | 2 +- ui/lib/etherscan-prefix-for-network.js | 2 +- ui/lib/webcam-utils.js | 2 +- 72 files changed, 96 insertions(+), 117 deletions(-) rename app/scripts/{controllers/network/contract-addresses.js => constants/contracts.js} (100%) rename app/scripts/lib/enums.js => shared/constants/app.js (59%) rename app/scripts/controllers/network/enums.js => shared/constants/network.js (100%) create mode 100644 shared/constants/permissions.js diff --git a/app/scripts/background.js b/app/scripts/background.js index 1f8badfda..c63c4ade0 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -19,6 +19,12 @@ import extension from 'extensionizer' import { storeAsStream, storeTransformStream } from '@metamask/obs-store' import PortStream from 'extension-port-stream' import { captureException } from '@sentry/browser' + +import { + ENVIRONMENT_TYPE_POPUP, + ENVIRONMENT_TYPE_NOTIFICATION, + ENVIRONMENT_TYPE_FULLSCREEN, +} from '../../shared/constants/app' import migrations from './migrations' import Migrator from './lib/migrator' import ExtensionPlatform from './platforms/extension' @@ -31,12 +37,6 @@ import rawFirstTimeState from './first-time-state' import getFirstPreferredLangCode from './lib/get-first-preferred-lang-code' import getObjStructure from './lib/getObjStructure' import setupEnsIpfsResolver from './lib/ens-ipfs/setup' - -import { - ENVIRONMENT_TYPE_POPUP, - ENVIRONMENT_TYPE_NOTIFICATION, - ENVIRONMENT_TYPE_FULLSCREEN, -} from './lib/enums' /* eslint-enable import/first */ const { sentry } = global diff --git a/app/scripts/controllers/network/contract-addresses.js b/app/scripts/constants/contracts.js similarity index 100% rename from app/scripts/controllers/network/contract-addresses.js rename to app/scripts/constants/contracts.js diff --git a/app/scripts/controllers/detect-tokens.js b/app/scripts/controllers/detect-tokens.js index 1ad46193d..d91fdb989 100644 --- a/app/scripts/controllers/detect-tokens.js +++ b/app/scripts/controllers/detect-tokens.js @@ -2,12 +2,11 @@ import Web3 from 'web3' import contracts from '@metamask/contract-metadata' import { warn } from 'loglevel' import SINGLE_CALL_BALANCES_ABI from 'single-call-balance-checker-abi' -import { MAINNET_CHAIN_ID } from './network/enums' +import { MAINNET_CHAIN_ID } from '../../../shared/constants/network' +import { SINGLE_CALL_BALANCES_ADDRESS } from '../constants/contracts' // By default, poll every 3 minutes const DEFAULT_INTERVAL = 180 * 1000 -const SINGLE_CALL_BALANCES_ADDRESS = - '0xb1f8e55c7f64d203c1400b9d8555d050f94adf39' /** * A controller that polls for token exchange diff --git a/app/scripts/controllers/incoming-transactions.js b/app/scripts/controllers/incoming-transactions.js index 625272740..e1ff68895 100644 --- a/app/scripts/controllers/incoming-transactions.js +++ b/app/scripts/controllers/incoming-transactions.js @@ -22,7 +22,7 @@ import { RINKEBY_CHAIN_ID, ROPSTEN, ROPSTEN_CHAIN_ID, -} from './network/enums' +} from '../../../shared/constants/network' const fetchWithTimeout = getFetchWithTimeout(30000) diff --git a/app/scripts/controllers/metametrics.js b/app/scripts/controllers/metametrics.js index 3ae74cbf8..2c84ee78c 100644 --- a/app/scripts/controllers/metametrics.js +++ b/app/scripts/controllers/metametrics.js @@ -1,7 +1,7 @@ import { merge, omit } from 'lodash' import { ObservableStore } from '@metamask/obs-store' import { bufferToHex, sha3 } from 'ethereumjs-util' -import { ENVIRONMENT_TYPE_BACKGROUND } from '../lib/enums' +import { ENVIRONMENT_TYPE_BACKGROUND } from '../../../shared/constants/app' import { METAMETRICS_ANONYMOUS_ID, METAMETRICS_BACKGROUND_PAGE_OBJECT, diff --git a/app/scripts/controllers/network/createInfuraClient.js b/app/scripts/controllers/network/createInfuraClient.js index 2a26c9b75..0f37ea4ca 100644 --- a/app/scripts/controllers/network/createInfuraClient.js +++ b/app/scripts/controllers/network/createInfuraClient.js @@ -8,7 +8,7 @@ import providerFromMiddleware from 'eth-json-rpc-middleware/providerFromMiddlewa import createInfuraMiddleware from 'eth-json-rpc-infura' import BlockTracker from 'eth-block-tracker' -import { NETWORK_TYPE_TO_ID_MAP } from './enums' +import { NETWORK_TYPE_TO_ID_MAP } from '../../../../shared/constants/network' export default function createInfuraClient({ network, projectId }) { const infuraMiddleware = createInfuraMiddleware({ diff --git a/app/scripts/controllers/network/network.js b/app/scripts/controllers/network/network.js index 9bfc0fc07..d7683618e 100644 --- a/app/scripts/controllers/network/network.js +++ b/app/scripts/controllers/network/network.js @@ -9,10 +9,6 @@ import { createEventEmitterProxy, } from 'swappable-obj-proxy' import EthQuery from 'eth-query' -import createMetamaskMiddleware from './createMetamaskMiddleware' -import createInfuraClient from './createInfuraClient' -import createJsonRpcClient from './createJsonRpcClient' - import { RINKEBY, MAINNET, @@ -20,7 +16,10 @@ import { NETWORK_TYPE_TO_ID_MAP, MAINNET_CHAIN_ID, RINKEBY_CHAIN_ID, -} from './enums' +} from '../../../../shared/constants/network' +import createMetamaskMiddleware from './createMetamaskMiddleware' +import createInfuraClient from './createInfuraClient' +import createJsonRpcClient from './createJsonRpcClient' const env = process.env.METAMASK_ENV diff --git a/app/scripts/controllers/network/util.js b/app/scripts/controllers/network/util.js index 958a1d4dd..9c80db551 100644 --- a/app/scripts/controllers/network/util.js +++ b/app/scripts/controllers/network/util.js @@ -1,4 +1,4 @@ -import { NETWORK_TO_NAME_MAP } from './enums' +import { NETWORK_TO_NAME_MAP } from '../../../../shared/constants/network' export const getNetworkDisplayName = (key) => NETWORK_TO_NAME_MAP[key] diff --git a/app/scripts/controllers/permissions/enums.js b/app/scripts/controllers/permissions/enums.js index 510fad1b3..21356804f 100644 --- a/app/scripts/controllers/permissions/enums.js +++ b/app/scripts/controllers/permissions/enums.js @@ -10,11 +10,6 @@ export const METADATA_STORE_KEY = 'domainMetadata' export const METADATA_CACHE_MAX_SIZE = 100 -export const CAVEAT_NAMES = { - exposedAccounts: 'exposedAccounts', - primaryAccountOnly: 'primaryAccountOnly', -} - export const CAVEAT_TYPES = { limitResponseLength: 'limitResponseLength', filterResponse: 'filterResponse', diff --git a/app/scripts/controllers/permissions/index.js b/app/scripts/controllers/permissions/index.js index c4ffd14fb..515741a7e 100644 --- a/app/scripts/controllers/permissions/index.js +++ b/app/scripts/controllers/permissions/index.js @@ -6,10 +6,7 @@ import { CapabilitiesController as RpcCap } from 'rpc-cap' import { ethErrors } from 'eth-json-rpc-errors' import { cloneDeep } from 'lodash' -import createPermissionsMethodMiddleware from './permissionsMethodMiddleware' -import PermissionsLogController from './permissionsLog' - -// Methods that do not require any permissions to use: +import { CAVEAT_NAMES } from '../../../../shared/constants/permissions' import { APPROVAL_TYPE, SAFE_METHODS, // methods that do not require any permissions to use @@ -18,11 +15,13 @@ import { METADATA_CACHE_MAX_SIZE, LOG_STORE_KEY, HISTORY_STORE_KEY, - CAVEAT_NAMES, NOTIFICATION_NAMES, CAVEAT_TYPES, } from './enums' +import createPermissionsMethodMiddleware from './permissionsMethodMiddleware' +import PermissionsLogController from './permissionsLog' + // instanbul ignore next const noop = () => undefined diff --git a/app/scripts/controllers/permissions/permissionsLog.js b/app/scripts/controllers/permissions/permissionsLog.js index e1a37f0c8..28c87af6b 100644 --- a/app/scripts/controllers/permissions/permissionsLog.js +++ b/app/scripts/controllers/permissions/permissionsLog.js @@ -1,6 +1,6 @@ import { cloneDeep } from 'lodash' +import { CAVEAT_NAMES } from '../../../../shared/constants/permissions' import { - CAVEAT_NAMES, HISTORY_STORE_KEY, LOG_IGNORE_METHODS, LOG_LIMIT, diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 7445be65b..d8ea05856 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -7,7 +7,7 @@ import ethers from 'ethers' import log from 'loglevel' import { isPrefixedFormattedHexString } from '../lib/util' import { LISTED_CONTRACT_ADDRESSES } from '../../../shared/constants/tokens' -import { NETWORK_TYPE_TO_ID_MAP } from './network/enums' +import { NETWORK_TYPE_TO_ID_MAP } from '../../../shared/constants/network' export default class PreferencesController { /** diff --git a/app/scripts/lib/account-tracker.js b/app/scripts/lib/account-tracker.js index 850c39291..6b78081f0 100644 --- a/app/scripts/lib/account-tracker.js +++ b/app/scripts/lib/account-tracker.js @@ -19,14 +19,14 @@ import { RINKEBY_CHAIN_ID, ROPSTEN_CHAIN_ID, KOVAN_CHAIN_ID, -} from '../controllers/network/enums' +} from '../../../shared/constants/network' import { SINGLE_CALL_BALANCES_ADDRESS, SINGLE_CALL_BALANCES_ADDRESS_RINKEBY, SINGLE_CALL_BALANCES_ADDRESS_ROPSTEN, SINGLE_CALL_BALANCES_ADDRESS_KOVAN, -} from '../controllers/network/contract-addresses' +} from '../constants/contracts' import { bnToHex } from './util' /** diff --git a/app/scripts/lib/decrypt-message-manager.js b/app/scripts/lib/decrypt-message-manager.js index fc8ce03ce..e84397d42 100644 --- a/app/scripts/lib/decrypt-message-manager.js +++ b/app/scripts/lib/decrypt-message-manager.js @@ -3,9 +3,9 @@ import { ObservableStore } from '@metamask/obs-store' import ethUtil from 'ethereumjs-util' import { ethErrors } from 'eth-json-rpc-errors' import log from 'loglevel' +import { MESSAGE_TYPE } from '../../../shared/constants/app' import { addHexPrefix } from './util' import createId from './random-id' -import { MESSAGE_TYPE } from './enums' const hexRe = /^[0-9A-Fa-f]+$/gu diff --git a/app/scripts/lib/encryption-public-key-manager.js b/app/scripts/lib/encryption-public-key-manager.js index d563cae0b..48f2ab701 100644 --- a/app/scripts/lib/encryption-public-key-manager.js +++ b/app/scripts/lib/encryption-public-key-manager.js @@ -2,8 +2,8 @@ import EventEmitter from 'events' import { ObservableStore } from '@metamask/obs-store' import { ethErrors } from 'eth-json-rpc-errors' import log from 'loglevel' +import { MESSAGE_TYPE } from '../../../shared/constants/app' import createId from './random-id' -import { MESSAGE_TYPE } from './enums' /** * Represents, and contains data about, an 'eth_getEncryptionPublicKey' type request. These are created when diff --git a/app/scripts/lib/message-manager.js b/app/scripts/lib/message-manager.js index 872f97b0d..a3f0dee58 100644 --- a/app/scripts/lib/message-manager.js +++ b/app/scripts/lib/message-manager.js @@ -2,8 +2,8 @@ import EventEmitter from 'events' import { ObservableStore } from '@metamask/obs-store' import ethUtil from 'ethereumjs-util' import { ethErrors } from 'eth-json-rpc-errors' +import { MESSAGE_TYPE } from '../../../shared/constants/app' import createId from './random-id' -import { MESSAGE_TYPE } from './enums' /** * Represents, and contains data about, an 'eth_sign' type signature request. These are created when a signature for diff --git a/app/scripts/lib/personal-message-manager.js b/app/scripts/lib/personal-message-manager.js index 52d20588f..c08dddbb2 100644 --- a/app/scripts/lib/personal-message-manager.js +++ b/app/scripts/lib/personal-message-manager.js @@ -3,9 +3,9 @@ import { ObservableStore } from '@metamask/obs-store' import ethUtil from 'ethereumjs-util' import { ethErrors } from 'eth-json-rpc-errors' import log from 'loglevel' +import { MESSAGE_TYPE } from '../../../shared/constants/app' import { addHexPrefix } from './util' import createId from './random-id' -import { MESSAGE_TYPE } from './enums' const hexRe = /^[0-9A-Fa-f]+$/gu diff --git a/app/scripts/lib/rpc-method-middleware/handlers/get-provider-state.js b/app/scripts/lib/rpc-method-middleware/handlers/get-provider-state.js index 32b3c18c6..760517e10 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/get-provider-state.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/get-provider-state.js @@ -1,4 +1,4 @@ -import { MESSAGE_TYPE } from '../../enums' +import { MESSAGE_TYPE } from '../../../../../shared/constants/app' /** * This RPC method gets background state relevant to the provider. diff --git a/app/scripts/lib/rpc-method-middleware/handlers/log-web3-shim-usage.js b/app/scripts/lib/rpc-method-middleware/handlers/log-web3-shim-usage.js index 21e908000..3fb5a5743 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/log-web3-shim-usage.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/log-web3-shim-usage.js @@ -1,4 +1,4 @@ -import { MESSAGE_TYPE } from '../../enums' +import { MESSAGE_TYPE } from '../../../../../shared/constants/app' /** * This RPC method is called by the inpage provider whenever it detects the diff --git a/app/scripts/lib/rpc-method-middleware/handlers/watch-asset.js b/app/scripts/lib/rpc-method-middleware/handlers/watch-asset.js index 1c5f4c1db..60c8ad6da 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/watch-asset.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/watch-asset.js @@ -1,4 +1,4 @@ -import { MESSAGE_TYPE } from '../../enums' +import { MESSAGE_TYPE } from '../../../../../shared/constants/app' const watchAsset = { methodNames: [MESSAGE_TYPE.WATCH_ASSET, MESSAGE_TYPE.WATCH_ASSET_LEGACY], diff --git a/app/scripts/lib/typed-message-manager.js b/app/scripts/lib/typed-message-manager.js index 6bcfe846b..1dce10bc8 100644 --- a/app/scripts/lib/typed-message-manager.js +++ b/app/scripts/lib/typed-message-manager.js @@ -6,8 +6,8 @@ import { typedSignatureHash, TYPED_MESSAGE_SCHEMA } from 'eth-sig-util' import { isValidAddress } from 'ethereumjs-util' import log from 'loglevel' import jsonschema from 'jsonschema' +import { MESSAGE_TYPE } from '../../../shared/constants/app' import createId from './random-id' -import { MESSAGE_TYPE } from './enums' /** * Represents, and contains data about, an 'eth_signTypedData' type signature request. These are created when a diff --git a/app/scripts/lib/util.js b/app/scripts/lib/util.js index 1816d04ab..6750d8b43 100644 --- a/app/scripts/lib/util.js +++ b/app/scripts/lib/util.js @@ -14,7 +14,7 @@ import { PLATFORM_CHROME, PLATFORM_EDGE, PLATFORM_BRAVE, -} from './enums' +} from '../../../shared/constants/app' /** * @see {@link getEnvironmentType} diff --git a/app/scripts/migrations/051.js b/app/scripts/migrations/051.js index 0128dd656..4c024458d 100644 --- a/app/scripts/migrations/051.js +++ b/app/scripts/migrations/051.js @@ -1,5 +1,5 @@ import { cloneDeep } from 'lodash' -import { NETWORK_TYPE_TO_ID_MAP } from '../controllers/network/enums' +import { NETWORK_TYPE_TO_ID_MAP } from '../../../shared/constants/network' const version = 51 diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js index 3644e02cb..88117700d 100644 --- a/app/scripts/platforms/extension.js +++ b/app/scripts/platforms/extension.js @@ -1,7 +1,7 @@ import extension from 'extensionizer' import { createExplorerLink as explorerLink } from '@metamask/etherscan-link' import { getEnvironmentType, checkForError } from '../lib/util' -import { ENVIRONMENT_TYPE_BACKGROUND } from '../lib/enums' +import { ENVIRONMENT_TYPE_BACKGROUND } from '../../../shared/constants/app' import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction' export default class ExtensionPlatform { diff --git a/app/scripts/ui.js b/app/scripts/ui.js index f1f4a7b78..7aca1b724 100644 --- a/app/scripts/ui.js +++ b/app/scripts/ui.js @@ -12,12 +12,12 @@ import EthQuery from 'eth-query' import StreamProvider from 'web3-stream-provider' import log from 'loglevel' import launchMetaMaskUi from '../../ui' -import ExtensionPlatform from './platforms/extension' -import { setupMultiplex } from './lib/stream-utils' import { ENVIRONMENT_TYPE_FULLSCREEN, ENVIRONMENT_TYPE_POPUP, -} from './lib/enums' +} from '../../shared/constants/app' +import ExtensionPlatform from './platforms/extension' +import { setupMultiplex } from './lib/stream-utils' import { getEnvironmentType } from './lib/util' start().catch(log.error) diff --git a/app/scripts/lib/enums.js b/shared/constants/app.js similarity index 59% rename from app/scripts/lib/enums.js rename to shared/constants/app.js index a6b7a99de..90e4726b0 100644 --- a/app/scripts/lib/enums.js +++ b/shared/constants/app.js @@ -6,19 +6,18 @@ * background - The background process that powers the extension * @typedef {'popup' | 'notification' | 'fullscreen' | 'background'} EnvironmentType */ +export const ENVIRONMENT_TYPE_POPUP = 'popup' +export const ENVIRONMENT_TYPE_NOTIFICATION = 'notification' +export const ENVIRONMENT_TYPE_FULLSCREEN = 'fullscreen' +export const ENVIRONMENT_TYPE_BACKGROUND = 'background' -const ENVIRONMENT_TYPE_POPUP = 'popup' -const ENVIRONMENT_TYPE_NOTIFICATION = 'notification' -const ENVIRONMENT_TYPE_FULLSCREEN = 'fullscreen' -const ENVIRONMENT_TYPE_BACKGROUND = 'background' +export const PLATFORM_BRAVE = 'Brave' +export const PLATFORM_CHROME = 'Chrome' +export const PLATFORM_EDGE = 'Edge' +export const PLATFORM_FIREFOX = 'Firefox' +export const PLATFORM_OPERA = 'Opera' -const PLATFORM_BRAVE = 'Brave' -const PLATFORM_CHROME = 'Chrome' -const PLATFORM_EDGE = 'Edge' -const PLATFORM_FIREFOX = 'Firefox' -const PLATFORM_OPERA = 'Opera' - -const MESSAGE_TYPE = { +export const MESSAGE_TYPE = { ETH_DECRYPT: 'eth_decrypt', ETH_GET_ENCRYPTION_PUBLIC_KEY: 'eth_getEncryptionPublicKey', ETH_SIGN: 'eth_sign', @@ -29,16 +28,3 @@ const MESSAGE_TYPE = { WATCH_ASSET: 'wallet_watchAsset', WATCH_ASSET_LEGACY: 'metamask_watchAsset', } - -export { - ENVIRONMENT_TYPE_POPUP, - ENVIRONMENT_TYPE_NOTIFICATION, - ENVIRONMENT_TYPE_FULLSCREEN, - ENVIRONMENT_TYPE_BACKGROUND, - MESSAGE_TYPE, - PLATFORM_BRAVE, - PLATFORM_CHROME, - PLATFORM_EDGE, - PLATFORM_FIREFOX, - PLATFORM_OPERA, -} diff --git a/shared/constants/metametrics.js b/shared/constants/metametrics.js index 7bd2c4c5e..edb37a2a1 100644 --- a/shared/constants/metametrics.js +++ b/shared/constants/metametrics.js @@ -1,6 +1,6 @@ // Type Imports /** - * @typedef {import('../../app/scripts/lib/enums').EnvironmentType} EnvironmentType + * @typedef {import('../../shared/constants/app').EnvironmentType} EnvironmentType */ // Type Declarations diff --git a/app/scripts/controllers/network/enums.js b/shared/constants/network.js similarity index 100% rename from app/scripts/controllers/network/enums.js rename to shared/constants/network.js diff --git a/shared/constants/permissions.js b/shared/constants/permissions.js new file mode 100644 index 000000000..f396fbeba --- /dev/null +++ b/shared/constants/permissions.js @@ -0,0 +1,4 @@ +export const CAVEAT_NAMES = { + exposedAccounts: 'exposedAccounts', + primaryAccountOnly: 'primaryAccountOnly', +} diff --git a/test/unit/app/controllers/detect-tokens-test.js b/test/unit/app/controllers/detect-tokens-test.js index 6039a943c..d76906d26 100644 --- a/test/unit/app/controllers/detect-tokens-test.js +++ b/test/unit/app/controllers/detect-tokens-test.js @@ -7,10 +7,7 @@ import BigNumber from 'bignumber.js' import DetectTokensController from '../../../../app/scripts/controllers/detect-tokens' import NetworkController from '../../../../app/scripts/controllers/network/network' import PreferencesController from '../../../../app/scripts/controllers/preferences' -import { - MAINNET, - ROPSTEN, -} from '../../../../app/scripts/controllers/network/enums' +import { MAINNET, ROPSTEN } from '../../../../shared/constants/network' describe('DetectTokensController', function () { const sandbox = sinon.createSandbox() diff --git a/test/unit/app/controllers/incoming-transactions-test.js b/test/unit/app/controllers/incoming-transactions-test.js index 61768cee8..af8ac1084 100644 --- a/test/unit/app/controllers/incoming-transactions-test.js +++ b/test/unit/app/controllers/incoming-transactions-test.js @@ -14,7 +14,7 @@ import { ROPSTEN, ROPSTEN_CHAIN_ID, ROPSTEN_NETWORK_ID, -} from '../../../../app/scripts/controllers/network/enums' +} from '../../../../shared/constants/network' import { TRANSACTION_CATEGORIES, TRANSACTION_STATUSES, diff --git a/test/unit/app/controllers/metametrics-test.js b/test/unit/app/controllers/metametrics-test.js index 4e66fec4a..11c012bfc 100644 --- a/test/unit/app/controllers/metametrics-test.js +++ b/test/unit/app/controllers/metametrics-test.js @@ -1,7 +1,7 @@ import { strict as assert } from 'assert' import sinon from 'sinon' import MetaMetricsController from '../../../../app/scripts/controllers/metametrics' -import { ENVIRONMENT_TYPE_BACKGROUND } from '../../../../app/scripts/lib/enums' +import { ENVIRONMENT_TYPE_BACKGROUND } from '../../../../shared/constants/app' import { createSegmentMock } from '../../../../app/scripts/lib/segment' import { METAMETRICS_ANONYMOUS_ID, diff --git a/test/unit/app/controllers/permissions/mocks.js b/test/unit/app/controllers/permissions/mocks.js index 48937faf2..8d7d75e75 100644 --- a/test/unit/app/controllers/permissions/mocks.js +++ b/test/unit/app/controllers/permissions/mocks.js @@ -5,8 +5,8 @@ import { ApprovalController } from '@metamask/controllers' import _getRestrictedMethods from '../../../../../app/scripts/controllers/permissions/restrictedMethods' +import { CAVEAT_NAMES } from '../../../../../shared/constants/permissions' import { - CAVEAT_NAMES, CAVEAT_TYPES, NOTIFICATION_NAMES, } from '../../../../../app/scripts/controllers/permissions/enums' diff --git a/test/unit/app/controllers/swaps-test.js b/test/unit/app/controllers/swaps-test.js index 38f948088..2622d04eb 100644 --- a/test/unit/app/controllers/swaps-test.js +++ b/test/unit/app/controllers/swaps-test.js @@ -8,7 +8,7 @@ import { ObservableStore } from '@metamask/obs-store' import { ROPSTEN_NETWORK_ID, MAINNET_NETWORK_ID, -} from '../../../../app/scripts/controllers/network/enums' +} from '../../../../shared/constants/network' import { ETH_SWAPS_TOKEN_ADDRESS } from '../../../../ui/app/helpers/constants/swaps' import { createTestProviderTools } from '../../../stub/provider' import SwapsController, { diff --git a/test/unit/app/util-test.js b/test/unit/app/util-test.js index f2372576f..802ae93c9 100644 --- a/test/unit/app/util-test.js +++ b/test/unit/app/util-test.js @@ -10,7 +10,7 @@ import { ENVIRONMENT_TYPE_NOTIFICATION, ENVIRONMENT_TYPE_FULLSCREEN, ENVIRONMENT_TYPE_BACKGROUND, -} from '../../../app/scripts/lib/enums' +} from '../../../shared/constants/app' describe('app utils', function () { describe('getEnvironmentType', function () { diff --git a/test/unit/migrations/051-test.js b/test/unit/migrations/051-test.js index d692e5773..ae0a78afe 100644 --- a/test/unit/migrations/051-test.js +++ b/test/unit/migrations/051-test.js @@ -3,7 +3,7 @@ import migration51 from '../../../app/scripts/migrations/051' import { INFURA_PROVIDER_TYPES, NETWORK_TYPE_TO_ID_MAP, -} from '../../../app/scripts/controllers/network/enums' +} from '../../../shared/constants/network' describe('migration #51', function () { it('should update the version metadata', async function () { diff --git a/ui/app/components/app/account-menu/account-menu.component.js b/ui/app/components/app/account-menu/account-menu.component.js index 00c889a94..f16cb41a4 100644 --- a/ui/app/components/app/account-menu/account-menu.component.js +++ b/ui/app/components/app/account-menu/account-menu.component.js @@ -4,7 +4,7 @@ import { debounce } from 'lodash' import Fuse from 'fuse.js' import InputAdornment from '@material-ui/core/InputAdornment' import classnames from 'classnames' -import { ENVIRONMENT_TYPE_POPUP } from '../../../../../app/scripts/lib/enums' +import { ENVIRONMENT_TYPE_POPUP } from '../../../../../shared/constants/app' import { getEnvironmentType } from '../../../../../app/scripts/lib/util' import Identicon from '../../ui/identicon' import SiteIcon from '../../ui/site-icon' diff --git a/ui/app/components/app/confirm-page-container/confirm-page-container-header/confirm-page-container-header.component.js b/ui/app/components/app/confirm-page-container/confirm-page-container-header/confirm-page-container-header.component.js index 72e741a6b..bdc6295d6 100644 --- a/ui/app/components/app/confirm-page-container/confirm-page-container-header/confirm-page-container-header.component.js +++ b/ui/app/components/app/confirm-page-container/confirm-page-container-header/confirm-page-container-header.component.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types' import { ENVIRONMENT_TYPE_POPUP, ENVIRONMENT_TYPE_NOTIFICATION, -} from '../../../../../../app/scripts/lib/enums' +} from '../../../../../../shared/constants/app' import { getEnvironmentType } from '../../../../../../app/scripts/lib/util' import NetworkDisplay from '../../network-display' import Identicon from '../../../ui/identicon' diff --git a/ui/app/components/app/dropdowns/network-dropdown.js b/ui/app/components/app/dropdowns/network-dropdown.js index e55f77afc..4f2c2bdc2 100644 --- a/ui/app/components/app/dropdowns/network-dropdown.js +++ b/ui/app/components/app/dropdowns/network-dropdown.js @@ -9,7 +9,7 @@ import { NETWORKS_ROUTE, NETWORKS_FORM_ROUTE, } from '../../../helpers/constants/routes' -import { ENVIRONMENT_TYPE_FULLSCREEN } from '../../../../../app/scripts/lib/enums' +import { ENVIRONMENT_TYPE_FULLSCREEN } from '../../../../../shared/constants/app' import { getEnvironmentType, isPrefixedFormattedHexString, diff --git a/ui/app/components/app/menu-bar/account-options-menu.js b/ui/app/components/app/menu-bar/account-options-menu.js index 60ca1c598..d3c9723e7 100644 --- a/ui/app/components/app/menu-bar/account-options-menu.js +++ b/ui/app/components/app/menu-bar/account-options-menu.js @@ -16,7 +16,7 @@ import { import { useI18nContext } from '../../../hooks/useI18nContext' import { useMetricEvent } from '../../../hooks/useMetricEvent' import { getEnvironmentType } from '../../../../../app/scripts/lib/util' -import { ENVIRONMENT_TYPE_FULLSCREEN } from '../../../../../app/scripts/lib/enums' +import { ENVIRONMENT_TYPE_FULLSCREEN } from '../../../../../shared/constants/app' export default function AccountOptionsMenu({ anchorElement, onClose }) { const t = useI18nContext() diff --git a/ui/app/components/app/menu-bar/menu-bar.js b/ui/app/components/app/menu-bar/menu-bar.js index d9d13fcb1..f6c70a43e 100644 --- a/ui/app/components/app/menu-bar/menu-bar.js +++ b/ui/app/components/app/menu-bar/menu-bar.js @@ -5,7 +5,7 @@ import { useSelector } from 'react-redux' import SelectedAccount from '../selected-account' import ConnectedStatusIndicator from '../connected-status-indicator' import { getEnvironmentType } from '../../../../../app/scripts/lib/util' -import { ENVIRONMENT_TYPE_POPUP } from '../../../../../app/scripts/lib/enums' +import { ENVIRONMENT_TYPE_POPUP } from '../../../../../shared/constants/app' import { CONNECTED_ACCOUNTS_ROUTE } from '../../../helpers/constants/routes' import { useI18nContext } from '../../../hooks/useI18nContext' import { useMetricEvent } from '../../../hooks/useMetricEvent' diff --git a/ui/app/components/app/modals/modal.js b/ui/app/components/app/modals/modal.js index 46f915b16..5ad7d3470 100644 --- a/ui/app/components/app/modals/modal.js +++ b/ui/app/components/app/modals/modal.js @@ -6,7 +6,7 @@ import * as actions from '../../../store/actions' import { resetCustomData as resetCustomGasData } from '../../../ducks/gas/gas.duck' import isMobileView from '../../../../lib/is-mobile-view' import { getEnvironmentType } from '../../../../../app/scripts/lib/util' -import { ENVIRONMENT_TYPE_POPUP } from '../../../../../app/scripts/lib/enums' +import { ENVIRONMENT_TYPE_POPUP } from '../../../../../shared/constants/app' // Modal Components import ConfirmCustomizeGasModal from '../gas-customization/gas-modal-page-container' diff --git a/ui/app/components/app/modals/qr-scanner/qr-scanner.component.js b/ui/app/components/app/modals/qr-scanner/qr-scanner.component.js index 54556f630..2f82ce65f 100644 --- a/ui/app/components/app/modals/qr-scanner/qr-scanner.component.js +++ b/ui/app/components/app/modals/qr-scanner/qr-scanner.component.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types' import log from 'loglevel' import { BrowserQRCodeReader } from '@zxing/library' import { getEnvironmentType } from '../../../../../../app/scripts/lib/util' -import { ENVIRONMENT_TYPE_FULLSCREEN } from '../../../../../../app/scripts/lib/enums' +import { ENVIRONMENT_TYPE_FULLSCREEN } from '../../../../../../shared/constants/app' import Spinner from '../../../ui/spinner' import WebcamUtils from '../../../../../lib/webcam-utils' import PageContainerFooter from '../../../ui/page-container/page-container-footer/page-container-footer.component' diff --git a/ui/app/components/app/network-display/network-display.component.js b/ui/app/components/app/network-display/network-display.component.js index 0838ddc57..de2fd18f5 100644 --- a/ui/app/components/app/network-display/network-display.component.js +++ b/ui/app/components/app/network-display/network-display.component.js @@ -7,7 +7,7 @@ import { RINKEBY_NETWORK_ID, KOVAN_NETWORK_ID, GOERLI_NETWORK_ID, -} from '../../../../../app/scripts/controllers/network/enums' +} from '../../../../../shared/constants/network' const networkIdToTypeMap = { [MAINNET_NETWORK_ID]: 'mainnet', diff --git a/ui/app/components/app/signature-request-original/signature-request-original.component.js b/ui/app/components/app/signature-request-original/signature-request-original.component.js index b961f4def..f20933ad9 100644 --- a/ui/app/components/app/signature-request-original/signature-request-original.component.js +++ b/ui/app/components/app/signature-request-original/signature-request-original.component.js @@ -7,7 +7,7 @@ import { ObjectInspector } from 'react-inspector' import { ENVIRONMENT_TYPE_NOTIFICATION, MESSAGE_TYPE, -} from '../../../../../app/scripts/lib/enums' +} from '../../../../../shared/constants/app' import { getEnvironmentType } from '../../../../../app/scripts/lib/util' import Identicon from '../../ui/identicon' import AccountListItem from '../account-list-item' diff --git a/ui/app/components/app/signature-request-original/signature-request-original.container.js b/ui/app/components/app/signature-request-original/signature-request-original.container.js index 9a421aa67..7c1749fd5 100644 --- a/ui/app/components/app/signature-request-original/signature-request-original.container.js +++ b/ui/app/components/app/signature-request-original/signature-request-original.container.js @@ -2,7 +2,7 @@ import { connect } from 'react-redux' import { compose } from 'redux' import { withRouter } from 'react-router-dom' -import { MESSAGE_TYPE } from '../../../../../app/scripts/lib/enums' +import { MESSAGE_TYPE } from '../../../../../shared/constants/app' import { goHome } from '../../../store/actions' import { accountsWithSendEtherInfoSelector, diff --git a/ui/app/components/app/signature-request/signature-request.constants.js b/ui/app/components/app/signature-request/signature-request.constants.js index 9cf241928..7311a7a18 100644 --- a/ui/app/components/app/signature-request/signature-request.constants.js +++ b/ui/app/components/app/signature-request/signature-request.constants.js @@ -1,3 +1,3 @@ -import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../../../app/scripts/lib/enums' +import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../../../shared/constants/app' export { ENVIRONMENT_TYPE_NOTIFICATION } diff --git a/ui/app/components/app/signature-request/signature-request.container.js b/ui/app/components/app/signature-request/signature-request.container.js index 0a521db4b..0c69f1c7a 100644 --- a/ui/app/components/app/signature-request/signature-request.container.js +++ b/ui/app/components/app/signature-request/signature-request.container.js @@ -2,7 +2,7 @@ import { connect } from 'react-redux' import { clearConfirmTransaction } from '../../../ducks/confirm-transaction/confirm-transaction.duck' import { accountsWithSendEtherInfoSelector } from '../../../selectors' import { getAccountByAddress } from '../../../helpers/utils/util' -import { MESSAGE_TYPE } from '../../../../../app/scripts/lib/enums' +import { MESSAGE_TYPE } from '../../../../../shared/constants/app' import SignatureRequest from './signature-request.component' function mapStateToProps(state) { diff --git a/ui/app/components/app/wallet-overview/eth-overview.js b/ui/app/components/app/wallet-overview/eth-overview.js index 4a550fcef..69aef6382 100644 --- a/ui/app/components/app/wallet-overview/eth-overview.js +++ b/ui/app/components/app/wallet-overview/eth-overview.js @@ -34,7 +34,7 @@ import { setSwapsFromToken, } from '../../../ducks/swaps/swaps' import IconButton from '../../ui/icon-button' -import { MAINNET_CHAIN_ID } from '../../../../../app/scripts/controllers/network/enums' +import { MAINNET_CHAIN_ID } from '../../../../../shared/constants/network' import WalletOverview from './wallet-overview' const EthOverview = ({ className }) => { diff --git a/ui/app/components/app/wallet-overview/token-overview.js b/ui/app/components/app/wallet-overview/token-overview.js index 3a2cfab90..58b5673db 100644 --- a/ui/app/components/app/wallet-overview/token-overview.js +++ b/ui/app/components/app/wallet-overview/token-overview.js @@ -27,7 +27,7 @@ import { getCurrentKeyring, getCurrentChainId, } from '../../../selectors/selectors' -import { MAINNET_CHAIN_ID } from '../../../../../app/scripts/controllers/network/enums' +import { MAINNET_CHAIN_ID } from '../../../../../shared/constants/network' import SwapIcon from '../../ui/icon/swap-icon.component' import SendIcon from '../../ui/icon/overview-send-icon.component' diff --git a/ui/app/pages/confirm-add-suggested-token/confirm-add-suggested-token.component.js b/ui/app/pages/confirm-add-suggested-token/confirm-add-suggested-token.component.js index 2ef4e0ea3..b65af863b 100644 --- a/ui/app/pages/confirm-add-suggested-token/confirm-add-suggested-token.component.js +++ b/ui/app/pages/confirm-add-suggested-token/confirm-add-suggested-token.component.js @@ -4,7 +4,7 @@ import Button from '../../components/ui/button' import Identicon from '../../components/ui/identicon' import TokenBalance from '../../components/ui/token-balance' import { getEnvironmentType } from '../../../../app/scripts/lib/util' -import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../../app/scripts/lib/enums' +import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../../shared/constants/app' export default class ConfirmAddSuggestedToken extends Component { static contextTypes = { diff --git a/ui/app/pages/confirm-decrypt-message/confirm-decrypt-message.component.js b/ui/app/pages/confirm-decrypt-message/confirm-decrypt-message.component.js index a9f68d388..bb5366bfd 100644 --- a/ui/app/pages/confirm-decrypt-message/confirm-decrypt-message.component.js +++ b/ui/app/pages/confirm-decrypt-message/confirm-decrypt-message.component.js @@ -9,7 +9,7 @@ import Identicon from '../../components/ui/identicon' import Tooltip from '../../components/ui/tooltip' import Copy from '../../components/ui/icon/copy-icon.component' -import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../../app/scripts/lib/enums' +import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../../shared/constants/app' import { getEnvironmentType } from '../../../../app/scripts/lib/util' import { conversionUtil } from '../../helpers/utils/conversion-util' diff --git a/ui/app/pages/confirm-encryption-public-key/confirm-encryption-public-key.component.js b/ui/app/pages/confirm-encryption-public-key/confirm-encryption-public-key.component.js index c3d1dfaa2..a1c1178f7 100644 --- a/ui/app/pages/confirm-encryption-public-key/confirm-encryption-public-key.component.js +++ b/ui/app/pages/confirm-encryption-public-key/confirm-encryption-public-key.component.js @@ -5,7 +5,7 @@ import AccountListItem from '../../components/app/account-list-item' import Button from '../../components/ui/button' import Identicon from '../../components/ui/identicon' -import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../../app/scripts/lib/enums' +import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../../shared/constants/app' import { getEnvironmentType } from '../../../../app/scripts/lib/util' import { conversionUtil } from '../../helpers/utils/conversion-util' diff --git a/ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js b/ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js index 24f452182..0b7d82ae0 100644 --- a/ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js +++ b/ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js @@ -1,7 +1,7 @@ import ethUtil from 'ethereumjs-util' import React, { Component } from 'react' import PropTypes from 'prop-types' -import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../../app/scripts/lib/enums' +import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../../shared/constants/app' import { getEnvironmentType } from '../../../../app/scripts/lib/util' import ConfirmPageContainer, { ConfirmDetailRow, diff --git a/ui/app/pages/confirm-transaction-switch/confirm-transaction-switch.component.js b/ui/app/pages/confirm-transaction-switch/confirm-transaction-switch.component.js index 88dd10084..0de4f2951 100644 --- a/ui/app/pages/confirm-transaction-switch/confirm-transaction-switch.component.js +++ b/ui/app/pages/confirm-transaction-switch/confirm-transaction-switch.component.js @@ -14,7 +14,7 @@ import { DECRYPT_MESSAGE_REQUEST_PATH, ENCRYPTION_PUBLIC_KEY_REQUEST_PATH, } from '../../helpers/constants/routes' -import { MESSAGE_TYPE } from '../../../../app/scripts/lib/enums' +import { MESSAGE_TYPE } from '../../../../shared/constants/app' import { TRANSACTION_CATEGORIES } from '../../../../shared/constants/transaction' export default class ConfirmTransactionSwitch extends Component { diff --git a/ui/app/pages/confirm-transaction/conf-tx.js b/ui/app/pages/confirm-transaction/conf-tx.js index cbf700548..3298baae6 100644 --- a/ui/app/pages/confirm-transaction/conf-tx.js +++ b/ui/app/pages/confirm-transaction/conf-tx.js @@ -10,7 +10,7 @@ import SignatureRequest from '../../components/app/signature-request' import SignatureRequestOriginal from '../../components/app/signature-request-original' import Loading from '../../components/ui/loading-screen' import { getMostRecentOverviewPage } from '../../ducks/history/history' -import { MESSAGE_TYPE } from '../../../../app/scripts/lib/enums' +import { MESSAGE_TYPE } from '../../../../shared/constants/app' import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction' function mapStateToProps(state) { diff --git a/ui/app/pages/error/error.component.js b/ui/app/pages/error/error.component.js index d3fe6f756..e7e9ff6ed 100644 --- a/ui/app/pages/error/error.component.js +++ b/ui/app/pages/error/error.component.js @@ -1,7 +1,7 @@ import React, { PureComponent } from 'react' import PropTypes from 'prop-types' import { getEnvironmentType } from '../../../../app/scripts/lib/util' -import { ENVIRONMENT_TYPE_POPUP } from '../../../../app/scripts/lib/enums' +import { ENVIRONMENT_TYPE_POPUP } from '../../../../shared/constants/app' class ErrorPage extends PureComponent { static contextTypes = { diff --git a/ui/app/pages/home/home.container.js b/ui/app/pages/home/home.container.js index fedebf4ad..ba4b9e6d4 100644 --- a/ui/app/pages/home/home.container.js +++ b/ui/app/pages/home/home.container.js @@ -33,7 +33,7 @@ import { getEnvironmentType } from '../../../../app/scripts/lib/util' import { ENVIRONMENT_TYPE_NOTIFICATION, ENVIRONMENT_TYPE_POPUP, -} from '../../../../app/scripts/lib/enums' +} from '../../../../shared/constants/app' import { ALERT_TYPES, WEB3_SHIM_USAGE_ALERT_STATES, diff --git a/ui/app/pages/permissions-connect/permissions-connect.component.js b/ui/app/pages/permissions-connect/permissions-connect.component.js index bb16d1425..06a4f136c 100644 --- a/ui/app/pages/permissions-connect/permissions-connect.component.js +++ b/ui/app/pages/permissions-connect/permissions-connect.component.js @@ -2,7 +2,7 @@ import PropTypes from 'prop-types' import React, { Component } from 'react' import { Switch, Route } from 'react-router-dom' import { getEnvironmentType } from '../../../../app/scripts/lib/util' -import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../../app/scripts/lib/enums' +import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../../shared/constants/app' import { DEFAULT_ROUTE } from '../../helpers/constants/routes' import PermissionPageContainer from '../../components/app/permission-page-container' import ChooseAccount from './choose-account' diff --git a/ui/app/pages/routes/routes.component.js b/ui/app/pages/routes/routes.component.js index 04db4f0e9..5aaf80124 100644 --- a/ui/app/pages/routes/routes.component.js +++ b/ui/app/pages/routes/routes.component.js @@ -58,7 +58,7 @@ import { import { ENVIRONMENT_TYPE_NOTIFICATION, ENVIRONMENT_TYPE_POPUP, -} from '../../../../app/scripts/lib/enums' +} from '../../../../shared/constants/app' import { getEnvironmentType } from '../../../../app/scripts/lib/util' import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction' diff --git a/ui/app/pages/send/send-content/add-recipient/ens-input.component.js b/ui/app/pages/send/send-content/add-recipient/ens-input.component.js index e8c498060..a1d884e79 100644 --- a/ui/app/pages/send/send-content/add-recipient/ens-input.component.js +++ b/ui/app/pages/send/send-content/add-recipient/ens-input.component.js @@ -13,7 +13,7 @@ import { isValidAddress, isValidAddressHead, } from '../../../../helpers/utils/util' -import { MAINNET_NETWORK_ID } from '../../../../../../app/scripts/controllers/network/enums' +import { MAINNET_NETWORK_ID } from '../../../../../../shared/constants/network' // Local Constants const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' diff --git a/ui/app/pages/settings/contact-list-tab/contact-list-tab.container.js b/ui/app/pages/settings/contact-list-tab/contact-list-tab.container.js index 5d9139014..101daf7ab 100644 --- a/ui/app/pages/settings/contact-list-tab/contact-list-tab.container.js +++ b/ui/app/pages/settings/contact-list-tab/contact-list-tab.container.js @@ -2,7 +2,7 @@ import { compose } from 'redux' import { connect } from 'react-redux' import { withRouter } from 'react-router-dom' import { getAddressBook } from '../../../selectors' -import { ENVIRONMENT_TYPE_POPUP } from '../../../../../app/scripts/lib/enums' +import { ENVIRONMENT_TYPE_POPUP } from '../../../../../shared/constants/app' import { getEnvironmentType } from '../../../../../app/scripts/lib/util' import { diff --git a/ui/app/pages/settings/networks-tab/networks-tab.constants.js b/ui/app/pages/settings/networks-tab/networks-tab.constants.js index 0271abcfc..9a9eb9699 100644 --- a/ui/app/pages/settings/networks-tab/networks-tab.constants.js +++ b/ui/app/pages/settings/networks-tab/networks-tab.constants.js @@ -9,7 +9,7 @@ import { RINKEBY_CHAIN_ID, ROPSTEN, ROPSTEN_CHAIN_ID, -} from '../../../../../app/scripts/controllers/network/enums' +} from '../../../../../shared/constants/network' const defaultNetworksData = [ { diff --git a/ui/app/pages/settings/networks-tab/networks-tab.container.js b/ui/app/pages/settings/networks-tab/networks-tab.container.js index 94fcddc81..61fc03836 100644 --- a/ui/app/pages/settings/networks-tab/networks-tab.container.js +++ b/ui/app/pages/settings/networks-tab/networks-tab.container.js @@ -10,7 +10,7 @@ import { showModal, } from '../../../store/actions' import { NETWORKS_FORM_ROUTE } from '../../../helpers/constants/routes' -import { ENVIRONMENT_TYPE_FULLSCREEN } from '../../../../../app/scripts/lib/enums' +import { ENVIRONMENT_TYPE_FULLSCREEN } from '../../../../../shared/constants/app' import { getEnvironmentType } from '../../../../../app/scripts/lib/util' import NetworksTab from './networks-tab.component' import { defaultNetworksData } from './networks-tab.constants' diff --git a/ui/app/pages/settings/settings.container.js b/ui/app/pages/settings/settings.container.js index ffade71da..d35fbbe6d 100644 --- a/ui/app/pages/settings/settings.container.js +++ b/ui/app/pages/settings/settings.container.js @@ -3,7 +3,7 @@ import { connect } from 'react-redux' import { withRouter } from 'react-router-dom' import { getAddressBookEntryName } from '../../selectors' import { isValidAddress } from '../../helpers/utils/util' -import { ENVIRONMENT_TYPE_POPUP } from '../../../../app/scripts/lib/enums' +import { ENVIRONMENT_TYPE_POPUP } from '../../../../shared/constants/app' import { getEnvironmentType } from '../../../../app/scripts/lib/util' import { getMostRecentOverviewPage } from '../../ducks/history/history' diff --git a/ui/app/pages/swaps/index.js b/ui/app/pages/swaps/index.js index 01c1f8f78..ca720910d 100644 --- a/ui/app/pages/swaps/index.js +++ b/ui/app/pages/swaps/index.js @@ -48,7 +48,7 @@ import { SWAP_FAILED_ERROR, OFFLINE_FOR_MAINTENANCE, } from '../../helpers/constants/swaps' -import { MAINNET_CHAIN_ID } from '../../../../app/scripts/controllers/network/enums' +import { MAINNET_CHAIN_ID } from '../../../../shared/constants/network' import { resetBackgroundSwapsState, diff --git a/ui/app/pages/unlock-page/unlock-page.container.js b/ui/app/pages/unlock-page/unlock-page.container.js index 222d8b04a..9284ebeba 100644 --- a/ui/app/pages/unlock-page/unlock-page.container.js +++ b/ui/app/pages/unlock-page/unlock-page.container.js @@ -2,7 +2,7 @@ import { connect } from 'react-redux' import { withRouter } from 'react-router-dom' import { compose } from 'redux' import { getEnvironmentType } from '../../../../app/scripts/lib/util' -import { ENVIRONMENT_TYPE_POPUP } from '../../../../app/scripts/lib/enums' +import { ENVIRONMENT_TYPE_POPUP } from '../../../../shared/constants/app' import { DEFAULT_ROUTE, RESTORE_VAULT_ROUTE, diff --git a/ui/app/selectors/permissions.js b/ui/app/selectors/permissions.js index a463d09d0..e6dfa4db5 100644 --- a/ui/app/selectors/permissions.js +++ b/ui/app/selectors/permissions.js @@ -1,5 +1,5 @@ import { forOwn } from 'lodash' -import { CAVEAT_NAMES } from '../../../app/scripts/controllers/permissions/enums' +import { CAVEAT_NAMES } from '../../../shared/constants/permissions' import { getMetaMaskAccountsOrdered, getOriginOfCurrentTab, diff --git a/ui/app/store/actions.js b/ui/app/store/actions.js index 780bb81c1..0dd31dc9f 100644 --- a/ui/app/store/actions.js +++ b/ui/app/store/actions.js @@ -12,7 +12,7 @@ import { import { getMethodDataAsync } from '../helpers/utils/transactions.util' import { fetchSymbolAndDecimals } from '../helpers/utils/token-util' import switchDirection from '../helpers/utils/switch-direction' -import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../app/scripts/lib/enums' +import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../shared/constants/app' import { hasUnconfirmedTransactions } from '../helpers/utils/confirm-tx.util' import { setCustomGasLimit } from '../ducks/gas/gas.duck' import txHelper from '../../lib/tx-helper' diff --git a/ui/index.js b/ui/index.js index 6c4541f17..3f0e172f8 100644 --- a/ui/index.js +++ b/ui/index.js @@ -6,7 +6,7 @@ import { render } from 'react-dom' import { getEnvironmentType } from '../app/scripts/lib/util' import { ALERT_TYPES } from '../shared/constants/alerts' import { SENTRY_STATE } from '../app/scripts/lib/setupSentry' -import { ENVIRONMENT_TYPE_POPUP } from '../app/scripts/lib/enums' +import { ENVIRONMENT_TYPE_POPUP } from '../shared/constants/app' import Root from './app/pages' import * as actions from './app/store/actions' import configureStore from './app/store/store' diff --git a/ui/lib/etherscan-prefix-for-network.js b/ui/lib/etherscan-prefix-for-network.js index 32183d1bc..82e92f3b1 100644 --- a/ui/lib/etherscan-prefix-for-network.js +++ b/ui/lib/etherscan-prefix-for-network.js @@ -1,4 +1,4 @@ -import * as networkEnums from '../../app/scripts/controllers/network/enums' +import * as networkEnums from '../../shared/constants/network' /** * Gets the etherscan.io URL prefix for a given network ID. diff --git a/ui/lib/webcam-utils.js b/ui/lib/webcam-utils.js index a242186df..6c451fd21 100644 --- a/ui/lib/webcam-utils.js +++ b/ui/lib/webcam-utils.js @@ -4,7 +4,7 @@ import { ENVIRONMENT_TYPE_POPUP, PLATFORM_BRAVE, PLATFORM_FIREFOX, -} from '../../app/scripts/lib/enums' +} from '../../shared/constants/app' import { getEnvironmentType, getPlatform } from '../../app/scripts/lib/util' class WebcamUtils { From 7077ee68dc1bf1060628a615fdfca6223d52a56d Mon Sep 17 00:00:00 2001 From: Erik Marks <25517051+rekmarks@users.noreply.github.com> Date: Wed, 20 Jan 2021 08:49:05 -0800 Subject: [PATCH 14/29] Add NETWORK_TYPE_RPC constant (#10203) * Refactor network display props * Add NETWORK_TYPE_RPC constant * Consolidate network constants --- app/scripts/controllers/network/network.js | 13 +++--- shared/constants/network.js | 1 + test/unit/actions/config_test.js | 3 +- test/unit/localhostState.js | 4 +- .../app/dropdowns/network-dropdown.js | 3 +- .../loading-network-screen.container.js | 5 +- .../network-display.component.js | 46 ++++++------------- .../network-display.container.js | 10 ++-- ui/app/ducks/metamask/metamask.js | 3 +- ui/app/helpers/constants/common.js | 8 ---- .../networks-tab/networks-tab.component.js | 7 +-- .../networks-tab/networks-tab.container.js | 5 +- .../tests/view-quote-price-difference.test.js | 3 +- ui/app/selectors/selectors.js | 6 +-- 14 files changed, 54 insertions(+), 63 deletions(-) diff --git a/app/scripts/controllers/network/network.js b/app/scripts/controllers/network/network.js index d7683618e..0de14fc5c 100644 --- a/app/scripts/controllers/network/network.js +++ b/app/scripts/controllers/network/network.js @@ -13,6 +13,7 @@ import { RINKEBY, MAINNET, INFURA_PROVIDER_TYPES, + NETWORK_TYPE_RPC, NETWORK_TYPE_TO_ID_MAP, MAINNET_CHAIN_ID, RINKEBY_CHAIN_ID, @@ -26,7 +27,7 @@ const env = process.env.METAMASK_ENV let defaultProviderConfigOpts if (process.env.IN_TEST === 'true') { defaultProviderConfigOpts = { - type: 'rpc', + type: NETWORK_TYPE_RPC, rpcUrl: 'http://localhost:8545', chainId: '0x539', nickname: 'Localhost 8545', @@ -160,7 +161,7 @@ export default class NetworkController extends EventEmitter { setRpcTarget(rpcUrl, chainId, ticker = 'ETH', nickname = '', rpcPrefs) { this.setProviderConfig({ - type: 'rpc', + type: NETWORK_TYPE_RPC, rpcUrl, chainId, ticker, @@ -172,8 +173,8 @@ export default class NetworkController extends EventEmitter { async setProviderType(type, rpcUrl = '', ticker = 'ETH', nickname = '') { assert.notEqual( type, - 'rpc', - `NetworkController - cannot call "setProviderType" with type 'rpc'. use "setRpcTarget"`, + NETWORK_TYPE_RPC, + `NetworkController - cannot call "setProviderType" with type "${NETWORK_TYPE_RPC}". Use "setRpcTarget"`, ) assert( INFURA_PROVIDER_TYPES.includes(type), @@ -208,7 +209,7 @@ export default class NetworkController extends EventEmitter { getNetworkIdentifier() { const provider = this.providerStore.getState() - return provider.type === 'rpc' ? provider.rpcUrl : provider.type + return provider.type === NETWORK_TYPE_RPC ? provider.rpcUrl : provider.type } // @@ -227,7 +228,7 @@ export default class NetworkController extends EventEmitter { if (isInfura) { this._configureInfuraProvider(type, this._infuraProjectId) // url-based rpc endpoints - } else if (type === 'rpc') { + } else if (type === NETWORK_TYPE_RPC) { this._configureStandardProvider(rpcUrl, chainId) } else { throw new Error( diff --git a/shared/constants/network.js b/shared/constants/network.js index 6887a08dd..eba397466 100644 --- a/shared/constants/network.js +++ b/shared/constants/network.js @@ -3,6 +3,7 @@ export const RINKEBY = 'rinkeby' export const KOVAN = 'kovan' export const MAINNET = 'mainnet' export const GOERLI = 'goerli' +export const NETWORK_TYPE_RPC = 'rpc' export const MAINNET_NETWORK_ID = '1' export const ROPSTEN_NETWORK_ID = '3' diff --git a/test/unit/actions/config_test.js b/test/unit/actions/config_test.js index ed60ac299..35064ad9c 100644 --- a/test/unit/actions/config_test.js +++ b/test/unit/actions/config_test.js @@ -2,6 +2,7 @@ import assert from 'assert' import freeze from 'deep-freeze-strict' import reducers from '../../../ui/app/ducks' import * as actionConstants from '../../../ui/app/store/actionConstants' +import { NETWORK_TYPE_RPC } from '../../../shared/constants/network' describe('config view actions', function () { const initialState = { @@ -25,7 +26,7 @@ describe('config view actions', function () { } const result = reducers(initialState, action) - assert.equal(result.metamask.provider.type, 'rpc') + assert.equal(result.metamask.provider.type, NETWORK_TYPE_RPC) assert.equal(result.metamask.provider.rpcUrl, 'foo') }) }) diff --git a/test/unit/localhostState.js b/test/unit/localhostState.js index 8b0c68507..069ac0b78 100644 --- a/test/unit/localhostState.js +++ b/test/unit/localhostState.js @@ -1,3 +1,5 @@ +import { NETWORK_TYPE_RPC } from '../../shared/constants/network' + /** * @typedef {Object} FirstTimeState * @property {Object} config Initial configuration parameters @@ -11,7 +13,7 @@ const initialState = { config: {}, NetworkController: { provider: { - type: 'rpc', + type: NETWORK_TYPE_RPC, rpcUrl: 'http://localhost:8545', chainId: '0x539', }, diff --git a/ui/app/components/app/dropdowns/network-dropdown.js b/ui/app/components/app/dropdowns/network-dropdown.js index 4f2c2bdc2..daf1048bb 100644 --- a/ui/app/components/app/dropdowns/network-dropdown.js +++ b/ui/app/components/app/dropdowns/network-dropdown.js @@ -10,6 +10,7 @@ import { NETWORKS_FORM_ROUTE, } from '../../../helpers/constants/routes' import { ENVIRONMENT_TYPE_FULLSCREEN } from '../../../../../shared/constants/app' +import { NETWORK_TYPE_RPC } from '../../../../../shared/constants/network' import { getEnvironmentType, isPrefixedFormattedHexString, @@ -117,7 +118,7 @@ class NetworkDropdown extends Component { return reversedRpcListDetail.map((entry) => { const { rpcUrl, chainId, ticker = 'ETH', nickname = '' } = entry const isCurrentRpcTarget = - provider.type === 'rpc' && rpcUrl === provider.rpcUrl + provider.type === NETWORK_TYPE_RPC && rpcUrl === provider.rpcUrl return ( { const { rpcUrl, chainId, ticker, nickname, type } = provider const setProviderArgs = - type === 'rpc' ? [rpcUrl, chainId, ticker, nickname] : [provider.type] + type === NETWORK_TYPE_RPC + ? [rpcUrl, chainId, ticker, nickname] + : [provider.type] return { isLoadingNetwork: network === 'loading', diff --git a/ui/app/components/app/network-display/network-display.component.js b/ui/app/components/app/network-display/network-display.component.js index de2fd18f5..c045c1527 100644 --- a/ui/app/components/app/network-display/network-display.component.js +++ b/ui/app/components/app/network-display/network-display.component.js @@ -1,21 +1,7 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import classnames from 'classnames' -import { - MAINNET_NETWORK_ID, - ROPSTEN_NETWORK_ID, - RINKEBY_NETWORK_ID, - KOVAN_NETWORK_ID, - GOERLI_NETWORK_ID, -} from '../../../../../shared/constants/network' - -const networkIdToTypeMap = { - [MAINNET_NETWORK_ID]: 'mainnet', - [ROPSTEN_NETWORK_ID]: 'ropsten', - [RINKEBY_NETWORK_ID]: 'rinkeby', - [GOERLI_NETWORK_ID]: 'goerli', - [KOVAN_NETWORK_ID]: 'kovan', -} +import { NETWORK_TYPE_RPC } from '../../../../../shared/constants/network' export default class NetworkDisplay extends Component { static defaultProps = { @@ -23,9 +9,9 @@ export default class NetworkDisplay extends Component { } static propTypes = { + networkNickname: PropTypes.string.isRequired, + networkType: PropTypes.string.isRequired, colored: PropTypes.bool, - network: PropTypes.string, - provider: PropTypes.object, } static contextTypes = { @@ -33,12 +19,11 @@ export default class NetworkDisplay extends Component { } renderNetworkIcon() { - const { network } = this.props - const networkClass = networkIdToTypeMap[network] + const { networkType } = this.props - return networkClass ? ( + return networkType ? (
) : (
- {networkClass ? ( + {networkType ? (
) : (
)}
- {type === 'rpc' && nickname ? nickname : this.context.t(type)} + {networkType === NETWORK_TYPE_RPC && networkNickname + ? networkNickname + : this.context.t(networkType)}
) diff --git a/ui/app/components/app/network-display/network-display.container.js b/ui/app/components/app/network-display/network-display.container.js index 99a14fff4..136336448 100644 --- a/ui/app/components/app/network-display/network-display.container.js +++ b/ui/app/components/app/network-display/network-display.container.js @@ -1,10 +1,14 @@ import { connect } from 'react-redux' import NetworkDisplay from './network-display.component' -const mapStateToProps = ({ metamask: { network, provider } }) => { +const mapStateToProps = ({ + metamask: { + provider: { nickname, type }, + }, +}) => { return { - network, - provider, + networkNickname: nickname, + networkType: type, } } diff --git a/ui/app/ducks/metamask/metamask.js b/ui/app/ducks/metamask/metamask.js index 24180f0d3..cdc644a02 100644 --- a/ui/app/ducks/metamask/metamask.js +++ b/ui/app/ducks/metamask/metamask.js @@ -1,5 +1,6 @@ import * as actionConstants from '../../store/actionConstants' import { ALERT_TYPES } from '../../../../shared/constants/alerts' +import { NETWORK_TYPE_RPC } from '../../../../shared/constants/network' export default function reduceMetamask(state = {}, action) { const metamaskState = { @@ -63,7 +64,7 @@ export default function reduceMetamask(state = {}, action) { return { ...metamaskState, provider: { - type: 'rpc', + type: NETWORK_TYPE_RPC, rpcUrl: action.value, }, } diff --git a/ui/app/helpers/constants/common.js b/ui/app/helpers/constants/common.js index 573bab820..7a0503112 100644 --- a/ui/app/helpers/constants/common.js +++ b/ui/app/helpers/constants/common.js @@ -5,14 +5,6 @@ export const WEI = 'WEI' export const PRIMARY = 'PRIMARY' export const SECONDARY = 'SECONDARY' -export const NETWORK_TYPES = { - KOVAN: 'kovan', - MAINNET: 'mainnet', - RINKEBY: 'rinkeby', - ROPSTEN: 'ropsten', - GOERLI: 'goerli', -} - export const GAS_ESTIMATE_TYPES = { SLOW: 'SLOW', AVERAGE: 'AVERAGE', diff --git a/ui/app/pages/settings/networks-tab/networks-tab.component.js b/ui/app/pages/settings/networks-tab/networks-tab.component.js index df2c0c029..00e66cca8 100644 --- a/ui/app/pages/settings/networks-tab/networks-tab.component.js +++ b/ui/app/pages/settings/networks-tab/networks-tab.component.js @@ -1,6 +1,7 @@ import React, { PureComponent } from 'react' import PropTypes from 'prop-types' import classnames from 'classnames' +import { NETWORK_TYPE_RPC } from '../../../../../shared/constants/network' import Button from '../../../components/ui/button' import LockIcon from '../../../components/ui/lock-icon' import { @@ -90,7 +91,7 @@ export default class NetworksTab extends PureComponent { const listItemNetworkIsSelected = selectRpcUrl && selectRpcUrl === rpcUrl const listItemUrlIsProviderUrl = rpcUrl === providerUrl const listItemTypeIsProviderNonRpcType = - providerType !== 'rpc' && currentProviderType === providerType + providerType !== NETWORK_TYPE_RPC && currentProviderType === providerType const listItemNetworkIsCurrentProvider = !networkIsSelected && !networksTabIsInAddMode && @@ -118,12 +119,12 @@ export default class NetworksTab extends PureComponent { className={classnames('networks-tab__networks-list-name', { 'networks-tab__networks-list-name--selected': displayNetworkListItemAsSelected, 'networks-tab__networks-list-name--disabled': - currentProviderType !== 'rpc' && + currentProviderType !== NETWORK_TYPE_RPC && !displayNetworkListItemAsSelected, })} > {label || this.context.t(labelKey)} - {currentProviderType !== 'rpc' && ( + {currentProviderType !== NETWORK_TYPE_RPC && ( )}
diff --git a/ui/app/pages/settings/networks-tab/networks-tab.container.js b/ui/app/pages/settings/networks-tab/networks-tab.container.js index 61fc03836..14f5d3929 100644 --- a/ui/app/pages/settings/networks-tab/networks-tab.container.js +++ b/ui/app/pages/settings/networks-tab/networks-tab.container.js @@ -11,6 +11,7 @@ import { } from '../../../store/actions' import { NETWORKS_FORM_ROUTE } from '../../../helpers/constants/routes' import { ENVIRONMENT_TYPE_FULLSCREEN } from '../../../../../shared/constants/app' +import { NETWORK_TYPE_RPC } from '../../../../../shared/constants/network' import { getEnvironmentType } from '../../../../../app/scripts/lib/util' import NetworksTab from './networks-tab.component' import { defaultNetworksData } from './networks-tab.constants' @@ -37,7 +38,7 @@ const mapStateToProps = (state, ownProps) => { return { label: rpc.nickname, iconColor: '#6A737D', - providerType: 'rpc', + providerType: NETWORK_TYPE_RPC, rpcUrl: rpc.rpcUrl, chainId: rpc.chainId, ticker: rpc.ticker, @@ -61,7 +62,7 @@ const mapStateToProps = (state, ownProps) => { networksToRender.find((network) => { return ( network.rpcUrl === provider.rpcUrl || - (network.providerType !== 'rpc' && + (network.providerType !== NETWORK_TYPE_RPC && network.providerType === provider.type) ) }) || {} diff --git a/ui/app/pages/swaps/view-quote/tests/view-quote-price-difference.test.js b/ui/app/pages/swaps/view-quote/tests/view-quote-price-difference.test.js index d32cc5759..bf37e0061 100644 --- a/ui/app/pages/swaps/view-quote/tests/view-quote-price-difference.test.js +++ b/ui/app/pages/swaps/view-quote/tests/view-quote-price-difference.test.js @@ -3,6 +3,7 @@ import React from 'react' import { shallow } from 'enzyme' import { Provider } from 'react-redux' import configureMockStore from 'redux-mock-store' +import { NETWORK_TYPE_RPC } from '../../../../../../shared/constants/network' import ViewQuotePriceDifference from '../view-quote-price-difference' describe('View Price Quote Difference', function () { @@ -11,7 +12,7 @@ describe('View Price Quote Difference', function () { const state = { metamask: { tokens: [], - provider: { type: 'rpc', nickname: '', rpcUrl: '' }, + provider: { type: NETWORK_TYPE_RPC, nickname: '', rpcUrl: '' }, preferences: { showFiatInTestnets: true }, currentCurrency: 'usd', conversionRate: 600.0, diff --git a/ui/app/selectors/selectors.js b/ui/app/selectors/selectors.js index 5607476a8..9db335a85 100644 --- a/ui/app/selectors/selectors.js +++ b/ui/app/selectors/selectors.js @@ -1,7 +1,7 @@ import { stripHexPrefix } from 'ethereumjs-util' import { createSelector } from 'reselect' import { addHexPrefix } from '../../../app/scripts/lib/util' -import { NETWORK_TYPES } from '../helpers/constants/common' +import { MAINNET, NETWORK_TYPE_RPC } from '../../../shared/constants/network' import { shortenAddress, checksumAddress, @@ -21,7 +21,7 @@ export function getNetworkIdentifier(state) { export function getMetricsNetworkIdentifier(state) { const { provider } = state.metamask - return provider.type === 'rpc' ? provider.rpcUrl : provider.type + return provider.type === NETWORK_TYPE_RPC ? provider.rpcUrl : provider.type } export function getCurrentChainId(state) { @@ -281,7 +281,7 @@ function getSuggestedTokenCount(state) { export function getIsMainnet(state) { const networkType = getNetworkIdentifier(state) - return networkType === NETWORK_TYPES.MAINNET + return networkType === MAINNET } export function getPreferences({ metamask }) { From 118281b9a9eebf76585012274a2f8de151cc6203 Mon Sep 17 00:00:00 2001 From: Erik Marks <25517051+rekmarks@users.noreply.github.com> Date: Wed, 20 Jan 2021 10:42:59 -0800 Subject: [PATCH 15/29] @metamask/inpage-provider@8.0.3 (#10219) Restores the provider `data` event. --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 39d6ea073..131f0f506 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "@metamask/eth-ledger-bridge-keyring": "^0.2.6", "@metamask/eth-token-tracker": "^3.0.1", "@metamask/etherscan-link": "^1.4.0", - "@metamask/inpage-provider": "^8.0.2", + "@metamask/inpage-provider": "^8.0.3", "@metamask/jazzicon": "^2.0.0", "@metamask/logo": "^2.5.0", "@metamask/obs-store": "^5.0.0", diff --git a/yarn.lock b/yarn.lock index 714252227..411f8b64c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2114,10 +2114,10 @@ resolved "https://registry.yarnpkg.com/@metamask/forwarder/-/forwarder-1.1.0.tgz#13829d8244bbf19ea658c0b20d21a77b67de0bdd" integrity sha512-Hggj4y0QIjDzKGTXzarhEPIQyFSB2bi2y6YLJNwaT4JmP30UB5Cj6gqoY0M4pj3QT57fzp0BUuGp7F/AUe28tw== -"@metamask/inpage-provider@^8.0.2": - version "8.0.2" - resolved "https://registry.yarnpkg.com/@metamask/inpage-provider/-/inpage-provider-8.0.2.tgz#50e7559a3ab729e46c5f1e92baa3a3465617c10e" - integrity sha512-LG4wqf7LKwv9akI38HR25Mt/9+YD+DOtbZZKZSG8zUx3hI8moIKxbSwS64pqEyARmLhLKXYkZNROkPjxqbvTdA== +"@metamask/inpage-provider@^8.0.3": + version "8.0.3" + resolved "https://registry.yarnpkg.com/@metamask/inpage-provider/-/inpage-provider-8.0.3.tgz#65f636233a13a00e1f199a421bdfa8099ed28ea4" + integrity sha512-pj9tGNoS1edohuRJzxOuILRqRrQTdgu5mJwMwa9wuOZIMQLFZtr3g2T6vayPBwoNkE1FzLhs/osUqaVQDRfDvQ== dependencies: "@metamask/object-multiplex" "^1.1.0" "@metamask/safe-event-emitter" "^2.0.0" From 29f4c93830036b629072dfb26030b557001b20eb Mon Sep 17 00:00:00 2001 From: Brad Decker Date: Wed, 20 Jan 2021 16:13:33 -0600 Subject: [PATCH 16/29] add new typography component (#10197) --- ui/app/components/ui/typography/index.js | 1 + ui/app/components/ui/typography/typography.js | 58 +++++++++++++++++++ .../components/ui/typography/typography.scss | 38 ++++++++++++ .../ui/typography/typography.stories.js | 53 +++++++++++++++++ ui/app/components/ui/ui-components.scss | 1 + 5 files changed, 151 insertions(+) create mode 100644 ui/app/components/ui/typography/index.js create mode 100644 ui/app/components/ui/typography/typography.js create mode 100644 ui/app/components/ui/typography/typography.scss create mode 100644 ui/app/components/ui/typography/typography.stories.js diff --git a/ui/app/components/ui/typography/index.js b/ui/app/components/ui/typography/index.js new file mode 100644 index 000000000..648ce1725 --- /dev/null +++ b/ui/app/components/ui/typography/index.js @@ -0,0 +1 @@ +export { default } from './typography' diff --git a/ui/app/components/ui/typography/typography.js b/ui/app/components/ui/typography/typography.js new file mode 100644 index 000000000..93990b00b --- /dev/null +++ b/ui/app/components/ui/typography/typography.js @@ -0,0 +1,58 @@ +import React from 'react' +import classnames from 'classnames' +import PropTypes from 'prop-types' +import { COLORS, TYPOGRAPHY } from '../../../helpers/constants/design-system' + +const { H6, H7, H8, H9 } = TYPOGRAPHY + +export default function Typography({ + variant = TYPOGRAPHY.Paragraph, + className, + color = COLORS.BLACK, + tag, + children, + spacing = 1, + fontWeight = 'normal', + align, +}) { + const computedClassName = classnames( + 'typography', + className, + `typography--${variant}`, + `typography--align-${align}`, + `typography--spacing-${spacing}`, + `typography--color-${color}`, + `typography--weight-${fontWeight}`, + ) + + let Tag = tag ?? variant + + if (Tag === TYPOGRAPHY.Paragraph) { + Tag = 'p' + } else if ([H7, H8, H9].includes(Tag)) { + Tag = H6 + } + + return {children} +} + +Typography.propTypes = { + variant: PropTypes.oneOf(Object.values(TYPOGRAPHY)), + children: PropTypes.node.isRequired, + color: PropTypes.oneOf(Object.values(COLORS)), + className: PropTypes.string, + align: PropTypes.oneOf(['center', 'right']), + spacing: PropTypes.oneOf([1, 2, 3, 4, 5, 6, 7, 8]), + fontWeight: PropTypes.oneOf(['bold', 'normal']), + tag: PropTypes.oneOf([ + 'p', + 'h1', + 'h2', + 'h3', + 'h4', + 'h5', + 'h6', + 'span', + 'div', + ]), +} diff --git a/ui/app/components/ui/typography/typography.scss b/ui/app/components/ui/typography/typography.scss new file mode 100644 index 000000000..e377f31d2 --- /dev/null +++ b/ui/app/components/ui/typography/typography.scss @@ -0,0 +1,38 @@ +@use "design-system"; +@use "sass:map"; + +.typography { + @include design-system.Paragraph; + + @each $variant in map.keys(design-system.$typography-variants) { + &--#{$variant} { + @include design-system.typography($variant); + } + } + + @each $variant, $color in design-system.$color-map { + &--color-#{$variant} { + color: $color; + } + } + + @each $variant, $weight in design-system.$typography-font-weights { + &--weight-#{$variant} { + font-weight: $weight; + } + } + + &--align-center { + text-align: center; + } + + &--align-right { + text-align: right; + } + + @for $i from 1 through 8 { + &--spacing-#{$i} { + margin: #{$i * 4}px auto; + } + } +} diff --git a/ui/app/components/ui/typography/typography.stories.js b/ui/app/components/ui/typography/typography.stories.js new file mode 100644 index 000000000..68d567e35 --- /dev/null +++ b/ui/app/components/ui/typography/typography.stories.js @@ -0,0 +1,53 @@ +import React from 'react' +import { number, select, text } from '@storybook/addon-knobs' +import { COLORS, TYPOGRAPHY } from '../../../helpers/constants/design-system' +import Typography from '.' + +export default { + title: 'Typography', +} + +const fontWeightOptions = { + bold: 'bold', + normal: 'normal', +} + +const alignOptions = { + left: undefined, + center: 'center', + right: 'right', +} + +export const list = () => ( +
+ {Object.values(TYPOGRAPHY).map((variant) => ( +
+ + {variant} + +
+ ))} +
+) + +export const TheQuickOrangeFox = () => ( +
+
+ + {text('content', 'The quick orange fox jumped over the lazy dog.')} + +
+
+) diff --git a/ui/app/components/ui/ui-components.scss b/ui/app/components/ui/ui-components.scss index 2c7c1163b..3d5e5446c 100644 --- a/ui/app/components/ui/ui-components.scss +++ b/ui/app/components/ui/ui-components.scss @@ -37,5 +37,6 @@ @import 'toggle-button/index'; @import 'token-balance/index'; @import 'tooltip/index'; +@import 'typography/typography'; @import 'unit-input/index'; @import 'url-icon/index'; From e9079be2b8403d43653df7ec8a5da60550bf7dc1 Mon Sep 17 00:00:00 2001 From: Brad Decker Date: Wed, 20 Jan 2021 17:06:01 -0600 Subject: [PATCH 17/29] add chip component (#10199) --- ui/app/components/ui/chip/chip.js | 55 +++++++++++++++ ui/app/components/ui/chip/chip.scss | 48 +++++++++++++ ui/app/components/ui/chip/chip.stories.js | 82 +++++++++++++++++++++++ ui/app/components/ui/chip/index.js | 1 + ui/app/components/ui/ui-components.scss | 1 + ui/app/css/design-system/colors.scss | 1 + ui/app/helpers/constants/design-system.js | 1 + 7 files changed, 189 insertions(+) create mode 100644 ui/app/components/ui/chip/chip.js create mode 100644 ui/app/components/ui/chip/chip.scss create mode 100644 ui/app/components/ui/chip/chip.stories.js create mode 100644 ui/app/components/ui/chip/index.js diff --git a/ui/app/components/ui/chip/chip.js b/ui/app/components/ui/chip/chip.js new file mode 100644 index 000000000..c2281f7d4 --- /dev/null +++ b/ui/app/components/ui/chip/chip.js @@ -0,0 +1,55 @@ +import React from 'react' +import PropTypes from 'prop-types' +import classnames from 'classnames' +import { omit } from 'lodash' +import Typography from '../typography' +import { COLORS } from '../../../helpers/constants/design-system' + +export default function Chip({ + className, + children, + borderColor = COLORS.UI1, + label, + labelProps = {}, + leftIcon, + rightIcon, + onClick, +}) { + return ( +
+ {leftIcon &&
{leftIcon}
} + {children ?? ( + + {label} + + )} + {rightIcon &&
{rightIcon}
} +
+ ) +} + +Chip.propTypes = { + borderColor: PropTypes.oneOf(Object.values(COLORS)), + label: PropTypes.string, + children: PropTypes.node, + labelProps: PropTypes.shape(omit(Typography.propTypes, ['className'])), + leftIcon: PropTypes.node, + rightIcon: PropTypes.node, + className: PropTypes.string, + onClick: PropTypes.func, +} diff --git a/ui/app/components/ui/chip/chip.scss b/ui/app/components/ui/chip/chip.scss new file mode 100644 index 000000000..911f5a8ce --- /dev/null +++ b/ui/app/components/ui/chip/chip.scss @@ -0,0 +1,48 @@ +@use "design-system"; + +.chip { + $self: &; + + border-radius: 100px; + border: 1px solid design-system.$ui-1; + padding: 8px 16px; + margin: 0 4px; + display: flex; + align-items: center; + width: max-content; + + &__left-icon, + &__right-icon { + display: flex; + align-items: center; + } + + @each $variant, $color in design-system.$color-map { + &--#{$variant} { + border-color: $color; + } + } + + &--with-left-icon, + &--with-right-icon { + padding-top: 4px; + padding-bottom: 4px; + } + + &--with-left-icon { + padding-left: 4px; + + #{$self}__label { + margin-left: 8px; + } + } + + + + &--with-right-icon { + padding-right: 4px; + #{$self}__label { + margin-right: 8px; + } + } +} diff --git a/ui/app/components/ui/chip/chip.stories.js b/ui/app/components/ui/chip/chip.stories.js new file mode 100644 index 000000000..e2f3fd5df --- /dev/null +++ b/ui/app/components/ui/chip/chip.stories.js @@ -0,0 +1,82 @@ +/* eslint-disable react/prop-types */ + +import React from 'react' +import { select, text } from '@storybook/addon-knobs' +import { COLORS, TYPOGRAPHY } from '../../../helpers/constants/design-system' +import ApproveIcon from '../icon/approve-icon.component' +import Identicon from '../identicon/identicon.component' +import Chip from '.' + +export default { + title: 'Chip', +} + +export const Plain = ({ + leftIcon, + rightIcon, + label = 'Hello', + borderColor = COLORS.UI1, + fontColor = COLORS.BLACK, +}) => ( + +) + +export const WithLeftIcon = () => ( + } + /> +) + +export const WithRightIcon = () => ( + + } + /> +) + +export const WithBothIcons = () => ( + + + + } + leftIcon={ + + } + /> +) diff --git a/ui/app/components/ui/chip/index.js b/ui/app/components/ui/chip/index.js new file mode 100644 index 000000000..54029bc48 --- /dev/null +++ b/ui/app/components/ui/chip/index.js @@ -0,0 +1 @@ +export { default } from './chip' diff --git a/ui/app/components/ui/ui-components.scss b/ui/app/components/ui/ui-components.scss index 3d5e5446c..f7f18b0a2 100644 --- a/ui/app/components/ui/ui-components.scss +++ b/ui/app/components/ui/ui-components.scss @@ -7,6 +7,7 @@ @import 'button/buttons'; @import 'card/index'; @import 'check-box/index'; +@import 'chip/chip'; @import 'circle-icon/index'; @import 'currency-display/index'; @import 'currency-input/index'; diff --git a/ui/app/css/design-system/colors.scss b/ui/app/css/design-system/colors.scss index a1383b661..b447315f8 100644 --- a/ui/app/css/design-system/colors.scss +++ b/ui/app/css/design-system/colors.scss @@ -136,4 +136,5 @@ $color-map: ( 'kovan': $kovan, 'rinkeby': $rinkeby, 'goerli': $goerli, + 'transparent': transparent, ); diff --git a/ui/app/helpers/constants/design-system.js b/ui/app/helpers/constants/design-system.js index 6d6512eba..0d1a42eea 100644 --- a/ui/app/helpers/constants/design-system.js +++ b/ui/app/helpers/constants/design-system.js @@ -25,6 +25,7 @@ export const COLORS = { KOVAN: 'kovan', RINKEBY: 'rinkeby', GOERLI: 'goerli', + TRANSPARENT: 'transparent', } export const TYPOGRAPHY = { From 4fef2b7443645e1a93d0bf82929267e888ddce43 Mon Sep 17 00:00:00 2001 From: Erik Marks <25517051+rekmarks@users.noreply.github.com> Date: Wed, 20 Jan 2021 15:37:18 -0800 Subject: [PATCH 18/29] Add MAX_SAFE_CHAIN_ID and refactor chain ID validation (#10224) * Add MAX_SAFE_CHAIN_ID constant * Add isSafeChainId to shared utils module * Move isPrefixedFormattedHexString to shared utils module * Validate custom RPC chain IDs in network controller * Update some network controller error messages. * Add isSafeChainId validation to UI --- app/_locales/en/messages.json | 3 ++ app/scripts/controllers/network/network.js | 18 +++++++++-- app/scripts/controllers/preferences.js | 2 +- app/scripts/lib/util.js | 16 ---------- app/scripts/metamask-controller.js | 8 ++--- shared/constants/network.js | 6 ++++ shared/modules/README.md | 3 -- shared/modules/utils.js | 30 +++++++++++++++++++ test/unit/app/util-test.js | 2 +- .../app/dropdowns/network-dropdown.js | 6 ++-- .../network-form/network-form.component.js | 16 ++++++---- 11 files changed, 73 insertions(+), 37 deletions(-) delete mode 100644 shared/modules/README.md create mode 100644 shared/modules/utils.js diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index c1c969b13..e6ff6ed73 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -845,6 +845,9 @@ "invalidBlockExplorerURL": { "message": "Invalid Block Explorer URL" }, + "invalidChainIdTooBig": { + "message": "Invalid chain ID. The chain ID is too big." + }, "invalidCustomNetworkAlertContent1": { "message": "The chain ID for custom network '$1' has to be re-entered.", "description": "$1 is the name/identifier of the network." diff --git a/app/scripts/controllers/network/network.js b/app/scripts/controllers/network/network.js index 0de14fc5c..605d01ade 100644 --- a/app/scripts/controllers/network/network.js +++ b/app/scripts/controllers/network/network.js @@ -18,6 +18,10 @@ import { MAINNET_CHAIN_ID, RINKEBY_CHAIN_ID, } from '../../../../shared/constants/network' +import { + isPrefixedFormattedHexString, + isSafeChainId, +} from '../../../../shared/modules/utils' import createMetamaskMiddleware from './createMetamaskMiddleware' import createInfuraClient from './createInfuraClient' import createJsonRpcClient from './createJsonRpcClient' @@ -160,6 +164,14 @@ export default class NetworkController extends EventEmitter { } setRpcTarget(rpcUrl, chainId, ticker = 'ETH', nickname = '', rpcPrefs) { + assert.ok( + isPrefixedFormattedHexString(chainId), + `Invalid chain ID "${chainId}": invalid hex string.`, + ) + assert.ok( + isSafeChainId(parseInt(chainId, 16)), + `Invalid chain ID "${chainId}": numerical value greater than max safe value.`, + ) this.setProviderConfig({ type: NETWORK_TYPE_RPC, rpcUrl, @@ -171,14 +183,14 @@ export default class NetworkController extends EventEmitter { } async setProviderType(type, rpcUrl = '', ticker = 'ETH', nickname = '') { - assert.notEqual( + assert.notStrictEqual( type, NETWORK_TYPE_RPC, `NetworkController - cannot call "setProviderType" with type "${NETWORK_TYPE_RPC}". Use "setRpcTarget"`, ) - assert( + assert.ok( INFURA_PROVIDER_TYPES.includes(type), - `NetworkController - Unknown rpc type "${type}"`, + `Unknown Infura provider type "${type}".`, ) const { chainId } = NETWORK_TYPE_TO_ID_MAP[type] this.setProviderConfig({ type, rpcUrl, chainId, ticker, nickname }) diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index d8ea05856..df81ead32 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -5,9 +5,9 @@ import { normalize as normalizeAddress } from 'eth-sig-util' import { isValidAddress } from 'ethereumjs-util' import ethers from 'ethers' import log from 'loglevel' -import { isPrefixedFormattedHexString } from '../lib/util' import { LISTED_CONTRACT_ADDRESSES } from '../../../shared/constants/tokens' import { NETWORK_TYPE_TO_ID_MAP } from '../../../shared/constants/network' +import { isPrefixedFormattedHexString } from '../../../shared/modules/utils' export default class PreferencesController { /** diff --git a/app/scripts/lib/util.js b/app/scripts/lib/util.js index 6750d8b43..04d83aabd 100644 --- a/app/scripts/lib/util.js +++ b/app/scripts/lib/util.js @@ -147,21 +147,6 @@ function checkForError() { return new Error(lastError.message) } -/** - * Checks whether the given value is a 0x-prefixed, non-zero, non-zero-padded, - * hexadecimal string. - * - * @param {any} value - The value to check. - * @returns {boolean} True if the value is a correctly formatted hex string, - * false otherwise. - */ -function isPrefixedFormattedHexString(value) { - if (typeof value !== 'string') { - return false - } - return /^0x[1-9a-f]+[0-9a-f]*$/iu.test(value) -} - /** * Prefixes a hex string with '0x' or '-0x' and returns it. Idempotent. * @@ -202,7 +187,6 @@ export { hexToBn, BnMultiplyByFraction, checkForError, - isPrefixedFormattedHexString, addHexPrefix, bnToHex, } diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 2e76464aa..ad6483821 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -2402,20 +2402,20 @@ export default class MetamaskController extends EventEmitter { nickname, rpcPrefs, ) { - await this.preferencesController.updateRpc({ + this.networkController.setRpcTarget( rpcUrl, chainId, ticker, nickname, rpcPrefs, - }) - this.networkController.setRpcTarget( + ) + await this.preferencesController.updateRpc({ rpcUrl, chainId, ticker, nickname, rpcPrefs, - ) + }) return rpcUrl } diff --git a/shared/constants/network.js b/shared/constants/network.js index eba397466..7a0f6daf0 100644 --- a/shared/constants/network.js +++ b/shared/constants/network.js @@ -17,6 +17,12 @@ export const RINKEBY_CHAIN_ID = '0x4' export const GOERLI_CHAIN_ID = '0x5' export const KOVAN_CHAIN_ID = '0x2a' +/** + * The largest possible chain ID we can handle. + * Explanation: https://gist.github.com/rekmarks/a47bd5f2525936c4b8eee31a16345553 + */ +export const MAX_SAFE_CHAIN_ID = 4503599627370476 + export const ROPSTEN_DISPLAY_NAME = 'Ropsten' export const RINKEBY_DISPLAY_NAME = 'Rinkeby' export const KOVAN_DISPLAY_NAME = 'Kovan' diff --git a/shared/modules/README.md b/shared/modules/README.md deleted file mode 100644 index 5b6e0ffd6..000000000 --- a/shared/modules/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Shared Modules - -This folder is reserved for modules that can be used globally within both the background and ui applications. diff --git a/shared/modules/utils.js b/shared/modules/utils.js new file mode 100644 index 000000000..b9778b40b --- /dev/null +++ b/shared/modules/utils.js @@ -0,0 +1,30 @@ +import { MAX_SAFE_CHAIN_ID } from '../constants/network' + +/** + * Checks whether the given number primitive chain ID is safe. + * Because some cryptographic libraries we use expect the chain ID to be a + * number primitive, it must not exceed a certain size. + * + * @param {number} chainId - The chain ID to check for safety. + * @returns {boolean} Whether the given chain ID is safe. + */ +export function isSafeChainId(chainId) { + return ( + Number.isSafeInteger(chainId) && chainId > 0 && chainId <= MAX_SAFE_CHAIN_ID + ) +} + +/** + * Checks whether the given value is a 0x-prefixed, non-zero, non-zero-padded, + * hexadecimal string. + * + * @param {any} value - The value to check. + * @returns {boolean} True if the value is a correctly formatted hex string, + * false otherwise. + */ +export function isPrefixedFormattedHexString(value) { + if (typeof value !== 'string') { + return false + } + return /^0x[1-9a-f]+[0-9a-f]*$/iu.test(value) +} diff --git a/test/unit/app/util-test.js b/test/unit/app/util-test.js index 802ae93c9..ca58f1118 100644 --- a/test/unit/app/util-test.js +++ b/test/unit/app/util-test.js @@ -2,8 +2,8 @@ import { strict as assert } from 'assert' import { getEnvironmentType, sufficientBalance, - isPrefixedFormattedHexString, } from '../../../app/scripts/lib/util' +import { isPrefixedFormattedHexString } from '../../../shared/modules/utils' import { ENVIRONMENT_TYPE_POPUP, diff --git a/ui/app/components/app/dropdowns/network-dropdown.js b/ui/app/components/app/dropdowns/network-dropdown.js index daf1048bb..c9e9464dc 100644 --- a/ui/app/components/app/dropdowns/network-dropdown.js +++ b/ui/app/components/app/dropdowns/network-dropdown.js @@ -11,10 +11,8 @@ import { } from '../../../helpers/constants/routes' import { ENVIRONMENT_TYPE_FULLSCREEN } from '../../../../../shared/constants/app' import { NETWORK_TYPE_RPC } from '../../../../../shared/constants/network' -import { - getEnvironmentType, - isPrefixedFormattedHexString, -} from '../../../../../app/scripts/lib/util' +import { isPrefixedFormattedHexString } from '../../../../../shared/modules/utils' +import { getEnvironmentType } from '../../../../../app/scripts/lib/util' import { Dropdown, DropdownMenuItem } from './components/dropdown' import NetworkDropdownIcon from './components/network-dropdown-icon' diff --git a/ui/app/pages/settings/networks-tab/network-form/network-form.component.js b/ui/app/pages/settings/networks-tab/network-form/network-form.component.js index ef4a4d765..a20aa5534 100644 --- a/ui/app/pages/settings/networks-tab/network-form/network-form.component.js +++ b/ui/app/pages/settings/networks-tab/network-form/network-form.component.js @@ -1,12 +1,14 @@ import React, { PureComponent } from 'react' import PropTypes from 'prop-types' import validUrl from 'valid-url' -import BigNumber from 'bignumber.js' import log from 'loglevel' import TextField from '../../../../components/ui/text-field' import Button from '../../../../components/ui/button' import Tooltip from '../../../../components/ui/tooltip' -import { isPrefixedFormattedHexString } from '../../../../../../app/scripts/lib/util' +import { + isPrefixedFormattedHexString, + isSafeChainId, +} from '../../../../../../shared/modules/utils' import { jsonRpcRequest } from '../../../../helpers/utils/util' const FORM_STATE_KEYS = [ @@ -126,7 +128,7 @@ export default class NetworkForm extends PureComponent { if (!chainId || typeof chainId !== 'string' || !chainId.startsWith('0x')) { return chainId } - return new BigNumber(chainId, 16).toString(10) + return parseInt(chainId, 16).toString(10) } onSubmit = async () => { @@ -155,7 +157,7 @@ export default class NetworkForm extends PureComponent { // Ensure chainId is a 0x-prefixed, lowercase hex string let chainId = formChainId if (!chainId.startsWith('0x')) { - chainId = `0x${new BigNumber(chainId, 10).toString(16)}` + chainId = `0x${parseInt(chainId, 10).toString(16)}` } if (!(await this.validateChainIdOnSubmit(formChainId, chainId, rpcUrl))) { @@ -308,8 +310,10 @@ export default class NetworkForm extends PureComponent { validateChainIdOnChange = (chainIdArg = '') => { const chainId = chainIdArg.trim() let errorMessage = '' + let radix = 10 if (chainId.startsWith('0x')) { + radix = 16 if (!/^0x[0-9a-f]+$/iu.test(chainId)) { errorMessage = this.context.t('invalidHexNumber') } else if (!isPrefixedFormattedHexString(chainId)) { @@ -319,6 +323,8 @@ export default class NetworkForm extends PureComponent { errorMessage = this.context.t('invalidNumber') } else if (chainId.startsWith('0')) { errorMessage = this.context.t('invalidNumberLeadingZeros') + } else if (!isSafeChainId(parseInt(chainId, radix))) { + errorMessage = this.context.t('invalidChainIdTooBig') } this.setErrorTo('chainId', errorMessage) @@ -356,7 +362,7 @@ export default class NetworkForm extends PureComponent { // in an error message in the form. if (!formChainId.startsWith('0x')) { try { - endpointChainId = new BigNumber(endpointChainId, 16).toString(10) + endpointChainId = parseInt(endpointChainId, 16).toString(10) } catch (err) { log.warn( 'Failed to convert endpoint chain ID to decimal', From 30ff153103dc43fee5a9e1f1031369511d0ebca7 Mon Sep 17 00:00:00 2001 From: Erik Marks <25517051+rekmarks@users.noreply.github.com> Date: Wed, 20 Jan 2021 22:06:41 -0800 Subject: [PATCH 19/29] eth-rpc-errors@4.0.2 (#10226) --- app/scripts/controllers/permissions/index.js | 2 +- .../controllers/permissions/permissionsMethodMiddleware.js | 2 +- app/scripts/controllers/preferences.js | 2 +- app/scripts/controllers/transactions/index.js | 2 +- app/scripts/controllers/transactions/lib/util.js | 2 +- app/scripts/lib/decrypt-message-manager.js | 2 +- app/scripts/lib/encryption-public-key-manager.js | 2 +- app/scripts/lib/message-manager.js | 2 +- app/scripts/lib/personal-message-manager.js | 2 +- app/scripts/lib/typed-message-manager.js | 2 +- package.json | 2 +- test/unit/app/controllers/permissions/mocks.js | 4 ++-- yarn.lock | 7 ------- 13 files changed, 13 insertions(+), 20 deletions(-) diff --git a/app/scripts/controllers/permissions/index.js b/app/scripts/controllers/permissions/index.js index 515741a7e..5d22a69c4 100644 --- a/app/scripts/controllers/permissions/index.js +++ b/app/scripts/controllers/permissions/index.js @@ -3,7 +3,7 @@ import { JsonRpcEngine } from 'json-rpc-engine' import { ObservableStore } from '@metamask/obs-store' import log from 'loglevel' import { CapabilitiesController as RpcCap } from 'rpc-cap' -import { ethErrors } from 'eth-json-rpc-errors' +import { ethErrors } from 'eth-rpc-errors' import { cloneDeep } from 'lodash' import { CAVEAT_NAMES } from '../../../../shared/constants/permissions' diff --git a/app/scripts/controllers/permissions/permissionsMethodMiddleware.js b/app/scripts/controllers/permissions/permissionsMethodMiddleware.js index de9009f13..add23196e 100644 --- a/app/scripts/controllers/permissions/permissionsMethodMiddleware.js +++ b/app/scripts/controllers/permissions/permissionsMethodMiddleware.js @@ -1,5 +1,5 @@ import { createAsyncMiddleware } from 'json-rpc-engine' -import { ethErrors } from 'eth-json-rpc-errors' +import { ethErrors } from 'eth-rpc-errors' /** * Create middleware for handling certain methods and preprocessing permissions requests. diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index df81ead32..605400c4c 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -1,6 +1,6 @@ import { strict as assert } from 'assert' import { ObservableStore } from '@metamask/obs-store' -import { ethErrors } from 'eth-json-rpc-errors' +import { ethErrors } from 'eth-rpc-errors' import { normalize as normalizeAddress } from 'eth-sig-util' import { isValidAddress } from 'ethereumjs-util' import ethers from 'ethers' diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index 670fce56f..a88cfff64 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -3,7 +3,7 @@ import { ObservableStore } from '@metamask/obs-store' import ethUtil from 'ethereumjs-util' import Transaction from 'ethereumjs-tx' import EthQuery from 'ethjs-query' -import { ethErrors } from 'eth-json-rpc-errors' +import { ethErrors } from 'eth-rpc-errors' import abi from 'human-standard-token-abi' import { ethers } from 'ethers' import NonceTracker from 'nonce-tracker' diff --git a/app/scripts/controllers/transactions/lib/util.js b/app/scripts/controllers/transactions/lib/util.js index b33d3029f..fbb975c83 100644 --- a/app/scripts/controllers/transactions/lib/util.js +++ b/app/scripts/controllers/transactions/lib/util.js @@ -1,5 +1,5 @@ import { isValidAddress } from 'ethereumjs-util' -import { ethErrors } from 'eth-json-rpc-errors' +import { ethErrors } from 'eth-rpc-errors' import { addHexPrefix } from '../../../lib/util' import { TRANSACTION_STATUSES } from '../../../../../shared/constants/transaction' diff --git a/app/scripts/lib/decrypt-message-manager.js b/app/scripts/lib/decrypt-message-manager.js index e84397d42..caa2970f6 100644 --- a/app/scripts/lib/decrypt-message-manager.js +++ b/app/scripts/lib/decrypt-message-manager.js @@ -1,7 +1,7 @@ import EventEmitter from 'events' import { ObservableStore } from '@metamask/obs-store' import ethUtil from 'ethereumjs-util' -import { ethErrors } from 'eth-json-rpc-errors' +import { ethErrors } from 'eth-rpc-errors' import log from 'loglevel' import { MESSAGE_TYPE } from '../../../shared/constants/app' import { addHexPrefix } from './util' diff --git a/app/scripts/lib/encryption-public-key-manager.js b/app/scripts/lib/encryption-public-key-manager.js index 48f2ab701..54504fd62 100644 --- a/app/scripts/lib/encryption-public-key-manager.js +++ b/app/scripts/lib/encryption-public-key-manager.js @@ -1,6 +1,6 @@ import EventEmitter from 'events' import { ObservableStore } from '@metamask/obs-store' -import { ethErrors } from 'eth-json-rpc-errors' +import { ethErrors } from 'eth-rpc-errors' import log from 'loglevel' import { MESSAGE_TYPE } from '../../../shared/constants/app' import createId from './random-id' diff --git a/app/scripts/lib/message-manager.js b/app/scripts/lib/message-manager.js index a3f0dee58..0e19c3560 100644 --- a/app/scripts/lib/message-manager.js +++ b/app/scripts/lib/message-manager.js @@ -1,7 +1,7 @@ import EventEmitter from 'events' import { ObservableStore } from '@metamask/obs-store' import ethUtil from 'ethereumjs-util' -import { ethErrors } from 'eth-json-rpc-errors' +import { ethErrors } from 'eth-rpc-errors' import { MESSAGE_TYPE } from '../../../shared/constants/app' import createId from './random-id' diff --git a/app/scripts/lib/personal-message-manager.js b/app/scripts/lib/personal-message-manager.js index c08dddbb2..c0a7fe4bf 100644 --- a/app/scripts/lib/personal-message-manager.js +++ b/app/scripts/lib/personal-message-manager.js @@ -1,7 +1,7 @@ import EventEmitter from 'events' import { ObservableStore } from '@metamask/obs-store' import ethUtil from 'ethereumjs-util' -import { ethErrors } from 'eth-json-rpc-errors' +import { ethErrors } from 'eth-rpc-errors' import log from 'loglevel' import { MESSAGE_TYPE } from '../../../shared/constants/app' import { addHexPrefix } from './util' diff --git a/app/scripts/lib/typed-message-manager.js b/app/scripts/lib/typed-message-manager.js index 1dce10bc8..858c945b0 100644 --- a/app/scripts/lib/typed-message-manager.js +++ b/app/scripts/lib/typed-message-manager.js @@ -1,7 +1,7 @@ import EventEmitter from 'events' import assert from 'assert' import { ObservableStore } from '@metamask/obs-store' -import { ethErrors } from 'eth-json-rpc-errors' +import { ethErrors } from 'eth-rpc-errors' import { typedSignatureHash, TYPED_MESSAGE_SCHEMA } from 'eth-sig-util' import { isValidAddress } from 'ethereumjs-util' import log from 'loglevel' diff --git a/package.json b/package.json index 131f0f506..0fb5476e4 100644 --- a/package.json +++ b/package.json @@ -105,7 +105,6 @@ "end-of-stream": "^1.4.4", "eth-block-tracker": "^4.4.2", "eth-ens-namehash": "^2.0.8", - "eth-json-rpc-errors": "^2.0.2", "eth-json-rpc-filters": "^4.2.1", "eth-json-rpc-infura": "^5.1.0", "eth-json-rpc-middleware": "^6.0.0", @@ -113,6 +112,7 @@ "eth-method-registry": "^2.0.0", "eth-phishing-detect": "^1.1.14", "eth-query": "^2.1.2", + "eth-rpc-errors": "^4.0.2", "eth-sig-util": "^3.0.0", "eth-trezor-keyring": "^0.4.0", "ethereum-ens-network-map": "^1.0.2", diff --git a/test/unit/app/controllers/permissions/mocks.js b/test/unit/app/controllers/permissions/mocks.js index 8d7d75e75..05bed739d 100644 --- a/test/unit/app/controllers/permissions/mocks.js +++ b/test/unit/app/controllers/permissions/mocks.js @@ -1,4 +1,4 @@ -import { ethErrors, ERROR_CODES } from 'eth-json-rpc-errors' +import { ethErrors, errorCodes } from 'eth-rpc-errors' import deepFreeze from 'deep-freeze-strict' import { ApprovalController } from '@metamask/controllers' @@ -336,7 +336,7 @@ export const getters = deepFreeze({ return { // name: 'EthereumRpcError', message: `Failed to add 'eth_accounts' to '${origin}'.`, - code: ERROR_CODES.rpc.internal, + code: errorCodes.rpc.internal, } }, }, diff --git a/yarn.lock b/yarn.lock index 411f8b64c..b8ba061fd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9747,13 +9747,6 @@ eth-hd-keyring@^3.5.0: events "^1.1.1" xtend "^4.0.1" -eth-json-rpc-errors@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/eth-json-rpc-errors/-/eth-json-rpc-errors-2.0.2.tgz#c1965de0301fe941c058e928bebaba2e1285e3c4" - integrity sha512-uBCRM2w2ewusRHGxN8JhcuOb2RN3ueAOYH/0BhqdFmQkZx5lj5+fLKTz0mIVOzd4FG5/kUksCzCD7eTEim6gaA== - dependencies: - fast-safe-stringify "^2.0.6" - eth-json-rpc-filters@^4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/eth-json-rpc-filters/-/eth-json-rpc-filters-4.2.1.tgz#82204a13c99927dbf42cbb3962846650c6281f33" From 6de41a1cf6f61e520d1fd3ba198b71ce8dc8abf9 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Thu, 21 Jan 2021 10:04:03 -0330 Subject: [PATCH 20/29] Update `@reduxjs/toolkit` from v1.3.2 to v1.5.0 (#10228) The changes made between v1.3.2 and v1.5.0 of `@reduxjs/toolkit` don't appear to affect us at all. They mostly consist of feature additions and bug fixes for edge cases we haven't encountered.[1] The one change that is technically breaking is that v8 of `immer` now freezes state objects in production rather than just in development. That would only be breaking if we were mutating Redux state though, which we aren't doing in the few Redux slices in which we use `@reduxjs/toolkit`. Even if we were, we would have noticed that it broke in development already. [1]: https://github.com/reduxjs/redux-toolkit/releases --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 0fb5476e4..c99168c04 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@metamask/logo": "^2.5.0", "@metamask/obs-store": "^5.0.0", "@popperjs/core": "^2.4.0", - "@reduxjs/toolkit": "^1.3.2", + "@reduxjs/toolkit": "^1.5.0", "@sentry/browser": "^5.26.0", "@sentry/integrations": "^5.26.0", "@zxing/library": "^0.8.0", diff --git a/yarn.lock b/yarn.lock index b8ba061fd..2ecccb45e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2245,12 +2245,12 @@ prop-types "^15.6.1" react-lifecycles-compat "^3.0.4" -"@reduxjs/toolkit@^1.3.2": - version "1.3.2" - resolved "https://registry.yarnpkg.com/@reduxjs/toolkit/-/toolkit-1.3.2.tgz#cbd062f0b806eb4611afeb2b30240e5186d6dd27" - integrity sha512-IRI9Nx6Ys/u4NDqPvUC0+e8MH+e1VME9vn30xAmd+MBqDsClc0Dhrlv4Scw2qltRy/mrINarU6BqJp4/dcyyFg== +"@reduxjs/toolkit@^1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@reduxjs/toolkit/-/toolkit-1.5.0.tgz#1025c1ccb224d1fc06d8d98a61f6717d57e6d477" + integrity sha512-E/FUraRx+8guw9Hlg/Ja8jI/hwCrmIKed8Annt9YsZw3BQp+F24t5I5b2OWR6pkEHY4hn1BgP08FrTZFRKsdaQ== dependencies: - immer "^6.0.1" + immer "^8.0.0" redux "^4.0.0" redux-thunk "^2.3.0" reselect "^4.0.0" @@ -13357,10 +13357,10 @@ immer@1.10.0: resolved "https://registry.yarnpkg.com/immer/-/immer-1.10.0.tgz#bad67605ba9c810275d91e1c2a47d4582e98286d" integrity sha512-O3sR1/opvCDGLEVcvrGTMtLac8GJ5IwZC4puPrLuRj3l7ICKvkmA0vGuU9OW8mV9WIBRnaxp5GJh9IEAaNOoYg== -immer@^6.0.1: - version "6.0.3" - resolved "https://registry.yarnpkg.com/immer/-/immer-6.0.3.tgz#94d5051cd724668160a900d66d85ec02816f29bd" - integrity sha512-12VvNrfSrXZdm/BJgi/KDW2soq5freVSf3I1+4CLunUM8mAGx2/0Njy0xBVzi5zewQZiwM7z1/1T+8VaI7NkmQ== +immer@^8.0.0: + version "8.0.1" + resolved "https://registry.yarnpkg.com/immer/-/immer-8.0.1.tgz#9c73db683e2b3975c424fb0572af5889877ae656" + integrity sha512-aqXhGP7//Gui2+UrEtvxZxSquQVXTpZ7KDxfCcKAF3Vysvw0CViVaW9RZ1j1xlIYqaaaipBoqdqeibkc18PNvA== import-cwd@^2.0.0: version "2.1.0" From cb8f82d1715e9d5c0ecab735be42a944e0685b4e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Jan 2021 10:54:17 -0330 Subject: [PATCH 21/29] Bump socket.io from 2.2.0 to 2.4.1 (#10232) Bumps [socket.io](https://github.com/socketio/socket.io) from 2.2.0 to 2.4.1. - [Release notes](https://github.com/socketio/socket.io/releases) - [Changelog](https://github.com/socketio/socket.io/blob/2.4.1/CHANGELOG.md) - [Commits](https://github.com/socketio/socket.io/compare/2.2.0...2.4.1) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 206 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 108 insertions(+), 98 deletions(-) diff --git a/yarn.lock b/yarn.lock index 2ecccb45e..b1828860d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5442,10 +5442,10 @@ base32.js@~0.1.0: resolved "https://registry.yarnpkg.com/base32.js/-/base32.js-0.1.0.tgz#b582dec693c2f11e893cf064ee6ac5b6131a2202" integrity sha1-tYLexpPC8R6JPPBk7mrFthMaIgI= -base64-arraybuffer@0.1.5: - version "0.1.5" - resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz#73926771923b5a19747ad666aa5cd4bf9c6e9ce8" - integrity sha1-c5JncZI7Whl0etZmqlzUv5xunOg= +base64-arraybuffer@0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-0.1.4.tgz#9818c79e059b1355f97e0428a017c838e90ba812" + integrity sha1-mBjHngWbE1X5fgQooBfIOOkLqBI= base64-js@^1.0.2, base64-js@^1.3.1: version "1.5.1" @@ -5457,6 +5457,11 @@ base64id@1.0.0: resolved "https://registry.yarnpkg.com/base64id/-/base64id-1.0.0.tgz#47688cb99bb6804f0e06d3e763b1c32e57d8e6b6" integrity sha1-R2iMuZu2gE8OBtPnY7HDLlfY5rY= +base64id@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/base64id/-/base64id-2.0.0.tgz#2770ac6bc47d312af97a8bf9a634342e0cd25cb6" + integrity sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog== + base64url@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/base64url/-/base64url-3.0.1.tgz#6399d572e2bc3f90a9a8b22d5dbb0a32d33f788d" @@ -5499,13 +5504,6 @@ bech32@^1.1.2: resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.3.tgz#bd47a8986bbb3eec34a56a097a84b8d3e9a2dfcd" integrity sha512-yuVFUvrNcoJi0sv5phmqc6P+Fl1HjRDRNOOkHY2X/3LBy2bIGNSFx4fZ95HMaXHupuS7cZR15AsvtmCIF4UEyg== -better-assert@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/better-assert/-/better-assert-1.0.2.tgz#40866b9e1b9e0b55b481894311e68faffaebc522" - integrity sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI= - dependencies: - callsite "1.0.0" - better-opn@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/better-opn/-/better-opn-2.1.1.tgz#94a55b4695dc79288f31d7d0e5f658320759f7c6" @@ -5705,10 +5703,10 @@ blakejs@^1.1.0: resolved "https://registry.yarnpkg.com/blakejs/-/blakejs-1.1.0.tgz#69df92ef953aa88ca51a32df6ab1c54a155fc7a5" integrity sha1-ad+S75U6qIylGjLfarHFShVfx6U= -blob@0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/blob/-/blob-0.0.4.tgz#bcf13052ca54463f30f9fc7e95b9a47630a94921" - integrity sha1-vPEwUspURj8w+fx+lbmkdjCpSSE= +blob@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/blob/-/blob-0.0.5.tgz#d680eeef25f8cd91ad533f5b01eed48e64caf683" + integrity sha512-gaqbzQPqOoamawKg0LGVd7SzLgXS+JH61oWprSLH+P+abTczqJbhTR8CmJ2u9/bUYNmHTGJx/UEmn6doAvvuig== block-stream@*: version "0.0.9" @@ -6434,11 +6432,6 @@ caller-path@^0.1.0: dependencies: callsites "^0.2.0" -callsite@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20" - integrity sha1-KAOY5dZkvXQDi28JBRU+borxvCA= - callsites@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-0.2.0.tgz#afab96262910a7f33c19a5775825c69f34e350ca" @@ -7213,6 +7206,11 @@ component-emitter@1.2.1, component-emitter@^1.2.0, component-emitter@^1.2.1: resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6" integrity sha1-E3kY1teCg/ffemt8WmPhQOaUJeY= +component-emitter@~1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0" + integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg== + component-inherit@0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/component-inherit/-/component-inherit-0.0.3.tgz#645fc4adf58b72b649d5cae65135619db26ff143" @@ -7389,16 +7387,16 @@ cookie-signature@1.0.6: resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" integrity sha1-4wOogrNCzD7oylE6eZmXNNqzriw= -cookie@0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" - integrity sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s= - cookie@0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba" integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg== +cookie@~0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.1.tgz#afd713fe26ebd21ba95ceb61f9a8116e50a537d1" + integrity sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA== + cookiejar@^2.1.0, cookiejar@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.2.tgz#dd8a235530752f988f9a0844f3fc589e3111125c" @@ -8964,45 +8962,45 @@ endent@^2.0.1: fast-json-parse "^1.0.3" objectorarray "^1.0.4" -engine.io-client@~3.3.1: - version "3.3.2" - resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-3.3.2.tgz#04e068798d75beda14375a264bb3d742d7bc33aa" - integrity sha512-y0CPINnhMvPuwtqXfsGuWE8BB66+B6wTtCofQDRecMQPYX3MYUZXFNKDhdrSe3EVjgOu4V3rxdeqN/Tr91IgbQ== +engine.io-client@~3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-3.5.0.tgz#fc1b4d9616288ce4f2daf06dcf612413dec941c7" + integrity sha512-12wPRfMrugVw/DNyJk34GQ5vIVArEcVMXWugQGGuw2XxUSztFNmJggZmv8IZlLyEdnpO1QB9LkcjeWewO2vxtA== dependencies: - component-emitter "1.2.1" + component-emitter "~1.3.0" component-inherit "0.0.3" debug "~3.1.0" - engine.io-parser "~2.1.1" + engine.io-parser "~2.2.0" has-cors "1.1.0" indexof "0.0.1" - parseqs "0.0.5" - parseuri "0.0.5" - ws "~6.1.0" + parseqs "0.0.6" + parseuri "0.0.6" + ws "~7.4.2" xmlhttprequest-ssl "~1.5.4" yeast "0.1.2" -engine.io-parser@~2.1.0, engine.io-parser@~2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-2.1.2.tgz#4c0f4cff79aaeecbbdcfdea66a823c6085409196" - integrity sha512-dInLFzr80RijZ1rGpx1+56/uFoH7/7InhH3kZt+Ms6hT8tNx3NGW/WNSA/f8As1WkOfkuyb3tnRyuXGxusclMw== +engine.io-parser@~2.2.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-2.2.1.tgz#57ce5611d9370ee94f99641b589f94c97e4f5da7" + integrity sha512-x+dN/fBH8Ro8TFwJ+rkB2AmuVw9Yu2mockR/p3W8f8YtExwFgDvBDi0GWyb4ZLkpahtDGZgtr3zLovanJghPqg== dependencies: after "0.8.2" arraybuffer.slice "~0.0.7" - base64-arraybuffer "0.1.5" - blob "0.0.4" + base64-arraybuffer "0.1.4" + blob "0.0.5" has-binary2 "~1.0.2" -engine.io@~3.3.1: - version "3.3.2" - resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-3.3.2.tgz#18cbc8b6f36e9461c5c0f81df2b830de16058a59" - integrity sha512-AsaA9KG7cWPXWHp5FvHdDWY3AMWeZ8x+2pUVLcn71qE5AtAzgGbxuclOytygskw8XGmiQafTmnI9Bix3uihu2w== +engine.io@~3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-3.5.0.tgz#9d6b985c8a39b1fe87cd91eb014de0552259821b" + integrity sha512-21HlvPUKaitDGE4GXNtQ7PLP0Sz4aWLddMPw2VTyFz1FVZqu/kZsJUO8WNpKuE/OCL7nkfRaOui2ZCJloGznGA== dependencies: accepts "~1.3.4" - base64id "1.0.0" - cookie "0.3.1" - debug "~3.1.0" - engine.io-parser "~2.1.0" - ws "~6.1.0" + base64id "2.0.0" + cookie "~0.4.1" + debug "~4.1.0" + engine.io-parser "~2.2.0" + ws "~7.4.2" enhanced-resolve@^4.3.0: version "4.3.0" @@ -17413,6 +17411,11 @@ mime-db@1.44.0, mime-db@1.x.x, mime-db@^1.28.0: resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.44.0.tgz#fa11c5eb0aca1334b4233cb4d52f10c5a6272f92" integrity sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg== +mime-db@1.45.0: + version "1.45.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.45.0.tgz#cceeda21ccd7c3a745eba2decd55d4b73e7879ea" + integrity sha512-CkqLUxUk15hofLoLyljJSrukZi8mAtgd+yE5uO4tqRZsdsAJKv0O+rFMhVDRJgozy+yG6md5KwuXhD4ocIoP+w== + mime-db@~1.33.0: version "1.33.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.33.0.tgz#a3492050a5cb9b63450541e39d9788d2272783db" @@ -17425,13 +17428,20 @@ mime-types@2.1.18: dependencies: mime-db "~1.33.0" -mime-types@^2.1.12, mime-types@^2.1.16, mime-types@^2.1.18, mime-types@^2.1.21, mime-types@^2.1.27, mime-types@~2.1.19, mime-types@~2.1.24: +mime-types@^2.1.12, mime-types@^2.1.16, mime-types@^2.1.18, mime-types@^2.1.21, mime-types@^2.1.27, mime-types@~2.1.19: version "2.1.27" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.27.tgz#47949f98e279ea53119f5722e0f34e529bec009f" integrity sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w== dependencies: mime-db "1.44.0" +mime-types@~2.1.24: + version "2.1.28" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.28.tgz#1160c4757eab2c5363888e005273ecf79d2a0ecd" + integrity sha512-0TO2yJ5YHYr7M2zzT7gDU1tbwHxEUWBCLt0lscSNpcdAfFyJOVEpRYNS7EXVcTLNj/25QO8gulHC5JtTzSE2UQ== + dependencies: + mime-db "1.45.0" + mime@1.6.0, mime@^1.4.1: version "1.6.0" resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" @@ -17739,11 +17749,16 @@ ms@2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== -ms@^2.0.0, ms@^2.1.1: +ms@^2.0.0: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== +ms@^2.1.1: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + multiaddr-to-uri@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/multiaddr-to-uri/-/multiaddr-to-uri-4.0.1.tgz#3b89d2a460a96602a16f3bfe296ee771ecb2558b" @@ -18533,11 +18548,6 @@ object-assign@^2.0.0: resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-2.1.1.tgz#43c36e5d569ff8e4816c4efa8be02d26967c18aa" integrity sha1-Q8NuXVaf+OSBbE76i+AtJpZ8GKo= -object-component@0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/object-component/-/object-component-0.0.3.tgz#f0c69aa50efc95b866c186f400a33769cb2f1291" - integrity sha1-8MaapQ78lbhmwYb0AKM3acsvEpE= - object-copy@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c" @@ -19472,19 +19482,15 @@ parse5@^3.0.1, parse5@^3.0.2: dependencies: "@types/node" "*" -parseqs@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/parseqs/-/parseqs-0.0.5.tgz#d5208a3738e46766e291ba2ea173684921a8b89d" - integrity sha1-1SCKNzjkZ2bikbouoXNoSSGouJ0= - dependencies: - better-assert "~1.0.0" +parseqs@0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/parseqs/-/parseqs-0.0.6.tgz#8e4bb5a19d1cdc844a08ac974d34e273afa670d5" + integrity sha512-jeAGzMDbfSHHA091hr0r31eYfTig+29g3GKKE/PPbEQ65X0lmMwlEoqmhzu0iztID5uJpZsFlUPDP8ThPL7M8w== -parseuri@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/parseuri/-/parseuri-0.0.5.tgz#80204a50d4dbb779bfdc6ebe2778d90e4bce320a" - integrity sha1-gCBKUNTbt3m/3G6+J3jZDkvOMgo= - dependencies: - better-assert "~1.0.0" +parseuri@0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/parseuri/-/parseuri-0.0.6.tgz#e1496e829e3ac2ff47f39a4dd044b32823c4a25a" + integrity sha512-AUjen8sAkGgao7UyCX6Ahv0gIK2fABKmYjvP4xmy5JaKvcbTRueIqIPHLAfq30xJddqSE033IOMUSOMCcK3Sow== parseurl@^1.3.2, parseurl@~1.3.2, parseurl@~1.3.3: version "1.3.3" @@ -23156,39 +23162,45 @@ snapdragon@^0.8.1: use "^3.1.0" socket.io-adapter@~1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-1.1.1.tgz#2a805e8a14d6372124dd9159ad4502f8cb07f06b" - integrity sha1-KoBeihTWNyEk3ZFZrUUC+MsH8Gs= + version "1.1.2" + resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-1.1.2.tgz#ab3f0d6f66b8fc7fca3959ab5991f82221789be9" + integrity sha512-WzZRUj1kUjrTIrUKpZLEzFZ1OLj5FwLlAFQs9kuZJzJi5DKdU7FsWc36SNmA8iDOtwBQyT8FkrriRM8vXLYz8g== -socket.io-client@2.2.0, socket.io-client@^2.1.1: - version "2.2.0" - resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-2.2.0.tgz#84e73ee3c43d5020ccc1a258faeeb9aec2723af7" - integrity sha512-56ZrkTDbdTLmBIyfFYesgOxsjcLnwAKoN4CiPyTVkMQj3zTUh0QAx3GbvIvLpFEOvQWu92yyWICxB0u7wkVbYA== +socket.io-client@2.4.0, socket.io-client@^2.1.1: + version "2.4.0" + resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-2.4.0.tgz#aafb5d594a3c55a34355562fc8aea22ed9119a35" + integrity sha512-M6xhnKQHuuZd4Ba9vltCLT9oa+YvTsP8j9NcEiLElfIg8KeYPyhWOes6x4t+LTAC8enQbE/995AdTem2uNyKKQ== dependencies: backo2 "1.0.2" - base64-arraybuffer "0.1.5" component-bind "1.0.0" - component-emitter "1.2.1" + component-emitter "~1.3.0" debug "~3.1.0" - engine.io-client "~3.3.1" + engine.io-client "~3.5.0" has-binary2 "~1.0.2" - has-cors "1.1.0" indexof "0.0.1" - object-component "0.0.3" - parseqs "0.0.5" - parseuri "0.0.5" + parseqs "0.0.6" + parseuri "0.0.6" socket.io-parser "~3.3.0" to-array "0.1.4" socket.io-parser@~3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.3.0.tgz#2b52a96a509fdf31440ba40fed6094c7d4f1262f" - integrity sha512-hczmV6bDgdaEbVqhAeVMM/jfUfzuEZHsQg6eOmLgJht6G3mPKMxYm75w2+qhAQZ+4X+1+ATZ+QFKeOZD5riHng== + version "3.3.2" + resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.3.2.tgz#ef872009d0adcf704f2fbe830191a14752ad50b6" + integrity sha512-FJvDBuOALxdCI9qwRrO/Rfp9yfndRtc1jSgVgV8FDraihmSP/MLGD5PEuJrNfjALvcQ+vMDM/33AWOYP/JSjDg== dependencies: - component-emitter "1.2.1" + component-emitter "~1.3.0" debug "~3.1.0" isarray "2.0.1" +socket.io-parser@~3.4.0: + version "3.4.1" + resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.4.1.tgz#b06af838302975837eab2dc980037da24054d64a" + integrity sha512-11hMgzL+WCLWf1uFtHSNvliI++tcRUWdoeYuwIl+Axvwy9z2gQM+7nJyN3STj1tLj5JyIUH8/gpDGxzAlDdi0A== + dependencies: + component-emitter "1.2.1" + debug "~4.1.0" + isarray "2.0.1" + socket.io-pull-stream@~0.1.5: version "0.1.5" resolved "https://registry.yarnpkg.com/socket.io-pull-stream/-/socket.io-pull-stream-0.1.5.tgz#4e5d282b93635d8bf7780da405d82fc149346710" @@ -23200,16 +23212,16 @@ socket.io-pull-stream@~0.1.5: uuid "^3.2.1" socket.io@^2.1.1: - version "2.2.0" - resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-2.2.0.tgz#f0f633161ef6712c972b307598ecd08c9b1b4d5b" - integrity sha512-wxXrIuZ8AILcn+f1B4ez4hJTPG24iNgxBBDaJfT6MsyOhVYiTXWexGoPkd87ktJG8kQEcL/NBvRi64+9k4Kc0w== + version "2.4.1" + resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-2.4.1.tgz#95ad861c9a52369d7f1a68acf0d4a1b16da451d2" + integrity sha512-Si18v0mMXGAqLqCVpTxBa8MGqriHGQh8ccEOhmsmNS3thNCGBwO8WGrwMibANsWtQQ5NStdZwHqZR3naJVFc3w== dependencies: debug "~4.1.0" - engine.io "~3.3.1" + engine.io "~3.5.0" has-binary2 "~1.0.2" socket.io-adapter "~1.1.0" - socket.io-client "2.2.0" - socket.io-parser "~3.3.0" + socket.io-client "2.4.0" + socket.io-parser "~3.4.0" socketcluster-client@^14.2.1: version "14.3.1" @@ -26464,12 +26476,10 @@ ws@^5.1.1: dependencies: async-limiter "~1.0.0" -ws@~6.1.0: - version "6.1.4" - resolved "https://registry.yarnpkg.com/ws/-/ws-6.1.4.tgz#5b5c8800afab925e94ccb29d153c8d02c1776ef9" - integrity sha512-eqZfL+NE/YQc1/ZynhojeV8q+H050oR8AZ2uIev7RU10svA9ZnJUddHcOUZTJLinZ9yEfdA2kSATS2qZK5fhJA== - dependencies: - async-limiter "~1.0.0" +ws@~7.4.2: + version "7.4.2" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.2.tgz#782100048e54eb36fe9843363ab1c68672b261dd" + integrity sha512-T4tewALS3+qsrpGI/8dqNMLIVdq/g/85U98HPMa6F0m6xTbvhXU6RCQLqPH3+SlomNV/LdY6RXEbBpMH6EOJnA== xdg-basedir@^3.0.0: version "3.0.0" From 408586aa4d730311d93ca1e862bd5251899c0017 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Thu, 21 Jan 2021 11:31:42 -0330 Subject: [PATCH 22/29] Increase minimum Firefox version to v68 (#10195) Firefox v68 is the _previous_ Extended Support Release. We are increasing this because our current minimum version doesn't support async iterators, so some of our dependencies cause the extension to crash. Our metrics show that usage of Firefox versions older than this is quite low (under 0.7% of Firefox users in the past month). These older versions are also _very behind_ on security updates. Using the Extended Support Release also makes it easier for us to test the minimum version, and ensure our extension remains compatible with it. Relates to #6805 --- app/manifest/firefox.json | 2 +- babel.config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/manifest/firefox.json b/app/manifest/firefox.json index c07b8e283..930e1e758 100644 --- a/app/manifest/firefox.json +++ b/app/manifest/firefox.json @@ -2,7 +2,7 @@ "applications": { "gecko": { "id": "webextension@metamask.io", - "strict_min_version": "56.0" + "strict_min_version": "68.0" } } } diff --git a/babel.config.js b/babel.config.js index f340966ab..d95fa7e3f 100644 --- a/babel.config.js +++ b/babel.config.js @@ -6,7 +6,7 @@ module.exports = function (api) { '@babel/preset-env', { targets: { - browsers: ['chrome >= 63', 'firefox >= 56.2'], + browsers: ['chrome >= 63', 'firefox >= 68'], }, }, ], From 9b4715cc8f40016d463686d3fc3ed8d617af061f Mon Sep 17 00:00:00 2001 From: David Walsh Date: Thu, 21 Jan 2021 11:12:54 -0600 Subject: [PATCH 23/29] Update postMessage structure for TrezorConnect 8 (#10192) --- app/vendor/trezor/content-script.js | 2 +- package.json | 2 +- yarn.lock | 406 ++++++++++++++++++++++++++-- 3 files changed, 378 insertions(+), 32 deletions(-) diff --git a/app/vendor/trezor/content-script.js b/app/vendor/trezor/content-script.js index a21332f46..8c7385ee4 100644 --- a/app/vendor/trezor/content-script.js +++ b/app/vendor/trezor/content-script.js @@ -16,6 +16,6 @@ Passing messages from popup to background script window.addEventListener('message', event => { if (port && event.source === window && event.data) { - port.postMessage(event.data); + port.postMessage({ data: event.data }); } }); diff --git a/package.json b/package.json index c99168c04..eae60a02b 100644 --- a/package.json +++ b/package.json @@ -114,7 +114,7 @@ "eth-query": "^2.1.2", "eth-rpc-errors": "^4.0.2", "eth-sig-util": "^3.0.0", - "eth-trezor-keyring": "^0.4.0", + "eth-trezor-keyring": "^0.5.2", "ethereum-ens-network-map": "^1.0.2", "ethereumjs-abi": "^0.6.4", "ethereumjs-tx": "1.3.7", diff --git a/yarn.lock b/yarn.lock index b1828860d..8964ecdd6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2867,6 +2867,51 @@ "@babel/runtime" "^7.10.3" "@testing-library/dom" "^7.17.1" +"@trezor/blockchain-link@^1.0.15": + version "1.0.15" + resolved "https://registry.yarnpkg.com/@trezor/blockchain-link/-/blockchain-link-1.0.15.tgz#a3f7c1122d568a1a945f7f0c43de217cdc2d3c7a" + integrity sha512-qcGHa1OXHdQb6SoPW6yfXyomkKwtd/JpFXL4eSGvAl08roxtgmtXNHmQaJ8F0oRSClbPEprqf/qR3BPdK33HoQ== + dependencies: + bignumber.js "^9.0.1" + es6-promise "^4.2.8" + events "^3.2.0" + ripple-lib "1.8.2" + tiny-worker "^2.3.0" + ws "^7.4.0" + +"@trezor/rollout@^1.0.4": + version "1.0.7" + resolved "https://registry.yarnpkg.com/@trezor/rollout/-/rollout-1.0.7.tgz#e4ee8281866ab6712ccc8873f3a383621b1a18ca" + integrity sha512-yFN2J/g3Epv1dM0dCsRnOagK7lrsfs7vDy1uc4T7DF9qtN0ZGO/tdCjSdgRGUZECRdXRcPrzRUsZDXGOkPcLoA== + dependencies: + cross-fetch "^3.0.6" + runtypes "^5.0.1" + +"@trezor/utxo-lib@0.1.1", "@trezor/utxo-lib@^0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@trezor/utxo-lib/-/utxo-lib-0.1.1.tgz#63cb4b3accc90352a42a1c866fce8bfbb1c94b26" + integrity sha512-Wonj9ldKCeoajCV6lSE6+hJ2hdPxmVaysWRO9GxhnKyiOdRhiOIQcdKOiXYqpcxwkIbbL9eLGDg73tfn3MUa6w== + dependencies: + bech32 "0.0.3" + bigi "^1.4.0" + bip66 "^1.1.0" + bitcoin-ops "^1.3.0" + blake2b "https://github.com/BitGo/blake2b#6268e6dd678661e0acc4359e9171b97eb1ebf8ac" + bs58check "^2.0.0" + create-hash "^1.1.0" + create-hmac "^1.1.3" + debug "~3.1.0" + ecurve "^1.0.0" + merkle-lib "^2.0.10" + pushdata-bitcoin "^1.0.1" + randombytes "^2.0.1" + safe-buffer "^5.0.1" + typeforce "^1.11.3" + varuint-bitcoin "^1.0.4" + wif "^2.0.1" + optionalDependencies: + secp256k1 "^3.5.2" + "@types/anymatch@*": version "1.3.1" resolved "https://registry.yarnpkg.com/@types/anymatch/-/anymatch-1.3.1.tgz#336badc1beecb9dacc38bea2cf32adf627a8421a" @@ -2969,6 +3014,11 @@ resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.124.tgz#16fb067a8fc4be42f044c505d8b5316c6f54de93" integrity sha512-6bKEUVbHJ8z34jisA7lseJZD2g31SIvee3cGX2KEZCS4XXWNbjPZpmO1/2rGNR9BhGtaYr6iYXPl1EzRrDAFTA== +"@types/lodash@^4.14.136": + version "4.14.168" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.168.tgz#fe24632e79b7ade3f132891afff86caa5e5ce008" + integrity sha512-oVfRvqHV/V6D1yifJbVRU3TMp8OT6o6BG+U9MkwuJ3U8/CsDHvalRpsxBqivn71ztOFZBTfJMvETbqHiaNSj7Q== + "@types/markdown-to-jsx@^6.11.0": version "6.11.3" resolved "https://registry.yarnpkg.com/@types/markdown-to-jsx/-/markdown-to-jsx-6.11.3.tgz#cdd1619308fecbc8be7e6a26f3751260249b020e" @@ -3182,6 +3232,13 @@ "@types/webpack-sources" "*" source-map "^0.6.0" +"@types/ws@^7.2.0": + version "7.4.0" + resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.4.0.tgz#499690ea08736e05a8186113dac37769ab251a0e" + integrity sha512-Y29uQ3Uy+58bZrFLhX36hcI3Np37nqWE7ky5tjiDoy1GDZnIwVxS0CgF+s+1bXMzjKBFy+fqaRfb708iNzdinw== + dependencies: + "@types/node" "*" + "@types/yargs-parser@*": version "15.0.0" resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-15.0.0.tgz#cb3f9f741869e20cce330ffbeb9271590483882d" @@ -3467,7 +3524,7 @@ abstract-logging@^1.0.0: resolved "https://registry.yarnpkg.com/abstract-logging/-/abstract-logging-1.0.0.tgz#8b7deafd310559bc28f77724dd1bb30177278c1b" integrity sha1-i33q/TEFWbwo93ck3RuzAXcnjBs= -accepts@^1.3.5, accepts@~1.3.4, accepts@~1.3.7: +accepts@^1.3.5, accepts@~1.3.7: version "1.3.7" resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd" integrity sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA== @@ -4270,6 +4327,14 @@ asap@^2.0.0, asap@^2.0.6: resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" integrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY= +ascli@~0.3: + version "0.3.0" + resolved "https://registry.yarnpkg.com/ascli/-/ascli-0.3.0.tgz#5e66230e5219fe3e8952a4efb4f20fae596a813a" + integrity sha1-XmYjDlIZ/j6JUqTvtPIPrllqgTo= + dependencies: + colour latest + optjs latest + asmcrypto.js@^2.3.2: version "2.3.2" resolved "https://registry.yarnpkg.com/asmcrypto.js/-/asmcrypto.js-2.3.2.tgz#b9f84bd0a1fb82f21f8c29cc284a707ad17bba2e" @@ -5427,6 +5492,13 @@ base-x@3.0.4, base-x@^3.0.2: dependencies: safe-buffer "^5.0.1" +base-x@3.0.8: + version "3.0.8" + resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.8.tgz#1e1106c2537f0162e8b52474a557ebb09000018d" + integrity sha512-Rl/1AWP4J/zRrk54hhlxH4drNxPJXYUaKffODVI53/dAsV4t9fBxyxYKAVPU1XBHxYwOWP9h9H0hM2MVw4YfJA== + dependencies: + safe-buffer "^5.0.1" + base-x@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/base-x/-/base-x-1.1.0.tgz#42d3d717474f9ea02207f6d1aa1f426913eeb7ac" @@ -5457,11 +5529,6 @@ base64id@1.0.0: resolved "https://registry.yarnpkg.com/base64id/-/base64id-1.0.0.tgz#47688cb99bb6804f0e06d3e763b1c32e57d8e6b6" integrity sha1-R2iMuZu2gE8OBtPnY7HDLlfY5rY= -base64id@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/base64id/-/base64id-2.0.0.tgz#2770ac6bc47d312af97a8bf9a634342e0cd25cb6" - integrity sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog== - base64url@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/base64url/-/base64url-3.0.1.tgz#6399d572e2bc3f90a9a8b22d5dbb0a32d33f788d" @@ -5492,6 +5559,22 @@ batch-processor@1.0.0: resolved "https://registry.yarnpkg.com/batch-processor/-/batch-processor-1.0.0.tgz#75c95c32b748e0850d10c2b168f6bdbe9891ace8" integrity sha1-dclcMrdI4IUNEMKxaPa9vpiRrOg= +bchaddrjs@0.4.9: + version "0.4.9" + resolved "https://registry.yarnpkg.com/bchaddrjs/-/bchaddrjs-0.4.9.tgz#c17036bf5bab31bfbb9f3cec432c7c578f0faf46" + integrity sha512-Mf5Uf+P452ltYg1b/NncX/eAEKW+iAfUs8rO1mcgro8S+/WG6gRh8OqgBtyCK1jBHViajovWoAG+ZCkKbhZbNg== + dependencies: + bs58check "^2.1.2" + cashaddrjs "^0.3.12" + +bchaddrjs@^0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/bchaddrjs/-/bchaddrjs-0.3.2.tgz#62d4915f8f69012b7a16ae9fd0c99eca3a8ccf91" + integrity sha512-jpoq2GX6PphcCpuvvrQG4oQmEzn4nGQSm5dT208W72r9GDdbmNPi0hG9TY/dFF3r9sNtdl0qKwNsh8dNL3Q62g== + dependencies: + bs58check "^2.1.2" + cashaddrjs "^0.3.3" + bcrypt-pbkdf@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e" @@ -5499,6 +5582,11 @@ bcrypt-pbkdf@^1.0.0: dependencies: tweetnacl "^0.14.3" +bech32@0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/bech32/-/bech32-0.0.3.tgz#736747c4a6531c5d8937d0400498de30e93b2f9c" + integrity sha512-O+K1w8P/aAOLcYwwQ4sbiPYZ51ZIW95lnS4/6nE8Aib/z+OOddQIIPdu2qi94qGDp4HhYy/wJotttXKkak1lXg== + bech32@^1.1.2: version "1.1.3" resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.3.tgz#bd47a8986bbb3eec34a56a097a84b8d3e9a2dfcd" @@ -5511,11 +5599,21 @@ better-opn@^2.0.0: dependencies: open "^7.0.3" +big-integer@1.6.36: + version "1.6.36" + resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.36.tgz#78631076265d4ae3555c04f85e7d9d2f3a071a36" + integrity sha512-t70bfa7HYEA1D9idDbmuv7YbsbVkQ+Hp+8KFSul4aE5e/i1bjCNIRYJZlA8Q8p0r9T8cF/RVvwUgRA//FydEyg== + big.js@^5.1.2, big.js@^5.2.2: version "5.2.2" resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ== +bigi@^1.1.0, bigi@^1.4.0, bigi@^1.4.1: + version "1.4.2" + resolved "https://registry.yarnpkg.com/bigi/-/bigi-1.4.2.tgz#9c665a95f88b8b08fc05cfd731f561859d725825" + integrity sha1-nGZalfiLiwj8Bc/XMfVhhZ1yWCU= + bignumber.js@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-4.1.0.tgz#db6f14067c140bd46624815a7916c92d9b6c24b1" @@ -5531,6 +5629,11 @@ bignumber.js@^9.0.0: resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.0.0.tgz#805880f84a329b5eac6e7cb6f8274b6d82bdf075" integrity sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A== +bignumber.js@^9.0.1: + version "9.0.1" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.0.1.tgz#8d7ba124c882bfd8e43260c67475518d0689e4e5" + integrity sha512-IdZR9mh6ahOBv/hYGiXyVuyCetmGJhtYkqLBpTStdhEGjegpPlUawydyaF3pbIOFynJTpllEs+NP+CS9jKFLjA== + "bignumber.js@git+https://github.com/frozeman/bignumber.js-nolookahead.git": version "2.0.7" resolved "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934" @@ -5698,6 +5801,19 @@ bl@^3.0.0: dependencies: readable-stream "^3.0.1" +"blake2b-wasm@https://github.com/BitGo/blake2b-wasm#193cdb71656c1a6c7f89b05d0327bb9b758d071b": + version "2.0.0" + resolved "https://github.com/BitGo/blake2b-wasm#193cdb71656c1a6c7f89b05d0327bb9b758d071b" + dependencies: + nanoassert "^1.0.0" + +"blake2b@https://github.com/BitGo/blake2b#6268e6dd678661e0acc4359e9171b97eb1ebf8ac": + version "2.1.3" + resolved "https://github.com/BitGo/blake2b#6268e6dd678661e0acc4359e9171b97eb1ebf8ac" + dependencies: + blake2b-wasm "https://github.com/BitGo/blake2b-wasm#193cdb71656c1a6c7f89b05d0327bb9b758d071b" + nanoassert "^1.0.0" + blakejs@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/blakejs/-/blakejs-1.1.0.tgz#69df92ef953aa88ca51a32df6ab1c54a155fc7a5" @@ -5740,6 +5856,11 @@ bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.10.0, bn.js@^4.11.0, bn.js@^4 resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.9.tgz#26d556829458f9d1e81fc48952493d0ba3507828" integrity sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw== +bn.js@^5.1.1: + version "5.1.3" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.1.3.tgz#beca005408f642ebebea80b042b4d18d2ac0ee6b" + integrity sha512-GkTiFpjFtUzU9CbMeJ5iazkCzGL3jrhzerzZIuqLABjbwRaFt33I9tUdSNryIptM+RxDet6OKm2WnLXzW51KsQ== + body-parser@1.19.0, body-parser@^1.15.0, body-parser@^1.16.0: version "1.19.0" resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a" @@ -5794,6 +5915,11 @@ borc@^2.1.0: iso-url "~0.4.4" json-text-sequence "~0.1.0" +bowser@^2.11.0: + version "2.11.0" + resolved "https://registry.yarnpkg.com/bowser/-/bowser-2.11.0.tgz#5ca3c35757a7aa5771500c70a73a9f91ef420a8f" + integrity sha512-AlcaJBi/pqqJBIQ8U9Mcpc9i8Aqxn88Skv5d+xBX006BY5u8N3mGLHa5Lgppa7L/HfwgwLgZ6NYs+Ag6uUmJRA== + boxen@^1.2.1: version "1.3.0" resolved "https://registry.yarnpkg.com/boxen/-/boxen-1.3.0.tgz#55c6c39a8ba58d9c61ad22cd877532deb665a20b" @@ -5885,7 +6011,7 @@ brfs@^2.0.2: static-module "^3.0.2" through2 "^2.0.0" -brorand@^1.0.1: +brorand@^1.0.1, brorand@^1.0.5: version "1.1.0" resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" integrity sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8= @@ -6259,11 +6385,24 @@ bufferutil@^4.0.1: dependencies: node-gyp-build "~3.7.0" +bufferview@~1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/bufferview/-/bufferview-1.0.1.tgz#7afd74a45f937fa422a1d338c08bbfdc76cd725d" + integrity sha1-ev10pF+Tf6QiodM4wIu/3HbNcl0= + builtin-status-codes@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" integrity sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug= +bytebuffer-old-fixed-webpack@3.5.6: + version "3.5.6" + resolved "https://registry.yarnpkg.com/bytebuffer-old-fixed-webpack/-/bytebuffer-old-fixed-webpack-3.5.6.tgz#5adc419c6a9b4692f217206703ec7431c759aa3f" + integrity sha1-WtxBnGqbRpLyFyBnA+x0McdZqj8= + dependencies: + bufferview "~1" + long "~2 >=2.2.3" + byteman@^1.3.5: version "1.3.5" resolved "https://registry.yarnpkg.com/byteman/-/byteman-1.3.5.tgz#d6061f7536c7e7c4bcb756037ef9c4c266ec51fd" @@ -6517,6 +6656,13 @@ caseless@~0.12.0: resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= +cashaddrjs@^0.3.12, cashaddrjs@^0.3.3: + version "0.3.12" + resolved "https://registry.yarnpkg.com/cashaddrjs/-/cashaddrjs-0.3.12.tgz#73089588113459741e854aa842db1f7816d8428d" + integrity sha512-GdjCYMVwd86HXcFcxyEZQLPLFv8a/u0ccYPsO0PpnUW26LhZzHX9l9QA+DjaeUah7tnebwPs33NWDbbUy8iVYQ== + dependencies: + big-integer "1.6.36" + caw@^2.0.0, caw@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/caw/-/caw-2.0.1.tgz#6c3ca071fc194720883c2dc5da9b074bfc7e9e95" @@ -7134,6 +7280,11 @@ colors@^1.1.2: resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78" integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA== +colour@latest: + version "0.7.1" + resolved "https://registry.yarnpkg.com/colour/-/colour-0.7.1.tgz#9cb169917ec5d12c0736d3e8685746df1cadf778" + integrity sha1-nLFpkX7F0SwHNtPoaFdG3xyt93g= + columnify@1.5.4: version "1.5.4" resolved "https://registry.yarnpkg.com/columnify/-/columnify-1.5.4.tgz#4737ddf1c7b69a8a7c340570782e947eec8e78bb" @@ -7392,11 +7543,6 @@ cookie@0.4.0: resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba" integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg== -cookie@~0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.1.tgz#afd713fe26ebd21ba95ceb61f9a8116e50a537d1" - integrity sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA== - cookiejar@^2.1.0, cookiejar@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.2.tgz#dd8a235530752f988f9a0844f3fc589e3111125c" @@ -7608,6 +7754,13 @@ cross-fetch@^2.1.0, cross-fetch@^2.1.1: node-fetch "2.1.2" whatwg-fetch "2.0.4" +cross-fetch@^3.0.6: + version "3.0.6" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.0.6.tgz#3a4040bc8941e653e0e9cf17f29ebcd177d3365c" + integrity sha512-KBPUbqgFjzWlVcURG+Svp9TlhA5uliYtiNx/0r8nv0pdypeQCRJ9IaSIc3q/x3q8t3F75cHuwxVql1HFGHCNJQ== + dependencies: + node-fetch "2.6.1" + cross-spawn@7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.1.tgz#0ab56286e0f7c24e153d04cc2aa027e43a9a5d14" @@ -8014,6 +8167,11 @@ decamelize@^1.1.0, decamelize@^1.1.1, decamelize@^1.1.2, decamelize@^1.2.0: resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= +decimal.js@^10.2.0: + version "10.2.1" + resolved "https://registry.yarnpkg.com/decimal.js/-/decimal.js-10.2.1.tgz#238ae7b0f0c793d3e3cea410108b35a2c01426a3" + integrity sha512-KaL7+6Fw6i5A2XSnsbhm/6B+NuEA7TZ4vqxnd5tXz9sbKtrN9Srj8ab4vKVdK8YAqZO9P1kg45Y6YLoduPf+kw== + decode-uri-component@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" @@ -8828,6 +8986,14 @@ ecdsa-sig-formatter@1.0.11: dependencies: safe-buffer "^5.0.1" +ecurve@^1.0.0, ecurve@^1.0.3: + version "1.0.6" + resolved "https://registry.yarnpkg.com/ecurve/-/ecurve-1.0.6.tgz#dfdabbb7149f8d8b78816be5a7d5b83fcf6de797" + integrity sha512-/BzEjNfiSuB7jIWKcS/z8FK9jNjmEWvUV2YZ4RLSmcDtP7Lq0m6FvDuSnJpBlDpGRpfRQeTLGLBI8H+kEv0r+w== + dependencies: + bigi "^1.1.0" + safe-buffer "^5.0.1" + editions@^1.3.3: version "1.3.4" resolved "https://registry.yarnpkg.com/editions/-/editions-1.3.4.tgz#3662cb592347c3168eb8e498a0ff73271d67f50b" @@ -9225,6 +9391,11 @@ es6-promise@^4.0.3: resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.4.tgz#dc4221c2b16518760bd8c39a52d8f356fc00ed29" integrity sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ== +es6-promise@^4.2.8: + version "4.2.8" + resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a" + integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w== + es6-promisify@6.0.2: version "6.0.2" resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-6.0.2.tgz#525c23725b8510f5f1f2feb5a1fbad93a93e29b4" @@ -9601,6 +9772,11 @@ eslint@^7.7.0: text-table "^0.2.0" v8-compile-cache "^2.0.3" +esm@^3.2.25: + version "3.2.25" + resolved "https://registry.yarnpkg.com/esm/-/esm-3.2.25.tgz#342c18c29d56157688ba5ce31f8431fbb795cc10" + integrity sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA== + espree@6.1.1: version "6.1.1" resolved "https://registry.yarnpkg.com/espree/-/espree-6.1.1.tgz#7f80e5f7257fc47db450022d723e356daeb1e5de" @@ -9960,17 +10136,16 @@ eth-simple-keyring@^3.5.0: events "^1.1.1" xtend "^4.0.1" -eth-trezor-keyring@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/eth-trezor-keyring/-/eth-trezor-keyring-0.4.0.tgz#f59c210f95aaf3d7321ae69d2b87a3b8db96a828" - integrity sha512-7F+C1ztxZStLzmG6r/2/MxjSuxw0aU9T26unJ03fQslktKG9izP+dU2IAJUnWxnyej2ZkfcgcH9M1t32LFbK2A== +eth-trezor-keyring@^0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/eth-trezor-keyring/-/eth-trezor-keyring-0.5.2.tgz#b2bbb52701e382e831d9889bc4dd71faaf8000c3" + integrity sha512-ciTDHBdKJQciNdGnoEdiORRcbHLUX1NvGmesup6EsW5eD023kvw2xVQlfDj8YxuUsA+sX47IDbS/SwWxvN/PiQ== dependencies: eth-sig-util "^1.4.2" ethereumjs-tx "^1.3.4" ethereumjs-util "^5.1.5" - events "^2.0.0" hdkey "0.8.0" - trezor-connect "^7.0.1" + trezor-connect "8.1.19-extended" eth-tx-summary@^3.1.2: version "3.2.4" @@ -10581,6 +10756,11 @@ events@^3.0.0: resolved "https://registry.yarnpkg.com/events/-/events-3.0.0.tgz#9a0a0dfaf62893d92b875b8f2698ca4114973e88" integrity sha512-Dc381HFWJzEOhQ+d8pkNon++bk9h6cdAoAj4iE6Q4y6xgTzySWXlKn05/TVNpjnfRqi/X0EpJEJohPjNI3zpVA== +events@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/events/-/events-3.2.0.tgz#93b87c18f8efcd4202a461aec4dfc0556b639379" + integrity sha512-/46HWwbfCX2xTawVfkKLGxMifJYQBWMwY1mjywRtb4c9x8l5NP3KoJtnIOiL1hfdRkIuYhETxQlo62IF8tcnlg== + evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz#7fcbdb198dc71959432efe13842684e0525acb02" @@ -12904,6 +13084,17 @@ hastscript@^6.0.0: property-information "^5.0.0" space-separated-tokens "^1.0.0" +hd-wallet@9.1.0: + version "9.1.0" + resolved "https://registry.yarnpkg.com/hd-wallet/-/hd-wallet-9.1.0.tgz#0cfdae4e0d7147438c7802fedce29b7d049c0f5f" + integrity sha512-Oto94Q1e9C9wPsrxErky8TFoOqERiL6EZEo3jZ3BSPu36hpz1KfsB3MqPorvoOWQt6AjC5FoIy/lIPLx3aDMew== + dependencies: + "@trezor/utxo-lib" "0.1.1" + bchaddrjs "^0.3.2" + bignumber.js "^9.0.1" + queue "^6.0.1" + socket.io-client "^2.2.0" + hdkey@0.8.0: version "0.8.0" resolved "https://registry.yarnpkg.com/hdkey/-/hdkey-0.8.0.tgz#08c9a9fcb6a42d9724d669f81c53a3c507f87bf1" @@ -15370,6 +15561,11 @@ jsonpointer@^4.0.0: resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" integrity sha1-T9kss04OnbPInIYi7PUfm5eMbLk= +jsonschema@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/jsonschema/-/jsonschema-1.2.2.tgz#83ab9c63d65bf4d596f91d81195e78772f6452bc" + integrity sha512-iX5OFQ6yx9NgbHCwse51ohhKgLuLL7Z5cNOeZOPIlDUtAMrxlruHLzVZxbltdHE5mEDXN+75oFOwq6Gn0MZwsA== + jsonschema@^1.2.4: version "1.2.4" resolved "https://registry.yarnpkg.com/jsonschema/-/jsonschema-1.2.4.tgz#a46bac5d3506a254465bc548876e267c6d0d6464" @@ -15553,7 +15749,7 @@ k-bucket@^5.0.0: dependencies: randombytes "^2.0.3" -keccak@3.0.1, keccak@^3.0.0: +keccak@3.0.1, keccak@^3.0.0, keccak@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.1.tgz#ae30a0e94dbe43414f741375cff6d64c8bea0bff" integrity sha512-epq90L9jlFWCW7+pQa6JOnKn2Xgl2mtI664seYR6MHskvI9agt7AnDqmAlp9TqU4/caMYbA08Hi5DMZAl5zdkA== @@ -16829,6 +17025,11 @@ long@^4.0.0: resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== +"long@~2 >=2.2.3": + version "2.4.0" + resolved "https://registry.yarnpkg.com/long/-/long-2.4.0.tgz#9fa180bb1d9500cdc29c4156766a1995e1f4524f" + integrity sha1-n6GAux2VAM3CnEFWdmoZleH0Uk8= + longest-streak@^2.0.1: version "2.0.3" resolved "https://registry.yarnpkg.com/longest-streak/-/longest-streak-2.0.3.tgz#3de7a3f47ee18e9074ded8575b5c091f5d0a4105" @@ -17952,6 +18153,11 @@ nano-json-stream-parser@^0.1.2: resolved "https://registry.yarnpkg.com/nano-json-stream-parser/-/nano-json-stream-parser-0.1.2.tgz#0cc8f6d0e2b622b479c40d499c46d64b755c6f5f" integrity sha1-DMj20OK2IrR5xA1JnEbWS3Vcb18= +nanoassert@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/nanoassert/-/nanoassert-1.1.0.tgz#4f3152e09540fde28c76f44b19bbcd1d5a42478d" + integrity sha1-TzFS4JVA/eKMdvRLGbvNHVpCR40= + nanoid@^2.0.0, nanoid@^2.1.6: version "2.1.11" resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-2.1.11.tgz#ec24b8a758d591561531b4176a01e3ab4f0f0280" @@ -18138,7 +18344,7 @@ node-fetch@2.1.2: resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.1.2.tgz#ab884e8e7e57e38a944753cec706f788d1768bb5" integrity sha1-q4hOjn5X44qUR1POxwb3iNF2i7U= -node-fetch@^2.3.0, node-fetch@^2.6.0, node-fetch@^2.6.1: +node-fetch@2.6.1, node-fetch@^2.3.0, node-fetch@^2.6.0, node-fetch@^2.6.1: version "2.6.1" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== @@ -18832,6 +19038,11 @@ optipng-bin@^6.0.0: bin-wrapper "^4.0.0" logalot "^2.0.0" +optjs@latest: + version "3.2.2" + resolved "https://registry.yarnpkg.com/optjs/-/optjs-3.2.2.tgz#69a6ce89c442a44403141ad2f9b370bd5bb6f4ee" + integrity sha1-aabOicRCpEQDFBrS+bNwvVu29O4= + orbit-db-access-controllers@^0.2.0, orbit-db-access-controllers@~0.2.0: version "0.2.2" resolved "https://registry.yarnpkg.com/orbit-db-access-controllers/-/orbit-db-access-controllers-0.2.2.tgz#4412b01a198208712d2a0a4065709eeea86b39d6" @@ -19465,6 +19676,11 @@ parse-repo@^1.0.4: resolved "https://registry.yarnpkg.com/parse-repo/-/parse-repo-1.0.4.tgz#74b91d2cb8675d11b99976a0065f6ce17fa1bcc8" integrity sha1-dLkdLLhnXRG5mXagBl9s4X+hvMg= +parse-uri@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/parse-uri/-/parse-uri-1.0.3.tgz#f3c24a74907a4e357c1741e96ca9faadecfd6db5" + integrity sha512-upMnGxNcm+45So85HoguwZTVZI9u11i36DdxJfGF2HYWS2eh3TIx7+/tTi7qrEq15qzGkVhsKjesau+kCk48pA== + parse-url@^5.0.0: version "5.0.1" resolved "https://registry.yarnpkg.com/parse-url/-/parse-url-5.0.1.tgz#99c4084fc11be14141efa41b3d117a96fcb9527f" @@ -20425,6 +20641,14 @@ proto-list@~1.2.1: resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849" integrity sha1-IS1b/hMYMGpCD2QCuOJv85ZHqEk= +protobufjs-old-fixed-webpack@3.8.5: + version "3.8.5" + resolved "https://registry.yarnpkg.com/protobufjs-old-fixed-webpack/-/protobufjs-old-fixed-webpack-3.8.5.tgz#5813c1af9f1d136bbf39f4f9f2e6f3e43c389d06" + integrity sha1-WBPBr58dE2u/OfT58ubz5Dw4nQY= + dependencies: + ascli "~0.3" + bytebuffer-old-fixed-webpack "3.5.6" + protocol-buffers-schema@^3.3.1: version "3.3.2" resolved "https://registry.yarnpkg.com/protocol-buffers-schema/-/protocol-buffers-schema-3.3.2.tgz#00434f608b4e8df54c59e070efeefc37fb4bb859" @@ -20813,6 +21037,13 @@ querystring@0.2.0, querystring@^0.2.0: resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA= +queue@^6.0.1: + version "6.0.2" + resolved "https://registry.yarnpkg.com/queue/-/queue-6.0.2.tgz#b91525283e2315c7553d2efa18d83e76432fed65" + integrity sha512-iHZWu+q3IdFZFX36ro/lKBkSvfkztY5Y7HMiPlOUjhupPcG2JMfst2KKEpu5XndviX/3UhFbRngUPNKtgvtZiA== + dependencies: + inherits "~2.0.3" + quick-format-unescaped@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/quick-format-unescaped/-/quick-format-unescaped-3.0.2.tgz#0137e94d8fb37ffeb70040535111c378e75396fb" @@ -22272,6 +22503,64 @@ ripemd160@^2.0.0, ripemd160@^2.0.1: hash-base "^3.0.0" inherits "^2.0.1" +ripple-address-codec@^4.0.0, ripple-address-codec@^4.1.0, ripple-address-codec@^4.1.1: + version "4.1.2" + resolved "https://registry.yarnpkg.com/ripple-address-codec/-/ripple-address-codec-4.1.2.tgz#c573309dbd0fdd4ef8c803bf36959b8a716c2aa1" + integrity sha512-bIhmaxOg6rwVYkPQha9cuHdIdwmD8XTnaklBmyRjFvNZwYJ6Cf0cdCt+SpJd+RRJhRU65+U1Eup6YkoCBrqebg== + dependencies: + base-x "3.0.8" + create-hash "^1.1.2" + +ripple-binary-codec@^0.2.7: + version "0.2.7" + resolved "https://registry.yarnpkg.com/ripple-binary-codec/-/ripple-binary-codec-0.2.7.tgz#c5390e97e4072747a3ff386ee99558b496c6e5ab" + integrity sha512-VD+sHgZK76q3kmO765klFHPDCEveS5SUeg/bUNVpNrj7w2alyDNkbF17XNbAjFv+kSYhfsUudQanoaSs2Y6uzw== + dependencies: + babel-runtime "^6.26.0" + bn.js "^5.1.1" + create-hash "^1.2.0" + decimal.js "^10.2.0" + inherits "^2.0.4" + lodash "^4.17.15" + ripple-address-codec "^4.1.0" + +ripple-keypairs@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/ripple-keypairs/-/ripple-keypairs-1.0.2.tgz#91c724210734e704e35053925a80bf1cd8104c92" + integrity sha512-3l2cUhUO4VEK42NfHtn7WA1NEO+vGU7p7/36QhCIvYFf8+lNdNrY0PrriJ3Mef/TG8hQvO8coCVEO5fpOKSAag== + dependencies: + bn.js "^5.1.1" + brorand "^1.0.5" + elliptic "^6.5.2" + hash.js "^1.0.3" + ripple-address-codec "^4.0.0" + +ripple-lib-transactionparser@0.8.2: + version "0.8.2" + resolved "https://registry.yarnpkg.com/ripple-lib-transactionparser/-/ripple-lib-transactionparser-0.8.2.tgz#7aaad3ba1e1aeee1d5bcff32334a7a838f834dce" + integrity sha512-1teosQLjYHLyOQrKUQfYyMjDR3MAq/Ga+MJuLUfpBMypl4LZB4bEoMcmG99/+WVTEiZOezJmH9iCSvm/MyxD+g== + dependencies: + bignumber.js "^9.0.0" + lodash "^4.17.15" + +ripple-lib@1.8.2: + version "1.8.2" + resolved "https://registry.yarnpkg.com/ripple-lib/-/ripple-lib-1.8.2.tgz#d36dafcb64a913a5dab8a2f66a3b0727baaa9347" + integrity sha512-7fLQtiXb8LfyedkXQtDSNQPy7omNu7rGUO8M8bK2qiE+DuX4FPl8B8tVJbxBwOusAuYzdoVQfZtfdXt4WmBpmw== + dependencies: + "@types/lodash" "^4.14.136" + "@types/ws" "^7.2.0" + bignumber.js "^9.0.0" + https-proxy-agent "^5.0.0" + jsonschema "1.2.2" + lodash "^4.17.4" + lodash.isequal "^4.5.0" + ripple-address-codec "^4.1.1" + ripple-binary-codec "^0.2.7" + ripple-keypairs "^1.0.0" + ripple-lib-transactionparser "0.8.2" + ws "^7.2.0" + rlp@^2.0.0, rlp@^2.2.1, rlp@^2.2.2, rlp@^2.2.3: version "2.2.4" resolved "https://registry.yarnpkg.com/rlp/-/rlp-2.2.4.tgz#d6b0e1659e9285fc509a5d169a9bd06f704951c1" @@ -22367,6 +22656,11 @@ run-queue@^1.0.0, run-queue@^1.0.3: dependencies: aproba "^1.1.1" +runtypes@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/runtypes/-/runtypes-5.0.1.tgz#406d140410266f6ece17c3501a37234f91faa346" + integrity sha512-+TWVlCmFsgrG4Nd2u+ambpNFO8Yp4heAflGQi9oNj6GRkxZo8aSDBxO1Y0vlKIQCWKKFxato+8Hn67XeAqKhRA== + rustbn.js@~0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/rustbn.js/-/rustbn.js-0.2.0.tgz#8082cb886e707155fd1cb6f23bd591ab8d55d0ca" @@ -22655,6 +22949,20 @@ secp256k1@^3.0.1, secp256k1@^3.6.1, secp256k1@^3.6.2: nan "^2.14.0" safe-buffer "^5.1.2" +secp256k1@^3.5.2: + version "3.8.0" + resolved "https://registry.yarnpkg.com/secp256k1/-/secp256k1-3.8.0.tgz#28f59f4b01dbee9575f56a47034b7d2e3b3b352d" + integrity sha512-k5ke5avRZbtl9Tqx/SA7CbY3NF6Ro+Sj9cZxezFzuBlLDmyqPiL8hJJ+EmzD8Ig4LUDByHJ3/iPOVoRixs/hmw== + dependencies: + bindings "^1.5.0" + bip66 "^1.1.5" + bn.js "^4.11.8" + create-hash "^1.2.0" + drbg.js "^1.0.1" + elliptic "^6.5.2" + nan "^2.14.0" + safe-buffer "^5.1.2" + secp256k1@^4.0.1: version "4.0.2" resolved "https://registry.yarnpkg.com/secp256k1/-/secp256k1-4.0.2.tgz#15dd57d0f0b9fdb54ac1fa1694f40e5e9a54f4a1" @@ -23166,7 +23474,7 @@ socket.io-adapter@~1.1.0: resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-1.1.2.tgz#ab3f0d6f66b8fc7fca3959ab5991f82221789be9" integrity sha512-WzZRUj1kUjrTIrUKpZLEzFZ1OLj5FwLlAFQs9kuZJzJi5DKdU7FsWc36SNmA8iDOtwBQyT8FkrriRM8vXLYz8g== -socket.io-client@2.4.0, socket.io-client@^2.1.1: +socket.io-client@2.4.0, socket.io-client@^2.1.1, socket.io-client@^2.2.0: version "2.4.0" resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-2.4.0.tgz#aafb5d594a3c55a34355562fc8aea22ed9119a35" integrity sha512-M6xhnKQHuuZd4Ba9vltCLT9oa+YvTsP8j9NcEiLElfIg8KeYPyhWOes6x4t+LTAC8enQbE/995AdTem2uNyKKQ== @@ -24648,6 +24956,13 @@ tiny-warning@^1.0.0, tiny-warning@^1.0.2: resolved "https://registry.yarnpkg.com/tiny-warning/-/tiny-warning-1.0.3.tgz#94a30db453df4c643d0fd566060d60a875d84754" integrity sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA== +tiny-worker@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/tiny-worker/-/tiny-worker-2.3.0.tgz#715ae34304c757a9af573ae9a8e3967177e6011e" + integrity sha512-pJ70wq5EAqTAEl9IkGzA+fN0836rycEuz2Cn6yeZ6FRzlVS5IDOkFHpIoEsksPRQV34GDqXm65+OlnZqUSyK2g== + dependencies: + esm "^3.2.25" + tinycolor2@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/tinycolor2/-/tinycolor2-1.4.1.tgz#f4fad333447bc0b07d4dc8e9209d8f39a8ac77e8" @@ -24791,14 +25106,40 @@ tree-kill@^1.2.2: resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc" integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A== -trezor-connect@^7.0.1: - version "7.0.3" - resolved "https://registry.yarnpkg.com/trezor-connect/-/trezor-connect-7.0.3.tgz#70c4bc26c0966e794fc280a12c1acc9fef88864f" - integrity sha512-1Y1ajCDF8dC5d2yrCUmVkNqXeOlucamQ6j6Ko7kaqNdge3g9KZ+O48jUwP/eGzei8oUvPZUHd7o4OhDHTlpLCw== +trezor-connect@8.1.19-extended: + version "8.1.19-extended" + resolved "https://registry.yarnpkg.com/trezor-connect/-/trezor-connect-8.1.19-extended.tgz#2b5f7f232f2064121f9b3adc05cbf2bc2f7c08cc" + integrity sha512-elm4fgPB79q5e+q8/i7pW2ms3mwkSQjYrgUD2nV40yP4cP8Cp7DYtu0bh4ZYhMNN0+BFwIYw86fvPSCo6D7OQA== dependencies: - "@babel/runtime" "^7.3.1" - events "^3.0.0" - whatwg-fetch "^3.0.0" + "@babel/runtime" "^7.12.5" + "@trezor/blockchain-link" "^1.0.15" + "@trezor/rollout" "^1.0.4" + "@trezor/utxo-lib" "^0.1.1" + bchaddrjs "0.4.9" + bignumber.js "^9.0.1" + bowser "^2.11.0" + events "^3.2.0" + hd-wallet "9.1.0" + keccak "^3.0.1" + node-fetch "^2.6.1" + parse-uri "^1.0.3" + tiny-worker "^2.3.0" + trezor-link "1.7.1" + whatwg-fetch "^3.5.0" + +trezor-link@1.7.1: + version "1.7.1" + resolved "https://registry.yarnpkg.com/trezor-link/-/trezor-link-1.7.1.tgz#8ad08f59ae4c9d49c44d1ed8be0bdb6a3e4bbe5b" + integrity sha512-2oEEUJgs4RmwifFaE+B14z4zUBVoekkXyT7S6U6667Fnqg40tpGC+gqbqwaeU/2ARsAXvbD5YBhPdTLsL9Up9w== + dependencies: + bigi "^1.4.1" + ecurve "^1.0.3" + json-stable-stringify "^1.0.1" + node-fetch "^2.6.1" + object.values "^1.1.1" + protobufjs-old-fixed-webpack "3.8.5" + semver-compare "^1.0.0" + whatwg-fetch "^3.5.0" trim-newlines@^1.0.0: version "1.0.0" @@ -26265,11 +26606,16 @@ whatwg-fetch@2.0.4: resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f" integrity sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng== -whatwg-fetch@^3.0.0, whatwg-fetch@^3.4.1: +whatwg-fetch@^3.4.1: version "3.4.1" resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.4.1.tgz#e5f871572d6879663fa5674c8f833f15a8425ab3" integrity sha512-sofZVzE1wKwO+EYPbWfiwzaKovWiZXf4coEzjGP9b2GBVgQRLQUZ2QcuPpQExGDAW5GItpEm6Tl4OU5mywnAoQ== +whatwg-fetch@^3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.5.0.tgz#605a2cd0a7146e5db141e29d1c62ab84c0c4c868" + integrity sha512-jXkLtsR42xhXg7akoDKvKWE40eJeI+2KZqcp2h3NsOrRnDvtWX36KcKl30dy+hxECivdk2BVUHVNrPtoMBUx6A== + whatwg-url@7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-7.0.0.tgz#fde926fa54a599f3adf82dff25a9f7be02dc6edd" @@ -26476,7 +26822,7 @@ ws@^5.1.1: dependencies: async-limiter "~1.0.0" -ws@~7.4.2: +ws@^7.2.0, ws@^7.4.0, ws@~7.4.2: version "7.4.2" resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.2.tgz#782100048e54eb36fe9843363ab1c68672b261dd" integrity sha512-T4tewALS3+qsrpGI/8dqNMLIVdq/g/85U98HPMa6F0m6xTbvhXU6RCQLqPH3+SlomNV/LdY6RXEbBpMH6EOJnA== From 183cc154facf72435a0ababd66a9e8164f25763d Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Thu, 21 Jan 2021 17:03:57 -0330 Subject: [PATCH 24/29] Update `yarn.lock` (#10241) A recent change resulted in an outdated lockfile. These changes resulted from running `yarn` with a clean working tree. --- yarn.lock | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 8964ecdd6..fa5098c80 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3524,7 +3524,7 @@ abstract-logging@^1.0.0: resolved "https://registry.yarnpkg.com/abstract-logging/-/abstract-logging-1.0.0.tgz#8b7deafd310559bc28f77724dd1bb30177278c1b" integrity sha1-i33q/TEFWbwo93ck3RuzAXcnjBs= -accepts@^1.3.5, accepts@~1.3.7: +accepts@^1.3.5, accepts@~1.3.4, accepts@~1.3.7: version "1.3.7" resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd" integrity sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA== @@ -5529,6 +5529,11 @@ base64id@1.0.0: resolved "https://registry.yarnpkg.com/base64id/-/base64id-1.0.0.tgz#47688cb99bb6804f0e06d3e763b1c32e57d8e6b6" integrity sha1-R2iMuZu2gE8OBtPnY7HDLlfY5rY= +base64id@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/base64id/-/base64id-2.0.0.tgz#2770ac6bc47d312af97a8bf9a634342e0cd25cb6" + integrity sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog== + base64url@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/base64url/-/base64url-3.0.1.tgz#6399d572e2bc3f90a9a8b22d5dbb0a32d33f788d" @@ -7543,6 +7548,11 @@ cookie@0.4.0: resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba" integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg== +cookie@~0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.1.tgz#afd713fe26ebd21ba95ceb61f9a8116e50a537d1" + integrity sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA== + cookiejar@^2.1.0, cookiejar@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.2.tgz#dd8a235530752f988f9a0844f3fc589e3111125c" From f6388f260b33b42774877657d605f8e6978ac104 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Thu, 21 Jan 2021 17:04:10 -0330 Subject: [PATCH 25/29] Remove unused environment variables (#10234) The environment variables `METAMETRICS_PROJECT_ID` and `ETH_GAS_STATION_API_KEY` were still being injected into the JavaScript build, despite being unused. The MetaMetrics project ID was made obsolete in #9646, and the ETH Gas Station API key was made obsolete in PR #9867 --- development/build/scripts.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/development/build/scripts.js b/development/build/scripts.js index 9236dbb7e..ae1a3472c 100644 --- a/development/build/scripts.js +++ b/development/build/scripts.js @@ -375,12 +375,10 @@ function createScriptTasks({ browserPlatforms, livereload }) { METAMASK_DEBUG: opts.devMode, METAMASK_ENVIRONMENT: environment, METAMASK_VERSION: baseManifest.version, - METAMETRICS_PROJECT_ID: process.env.METAMETRICS_PROJECT_ID, NODE_ENV: opts.devMode ? 'development' : 'production', IN_TEST: opts.testing ? 'true' : false, PUBNUB_SUB_KEY: process.env.PUBNUB_SUB_KEY || '', PUBNUB_PUB_KEY: process.env.PUBNUB_PUB_KEY || '', - ETH_GAS_STATION_API_KEY: process.env.ETH_GAS_STATION_API_KEY || '', CONF: opts.devMode ? conf : {}, SENTRY_DSN: process.env.SENTRY_DSN, INFURA_PROJECT_ID: opts.testing From 288f60bff2e1a492a4a37568e8fcbd1a1a470a64 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Fri, 22 Jan 2021 12:05:01 -0330 Subject: [PATCH 26/29] Fix design system error constants (#10246) The design system error constants were missing a hyphen. Now they match the CSS color variable they were intended to match. --- ui/app/helpers/constants/design-system.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/app/helpers/constants/design-system.js b/ui/app/helpers/constants/design-system.js index 0d1a42eea..288a1f0be 100644 --- a/ui/app/helpers/constants/design-system.js +++ b/ui/app/helpers/constants/design-system.js @@ -14,9 +14,9 @@ export const COLORS = { SUCCESS1: 'success-1', SUCCESS2: 'success-2', SUCCESS3: 'success-3', - ERROR1: 'error1', - ERROR2: 'error2', - ERROR3: 'error3', + ERROR1: 'error-1', + ERROR2: 'error-2', + ERROR3: 'error-3', ALERT1: 'alert-1', ALERT2: 'alert-2', ALERT3: 'alert-3', From 1dad4abfdc6f013ea9ebab264c3b7bcfcdefdd2c Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Fri, 22 Jan 2021 10:27:07 -0800 Subject: [PATCH 27/29] Fix site metadata JSON-RPC handler (#10243) * Fix getting the site metadata from the request origin params. Regressed from inpage-provider ts migration the request. The property domainMetadata is now set as a params key for the request. https://github.com/MetaMask/inpage-provider/blob/v7.0.0/src/siteMetadata.js#L19-L25 vs https://github.com/MetaMask/inpage-provider/blob/main/src/siteMetadata.ts#L19-L27 * Change hardcoded mocked response of the request to the prod response. --- .../controllers/permissions/permissionsMethodMiddleware.js | 4 ++-- test/unit/app/controllers/permissions/mocks.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/scripts/controllers/permissions/permissionsMethodMiddleware.js b/app/scripts/controllers/permissions/permissionsMethodMiddleware.js index add23196e..a4bac3976 100644 --- a/app/scripts/controllers/permissions/permissionsMethodMiddleware.js +++ b/app/scripts/controllers/permissions/permissionsMethodMiddleware.js @@ -74,8 +74,8 @@ export default function createPermissionsMethodMiddleware({ // custom method for getting metadata from the requesting domain, // sent automatically by the inpage provider when it's initialized case 'metamask_sendDomainMetadata': { - if (typeof req.domainMetadata?.name === 'string') { - addDomainMetadata(req.origin, req.domainMetadata) + if (typeof req.params?.name === 'string') { + addDomainMetadata(req.origin, req.params) } res.result = true return diff --git a/test/unit/app/controllers/permissions/mocks.js b/test/unit/app/controllers/permissions/mocks.js index 05bed739d..be4a2321b 100644 --- a/test/unit/app/controllers/permissions/mocks.js +++ b/test/unit/app/controllers/permissions/mocks.js @@ -600,7 +600,7 @@ export const getters = deepFreeze({ return { origin, method: 'metamask_sendDomainMetadata', - domainMetadata: { + params: { ...args, name, }, From ab3b64e64368d0b84e94547916aa39869cd5ecd1 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Fri, 22 Jan 2021 15:10:43 -0330 Subject: [PATCH 28/29] Fix decrypt message confirmation UI crash (#10252) The decrupt message confirmation UI will crash if the origin metadata is not present. This PR makes the UI tolerant of that metadata being missing. It was always intended to be optional anyway. --- .../confirm-decrypt-message.component.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ui/app/pages/confirm-decrypt-message/confirm-decrypt-message.component.js b/ui/app/pages/confirm-decrypt-message/confirm-decrypt-message.component.js index bb5366bfd..42325302e 100644 --- a/ui/app/pages/confirm-decrypt-message/confirm-decrypt-message.component.js +++ b/ui/app/pages/confirm-decrypt-message/confirm-decrypt-message.component.js @@ -174,8 +174,9 @@ export default class ConfirmDecryptMessage extends Component { const { decryptMessageInline, domainMetadata, txData } = this.props const { t } = this.context - const origin = domainMetadata[txData.msgParams.origin] - const notice = t('decryptMessageNotice', [origin.name]) + const originMetadata = domainMetadata[txData.msgParams.origin] + const name = originMetadata?.name || txData.msgParams.origin + const notice = t('decryptMessageNotice', [txData.msgParams.origin]) const { hasCopied, @@ -191,15 +192,15 @@ export default class ConfirmDecryptMessage extends Component { {this.renderAccountInfo()}
- {origin.icon ? ( + {originMetadata?.icon ? ( ) : ( - {origin.name.charAt(0).toUpperCase()} + {name.charAt(0).toUpperCase()} )}
{notice}
From b1fc4addfd4d9a0c2d392dbf97ddd4cb66505470 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Fri, 22 Jan 2021 15:30:56 -0330 Subject: [PATCH 29/29] Reset swaps routeState in navigateBackToBuildQuote (#10166) --- ui/app/ducks/swaps/swaps.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/ducks/swaps/swaps.js b/ui/app/ducks/swaps/swaps.js index 876bd50ec..0278df774 100644 --- a/ui/app/ducks/swaps/swaps.js +++ b/ui/app/ducks/swaps/swaps.js @@ -329,8 +329,8 @@ export { export const navigateBackToBuildQuote = (history) => { return async (dispatch) => { // TODO: Ensure any fetch in progress is cancelled + await dispatch(setBackgroundSwapRouteState('')) dispatch(navigatedBackToBuildQuote()) - history.push(BUILD_QUOTE_ROUTE) } }