aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorAlexander Tseung <alextsg@gmail.com>2018-03-30 00:37:29 +0800
committerAlexander Tseung <alextsg@gmail.com>2018-03-30 00:37:29 +0800
commitef61ef2ce885635862bb242612dd821cb3a65b6b (patch)
tree0f128f8b56b57a1bbe96dcf5743d34b5f95dc4cc /app
parent58f52b2b8de9efd43896e23ab0ac9972f45bb278 (diff)
parent8766420f19251b95211dd99ff9a45e60cf0177ad (diff)
downloadtangerine-wallet-browser-ef61ef2ce885635862bb242612dd821cb3a65b6b.tar
tangerine-wallet-browser-ef61ef2ce885635862bb242612dd821cb3a65b6b.tar.gz
tangerine-wallet-browser-ef61ef2ce885635862bb242612dd821cb3a65b6b.tar.bz2
tangerine-wallet-browser-ef61ef2ce885635862bb242612dd821cb3a65b6b.tar.lz
tangerine-wallet-browser-ef61ef2ce885635862bb242612dd821cb3a65b6b.tar.xz
tangerine-wallet-browser-ef61ef2ce885635862bb242612dd821cb3a65b6b.tar.zst
tangerine-wallet-browser-ef61ef2ce885635862bb242612dd821cb3a65b6b.zip
Fix i18n merge conflicts
Diffstat (limited to 'app')
-rw-r--r--app/_locales/en/messages.json12
-rw-r--r--app/_locales/index.json19
-rw-r--r--app/_locales/it/messages.json2
-rw-r--r--app/_locales/ja/messages.json76
-rw-r--r--app/_locales/pt/messages.json2
-rw-r--r--app/_locales/zh_TW/messages.json61
-rw-r--r--app/manifest.json2
-rw-r--r--app/scripts/background.js13
-rw-r--r--app/scripts/controllers/currency.js2
-rw-r--r--app/scripts/controllers/preferences.js5
-rw-r--r--app/scripts/controllers/transactions.js10
-rw-r--r--app/scripts/lib/extractEthjsErrorMessage.js27
-rw-r--r--app/scripts/lib/get-first-preferred-lang-code.js16
-rw-r--r--app/scripts/lib/reportFailedTxToSentry.js26
-rw-r--r--app/scripts/lib/setupRaven.js17
-rw-r--r--app/scripts/lib/tx-state-manager.js23
-rw-r--r--app/scripts/metamask-controller.js86
-rw-r--r--app/scripts/migrations/023.js50
-rw-r--r--app/scripts/migrations/index.js2
-rw-r--r--app/scripts/popup.js126
20 files changed, 404 insertions, 173 deletions
diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json
index 0bfa992b4..3e469cf44 100644
--- a/app/_locales/en/messages.json
+++ b/app/_locales/en/messages.json
@@ -185,7 +185,7 @@
},
"decimal": {
"message": "Decimals of Precision"
- },
+ },
"defaultNetwork": {
"message": "The default network for Ether transactions is Main Net."
},
@@ -235,7 +235,7 @@
"done": {
"message": "Done"
},
- "downloadStatelogs": {
+ "downloadStateLogs": {
"message": "Download State Logs"
},
"dropped": {
@@ -671,6 +671,12 @@
"save": {
"message": "Save"
},
+ "reprice_title": {
+ "message": "Reprice Transaction"
+ },
+ "reprice_subtitle": {
+ "message": "Increase your gas price to attempt to overwrite and speed up your transaction"
+ },
"saveAsFile": {
"message": "Save as File",
"description": "Account export process"
@@ -884,7 +890,7 @@
},
"visitWebSite": {
"message": "Visit our web site"
- },
+ },
"warning": {
"message": "Warning"
},
diff --git a/app/_locales/index.json b/app/_locales/index.json
new file mode 100644
index 000000000..c085deb72
--- /dev/null
+++ b/app/_locales/index.json
@@ -0,0 +1,19 @@
+[
+ { "code": "de", "name": "German" },
+ { "code": "en", "name": "English" },
+ { "code": "es", "name": "Spanish" },
+ { "code": "fr", "name": "French" },
+ { "code": "hn", "name": "Hindi" },
+ { "code": "it", "name": "Italian" },
+ { "code": "ja", "name": "Japanese" },
+ { "code": "ko", "name": "Korean" },
+ { "code": "nl", "name": "Dutch" },
+ { "code": "ph", "name": "Tagalog" },
+ { "code": "pt", "name": "Portuguese" },
+ { "code": "ru", "name": "Russian" },
+ { "code": "sl", "name": "Slovenian" },
+ { "code": "th", "name": "Thai" },
+ { "code": "vi", "name": "Vietnamese" },
+ { "code": "zh_CN", "name": "Mandarin" },
+ { "code": "zh_TW", "name": "Taiwanese" }
+]
diff --git a/app/_locales/it/messages.json b/app/_locales/it/messages.json
index f54ef98ca..ef3ed4025 100644
--- a/app/_locales/it/messages.json
+++ b/app/_locales/it/messages.json
@@ -223,7 +223,7 @@
"done": {
"message": "Finito"
},
- "downloadStatelogs": {
+ "downloadStateLogs": {
"message": "Scarica i log di Stato"
},
"edit": {
diff --git a/app/_locales/ja/messages.json b/app/_locales/ja/messages.json
index bab8d3b95..d9762a3e9 100644
--- a/app/_locales/ja/messages.json
+++ b/app/_locales/ja/messages.json
@@ -14,6 +14,9 @@
"address": {
"message": "アドレス"
},
+ "addCustomToken": {
+ "message": "カスタムトークンを追加"
+ },
"addToken": {
"message": "トークンを追加"
},
@@ -63,11 +66,14 @@
"message": "Coinbaseで購入"
},
"buyCoinbaseExplainer": {
- "message": "Coinbaseは、世界で最もポピュラーなBitcoin、Ethereum、そしてLitecoinの取引所です。"
+ "message": "Coinbaseは、世界的なBitcoin、Ethereum、そしてLitecoinの取引所です。"
},
"cancel": {
"message": "キャンセル"
},
+ "classicInterface": {
+ "message": "旧インタフェイスを使用"
+ },
"clickCopy": {
"message": "クリックしてコピー"
},
@@ -126,6 +132,9 @@
"message": "暗号通貨",
"description": "Exchange type (cryptocurrencies)"
},
+ "currentConversion": {
+ "message": "基軸通貨"
+ },
"customGas": {
"message": "ガスのカスタマイズ"
},
@@ -135,14 +144,17 @@
"customRPC": {
"message": "カスタムRPC"
},
+ "decimal": {
+ "message": "小数点桁数"
+ },
"defaultNetwork": {
- "message": "Etherトランザクションのデフォルトのネットワークはメインネットです。"
+ "message": "デフォルトのEther送受信ネットワークはメインネットです。"
},
"denExplainer": {
"message": "DENとは、あなたのパスワードが暗号化されたMetaMask内のストレージです。"
},
"deposit": {
- "message": "デポジット"
+ "message": "受取り"
},
"depositBTC": {
"message": "あなたのBTCを次のアドレスへデポジット:"
@@ -161,13 +173,13 @@
"message": "法定通貨でデポジット"
},
"depositFromAccount": {
- "message": "別のアカウントからデポジット"
+ "message": "別のアカウントから入金"
},
"depositShapeShift": {
- "message": "ShapeShiftでデポジット"
+ "message": "ShapeShiftで入金"
},
"depositShapeShiftExplainer": {
- "message": "あなたが他の暗号通貨を持っているなら、Etherにトレードしてダイレクトにメタマスクウォレットへのデポジットが可能です。アカウント作成は不要。"
+ "message": "他の暗号通貨をEtherと交換してMetaMaskのウォレットへ入金できます。アカウント作成は不要です。"
},
"details": {
"message": "詳細"
@@ -176,10 +188,10 @@
"message": "ダイレクトデポジット"
},
"directDepositEther": {
- "message": "Etherをダイレクトデポジット"
+ "message": "Etherを直接受け取り"
},
"directDepositEtherExplainer": {
- "message": "あなたがEtherをすでにお持ちなら、ダイレクトデポジットは新しいウォレットにEtherを入手する最も迅速な方法です。"
+ "message": "Etherをすでにお持ちなら、MetaMaskの新しいウォレットにEtherを送信することができます。"
},
"done": {
"message": "完了"
@@ -197,7 +209,7 @@
"message": "パスワードを入力"
},
"etherscanView": {
- "message": "Etherscanでアカウントを見る"
+ "message": "Etherscanでアカウントを参照"
},
"exchangeRate": {
"message": "交換レート"
@@ -257,7 +269,7 @@
"message": "Etherをゲット"
},
"getEtherFromFaucet": {
- "message": "フォーセットで $1のEtherをゲット",
+ "message": "フォーセットで $1のEtherを得ることができます。",
"description": "Displays network name for Ether faucet"
},
"greaterThanMin": {
@@ -281,12 +293,15 @@
"message": "どのようにEtherをデポジットしますか?"
},
"import": {
- "message": "インポート",
+ "message": "追加",
"description": "Button to import an account from a selected file"
},
"importAccount": {
"message": "アカウントのインポート"
},
+ "importAccountMsg": {
+ "message":"追加したアカウントはMetaMaskのアカウントシードフレーズとは関連付けられません。インポートしたアカウントについての詳細は"
+ },
"importAnAccount": {
"message": "アカウントをインポート"
},
@@ -298,7 +313,10 @@
"description": "status showing that an account has been fully loaded into the keyring"
},
"infoHelp": {
- "message": "インフォメーションとヘルプ"
+ "message": "情報とヘルプ"
+ },
+ "insufficientFunds": {
+ "message": "残高不足"
},
"invalidAddress": {
"message": "アドレスが無効です。"
@@ -354,7 +372,7 @@
"message": "マイアカウント"
},
"needEtherInWallet": {
- "message": "MetaMaskを使って分散型アプリケーションと対話するためには、あなたのウォレットにEtherが必要になります。"
+ "message": "MetaMaskを使って分散型アプリケーションを使用するためには、このウォレットにEtherが必要です。"
},
"needImportFile": {
"message": "インポートするファイルを選択してください。",
@@ -383,6 +401,9 @@
"newRecipient": {
"message": "新規受取人"
},
+ "newRPC": {
+ "message": "新しいRPCのURLを追加"
+ },
"next": {
"message": "次へ"
},
@@ -460,12 +481,21 @@
"rejected": {
"message": "拒否されました"
},
+ "resetAccount": {
+ "message": "アカウントをリセット"
+ },
+ "restoreFromSeed": {
+ "message": "パスフレーズから復元する"
+ },
"required": {
"message": "必要です。"
},
"retryWithMoreGas": {
"message": "より高いガスプライスで再度試して下さい。"
},
+ "revealSeedWords": {
+ "message": "パスフレーズを表示"
+ },
"revert": {
"message": "元に戻す"
},
@@ -495,8 +525,11 @@
"sendTokens": {
"message": "トークンを送る"
},
+ "onlySendToEtherAddress": {
+ "message": "ETHはイーサリウムアカウントのみに送信できます。"
+ },
"sendTokensAnywhere": {
- "message": "イーサリアムのアカウントを持っている人にトークンを送る"
+ "message": "イーサリアムアカウントを持っている人にトークンを送る"
},
"settings": {
"message": "設定"
@@ -544,9 +577,21 @@
"message": "ShapeShiftで $1をETHにする",
"description": "system will fill in deposit type in start of message"
},
+ "tokenAddress": {
+ "message": "トークンアドレス"
+ },
"tokenBalance": {
"message": "あなたのトークン残高:"
},
+ "tokenSelection": {
+ "message": "トークンを検索、またはリストから選択してください。"
+ },
+ "tokenSymbol": {
+ "message": "トークンシンボル"
+ },
+ "tokenWarning1": {
+ "message": "MetaMaskのアカウントで取得したアカウントのみ追加できます。他のアカウントを使用して取得したトークンは、カスタムトークンを使用してください。"
+ },
"total": {
"message": "合計"
},
@@ -591,6 +636,9 @@
"usedByClients": {
"message": "様々なクライアントによって使用されています。"
},
+ "useOldUI": {
+ "message": "旧UIに切り替え"
+ },
"viewAccount": {
"message": "アカウントを見る"
},
diff --git a/app/_locales/pt/messages.json b/app/_locales/pt/messages.json
index c9eb178f9..e770392d0 100644
--- a/app/_locales/pt/messages.json
+++ b/app/_locales/pt/messages.json
@@ -223,7 +223,7 @@
"done": {
"message": "Finalizado"
},
- "downloadStatelogs": {
+ "downloadStateLogs": {
"message": "Descarregar Registos de Estado"
},
"edit": {
diff --git a/app/_locales/zh_TW/messages.json b/app/_locales/zh_TW/messages.json
index 90f63c6a6..e39793430 100644
--- a/app/_locales/zh_TW/messages.json
+++ b/app/_locales/zh_TW/messages.json
@@ -171,6 +171,9 @@
"customGas": {
"message": "自訂 Gas"
},
+ "customToken": {
+ "message": "自訂代幣"
+ },
"customize": {
"message": "自訂"
},
@@ -184,7 +187,7 @@
"message": "小數點精度"
},
"defaultNetwork": {
- "message": "預設Ether交易網路為主網(Main Net)。"
+ "message": "預設 Ether 交易網路為主網路(Main Net)。"
},
"denExplainer": {
"message": "你的 DEN 是在你的 MetaMask 中的加密密碼儲存庫。"
@@ -215,7 +218,7 @@
"message": "從 ShapeShift 存入"
},
"depositShapeShiftExplainer": {
- "message": "如果你擁有其他加密貨幣,你可以直接交易並存入 Ether 到你的MetaMask錢包。不需要開帳戶。"
+ "message": "如果你擁有其他加密貨幣,你可以直接交易並存入 Ether 到你的 MetaMask 錢包。不需要開帳戶。"
},
"details": {
"message": "詳情"
@@ -227,7 +230,7 @@
"message": "直接存入 Ether"
},
"directDepositEtherExplainer": {
- "message": "如果你已經擁有了一些Ether,使用直接存入功能是讓你的新錢包最快取得Ether的方式。"
+ "message": "如果你已經擁有了一些 Ether,使用直接存入功能是讓你的新錢包最快取得 Ether 的方式。"
},
"done": {
"message": "完成"
@@ -285,6 +288,9 @@
"message": "檔案導入失敗?點擊這裡!",
"description": "Helps user import their account from a JSON file"
},
+ "followTwitter": {
+ "message": "追蹤 Twitter"
+ },
"from": {
"message": "來源地址"
},
@@ -313,6 +319,9 @@
"gasLimitTooLow": {
"message": "Gas 上限至少為 21000"
},
+ "generatingSeed": {
+ "message": "產生助憶詞中..."
+ },
"gasPrice": {
"message": "Gas 價格 (GWEI)"
},
@@ -362,6 +371,9 @@
"importAccount": {
"message": "導入帳戶"
},
+ "importAccountMsg": {
+ "message":" 匯入的帳戶與您原有 MetaMask 帳戶的助憶詞並無關聯. 請查看與導入帳戶相關的資料 "
+ },
"importAnAccount": {
"message": "導入一個帳戶"
},
@@ -400,12 +412,15 @@
"message": "無效的 RPC URI"
},
"jsonFail": {
- "message": "有東西出錯了. 請確認你的 JSON 檔案格式正確."
+ "message": "有東西出錯了. 請確認你的 JSON 檔案格式正確。"
},
"jsonFile": {
"message": "JSON 檔案",
"description": "format for importing an account"
},
+ "keepTrackTokens": {
+ "message": "持續追蹤您 MetaMask 帳戶中的代幣。"
+ },
"kovan": {
"message": "Kovan 測試網路"
},
@@ -415,6 +430,9 @@
"max": {
"message": "最大值"
},
+ "learnMore": {
+ "message": "了解更多。"
+ },
"lessThanMax": {
"message": "必須小於等於 $1.",
"description": "helper for inputting hex as decimal input"
@@ -437,17 +455,20 @@
"localhost": {
"message": "Localhost 8545"
},
+ "login": {
+ "message": "登入"
+ },
"logout": {
"message": "登出"
},
"loose": {
- "message": "非Metamask帳號"
+ "message": "非 MetaMask 帳號"
},
"loweCaseWords": {
"message": "助憶詞僅包含小寫字元"
},
"mainnet": {
- "message": "主乙太坊網路"
+ "message": "乙太坊 主網路"
},
"message": {
"message": "訊息"
@@ -465,7 +486,7 @@
"message": "必須選擇至少 1 代幣."
},
"needEtherInWallet": {
- "message": "要使用 MetaMask 存取 DAPP時,您的錢包中需要有 Ether。"
+ "message": "要使用 MetaMask 存取 DAPP 時,您的錢包中需要有 Ether。"
},
"needImportFile": {
"message": "您必須選擇一個檔案來導入。",
@@ -475,6 +496,9 @@
"message": "您必須為選擇好的檔案輸入密碼。",
"description": "Password and file needed to import an account"
},
+ "negativeETH": {
+ "message": "不能送出負值的 ETH。"
+ },
"networks": {
"message": "網路"
},
@@ -525,6 +549,9 @@
"message": "或",
"description": "choice between creating or importing a new account"
},
+ "passwordCorrect": {
+ "message": "請確認您的密碼是正確的。"
+ },
"passwordMismatch": {
"message": "密碼不一致",
"description": "in password creation process, the two new password fields did not match"
@@ -546,6 +573,12 @@
"pleaseReviewTransaction": {
"message": "請檢查你的交易。"
},
+ "popularTokens": {
+ "message": "常見的代幣"
+ },
+ "privacyMsg": {
+ "message": "隱私政策"
+ },
"privateKey": {
"message": "私鑰",
"description": "select this type of file to use to import an account"
@@ -681,6 +714,9 @@
"onlySendToEtherAddress": {
"message": "只發送 ETH 到乙太坊地址."
},
+ "searchTokens": {
+ "message": "搜尋代幣"
+ },
"sendTokensAnywhere": {
"message": "發送代幣給擁有乙太坊帳戶的任何人"
},
@@ -700,13 +736,16 @@
"message": "顯示 QR Code"
},
"sign": {
- "message": "簽名"
+ "message": "簽署"
+ },
+ "signed": {
+ "message": "已簽署"
},
"signMessage": {
"message": "簽署訊息"
},
"signNotice": {
- "message": "簽署此訊息可能會產生危險的副作用。 \n只從你完全信任的網站上簽名。這種危險的方法;將在未來的版本中被移除。"
+ "message": "簽署此訊息可能會產生危險地副作用。 \n只從你完全信任的網站上簽署。這種危險的方法;將在未來的版本中被移除。"
},
"sigRequest": {
"message": "請求簽署"
@@ -767,7 +806,7 @@
"message": "代幣餘額:"
},
"tokenSelection": {
- "message": "搜尋代幣或是從熱門代幣列表中選擇。"
+ "message": "搜尋代幣或是從常見代幣列表中選擇。"
},
"tokenSymbol": {
"message": "代幣代號"
@@ -804,7 +843,7 @@
"message": "歡迎使用新版界面 (Beta)"
},
"uiWelcomeMessage": {
- "message": "你現在正在使用新的 Metamask 界面。試試諸如發送代幣等新功能,有任何問題請告知我們。"
+ "message": "你現在正在使用新版 MetaMask 界面。試試諸如發送代幣等新功能吧,有任何問題請告知我們。"
},
"unapproved": {
"message": "未同意"
diff --git a/app/manifest.json b/app/manifest.json
index 0aac1c8df..a20f9b976 100644
--- a/app/manifest.json
+++ b/app/manifest.json
@@ -1,7 +1,7 @@
{
"name": "__MSG_appName__",
"short_name": "__MSG_appName__",
- "version": "4.3.0",
+ "version": "4.4.0",
"manifest_version": 2,
"author": "https://metamask.io",
"description": "__MSG_appDescription__",
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 8bd7766ad..7782fc41e 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -19,7 +19,7 @@ const setupRaven = require('./lib/setupRaven')
const reportFailedTxToSentry = require('./lib/reportFailedTxToSentry')
const setupMetamaskMeshMetrics = require('./lib/setupMetamaskMeshMetrics')
const EdgeEncryptor = require('./edge-encryptor')
-
+const getFirstPreferredLangCode = require('./lib/get-first-preferred-lang-code')
const STORAGE_KEY = 'metamask-config'
const METAMASK_DEBUG = 'GULP_METAMASK_DEBUG'
@@ -58,7 +58,8 @@ setupMetamaskMeshMetrics()
async function initialize () {
const initState = await loadStateFromPersistence()
- await setupController(initState)
+ const initLangCode = await getFirstPreferredLangCode()
+ await setupController(initState, initLangCode)
log.debug('MetaMask initialization complete.')
}
@@ -84,17 +85,16 @@ async function loadStateFromPersistence () {
// write to disk
if (localStore.isSupported) localStore.set(versionedData)
- diskStore.putState(versionedData)
// return just the data
return versionedData.data
}
-function setupController (initState) {
+function setupController (initState, initLangCode) {
//
// MetaMask Controller
//
-
+
const controller = new MetamaskController({
// User confirmation callbacks:
showUnconfirmedMessage: triggerUi,
@@ -102,6 +102,8 @@ function setupController (initState) {
showUnapprovedTx: triggerUi,
// initial state
initState,
+ // initial locale code
+ initLangCode,
// platform specific api
platform,
encryptor: isEdge ? new EdgeEncryptor() : undefined,
@@ -121,7 +123,6 @@ function setupController (initState) {
debounce(1000),
storeTransform(versionifyData),
storeTransform(syncDataWithExtension),
- asStream(diskStore),
(error) => {
log.error('pump hit error', error)
}
diff --git a/app/scripts/controllers/currency.js b/app/scripts/controllers/currency.js
index 25a7a942e..930fc52e8 100644
--- a/app/scripts/controllers/currency.js
+++ b/app/scripts/controllers/currency.js
@@ -52,7 +52,7 @@ class CurrencyController {
this.setConversionDate(Number(parsedResponse.timestamp))
}).catch((err) => {
if (err) {
- console.warn('MetaMask - Failed to query currency conversion.')
+ console.warn(`MetaMask - Failed to query currency conversion:`, currentCurrency, err)
this.setConversionRate(0)
this.setConversionDate('N/A')
}
diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js
index 39d15fd83..b4819d951 100644
--- a/app/scripts/controllers/preferences.js
+++ b/app/scripts/controllers/preferences.js
@@ -11,6 +11,7 @@ class PreferencesController {
tokens: [],
useBlockie: false,
featureFlags: {},
+ currentLocale: opts.initLangCode,
}, opts.initState)
this.store = new ObservableStore(initState)
}
@@ -24,6 +25,10 @@ class PreferencesController {
return this.store.getState().useBlockie
}
+ setCurrentLocale (key) {
+ this.store.updateState({ currentLocale: key })
+ }
+
setSelectedAddress (_address) {
return new Promise((resolve, reject) => {
const address = normalizeAddress(_address)
diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js
index 3e3909361..7e2cc15da 100644
--- a/app/scripts/controllers/transactions.js
+++ b/app/scripts/controllers/transactions.js
@@ -250,7 +250,7 @@ module.exports = class TransactionController extends EventEmitter {
// wait for a nonce
nonceLock = await this.nonceTracker.getNonceLock(fromAddress)
// add nonce to txParams
- // if txMeta has lastGasPrice then it is a retry at same nonce with higher
+ // if txMeta has lastGasPrice then it is a retry at same nonce with higher
// gas price transaction and their for the nonce should not be calculated
const nonce = txMeta.lastGasPrice ? txMeta.txParams.nonce : nonceLock.nextNonce
txMeta.txParams.nonce = ethUtil.addHexPrefix(nonce.toString(16))
@@ -273,12 +273,14 @@ module.exports = class TransactionController extends EventEmitter {
async signTransaction (txId) {
const txMeta = this.txStateManager.getTx(txId)
- const txParams = txMeta.txParams
- const fromAddress = txParams.from
// add network/chain id
- txParams.chainId = ethUtil.addHexPrefix(this.getChainId().toString(16))
+ const chainId = this.getChainId()
+ const txParams = Object.assign({}, txMeta.txParams, { chainId })
+ // sign tx
+ const fromAddress = txParams.from
const ethTx = new Transaction(txParams)
await this.signEthTx(ethTx, fromAddress)
+ // set state to signed
this.txStateManager.setTxStatusSigned(txMeta.id)
const rawTx = ethUtil.bufferToHex(ethTx.serialize())
return rawTx
diff --git a/app/scripts/lib/extractEthjsErrorMessage.js b/app/scripts/lib/extractEthjsErrorMessage.js
new file mode 100644
index 000000000..bac541735
--- /dev/null
+++ b/app/scripts/lib/extractEthjsErrorMessage.js
@@ -0,0 +1,27 @@
+const ethJsRpcSlug = 'Error: [ethjs-rpc] rpc error with payload '
+const errorLabelPrefix = 'Error: '
+
+module.exports = extractEthjsErrorMessage
+
+
+//
+// ethjs-rpc provides overly verbose error messages
+// if we detect this type of message, we extract the important part
+// Below is an example input and output
+//
+// Error: [ethjs-rpc] rpc error with payload {"id":3947817945380,"jsonrpc":"2.0","params":["0xf8eb8208708477359400830398539406012c8cf97bead5deae237070f9587f8e7a266d80b8843d7d3f5a0000000000000000000000000000000000000000000000000000000000081d1a000000000000000000000000000000000000000000000000001ff973cafa800000000000000000000000000000000000000000000000000000038d7ea4c68000000000000000000000000000000000000000000000000000000000000003f48025a04c32a9b630e0d9e7ff361562d850c86b7a884908135956a7e4a336fa0300d19ca06830776423f25218e8d19b267161db526e66895567147015b1f3fc47aef9a3c7"],"method":"eth_sendRawTransaction"} Error: replacement transaction underpriced
+//
+// Transaction Failed: replacement transaction underpriced
+//
+
+
+function extractEthjsErrorMessage(errorMessage) {
+ const isEthjsRpcError = errorMessage.includes(ethJsRpcSlug)
+ if (isEthjsRpcError) {
+ const payloadAndError = errorMessage.slice(ethJsRpcSlug.length)
+ const originalError = payloadAndError.slice(payloadAndError.indexOf(errorLabelPrefix) + errorLabelPrefix.length)
+ return originalError
+ } else {
+ return errorMessage
+ }
+}
diff --git a/app/scripts/lib/get-first-preferred-lang-code.js b/app/scripts/lib/get-first-preferred-lang-code.js
new file mode 100644
index 000000000..28612f763
--- /dev/null
+++ b/app/scripts/lib/get-first-preferred-lang-code.js
@@ -0,0 +1,16 @@
+const extension = require('extensionizer')
+const promisify = require('pify')
+const allLocales = require('../../_locales/index.json')
+
+const existingLocaleCodes = allLocales.map(locale => locale.code)
+
+async function getFirstPreferredLangCode () {
+ const userPreferredLocaleCodes = await promisify(
+ extension.i18n.getAcceptLanguages,
+ { errorFirst: false }
+ )()
+ const firstPreferredLangCode = userPreferredLocaleCodes.find(code => existingLocaleCodes.includes(code))
+ return firstPreferredLangCode || 'en'
+}
+
+module.exports = getFirstPreferredLangCode
diff --git a/app/scripts/lib/reportFailedTxToSentry.js b/app/scripts/lib/reportFailedTxToSentry.js
index ee73f6845..e09f4f1f8 100644
--- a/app/scripts/lib/reportFailedTxToSentry.js
+++ b/app/scripts/lib/reportFailedTxToSentry.js
@@ -1,5 +1,4 @@
-const ethJsRpcSlug = 'Error: [ethjs-rpc] rpc error with payload '
-const errorLabelPrefix = 'Error: '
+const extractEthjsErrorMessage = require('./extractEthjsErrorMessage')
module.exports = reportFailedTxToSentry
@@ -9,30 +8,9 @@ module.exports = reportFailedTxToSentry
//
function reportFailedTxToSentry({ raven, txMeta }) {
- const errorMessage = extractErrorMessage(txMeta.err.message)
+ const errorMessage = 'Transaction Failed: ' + extractEthjsErrorMessage(txMeta.err.message)
raven.captureMessage(errorMessage, {
// "extra" key is required by Sentry
extra: txMeta,
})
}
-
-//
-// ethjs-rpc provides overly verbose error messages
-// if we detect this type of message, we extract the important part
-// Below is an example input and output
-//
-// Error: [ethjs-rpc] rpc error with payload {"id":3947817945380,"jsonrpc":"2.0","params":["0xf8eb8208708477359400830398539406012c8cf97bead5deae237070f9587f8e7a266d80b8843d7d3f5a0000000000000000000000000000000000000000000000000000000000081d1a000000000000000000000000000000000000000000000000001ff973cafa800000000000000000000000000000000000000000000000000000038d7ea4c68000000000000000000000000000000000000000000000000000000000000003f48025a04c32a9b630e0d9e7ff361562d850c86b7a884908135956a7e4a336fa0300d19ca06830776423f25218e8d19b267161db526e66895567147015b1f3fc47aef9a3c7"],"method":"eth_sendRawTransaction"} Error: replacement transaction underpriced
-//
-// Transaction Failed: replacement transaction underpriced
-//
-
-function extractErrorMessage(errorMessage) {
- const isEthjsRpcError = errorMessage.includes(ethJsRpcSlug)
- if (isEthjsRpcError) {
- const payloadAndError = errorMessage.slice(ethJsRpcSlug.length)
- const originalError = payloadAndError.slice(payloadAndError.indexOf(errorLabelPrefix) + errorLabelPrefix.length)
- return `Transaction Failed: ${originalError}`
- } else {
- return `Transaction Failed: ${errorMessage}`
- }
-}
diff --git a/app/scripts/lib/setupRaven.js b/app/scripts/lib/setupRaven.js
index 02c01b755..b93591e65 100644
--- a/app/scripts/lib/setupRaven.js
+++ b/app/scripts/lib/setupRaven.js
@@ -1,5 +1,6 @@
const Raven = require('raven-js')
const METAMASK_DEBUG = 'GULP_METAMASK_DEBUG'
+const extractEthjsErrorMessage = require('./extractEthjsErrorMessage')
const PROD = 'https://3567c198f8a8412082d32655da2961d0@sentry.io/273505'
const DEV = 'https://f59f3dd640d2429d9d0e2445a87ea8e1@sentry.io/273496'
@@ -21,8 +22,22 @@ function setupRaven(opts) {
const client = Raven.config(ravenTarget, {
release,
transport: function(opts) {
- // modify report urls
const report = opts.data
+ // simplify certain complex error messages
+ report.exception.values.forEach(item => {
+ let errorMessage = item.value
+ // simplify ethjs error messages
+ errorMessage = extractEthjsErrorMessage(errorMessage)
+ // simplify 'Transaction Failed: known transaction'
+ if (errorMessage.indexOf('Transaction Failed: known transaction') === 0) {
+ // cut the hash from the error message
+ errorMessage = 'Transaction Failed: known transaction'
+ }
+ // finalize
+ item.value = errorMessage
+ })
+
+ // modify report urls
rewriteReportUrls(report)
// make request normally
client._makeRequest(opts)
diff --git a/app/scripts/lib/tx-state-manager.js b/app/scripts/lib/tx-state-manager.js
index ad07c813f..23c915a61 100644
--- a/app/scripts/lib/tx-state-manager.js
+++ b/app/scripts/lib/tx-state-manager.js
@@ -38,11 +38,6 @@ module.exports = class TransactionStateManager extends EventEmitter {
}, opts)
}
- // Returns the number of txs for the current network.
- getTxCount () {
- return this.getTxList().length
- }
-
getTxList () {
const network = this.getNetwork()
const fullTxList = this.getFullTxList()
@@ -88,7 +83,7 @@ module.exports = class TransactionStateManager extends EventEmitter {
txMeta.history.push(snapshot)
const transactions = this.getFullTxList()
- const txCount = this.getTxCount()
+ const txCount = transactions.length
const txHistoryLimit = this.txHistoryLimit
// checks if the length of the tx history is
@@ -111,12 +106,9 @@ module.exports = class TransactionStateManager extends EventEmitter {
}
updateTx (txMeta, note) {
+ // validate txParams
if (txMeta.txParams) {
- Object.keys(txMeta.txParams).forEach((key) => {
- const value = txMeta.txParams[key]
- if (typeof value !== 'string') console.error(`${key}: ${value} in txParams is not a string`)
- if (!ethUtil.isHexPrefixed(value)) console.error('is not hex prefixed, anything on txParams must be hex prefixed')
- })
+ this.validateTxParams(txMeta.txParams)
}
// create txMeta snapshot for history
@@ -144,6 +136,15 @@ module.exports = class TransactionStateManager extends EventEmitter {
this.updateTx(txMeta, `txStateManager#updateTxParams`)
}
+ // validates txParams members by type
+ validateTxParams(txParams) {
+ Object.keys(txParams).forEach((key) => {
+ const value = txParams[key]
+ if (typeof value !== 'string') throw new Error(`${key}: ${value} in txParams is not a string`)
+ if (!ethUtil.isHexPrefixed(value)) throw new Error('is not hex prefixed, everything on txParams must be hex prefixed')
+ })
+ }
+
/*
Takes an object of fields to search for eg:
let thingsToLookFor = {
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 18d71874a..4422a5cf3 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -49,7 +49,7 @@ module.exports = class MetamaskController extends EventEmitter {
/**
* @constructor
- * @param {Object} opts
+ * @param {Object} opts
*/
constructor (opts) {
super()
@@ -57,7 +57,7 @@ module.exports = class MetamaskController extends EventEmitter {
this.defaultMaxListeners = 20
this.sendUpdate = debounce(this.privateSendUpdate.bind(this), 200)
-
+
this.opts = opts
const initState = opts.initState || {}
this.recordFirstTimeInfo(initState)
@@ -82,6 +82,7 @@ module.exports = class MetamaskController extends EventEmitter {
// preferences controller
this.preferencesController = new PreferencesController({
initState: initState.PreferencesController,
+ initLangCode: opts.initLangCode,
})
// currency controller
@@ -296,8 +297,8 @@ module.exports = class MetamaskController extends EventEmitter {
/**
* The metamask-state of the various controllers, made available to the UI
- *
- * @returns {Object} status
+ *
+ * @returns {Object} status
*/
getState () {
const wallet = this.configManager.getWallet()
@@ -335,8 +336,8 @@ module.exports = class MetamaskController extends EventEmitter {
/**
* Returns an api-object which is consumed by the UI
- *
- * @returns {Object}
+ *
+ * @returns {Object}
*/
getApi () {
const keyringController = this.keyringController
@@ -351,6 +352,7 @@ module.exports = class MetamaskController extends EventEmitter {
getState: (cb) => cb(null, this.getState()),
setCurrentCurrency: this.setCurrentCurrency.bind(this),
setUseBlockie: this.setUseBlockie.bind(this),
+ setCurrentLocale: this.setCurrentLocale.bind(this),
markAccountsFound: this.markAccountsFound.bind(this),
markPasswordForgotten: this.markPasswordForgotten.bind(this),
unMarkPasswordForgotten: this.unMarkPasswordForgotten.bind(this),
@@ -365,7 +367,7 @@ module.exports = class MetamaskController extends EventEmitter {
placeSeedWords: this.placeSeedWords.bind(this),
verifySeedPhrase: nodeify(this.verifySeedPhrase, this),
clearSeedWordCache: this.clearSeedWordCache.bind(this),
- resetAccount: this.resetAccount.bind(this),
+ resetAccount: nodeify(this.resetAccount, this),
importAccountWithStrategy: this.importAccountWithStrategy.bind(this),
// vault management
@@ -426,14 +428,14 @@ module.exports = class MetamaskController extends EventEmitter {
/**
* Creates a new Vault(?) and create a new keychain(?)
- *
+ *
* A vault is ...
- *
+ *
* A keychain is ...
- *
+ *
*
* @param {} password
- *
+ *
* @returns {} vault
*/
async createNewVaultAndKeychain (password) {
@@ -479,9 +481,9 @@ module.exports = class MetamaskController extends EventEmitter {
/**
* Retrieves the first Identiy from the passed Vault and selects the related address
- *
+ *
* An Identity is ...
- *
+ *
* @param {} vault
*/
selectFirstIdentity (vault) {
@@ -495,8 +497,8 @@ module.exports = class MetamaskController extends EventEmitter {
//
/**
- * Adds a new account to ...
- *
+ * Adds a new account to ...
+ *
* @returns {} keyState
*/
async addNewAccount () {
@@ -522,10 +524,10 @@ module.exports = class MetamaskController extends EventEmitter {
/**
* Adds the current vault's seed words to the UI's state tree.
- *
+ *
* Used when creating a first vault, to allow confirmation.
* Also used when revealing the seed words in the confirmation view.
- */
+ */
placeSeedWords (cb) {
this.verifySeedPhrase()
@@ -540,7 +542,7 @@ module.exports = class MetamaskController extends EventEmitter {
/**
* Verifies the validity of the current vault's seed phrase.
- *
+ *
* Validity: seed phrase restores the accounts belonging to the current vault.
*
* Called when the first account is created and on unlocking the vault.
@@ -571,27 +573,32 @@ module.exports = class MetamaskController extends EventEmitter {
/**
* Remove the primary account seed phrase from the UI's state tree.
- *
+ *
* The seed phrase remains available in the background process.
- *
+ *
*/
clearSeedWordCache (cb) {
this.configManager.setSeedWords(null)
cb(null, this.preferencesController.getSelectedAddress())
}
-
+
/**
* ?
*/
- resetAccount (cb) {
+ async resetAccount (cb) {
const selectedAddress = this.preferencesController.getSelectedAddress()
this.txController.wipeTransactions(selectedAddress)
- cb(null, selectedAddress)
+
+ const networkController = this.networkController
+ const oldType = networkController.getProviderConfig().type
+ await networkController.setProviderType(oldType, true)
+
+ return selectedAddress
}
/**
* Imports an account ... ?
- *
+ *
* @param {} strategy
* @param {} args
* @param {} cb
@@ -634,9 +641,9 @@ module.exports = class MetamaskController extends EventEmitter {
}
// Prefixed Style Message Signing Methods:
-
+
/**
- *
+ *
* @param {} msgParams
* @param {} cb
*/
@@ -655,7 +662,7 @@ module.exports = class MetamaskController extends EventEmitter {
}
})
}
-
+
/**
* @param {} msgParams
*/
@@ -676,7 +683,7 @@ module.exports = class MetamaskController extends EventEmitter {
return this.getState()
})
}
-
+
/**
* @param {} msgParams
*/
@@ -697,13 +704,13 @@ module.exports = class MetamaskController extends EventEmitter {
return this.getState()
})
}
-
+
// ---------------------------------------------------------------------------
// Account Restauration
/**
* ?
- *
+ *
* @param {} migratorOutput
*/
restoreOldVaultAccounts (migratorOutput) {
@@ -714,7 +721,7 @@ module.exports = class MetamaskController extends EventEmitter {
/**
* ?
- *
+ *
* @param {} migratorOutput
*/
restoreOldLostAccounts (migratorOutput) {
@@ -728,9 +735,9 @@ module.exports = class MetamaskController extends EventEmitter {
/**
* Import (lost) Accounts
- *
+ *
* @param {Object} {lostAccounts} @Array accounts <{ address, privateKey }>
- *
+ *
* Uses the array's private keys to create a new Simple Key Pair keychain
* and add it to the keyring controller.
*/
@@ -823,7 +830,7 @@ module.exports = class MetamaskController extends EventEmitter {
if (cb && typeof cb === 'function') {
cb(null, this.getState())
}
- }
+ }
cancelPersonalMessage (msgId, cb) {
const messageManager = this.personalMessageManager
@@ -978,7 +985,7 @@ module.exports = class MetamaskController extends EventEmitter {
const percentileNum = percentile(50, lowestPrices)
const percentileNumBn = new BN(percentileNum)
return '0x' + percentileNumBn.mul(GWEI_BN).toString(16)
- }
+ }
//=============================================================================
// CONFIG
@@ -1029,6 +1036,15 @@ module.exports = class MetamaskController extends EventEmitter {
}
}
+ setCurrentLocale (key, cb) {
+ try {
+ this.preferencesController.setCurrentLocale(key)
+ cb(null)
+ } catch (err) {
+ cb(err)
+ }
+ }
+
recordFirstTimeInfo (initState) {
if (!('firstTimeInfo' in initState)) {
initState.firstTimeInfo = {
diff --git a/app/scripts/migrations/023.js b/app/scripts/migrations/023.js
new file mode 100644
index 000000000..bce0a5bea
--- /dev/null
+++ b/app/scripts/migrations/023.js
@@ -0,0 +1,50 @@
+
+const version = 23
+
+/*
+
+This migration removes transactions that are no longer usefull down to 40 total
+
+*/
+
+const clone = require('clone')
+
+module.exports = {
+ version,
+
+ migrate: function (originalVersionedData) {
+ const versionedData = clone(originalVersionedData)
+ versionedData.meta.version = version
+ try {
+ const state = versionedData.data
+ const newState = transformState(state)
+ versionedData.data = newState
+ } catch (err) {
+ console.warn(`MetaMask Migration #${version}` + err.stack)
+ }
+ return Promise.resolve(versionedData)
+ },
+}
+
+function transformState (state) {
+ const newState = state
+ const transactions = newState.TransactionController.transactions
+
+ if (transactions.length <= 40) return newState
+
+ let reverseTxList = transactions.reverse()
+ let stripping = true
+ while (reverseTxList.length > 40 && stripping) {
+ let txIndex = reverseTxList.findIndex((txMeta) => {
+ return (txMeta.status === 'failed' ||
+ txMeta.status === 'rejected' ||
+ txMeta.status === 'confirmed' ||
+ txMeta.status === 'dropped')
+ })
+ if (txIndex < 0) stripping = false
+ else reverseTxList.splice(txIndex, 1)
+ }
+
+ newState.TransactionController.transactions = reverseTxList.reverse()
+ return newState
+}
diff --git a/app/scripts/migrations/index.js b/app/scripts/migrations/index.js
index a0cf5f4d4..811e06b6b 100644
--- a/app/scripts/migrations/index.js
+++ b/app/scripts/migrations/index.js
@@ -32,4 +32,6 @@ module.exports = [
require('./019'),
require('./020'),
require('./021'),
+ require('./022'),
+ require('./023'),
]
diff --git a/app/scripts/popup.js b/app/scripts/popup.js
index e78981f06..13c7ac5ec 100644
--- a/app/scripts/popup.js
+++ b/app/scripts/popup.js
@@ -10,69 +10,75 @@ const NotificationManager = require('./lib/notification-manager')
const notificationManager = new NotificationManager()
const setupRaven = require('./lib/setupRaven')
-// create platform global
-global.platform = new ExtensionPlatform()
-
-// setup sentry error reporting
-const release = global.platform.getVersion()
-setupRaven({ release })
-
-// inject css
-// const css = MetaMaskUiCss()
-// injectCss(css)
-
-// identify window type (popup, notification)
-const windowType = isPopupOrNotification()
-global.METAMASK_UI_TYPE = windowType
-closePopupIfOpen(windowType)
-
-// setup stream to background
-const extensionPort = extension.runtime.connect({ name: windowType })
-const connectionStream = new PortStream(extensionPort)
-
-// start ui
-const container = document.getElementById('app-content')
-startPopup({ container, connectionStream }, (err, store) => {
- if (err) return displayCriticalError(err)
-
- // Code commented out until we begin auto adding users to NewUI
- // const { isMascara, identities = {}, featureFlags = {} } = store.getState().metamask
- // const firstTime = Object.keys(identities).length === 0
- const { isMascara, featureFlags = {} } = store.getState().metamask
- let betaUIState = featureFlags.betaUI
-
- // Code commented out until we begin auto adding users to NewUI
- // const useBetaCss = isMascara || firstTime || betaUIState
- const useBetaCss = isMascara || betaUIState
-
- let css = useBetaCss ? NewMetaMaskUiCss() : OldMetaMaskUiCss()
- let deleteInjectedCss = injectCss(css)
- let newBetaUIState
-
- store.subscribe(() => {
- const state = store.getState()
- newBetaUIState = state.metamask.featureFlags.betaUI
- if (newBetaUIState !== betaUIState) {
- deleteInjectedCss()
- betaUIState = newBetaUIState
- css = betaUIState ? NewMetaMaskUiCss() : OldMetaMaskUiCss()
- deleteInjectedCss = injectCss(css)
- }
- if (state.appState.shouldClose) notificationManager.closePopup()
+start().catch(log.error)
+
+async function start() {
+
+ // create platform global
+ global.platform = new ExtensionPlatform()
+
+ // setup sentry error reporting
+ const release = global.platform.getVersion()
+ setupRaven({ release })
+
+ // inject css
+ // const css = MetaMaskUiCss()
+ // injectCss(css)
+
+ // identify window type (popup, notification)
+ const windowType = isPopupOrNotification()
+ global.METAMASK_UI_TYPE = windowType
+ closePopupIfOpen(windowType)
+
+ // setup stream to background
+ const extensionPort = extension.runtime.connect({ name: windowType })
+ const connectionStream = new PortStream(extensionPort)
+
+ // start ui
+ const container = document.getElementById('app-content')
+ startPopup({ container, connectionStream }, (err, store) => {
+ if (err) return displayCriticalError(err)
+
+ // Code commented out until we begin auto adding users to NewUI
+ // const { isMascara, identities = {}, featureFlags = {} } = store.getState().metamask
+ // const firstTime = Object.keys(identities).length === 0
+ const { isMascara, featureFlags = {} } = store.getState().metamask
+ let betaUIState = featureFlags.betaUI
+
+ // Code commented out until we begin auto adding users to NewUI
+ // const useBetaCss = isMascara || firstTime || betaUIState
+ const useBetaCss = isMascara || betaUIState
+
+ let css = useBetaCss ? NewMetaMaskUiCss() : OldMetaMaskUiCss()
+ let deleteInjectedCss = injectCss(css)
+ let newBetaUIState
+
+ store.subscribe(() => {
+ const state = store.getState()
+ newBetaUIState = state.metamask.featureFlags.betaUI
+ if (newBetaUIState !== betaUIState) {
+ deleteInjectedCss()
+ betaUIState = newBetaUIState
+ css = betaUIState ? NewMetaMaskUiCss() : OldMetaMaskUiCss()
+ deleteInjectedCss = injectCss(css)
+ }
+ if (state.appState.shouldClose) notificationManager.closePopup()
+ })
})
-})
-function closePopupIfOpen (windowType) {
- if (windowType !== 'notification') {
- // should close only chrome popup
- notificationManager.closePopup()
+ function closePopupIfOpen (windowType) {
+ if (windowType !== 'notification') {
+ // should close only chrome popup
+ notificationManager.closePopup()
+ }
+ }
+
+ function displayCriticalError (err) {
+ container.innerHTML = '<div class="critical-error">The MetaMask app failed to load: please open and close MetaMask again to restart.</div>'
+ container.style.height = '80px'
+ log.error(err.stack)
+ throw err
}
-}
-function displayCriticalError (err) {
- container.innerHTML = '<div class="critical-error">The MetaMask app failed to load: please open and close MetaMask again to restart.</div>'
- container.style.height = '80px'
- log.error(err.stack)
- throw err
}