feature/default_network_editable
Thomas 7 years ago
commit d9be7f989a
  1. 34
      .circleci/config.yml
  2. 1
      .eslintrc
  3. 1
      .gitignore
  4. 27
      .jshintrc
  5. 29
      CHANGELOG.md
  6. 6
      CONTRIBUTING.md
  7. 2
      README.md
  8. 912
      app/_locales/cs/messages.json
  9. 32
      app/_locales/en/messages.json
  10. 20
      app/_locales/hn/messages.json
  11. 3
      app/_locales/index.json
  12. 99
      app/_locales/ja/messages.json
  13. 8
      app/_locales/sl/messages.json
  14. 912
      app/_locales/tml/messages.json
  15. 912
      app/_locales/tr/messages.json
  16. 24
      app/images/copy-to-clipboard.svg
  17. 41
      app/images/download.svg
  18. 22
      app/images/warning.svg
  19. 2
      app/manifest.json
  20. 255
      app/scripts/background.js
  21. 44
      app/scripts/config.js
  22. 43
      app/scripts/contentscript.js
  23. 66
      app/scripts/controllers/address-book.js
  24. 56
      app/scripts/controllers/balance.js
  25. 54
      app/scripts/controllers/blacklist.js
  26. 45
      app/scripts/controllers/computed-balances.js
  27. 68
      app/scripts/controllers/currency.js
  28. 1
      app/scripts/controllers/infura.js
  29. 56
      app/scripts/controllers/network/enums.js
  30. 2
      app/scripts/controllers/network/index.js
  31. 30
      app/scripts/controllers/network/network.js
  32. 65
      app/scripts/controllers/network/util.js
  33. 124
      app/scripts/controllers/preferences.js
  34. 69
      app/scripts/controllers/recent-blocks.js
  35. 75
      app/scripts/controllers/shapeshift.js
  36. 81
      app/scripts/controllers/token-rates.js
  37. 92
      app/scripts/controllers/transactions/README.md
  38. 318
      app/scripts/controllers/transactions/index.js
  39. 27
      app/scripts/controllers/transactions/lib/tx-state-history-helper.js
  40. 99
      app/scripts/controllers/transactions/lib/util.js
  41. 44
      app/scripts/controllers/transactions/nonce-tracker.js
  42. 77
      app/scripts/controllers/transactions/pending-tx-tracker.js
  43. 69
      app/scripts/controllers/transactions/tx-gas-utils.js
  44. 217
      app/scripts/controllers/transactions/tx-state-manager.js
  45. 142
      app/scripts/edge-encryptor.js
  46. 19
      app/scripts/first-time-state.js
  47. 20
      app/scripts/inpage.js
  48. 49
      app/scripts/lib/ComposableObservableStore.js
  49. 81
      app/scripts/lib/account-tracker.js
  50. 11
      app/scripts/lib/buy-eth-url.js
  51. 23
      app/scripts/lib/config-manager.js
  52. 16
      app/scripts/lib/createLoggerMiddleware.js
  53. 12
      app/scripts/lib/createOriginMiddleware.js
  54. 6
      app/scripts/lib/createProviderMiddleware.js
  55. 9
      app/scripts/lib/enums.js
  56. 10
      app/scripts/lib/environment-type.js
  57. 25
      app/scripts/lib/events-proxy.js
  58. 23
      app/scripts/lib/extractEthjsErrorMessage.js
  59. 13
      app/scripts/lib/get-first-preferred-lang-code.js
  60. 50
      app/scripts/lib/getObjStructure.js
  61. 7
      app/scripts/lib/hex-to-bn.js
  62. 11
      app/scripts/lib/is-popup-or-notification.js
  63. 38
      app/scripts/lib/local-store.js
  64. 137
      app/scripts/lib/message-manager.js
  65. 62
      app/scripts/lib/migrator/index.js
  66. 8
      app/scripts/lib/nodeify.js
  67. 44
      app/scripts/lib/notification-manager.js
  68. 38
      app/scripts/lib/pending-balance-calculator.js
  69. 143
      app/scripts/lib/personal-message-manager.js
  70. 37
      app/scripts/lib/port-stream.js
  71. 19
      app/scripts/lib/seed-phrase-verifier.js
  72. 3
      app/scripts/lib/setupMetamaskMeshMetrics.js
  73. 61
      app/scripts/lib/setupRaven.js
  74. 18
      app/scripts/lib/stream-utils.js
  75. 137
      app/scripts/lib/typed-message-manager.js
  76. 81
      app/scripts/lib/util.js
  77. 585
      app/scripts/metamask-controller.js
  78. 7
      app/scripts/migrations/013.js
  79. 15
      app/scripts/migrations/015.js
  80. 22
      app/scripts/migrations/016.js
  81. 21
      app/scripts/migrations/017.js
  82. 41
      app/scripts/migrations/018.js
  83. 44
      app/scripts/migrations/019.js
  84. 17
      app/scripts/migrations/022.js
  85. 38
      app/scripts/migrations/023.js
  86. 41
      app/scripts/migrations/024.js
  87. 61
      app/scripts/migrations/025.js
  88. 2
      app/scripts/migrations/index.js
  89. 29
      app/scripts/migrations/template.js
  90. 27
      app/scripts/platforms/sw.js
  91. 23
      app/scripts/platforms/window.js
  92. 25
      app/scripts/popup-core.js
  93. 8
      app/scripts/ui.js
  94. 21
      development/mock-dev.js
  95. 49
      development/sourcemap-validator.js
  96. 134
      development/states/currency-localization.json
  97. 0
      development/states/tx-list-items.json
  98. 25
      development/tools/.jsdoc.json
  99. 15
      development/tools/README.md
  100. 21
      development/tools/appveyor.txt
  101. Some files were not shown because too many files have changed in this diff Show More

@ -15,19 +15,13 @@ workflows:
- test-lint:
requires:
- prep-deps-npm
- test-e2e:
- test-deps:
requires:
- prep-deps-npm
- prep-build
- job-screens:
requires:
- prep-deps-npm
- prep-build
- job-publish:
- test-e2e:
requires:
- prep-deps-npm
- prep-build
- job-screens
- test-unit:
requires:
- prep-deps-npm
@ -52,13 +46,24 @@ workflows:
- all-tests-pass:
requires:
- test-lint
- test-deps
- test-unit
- test-e2e
- job-screens
- test-integration-mascara-chrome
- test-integration-mascara-firefox
- test-integration-flat-chrome
- test-integration-flat-firefox
- job-screens:
requires:
- prep-deps-npm
- prep-build
- all-tests-pass
- job-publish:
requires:
- prep-deps-npm
- prep-build
- job-screens
- all-tests-pass
jobs:
prep-deps-npm:
@ -144,6 +149,17 @@ jobs:
name: Test
command: npm run lint
test-deps:
docker:
- image: circleci/node:8-browsers
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ .Revision }}
- run:
name: Test
command: npx nsp check
test-e2e:
docker:
- image: circleci/node:8-browsers

@ -35,7 +35,6 @@
"globals": {
"document": false,
"log": true,
"navigator": false,
"web3": true,
"window": false

1
.gitignore vendored

@ -20,6 +20,7 @@ dist
builds/
disc/
builds.zip
docs/jsdocs
development/bundle.js
development/states.js

@ -1,27 +0,0 @@
{
"node": true,
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": true,
"newcap": true,
"noarg": true,
"quotmark": "single",
"regexp": true,
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"smarttabs": true,
"globals" : {
"chrome": true,
"crypto": true,
"describe": true,
"it": true
}
}

@ -2,6 +2,35 @@
## Current Master
## 4.6.0 Thu Apr 26 2018
- Correctly format currency conversion for locally selected preferred currency.
- Improved performance of 3D fox logo.
- Fetch token prices based on contract address, not symbol
- Fix bug that prevents setting language locale in settings.
- Show checksum addresses throughout the UI
- Allow transactions with a 0 gwei gas price
## 4.5.5 Fri Apr 06 2018
- Graceful handling of unknown keys in txParams
- Fixes buggy handling of historical transactions with unknown keys in txParams
- Fix link for 'Learn More' in the Add Token Screen to open to a new tab.
- Fix Download State Logs button [#3791](https://github.com/MetaMask/metamask-extension/issues/3791)
- Enhanced migration error handling + reporting
## 4.5.4 (aborted) Thu Apr 05 2018
- Graceful handling of unknown keys in txParams
- Fix link for 'Learn More' in the Add Token Screen to open to a new tab.
- Fix Download State Logs button [#3791](https://github.com/MetaMask/metamask-extension/issues/3791)
- Fix migration error reporting
## 4.5.3 Wed Apr 04 2018
- Fix bug where checksum address are messing with balance issue [#3843](https://github.com/MetaMask/metamask-extension/issues/3843)
- new ui: fix the confirm transaction screen
## 4.5.2 Wed Apr 04 2018
- Fix overly strict validation where transactions were rejected with hex encoded "chainId"

@ -12,12 +12,14 @@ For any new programmatic functionality, we like unit tests when possible, so if
### PR Format
We use [waffle](https://waffle.io/) for project management, and it will automatically keep us organized if you do one simple thing:
If this PR closes the issue, add the line `Fixes #$ISSUE_NUMBER`. Ex. For closing issue 418, include the line `Fixes #418`.
If it doesn't close the issue but addresses it partially, just include a reference to the issue number, like `#418`.
Submit your PR against the `develop` branch. This is where we merge new features so they get some time to receive extra testing before being pushed to `master` for production.
If your PR is a hot-fix that needs to be published urgently, you may submit a PR against the `master` branch, but this PR will receive tighter scrutiny before merging.
## Before Merging
Make sure you get a `:thumbsup`, `:+1`, or `LGTM` from another collaborator before merging.

@ -1,6 +1,7 @@
# MetaMask Browser Extension
[![Build Status](https://circleci.com/gh/MetaMask/metamask-extension.svg?style=shield&circle-token=a1ddcf3cd38e29267f254c9c59d556d513e3a1fd)](https://circleci.com/gh/MetaMask/metamask-extension) [![Coverage Status](https://coveralls.io/repos/github/MetaMask/metamask-extension/badge.svg?branch=master)](https://coveralls.io/github/MetaMask/metamask-extension?branch=master) [![Greenkeeper badge](https://badges.greenkeeper.io/MetaMask/metamask-extension.svg)](https://greenkeeper.io/) [![Stories in Ready](https://badge.waffle.io/MetaMask/metamask-extension.png?label=in%20progress&title=waffle.io)](https://waffle.io/MetaMask/metamask-extension)
[Internal documentation](./docs/jsdocs)
## Support
@ -68,6 +69,7 @@ To write tests that will be run in the browser using QUnit, add your test files
- [How to develop a live-reloading UI](./docs/ui-dev-mode.md)
- [How to add a new translation to MetaMask](./docs/translating-guide.md)
- [Publishing Guide](./docs/publishing.md)
- [The MetaMask Team](./docs/team.md)
- [How to develop an in-browser mocked UI](./docs/ui-mock-mode.md)
- [How to live reload on local dependency changes](./docs/developing-on-deps.md)
- [How to add new networks to the Provider Menu](./docs/adding-new-networks.md)

@ -0,0 +1,912 @@
{
"accept": {
"message": "Přijmout"
},
"account": {
"message": "Účet"
},
"accountDetails": {
"message": "Detaily účtu"
},
"accountName": {
"message": "Název účtu"
},
"address": {
"message": "Adresa"
},
"addCustomToken": {
"message": "Přidat vlastní token"
},
"addToken": {
"message": "Přidat token"
},
"addTokens": {
"message": "Přidat tokeny"
},
"amount": {
"message": "Částka"
},
"amountPlusGas": {
"message": "Částka + palivo"
},
"appDescription": {
"message": "Ethereum rozšíření prohlížeče",
"description": "The description of the application"
},
"appName": {
"message": "MetaMask",
"description": "The name of the application"
},
"approved": {
"message": "Schváleno"
},
"attemptingConnect": {
"message": "Pokouším se připojit k blockchainu."
},
"attributions": {
"message": "Zásluhy"
},
"available": {
"message": "Dostupné"
},
"back": {
"message": "Zpět"
},
"balance": {
"message": "Zůstatek:"
},
"balances": {
"message": "Zůstatek tokenu"
},
"balanceIsInsufficientGas": {
"message": "Nedostatek prostředků pro aktuální množství paliva"
},
"beta": {
"message": "BETA"
},
"betweenMinAndMax": {
"message": "musí být větší nebo roven $1 a menší nebo roven $2.",
"description": "helper for inputting hex as decimal input"
},
"blockiesIdenticon": {
"message": "Použít Blockies Identicon"
},
"borrowDharma": {
"message": "Pújčit si přes Dharma (Beta)"
},
"builtInCalifornia": {
"message": "MetaMask je navržen a vytvořen v Kalifornii."
},
"buy": {
"message": "Koupit"
},
"buyCoinbase": {
"message": "Nákup na Coinbase"
},
"buyCoinbaseExplainer": {
"message": "Coinbase je světově nejoblíbenější místo k nákupu a prodeji bitcoinu, etherea nebo litecoinu."
},
"ok": {
"message": "Ok"
},
"cancel": {
"message": "Zrušit"
},
"classicInterface": {
"message": "Použít klasické rozhraní"
},
"clickCopy": {
"message": "Kliknutím zkopírovat"
},
"confirm": {
"message": "Potvrdit"
},
"confirmed": {
"message": "Potvrzeno"
},
"confirmContract": {
"message": "Potvrdit kontrakt"
},
"confirmPassword": {
"message": "Potvrdit heslo"
},
"confirmTransaction": {
"message": "Potvrdit transakci"
},
"continue": {
"message": "Pokračovat"
},
"continueToCoinbase": {
"message": "Přejít na Coinbase"
},
"contractDeployment": {
"message": "Nasazení kontraktu"
},
"conversionProgress": {
"message": "Provádí se převod"
},
"copiedButton": {
"message": "Zkopírováno"
},
"copiedClipboard": {
"message": "Zkopírováno do schránky"
},
"copiedExclamation": {
"message": "Zkopírováno!"
},
"copiedSafe": {
"message": "Zkopíroval jsem to na bezpečné místo"
},
"copy": {
"message": "Kopírovat"
},
"copyToClipboard": {
"message": "Kopírovat do schránky"
},
"copyButton": {
"message": " Kopírovat "
},
"copyPrivateKey": {
"message": "Toto je váš privátní klíč (kliknutím zkopírujte)"
},
"create": {
"message": "Vytvořit"
},
"createAccount": {
"message": "Vytvořit účet"
},
"createDen": {
"message": "Vytvořit"
},
"crypto": {
"message": "Krypto",
"description": "Exchange type (cryptocurrencies)"
},
"currentConversion": {
"message": "Aktuální převod"
},
"currentNetwork": {
"message": "Aktuální síť"
},
"customGas": {
"message": "Nastavit palivo"
},
"customToken": {
"message": "Vlastní token"
},
"customize": {
"message": "Nastavit"
},
"customRPC": {
"message": "Vlastní RPC"
},
"decimalsMustZerotoTen": {
"message": "Desetinných míst musí být od 0 do 36."
},
"decimal": {
"message": "Počet desetinných míst přesnosti"
},
"defaultNetwork": {
"message": "Výchozí síť pro Etherové transakce je Main Net."
},
"denExplainer": {
"message": "Váš DEN je heslem šifrované uložiště v MetaMasku."
},
"deposit": {
"message": "Vklad"
},
"depositBTC": {
"message": "Vložte BTC na níže uvedenou adresu:"
},
"depositCoin": {
"message": "Vložte $1 na níže uvedenou adresu",
"description": "Tells the user what coin they have selected to deposit with shapeshift"
},
"depositEth": {
"message": "Vložit Eth"
},
"depositEther": {
"message": "Vložit Ether"
},
"depositFiat": {
"message": "Vklad s fiat měnou"
},
"depositFromAccount": {
"message": "Vložte z jiného účtu"
},
"depositShapeShift": {
"message": "Vklad přes ShapeShift"
},
"depositShapeShiftExplainer": {
"message": "Pokud vlastníte jiné kryptoměny, můžete je směnit Ether a vložit ho přímo do peněženky MetaMask. Bez založení účtu."
},
"details": {
"message": "Podrobnosti"
},
"directDeposit": {
"message": "Přímý vklad"
},
"directDepositEther": {
"message": "Vložit Ether přímo"
},
"directDepositEtherExplainer": {
"message": "Pokud už vlastníte nějaký Ether, nejrychleji ho dostanete do peněženky přímým vkladem."
},
"done": {
"message": "Hotovo"
},
"downloadStateLogs": {
"message": "Stáhnout stavové protokoly"
},
"dropped": {
"message": "Zrušeno"
},
"edit": {
"message": "Upravit"
},
"editAccountName": {
"message": "Upravit název účtu"
},
"emailUs": {
"message": "Napište nám e-mail!"
},
"encryptNewDen": {
"message": "Zašifrujte svůj nový DEN"
},
"enterPassword": {
"message": "Zadejte heslo"
},
"enterPasswordConfirm": {
"message": "Zadejte heslo k potvrzení"
},
"passwordNotLongEnough": {
"message": "Heslo není dost dlouhé"
},
"passwordsDontMatch": {
"message": "Hesla nejsou stejná"
},
"etherscanView": {
"message": "Prohlédněte si účet na Etherscan"
},
"exchangeRate": {
"message": "Směnný kurz"
},
"exportPrivateKey": {
"message": "Exportovat privátní klíč"
},
"exportPrivateKeyWarning": {
"message": "Exportujte privátní klíč na vlastní riziko."
},
"failed": {
"message": "Neúspěšné"
},
"fiat": {
"message": "FIAT",
"description": "Exchange type"
},
"fileImportFail": {
"message": "Import souboru nefunguje? Klikněte sem!",
"description": "Helps user import their account from a JSON file"
},
"followTwitter": {
"message": "Sledujte nás na Twitteru"
},
"from": {
"message": "Od"
},
"fromToSame": {
"message": "Adresy odesílatele a příjemce nemohou být stejné"
},
"fromShapeShift": {
"message": "Z ShapeShift"
},
"gas": {
"message": "Palivo",
"description": "Short indication of gas cost"
},
"gasFee": {
"message": "Poplatek za palivo"
},
"gasLimit": {
"message": "Limit paliva"
},
"gasLimitCalculation": {
"message": "Počítáme doporučený limit paliva na základě úspěšnosti v síti."
},
"gasLimitRequired": {
"message": "Limit paliva je povinný"
},
"gasLimitTooLow": {
"message": "Limit paliva musí být alespoň 21000"
},
"generatingSeed": {
"message": "Generuji klíčovou frázi..."
},
"gasPrice": {
"message": "Cena paliva (GWEI)"
},
"gasPriceCalculation": {
"message": "Počítáme doporučenou cenu paliva na základě úspěšnosti v síti."
},
"gasPriceRequired": {
"message": "Cena paliva je povinná"
},
"getEther": {
"message": "Získejte Ether"
},
"getEtherFromFaucet": {
"message": "Získejte Ether z faucetu za $1.",
"description": "Displays network name for Ether faucet"
},
"greaterThanMin": {
"message": "musí být větší nebo roven $1.",
"description": "helper for inputting hex as decimal input"
},
"here": {
"message": "zde",
"description": "as in -click here- for more information (goes with troubleTokenBalances)"
},
"hereList": {
"message": "Tady je seznam!!!!"
},
"hide": {
"message": "Skrýt"
},
"hideToken": {
"message": "Skrýt token"
},
"hideTokenPrompt": {
"message": "Skrýt token?"
},
"howToDeposit": {
"message": "Jakým způsobem chcete vložit Ether?"
},
"holdEther": {
"message": "Dovoluje vám držet ether a tokeny a slouží jako most k decentralizovaným aplikacím."
},
"import": {
"message": "Import",
"description": "Button to import an account from a selected file"
},
"importAccount": {
"message": "Import účtu"
},
"importAccountMsg": {
"message":"Importované účty nebudou spojeny s vaší původní MetaMaskovou klíčovou frází. Zjistěte více o importovaných účtech "
},
"importAnAccount": {
"message": "Import účtu"
},
"importDen": {
"message": "Import existujícího DEN"
},
"imported": {
"message": "Importováno",
"description": "status showing that an account has been fully loaded into the keyring"
},
"infoHelp": {
"message": "Informace a nápověda"
},
"insufficientFunds": {
"message": "Nedostatek finančních prostředků."
},
"insufficientTokens": {
"message": "Nedostatek tokenů."
},
"invalidAddress": {
"message": "Neplatná adresa"
},
"invalidAddressRecipient": {
"message": "Adresa příjemce je neplatná"
},
"invalidGasParams": {
"message": "Neplatná parametry paliva"
},
"invalidInput": {
"message": "Neplatný vstup."
},
"invalidRequest": {
"message": "Neplatný požadavek"
},
"invalidRPC": {
"message": "Neplatné RPC URI"
},
"jsonFail": {
"message": "Něco se pokazilo. Prosím, ujistěte se, že váš JSON soubor má správný formát."
},
"jsonFile": {
"message": "JSON soubor",
"description": "format for importing an account"
},
"keepTrackTokens": {
"message": "Udržujte si záznamy o tokenech, které jste koupili s účtem v MetaMasku."
},
"kovan": {
"message": "Kovan Test Network"
},
"knowledgeDataBase": {
"message": "Navštivte naši Knowledge Base"
},
"max": {
"message": "Max"
},
"learnMore": {
"message": "Zjistěte více."
},
"lessThanMax": {
"message": "musí být menší nebo roven $1.",
"description": "helper for inputting hex as decimal input"
},
"likeToAddTokens": {
"message": "Chcete přidat tyto tokeny?"
},
"links": {
"message": "Odkazy"
},
"limit": {
"message": "Limit"
},
"loading": {
"message": "Načítám..."
},
"loadingTokens": {
"message": "Načítám tokeny..."
},
"localhost": {
"message": "Localhost 8545"
},
"login": {
"message": "Přihlásit"
},
"logout": {
"message": "Odhlásit"
},
"loose": {
"message": "Nevázané"
},
"loweCaseWords": {
"message": "slova klíčové fráze mají pouze malá písmena"
},
"mainnet": {
"message": "Main Ethereum Network"
},
"message": {
"message": "Zpráva"
},
"metamaskDescription": {
"message": "MetaMask je bezpečný osobní trezor pro Ethereum."
},
"min": {
"message": "Minimum"
},
"myAccounts": {
"message": "Moje účty"
},
"mustSelectOne": {
"message": "Musíte zvolit aspoň 1 token."
},
"needEtherInWallet": {
"message": "Potřebujete Ether v peněžence, abyste mohli pomocí MetaMasku interagovat s decentralizovanými aplikacemi."
},
"needImportFile": {
"message": "Musíte zvolit soubor k importu.",
"description": "User is important an account and needs to add a file to continue"
},
"needImportPassword": {
"message": "Musíte zadat heslo pro zvolený soubor.",
"description": "Password and file needed to import an account"
},
"negativeETH": {
"message": "Nelze odeslat zápornou částku ETH."
},
"networks": {
"message": "Sítě"
},
"newAccount": {
"message": "Nový účet"
},
"newAccountNumberName": {
"message": "Účet $1",
"description": "Default name of next account to be created on create account screen"
},
"newContract": {
"message": "Nový kontrakt"
},
"newPassword": {
"message": "Nové heslo (min 8 znaků)"
},
"newRecipient": {
"message": "Nový příjemce"
},
"newRPC": {
"message": "Nová RPC URL"
},
"next": {
"message": "Další"
},
"noAddressForName": {
"message": "Pro toto jméno nebyla nastavena žádná adresa."
},
"noDeposits": {
"message": "Žádný vklad"
},
"noTransactionHistory": {
"message": "Žádná historie transakcí."
},
"noTransactions": {
"message": "Žádné transakce"
},
"notStarted": {
"message": "Nezačalo"
},
"oldUI": {
"message": "Staré rozhraní"
},
"oldUIMessage": {
"message": "Vrátili jste se ke starému rozhraní. Můžete přepnout na nové rozhraní v nastavení v pravém horním menu."
},
"or": {
"message": "nebo",
"description": "choice between creating or importing a new account"
},
"passwordCorrect": {
"message": "Ujistěte se, že je vaše heslo správně."
},
"passwordMismatch": {
"message": "hesla nesouhlasí",
"description": "in password creation process, the two new password fields did not match"
},
"passwordShort": {
"message": "heslo je krátké",
"description": "in password creation process, the password is not long enough to be secure"
},
"pastePrivateKey": {
"message": "Vložte zde svůj privátní klíč:",
"description": "For importing an account from a private key"
},
"pasteSeed": {
"message": "Svou klíčovou frázi vložte zde!"
},
"personalAddressDetected": {
"message": "Detekována osobní adresa. Zadejte adresu kontraktu tokenu."
},
"pleaseReviewTransaction": {
"message": "Zkontrolujte si transakci."
},
"popularTokens": {
"message": "Oblíbené tokeny"
},
"privacyMsg": {
"message": "Zásady ochrany osobních údajů"
},
"privateKey": {
"message": "Privátní klíč",
"description": "select this type of file to use to import an account"
},
"privateKeyWarning": {
"message": "Upozornění: Nikdy nezveřejněte tento klíč. Kdokoli může s vaším privátním klíčem odcizit vaše aktiva z účtu."
},
"privateNetwork": {
"message": "Soukromá síť"
},
"qrCode": {
"message": "Ukázat QR kód"
},
"readdToken": {
"message": "Tento token můžete v budoucnu přidat zpět s „Přidat token“ v nastavení účtu."
},
"readMore": {
"message": "Přečtěte si více zde."
},
"readMore2": {
"message": "Přečtěte si více."
},
"receive": {
"message": "Obrdžet"
},
"recipientAddress": {
"message": "Adresa příjemce"
},
"refundAddress": {
"message": "Adresa pro vrácení peněz"
},
"rejected": {
"message": "Odmítnuto"
},
"resetAccount": {
"message": "Resetovat účet"
},
"restoreFromSeed": {
"message": "Obnovit z seed fráze"
},
"restoreVault": {
"message": "Obnovit trezor"
},
"required": {
"message": "Povinné"
},
"retryWithMoreGas": {
"message": "Opakujte s vyšší cenou paliva"
},
"walletSeed": {
"message": "Klíčová fráze peněženky"
},
"revealSeedWords": {
"message": "Zobrazit slova klíčové fráze"
},
"revealSeedWordsWarning": {
"message": "Nebnovujte slova klíčové fráze na veřejnosti! Tato slova mohou být použita k odcizení veškerých vyašich účtů."
},
"revert": {
"message": "Zvrátit"
},
"rinkeby": {
"message": "Rinkeby Test Network"
},
"ropsten": {
"message": "Ropsten Test Network"
},
"currentRpc": {
"message": "Současné RPC"
},
"connectingToMainnet": {
"message": "Připojuji se k Main Ethereum Network"
},
"connectingToRopsten": {
"message": "Připojuji se k Ropsten Test Network"
},
"connectingToKovan": {
"message": "Připojuji se k Kovan Test Network"
},
"connectingToRinkeby": {
"message": "Připojuji se k Rinkeby Test Network"
},
"connectingToUnknown": {
"message": "Připojuji se k neznámé síti"
},
"sampleAccountName": {
"message": "Např. můj nový účet",
"description": "Help user understand concept of adding a human-readable name to their account"
},
"save": {
"message": "Uložit"
},
"reprice_title": {
"message": "Změnit cenu transakce"
},
"reprice_subtitle": {
"message": "Navyšte cenu paliva ve snaze k přepsání a urychlení vyší transakce"
},
"saveAsFile": {
"message": "Uložit do souboru",
"description": "Account export process"
},
"saveSeedAsFile": {
"message": "Uložit slova klíčové fráze do souboru"
},
"search": {
"message": "Hledat"
},
"secretPhrase": {
"message": "Zadejte svých 12 slov tajné fráze k obnovení trezoru."
},
"newPassword8Chars": {
"message": "Nové heslo (min 8 znaků)"
},
"seedPhraseReq": {
"message": "klíčové fráze mají 12 slov"
},
"select": {
"message": "Vybrat"
},
"selectCurrency": {
"message": "Vybrat měnu"
},
"selectService": {
"message": "Vybrat službu"
},
"selectType": {
"message": "Vybrat typ"
},
"send": {
"message": "Odeslat"
},
"sendETH": {
"message": "Odeslat ETH"
},
"sendTokens": {
"message": "Odeslat tokeny"
},
"onlySendToEtherAddress": {
"message": "Posílejte jen ETH na Ethereum adresu."
},
"searchTokens": {
"message": "Hledat tokeny"
},
"sendTokensAnywhere": {
"message": "Posílejte tokeny komukoli s Ethereum účtem"
},
"settings": {
"message": "Nastavení"
},
"info": {
"message": "Informace"
},
"shapeshiftBuy": {
"message": "Nakoupit na ShapeShift"
},
"showPrivateKeys": {
"message": "Zobrazit privátní klíče"
},
"showQRCode": {
"message": "Zobrazit QR kód"
},
"sign": {
"message": "Podepsat"
},
"signed": {
"message": "Podepsáno"
},
"signMessage": {
"message": "Podepsat zprávu"
},
"signNotice": {
"message": "Podepsání zprávy může mít \nnebezpečný vedlejší učinek. Podepisujte zprávy pouze ze \nstránek, kterým plně důvěřujete celým svým účtem.\n Tato nebezpečná metoda bude odebrána v budoucí verzi. "
},
"sigRequest": {
"message": "Požadavek podpisu"
},
"sigRequested": {
"message": "Požádáno o podpis"
},
"spaceBetween": {
"message": "mezi slovy může být pouze mezera"
},
"status": {
"message": "Stav"
},
"stateLogs": {
"message": "Stavové protokoly"
},
"stateLogsDescription": {
"message": "Stavové protokoly obsahují vaše veřejné adresy účtů a odeslané transakce."
},
"stateLogError": {
"message": "Chyba během získávání stavových protokolů."
},
"submit": {
"message": "Odeslat"
},
"submitted": {
"message": "Odesláno"
},
"supportCenter": {
"message": "Navštivte naše centrum podpory"
},
"symbolBetweenZeroTen": {
"message": "Symbol musí být mezi 0 a 10 znaky."
},
"takesTooLong": {
"message": "Trvá to dlouho?"
},
"terms": {
"message": "Podmínky použití"
},
"testFaucet": {
"message": "Testovací faucet"
},
"to": {
"message": "Komu: "
},
"toETHviaShapeShift": {
"message": "$1 na ETH přes ShapeShift",
"description": "system will fill in deposit type in start of message"
},
"tokenAddress": {
"message": "Adresa tokenu"
},
"tokenAlreadyAdded": {
"message": "Token byl už přidán."
},
"tokenBalance": {
"message": "Váš zůstatek tokenu je:"
},
"tokenSelection": {
"message": "Vyhledejte token nebo je vyberte z našeho seznamu oblíbených tokenů."
},
"tokenSymbol": {
"message": "Symbol tokenu"
},
"tokenWarning1": {
"message": "Mějte přehled o tokenech, které jste koupili s účtem MetaMasku. Pokud jste koupili tokeny s jiným účtem, tyto tokeny se zde nezobrazí."
},
"total": {
"message": "Celkem"
},
"transactions": {
"message": "transakce"
},
"transactionError": {
"message": "Chyba transakce. Vyhozena výjimka v kódu kontraktu."
},
"transactionMemo": {
"message": "Poznámka transakce (nepovinné)"
},
"transactionNumber": {
"message": "Číslo transakce"
},
"transfers": {
"message": "Převody"
},
"troubleTokenBalances": {
"message": "Měli jsme problém s načtením vašich tokenových zůstatků. Můžete je vidět ",
"description": "Followed by a link (here) to view token balances"
},
"twelveWords": {
"message": "Těchto 12 slov je jedinou možností, jak obnovit MetaMask účet. \nUložte je na bezpečné a neveřejné místo."
},
"typePassword": {
"message": "Zadejte své heslo"
},
"uiWelcome": {
"message": "Vítejte v novém rozhraní (Beta)"
},
"uiWelcomeMessage": {
"message": "Používáte nyní nové rozhraní MetaMasku. Rozhlédněte se kolem, vyzkoušejte nové funkce, jako jsou zasílání tokenů, a dejte nám vědět, pokud narazíte na problém."
},
"unapproved": {
"message": "Neschváleno"
},
"unavailable": {
"message": "Nedostupné"
},
"unknown": {
"message": "Neznámé"
},
"unknownNetwork": {
"message": "Neznámá soukromá síť"
},
"unknownNetworkId": {
"message": "Neznámé ID sítě"
},
"uriErrorMsg": {
"message": "URI vyžadují korektní HTTP/HTTPS prefix."
},
"usaOnly": {
"message": "jen v USA",
"description": "Using this exchange is limited to people inside the USA"
},
"usedByClients": {
"message": "Používána různými klienty"
},
"useOldUI": {
"message": "Použijte staré rozhraní"
},
"validFileImport": {
"message": "Musíte vybrat validní soubor k importu."
},
"vaultCreated": {
"message": "Trezor vytvořen"
},
"viewAccount": {
"message": "Zobrazit účet"
},
"visitWebSite": {
"message": "Navštivte naši stránku"
},
"warning": {
"message": "Varování"
},
"welcomeBeta": {
"message": "Vítejte v MetaMask Beta"
},
"whatsThis": {
"message": "Co to je?"
},
"yourSigRequested": {
"message": "Je vyžadován váš podpis"
},
"youSign": {
"message": "Podepisujete"
}
}

@ -98,6 +98,9 @@
"clickCopy": {
"message": "Click to Copy"
},
"close": {
"message": "Close"
},
"confirm": {
"message": "Confirm"
},
@ -259,6 +262,9 @@
"enterPasswordConfirm": {
"message": "Enter your password to confirm"
},
"enterPasswordContinue": {
"message": "Enter password to continue"
},
"passwordNotLongEnough": {
"message": "Password not long enough"
},
@ -331,6 +337,9 @@
"gasPriceRequired": {
"message": "Gas Price Required"
},
"generatingTransaction": {
"message": "Generating transaction"
},
"getEther": {
"message": "Get Ether"
},
@ -476,6 +485,9 @@
"metamaskDescription": {
"message": "MetaMask is a secure identity vault for Ethereum."
},
"metamaskSeedWords": {
"message": "MetaMask Seed Words"
},
"min": {
"message": "Minimum"
},
@ -549,6 +561,9 @@
"message": "or",
"description": "choice between creating or importing a new account"
},
"password": {
"message": "Password"
},
"passwordCorrect": {
"message": "Please make sure your password is correct."
},
@ -634,8 +649,17 @@
"revealSeedWords": {
"message": "Reveal Seed Words"
},
"revealSeedWordsTitle": {
"message": "Seed Phrase"
},
"revealSeedWordsDescription": {
"message": "If you ever change browsers or move computers, you will need this seed phrase to access your accounts. Save them somewhere safe and secret."
},
"revealSeedWordsWarningTitle": {
"message": "DO NOT share this phrase with anyone!"
},
"revealSeedWordsWarning": {
"message": "Do not recover your seed words in a public place! These words can be used to steal all your accounts."
"message": "These words can be used to steal all your accounts."
},
"revert": {
"message": "Revert"
@ -677,6 +701,9 @@
"reprice_subtitle": {
"message": "Increase your gas price to attempt to overwrite and speed up your transaction"
},
"saveAsCsvFile": {
"message": "Save as CSV File"
},
"saveAsFile": {
"message": "Save as File",
"description": "Account export process"
@ -908,5 +935,8 @@
},
"youSign": {
"message": "You are signing"
},
"yourPrivateSeedPhrase": {
"message": "Your private seed phrase"
}
}

@ -9,7 +9,7 @@
"message": "खिवरण"
},
"accountName": {
"message": "खम"
"message": "खम"
},
"address": {
"message": "ख पत"
@ -21,7 +21,7 @@
"message": "टकन ज"
},
"addTokens": {
"message": "टकन"
"message": "टकन"
},
"amount": {
"message": "रि"
@ -30,7 +30,7 @@
"message": "रि + गस"
},
"appDescription": {
"message": "एथरम बउजर एकसटशन",
"message": "इथिम बउजर एकसटशन",
"description": "आवदन किवरण"
},
"appName": {
@ -53,7 +53,7 @@
"message": "उपलबध बस।"
},
"balances": {
"message": "पक उपलबध बस"
"message": "पक उपलबध बस"
},
"balanceIsInsufficientGas": {
"message": "वरतमन गस कल किए अपरत शष"
@ -78,10 +78,10 @@
"message": "खर"
},
"buyCoinbase": {
"message": "कनबस पर खर"
"message": "कनबस पर खर"
},
"buyCoinbaseExplainer": {
"message": "बिटकइन, एथरम और लइटकइन खरदन और बचनिए दि सबसकपिय तर Coinbase।"
"message": "बिटकइन, इथिम और लइटकइन खरदन और बचनिए दि सबसकपिय तर इनब।"
},
"cancel": {
"message": "रदद कर"
@ -108,7 +108,7 @@
"message": "ज रख"
},
"continueToCoinbase": {
"message": "कनबस कजन रख"
"message": "कनबस कजन रख"
},
"contractDeployment": {
"message": "अनध परििजन व त"
@ -435,13 +435,13 @@
"message": "बज शबद मवल लअरकस वरण ह"
},
"mainnet": {
"message": "मईथरम नटवरक"
"message": "मइथिम नटवरक"
},
"message": {
"message": "सश"
},
"metamaskDescription": {
"message": "मएथरम किए एक सरकित पहचन वट ह।"
"message": "मइथिम किए एक सरकित पहचन वट ह।"
},
"min": {
"message": "ननतम"
@ -649,7 +649,7 @@
"message": "भकन"
},
"sendTokensAnywhere": {
"message": "इम खिकन भ"
"message": "इिम खिकन भ"
},
"settings": {
"message": "सिस"

@ -1,4 +1,5 @@
[
{ "code": "cs", "name": "Czech" },
{ "code": "de", "name": "German" },
{ "code": "en", "name": "English" },
{ "code": "es", "name": "Spanish" },
@ -13,6 +14,8 @@
{ "code": "ru", "name": "Russian" },
{ "code": "sl", "name": "Slovenian" },
{ "code": "th", "name": "Thai" },
{ "code": "tml", "name": "Tamil" },
{ "code": "tr", "name": "Turkish" },
{ "code": "vi", "name": "Vietnamese" },
{ "code": "zh_CN", "name": "Mandarin" },
{ "code": "zh_TW", "name": "Taiwanese" }

@ -20,6 +20,9 @@
"addToken": {
"message": "トークンを追加"
},
"addTokens": {
"message": "トークンを追加"
},
"amount": {
"message": "金額"
},
@ -46,6 +49,9 @@
"balance": {
"message": "残高:"
},
"balances": {
"message": "トークン残高"
},
"balanceIsInsufficientGas": {
"message": "現在のガス総量に対して残高が不足しています"
},
@ -63,10 +69,10 @@
"message": "購入"
},
"buyCoinbase": {
"message": "Coinbaseで購入"
"message": "Coinbaseのサイトで購入"
},
"buyCoinbaseExplainer": {
"message": "Coinbaseは、世界的なBitcoin、Ethereum、そしてLitecoinの取引所です。"
"message": "Etherを購入できます。Coinbaseは、世界的なBitcoin、Ethereum、そしてLitecoinの取引所です。"
},
"cancel": {
"message": "キャンセル"
@ -90,7 +96,7 @@
"message": "トランザクションの確認"
},
"continueToCoinbase": {
"message": "Coinbaseで続行"
"message": "Coinbaseを開く"
},
"contractDeployment": {
"message": "コントラクトのデプロイ"
@ -138,6 +144,9 @@
"customGas": {
"message": "ガスのカスタマイズ"
},
"customToken": {
"message": "カスタムトークン"
},
"customize": {
"message": "カスタマイズ"
},
@ -154,20 +163,20 @@
"message": "DENとは、あなたのパスワードが暗号化されたMetaMask内のストレージです。"
},
"deposit": {
"message": "受取り"
"message": "振込"
},
"depositBTC": {
"message": "あなたのBTCを次のアドレスへデポジット:"
"message": "BTCを下記のアドレスへ振込んでください:"
},
"depositCoin": {
"message": "あなたの $1を次のアドレスへデポジット",
"message": "$1を下記のアドレスへ振込んでください",
"description": "Tells the user what coin they have selected to deposit with shapeshift"
},
"depositEth": {
"message": "ETHをデポジット"
"message": "ETHを入金"
},
"depositEther": {
"message": "Etherをデポジット"
"message": "Etherを振込"
},
"depositFiat": {
"message": "法定通貨でデポジット"
@ -176,10 +185,10 @@
"message": "別のアカウントから入金"
},
"depositShapeShift": {
"message": "ShapeShiftで入金"
"message": "ShapeShiftで交換"
},
"depositShapeShiftExplainer": {
"message": "他の暗号通貨をEtherと交換してMetaMaskのウォレットへ入金できます。アカウント作成は不要です。"
"message": "他の暗号通貨とEtherを交換して、MetaMaskのウォレットへ入金できます。アカウント作成は不要です。"
},
"details": {
"message": "詳細"
@ -188,10 +197,10 @@
"message": "ダイレクトデポジット"
},
"directDepositEther": {
"message": "Etherを直接受け取り"
"message": "Etherを直接入金"
},
"directDepositEtherExplainer": {
"message": "Etherをすでにお持ちなら、MetaMaskの新しいウォレットにEtherを送信することができます。"
"message": "既にEtherをお持ちなら、MetaMaskの新しいウォレットにEtherを送信することができます。"
},
"done": {
"message": "完了"
@ -209,7 +218,7 @@
"message": "パスワードを入力"
},
"etherscanView": {
"message": "Etherscanでアカウントを参照"
"message": "Etherscanでアカウントを確認"
},
"exchangeRate": {
"message": "交換レート"
@ -266,7 +275,7 @@
"message": "必要ガスプライス"
},
"getEther": {
"message": "Etherをゲット"
"message": "Etherを取得する"
},
"getEtherFromFaucet": {
"message": "フォーセットで $1のEtherを得ることができます。",
@ -287,7 +296,7 @@
"message": "トークンを隠す"
},
"hideTokenPrompt": {
"message": "トークンを隠しますか?"
"message": "トークンを隠しますか?"
},
"howToDeposit": {
"message": "どのようにEtherをデポジットしますか?"
@ -300,7 +309,7 @@
"message": "アカウントのインポート"
},
"importAccountMsg": {
"message":"追加したアカウントはMetaMaskのアカウントシードフレーズとは関連付けられません。インポートしたアカウントについての詳細は"
"message":"追加したアカウントはMetaMaskのアカウントパスフレーズとは関連付けられません。インポートしたアカウントについての詳細は"
},
"importAnAccount": {
"message": "アカウントをインポート"
@ -334,13 +343,22 @@
"message": "JSONファイル",
"description": "format for importing an account"
},
"keepTrackTokens": {
"message": "MetaMaskアカウントで入手したトークンを検索できます。"
},
"kovan": {
"message": "Kovanテストネットワーク"
},
"learnMore": {
"message": "詳細"
},
"lessThanMax": {
"message": " $1以下にして下さい。",
"description": "helper for inputting hex as decimal input"
},
"likeToAddTokens": {
"message": "トークンを追加しますか?"
},
"limit": {
"message": "リミット"
},
@ -371,8 +389,11 @@
"myAccounts": {
"message": "マイアカウント"
},
"mustSelectOne": {
"message": "一つ以上のトークンを選択してください。"
},
"needEtherInWallet": {
"message": "MetaMaskを使って分散型アプリケーションを使用するためには、このウォレットにEtherが必要です。"
"message": "MetaMask分散型アプリケーションを使用するためには、このウォレットにEtherが必要です。"
},
"needImportFile": {
"message": "インポートするファイルを選択してください。",
@ -411,7 +432,7 @@
"message": "この名前にはアドレスが設定されていません。"
},
"noDeposits": {
"message": "デポジットがありません。"
"message": "振込みがありません。"
},
"noTransactionHistory": {
"message": "トランザクション履歴がありません。"
@ -445,10 +466,13 @@
"description": "For importing an account from a private key"
},
"pasteSeed": {
"message": "シードをここにペーストして下さい!"
"message": "パスフレーズをここにペーストして下さい!"
},
"pleaseReviewTransaction": {
"message": "トランザクションをレビューして下さい。"
"message": "トランザクションを確認して下さい。"
},
"popularTokens": {
"message": "人気のトークン"
},
"privateKey": {
"message": "秘密鍵",
@ -470,13 +494,13 @@
"message": "もっと読む"
},
"receive": {
"message": "受"
"message": "受取"
},
"recipientAddress": {
"message": "受取人アドレス"
},
"refundAddress": {
"message": "あなたの返金先アドレス"
"message": "受取アドレス"
},
"rejected": {
"message": "拒否されました"
@ -487,12 +511,18 @@
"restoreFromSeed": {
"message": "パスフレーズから復元する"
},
"restoreVault": {
"message": "ウォレットを復元する"
},
"required": {
"message": "必要です。"
},
"retryWithMoreGas": {
"message": "より高いガスプライスで再度試して下さい。"
},
"walletSeed": {
"message": "ウォレットのパスフレーズ"
},
"revealSeedWords": {
"message": "パスフレーズを表示"
},
@ -519,23 +549,35 @@
"selectService": {
"message": "サービスを選択"
},
"selectType": {
"message": "キーの種類"
},
"send": {
"message": "送信"
},
"sendETH": {
"message": "ETHの送信"
},
"sendTokens": {
"message": "トークンを送る"
},
"onlySendToEtherAddress": {
"message": "ETHはイーサリウムアカウントのみに送信できます。"
},
"searchTokens": {
"message": "トークンの検索"
},
"sendTokensAnywhere": {
"message": "イーサリアムアカウントを持っている人にトークンを送る"
},
"settings": {
"message": "設定"
},
"info": {
"message": "情報"
},
"shapeshiftBuy": {
"message": "Shapeshiftで買う"
"message": "Shapeshiftで交換"
},
"showPrivateKeys": {
"message": "秘密鍵を表示"
@ -565,13 +607,13 @@
"message": "送信"
},
"takesTooLong": {
"message": "長くかかりすぎていますか?"
"message": "送信に時間がかかりますか?"
},
"testFaucet": {
"message": "Faucetをテスト"
},
"to": {
"message": "先"
"message": "送信先"
},
"toETHviaShapeShift": {
"message": "ShapeShiftで $1をETHにする",
@ -595,6 +637,9 @@
"total": {
"message": "合計"
},
"transactions": {
"message": "トランザクション"
},
"transactionMemo": {
"message": "トランザクションメモ (オプション)"
},
@ -609,7 +654,7 @@
"description": "Followed by a link (here) to view token balances"
},
"typePassword": {
"message": "パスワードタイプ"
"message": "パスワードの入力"
},
"uiWelcome": {
"message": "新UIへようこそ!(ベータ版)"
@ -646,7 +691,7 @@
"message": "警告"
},
"whatsThis": {
"message": "これは何でしょう?"
"message": "この機能について"
},
"yourSigRequested": {
"message": "あなたの署名がリクエストされています。"

@ -181,7 +181,7 @@
"message": "DEN je vaša šifrirana shramba v MetaMasku."
},
"deposit": {
"message": "Vplačilo"
"message": "Vplačaj"
},
"depositBTC": {
"message": "Vplačajte vaš BTC na spodnji naslov:"
@ -507,10 +507,10 @@
"message": "Ni se začelo"
},
"oldUI": {
"message": "Starejši uporabniški vmesnik"
"message": "Star UI"
},
"oldUIMessage": {
"message": "Vrnili ste se v starejši uporabniški vmesnik. V novega se lahko vrnete z možnostjo v spustnem meniju v zgornjem desnem kotu."
"message": "Vrnili ste se v star uporabniški vmesnik. V novega se lahko vrnete z možnostjo v spustnem meniju v zgornjem desnem kotu."
},
"or": {
"message": "ali",
@ -759,7 +759,7 @@
"message": "Vpišite vaše geslo"
},
"uiWelcome": {
"message": "Dobrodošli v novem uporabniškem vmesniku (Beta)"
"message": "Dobrodošli v nov UI (Beta)"
},
"uiWelcomeMessage": {
"message": "Zdaj uporabljate novi MetaMask uporabniški vmesnik. Razglejte se, preizkusite nove funkcije, kot so pošiljanje žetonov, in nas obvestite, če imate kakšne težave."

@ -0,0 +1,912 @@
{
"accept": {
"message": "ஏறகவ"
},
"account": {
"message": "கணக"
},
"accountDetails": {
"message": "கணகிவரஙகள"
},
"accountName": {
"message": "கணகியர"
},
"address": {
"message": "மகவரி"
},
"addCustomToken": {
"message": "தனிபயனகனகவ"
},
"addToken": {
"message": "டகன"
},
"addTokens": {
"message": "டகனகள"
},
"amount": {
"message": "த"
},
"amountPlusGas": {
"message": "த + எரி"
},
"appDescription": {
"message": "எதிிசரி",
"description": "பயனிிளககம"
},
"appName": {
"message": "மடமஸ ",
"description": "பயனியர"
},
"approved": {
"message": "அஙகரிகபபடட"
},
"attemptingConnect": {
"message": "இணக மயறிக ப"
},
"attributions": {
"message": "பணகள"
},
"available": {
"message": "கி"
},
"back": {
"message": "ம"
},
"balance": {
"message": "இர:"
},
"balances": {
"message": "உஙகள இர"
},
"balanceIsInsufficientGas": {
"message": "நடபதமன சமநி"
},
"beta": {
"message": "ப"
},
"betweenMinAndMax": {
"message": "$ 1 க அதிகமகவ அலலத $ 2 க சமமகவ இரக வ.",
"description": "ஹ உள தசம உள என உதவி"
},
"blockiesIdenticon": {
"message": "பி ஐடி பயன"
},
"borrowDharma": {
"message": "தரமதடன கடனகள (ப)"
},
"builtInCalifornia": {
"message": "மடமஸ வடிவமகபபட கலிிி கடடபபடளத."
},
"buy": {
"message": "வக"
},
"buyCoinbase": {
"message": "கஇனபசகவ"
},
"buyCoinbaseExplainer": {
"message": "கஇனபசிறக , எதி மறிடசக மறிக உலகிிகவிரபலமன வழி"
},
"ok": {
"message": "சரி"
},
"cancel": {
"message": "ரத"
},
"classicInterface": {
"message": "கிி இடகத பயனபடதவ"
},
"clickCopy": {
"message": "நகலக கிியவ"
},
"confirm": {
"message": "உறிபடதவ"
},
"confirmed": {
"message": "உறி"
},
"confirmContract": {
"message": "ஒபபநதத உறிபடக"
},
"confirmPassword": {
"message": "கடவ உறிபடக"
},
"confirmTransaction": {
"message": "பரிவரதன உறிபடதவ"
},
"continue": {
"message": "தடர"
},
"continueToCoinbase": {
"message": "கஇனபச ஐதடரவ"
},
"contractDeployment": {
"message": "ஒபபநத வரிபடதல"
},
"conversionProgress": {
"message": "மறமறம"
},
"copiedButton": {
"message": "நகலகபபடடன"
},
"copiedClipboard": {
"message": "கிி நகலகபபடடத"
},
"copiedExclamation": {
"message": "நகலகபபடடன!"
},
"copiedSafe": {
"message": "ந எஙவதக நகலிி"
},
"copy": {
"message": "நகல"
},
"copyToClipboard": {
"message": "கிி நகலகபபடடத"
},
"copyButton": {
"message": " நகல "
},
"copyPrivateKey": {
"message": "இத உஙகள தனிபடட வி (நகலக கிியவ)"
},
"create": {
"message": "உரகவ"
},
"createAccount": {
"message": "உஙகள கணகவஙகள"
},
"createDen": {
"message": "உரகவ"
},
"crypto": {
"message": "கிி",
"description": "பரிற வக (கிிி)"
},
"currentConversion": {
"message": "தறய மறம"
},
"currentNetwork": {
"message": "தறய ந"
},
"customGas": {
"message": "எரி தனிபயனகள"
},
"customToken": {
"message": "தனிபயனகன"
},
"customize": {
"message": "தனிபயனகல"
},
"customRPC": {
"message": "விப RPC ஐ"
},
"decimalsMustZerotoTen": {
"message": "தசமஙகளதபடசம 0, மற 36 க இரக வ."
},
"decimal": {
"message": "தியதிி"
},
"defaultNetwork": {
"message": "எதி பரிவரதனகளன மி வலயமதனிகரம."
},
"denExplainer": {
"message": "உஙகள DEN எனபத உஙகள கடவ-மறிகபபடட சிபகமி."
},
"deposit": {
"message": "வ"
},
"depositBTC": {
"message": "க உஙகளகவரி உஙகள BTC வ:"
},
"depositCoin": {
"message": "உஙகளகவரி $ 1 ஐ க உளிடவ",
"description": "சபஷிி உடனகபபடட நணயத பயனரிடமி"
},
"depositEth": {
"message": "வ எத "
},
"depositEther": {
"message": "வ எதி "
},
"depositFiat": {
"message": "ஃபியட உடன"
},
"depositFromAccount": {
"message": "மற கணகிி"
},
"depositShapeShift": {
"message": "ShapeShift உடன"
},
"depositShapeShiftExplainer": {
"message": "நகள மறற கிிிரனகளதமக வி, உஙகள பணபிரடிக ஈதர வரதகமயல மறயல. கணகி."
},
"details": {
"message": "விவரஙகள"
},
"directDeposit": {
"message": "நரடி"
},
"directDepositEther": {
"message": "நரடிக வ"
},
"directDepositEtherExplainer": {
"message": "நகள ஏறகனவ ஏத இர, நரடிலம உஙகளிய பணபி ஈததரற வின வழி."
},
"done": {
"message": "மிதத"
},
"downloadStateLogs": {
"message": "மில பதிகள பதிிறகக"
},
"dropped": {
"message": "நகபபட"
},
"edit": {
"message": "த"
},
"editAccountName": {
"message": "கணகயரக"
},
"emailUs": {
"message": "எஙகளினஞசல!"
},
"encryptNewDen": {
"message": "உஙகளிய DEN ஐ கிக"
},
"enterPassword": {
"message": "கடவ உளிடவ"
},
"enterPasswordConfirm": {
"message": "உறிபடத உஙகள கடவ உளிடவ"
},
"passwordNotLongEnough": {
"message": "கடவ"
},
"passwordsDontMatch": {
"message": "கடவகள"
},
"etherscanView": {
"message": "Etherscan கணககவ"
},
"exchangeRate": {
"message": "மிிதம"
},
"exportPrivateKey": {
"message": "தனிி ஐ ஏறமதிக"
},
"exportPrivateKeyWarning": {
"message": "தனிபடட விகள உஙகளத ஆபதி ஏறமதிகள."
},
"failed": {
"message": "தி"
},
"fiat": {
"message": "FIAT",
"description": "பரிற வக"
},
"fileImportFail": {
"message": "க இறகமதியவி? இஙிியவ!",
"description": "JSON கி பயனர கணக தஙகள கணக இறகமதிய உதவிறத"
},
"followTwitter": {
"message": "Twitter இல எஙகளிடரவ"
},
"from": {
"message": "இர"
},
"fromToSame": {
"message": "இர மறகவரி அத இரக மி"
},
"fromShapeShift": {
"message": "ShapeShift இலி"
},
"gas": {
"message": "எரி",
"description": "எரிி"
},
"gasFee": {
"message": "எரி கடடணம"
},
"gasLimit": {
"message": "எரி வரம"
},
"gasLimitCalculation": {
"message": "நிிிதஙகளி அடிபடி பரிகபபடட எரி வரமகள கணகிி."
},
"gasLimitRequired": {
"message": "எரி வரம"
},
"gasLimitTooLow": {
"message": "எரி வரமதத 21000 ஆக இரக வ"
},
"generatingSeed": {
"message": "வி உரிறத ..."
},
"gasPrice": {
"message": "எரிி (GWEI)"
},
"gasPriceCalculation": {
"message": "நிிிதஙகளி அடிபடி பரிகபபடட எரிிகளகள கணகிி."
},
"gasPriceRequired": {
"message": "எரிிபடிறத"
},
"getEther": {
"message": "ஈததரி"
},
"getEtherFromFaucet": {
"message": "$ 1 க ஒர இர ஈதரி$1",
"description": "ஈததர ஐநிய பயரிறத"
},
"greaterThanMin": {
"message": "$ 1 க அதிகமகவ அலலத சமமகவ இரக வ",
"description": "ஹ உள தசம உள என உதவி"
},
"here": {
"message": "இங",
"description": "இங-கிியவ- ம தகவல (troubleTokenBalances சிறத)"
},
"hereList": {
"message": "இங ஒர படியல !!!!"
},
"hide": {
"message": "மற"
},
"hideToken": {
"message": "டகன மற"
},
"hideTokenPrompt": {
"message": "டகன மற?"
},
"howToDeposit": {
"message": "எபபடி ஈததரபத?"
},
"holdEther": {
"message": "இதகள ஈததர மறகனகளிக உதவிறத, மற பரவலகபபடட பயனகள உஙகளலமக சயலபடிறத."
},
"import": {
"message": "இறகமதி",
"description": "தகபபடட கிி ஒர கணக இறகமதிய ப அழதவ"
},
"importAccount": {
"message": "கணக இறகமதிக"
},
"importAccountMsg": {
"message":" இறகமதியபபடட கணக உஙகளதலி உரகபபடட ம கணகிலமடரயதக இர. இறகமதியபபடட கணககள பறி அறிக "
},
"importAnAccount": {
"message": "ஒர கணக இறகமதிக"
},
"importDen": {
"message": "இறகமதி DEN இறகமதி"
},
"imported": {
"message": "இறகமதி",
"description": "ஒர கணகக விபலகி ஏறறபபடடதிறத"
},
"infoHelp": {
"message": "தகவல மற உதவி"
},
"insufficientFunds": {
"message": "பன பணம இல."
},
"insufficientTokens": {
"message": "பன டகனகள."
},
"invalidAddress": {
"message": "தவறன மகவரி"
},
"invalidAddressRecipient": {
"message": "பநரகவரி தவறனத"
},
"invalidGasParams": {
"message": "தவறன எரி அளவகள"
},
"invalidInput": {
"message": "தவறன உள.."
},
"invalidRequest": {
"message": "தவறன கி"
},
"invalidRPC": {
"message": "தவறன RPC URI"
},
"jsonFail": {
"message": "ஏத தவற நடநிடத. உஙகள JSON க ஒழக வடிவமகபபடளத எனபத உறிபடதவ"
},
"jsonFile": {
"message": "JSON க",
"description": "ஒர கணக இறகமதிய வடிவமகபபடளத"
},
"keepTrackTokens": {
"message": "உஙகளடமஸ கணகடனகளிய டகனகள கணிகள."
},
"kovan": {
"message": "கவன"
},
"knowledgeDataBase": {
"message": "எஙகள அறி தளதிடவ"
},
"max": {
"message": "ம"
},
"learnMore": {
"message": "ம அறிக"
},
"lessThanMax": {
"message": "$ 1 ககவ அலலத சமமகவ இரக வ.",
"description": "ஹ உள தசம உள என உதவி"
},
"likeToAddTokens": {
"message": "இநத டகனகளக விிகள?"
},
"links": {
"message": "இணகள"
},
"limit": {
"message": "அளவ"
},
"loading": {
"message": "ஏறதல ..."
},
"loadingTokens": {
"message": "டகனகள ஏறிறத ..."
},
"localhost": {
"message": "லகல 8545"
},
"login": {
"message": "உள"
},
"logout": {
"message": "வி"
},
"loose": {
"message": "ல"
},
"loweCaseWords": {
"message": "விகள எழகள மட"
},
"mainnet": {
"message": "மதன எதி"
},
"message": {
"message": "சி"
},
"metamaskDescription": {
"message": "மடமஸ எனபத ஒரன அடள வ எதி"
},
"min": {
"message": "கதபடச"
},
"myAccounts": {
"message": "எனத கணககள"
},
"mustSelectOne": {
"message": "கதத 1 டகனக வ."
},
"needEtherInWallet": {
"message": "மடமஸ ஐ பயனபடி பரவலகபபடட பயனகளடனடரள, உஙகள பணபபரிறதி ஈதர."
},
"needImportFile": {
"message": "இறகமதிய ஒரகளக வ.",
"description": "பயனர ஒர கணகியம மறடர ஒரக வ"
},
"needImportPassword": {
"message": "நகளத க ஒர கடவ உளிட வ.",
"description": "ஒர கணக இறகமதிய கடவ மற"
},
"negativeETH": {
"message": "ETH எதிமற அளவகள அனப மி."
},
"networks": {
"message": "ந"
},
"newAccount": {
"message": "பிய கணக"
},
"newAccountNumberName": {
"message": "கணக $ 1",
"description": "கணக கணக உரவதற அடத கணகி இயலியர உரகபபட"
},
"newContract": {
"message": "பிய ஒபபநதம"
},
"newPassword": {
"message": "பிய கடவ (min 8 எழகள)"
},
"newRecipient": {
"message": "பிய பநர"
},
"newRPC": {
"message": "பிய RPC URL"
},
"next": {
"message": "அடத"
},
"noAddressForName": {
"message": "இநத பயரன மகவரி அமகபபடவி."
},
"noDeposits": {
"message": "எநத வகளிகவி"
},
"noTransactionHistory": {
"message": "பரிவரதன வரல இல."
},
"noTransactions": {
"message": "பரிவரதனகள இல"
},
"notStarted": {
"message": "தவஙகவி"
},
"oldUI": {
"message": "பழய UI"
},
"oldUIMessage": {
"message": "நகள பழய UI கிிகள. ம வலதி உளள விபதிலமிய UI ஐ மறல."
},
"or": {
"message": "அலலத",
"description": "ஒரிய கணக உரக அலலத இறகமதிவதற இட"
},
"passwordCorrect": {
"message": "தயவ உஙகள கடவ சரினத என உறிபடதவ."
},
"passwordMismatch": {
"message": "கடவகளதவி",
"description": "கடவ உரகதி, இரணிய கடவலஙகளதவி"
},
"passwordShort": {
"message": "கடவட கலமக இல",
"description": "கடவ உரகதி, பனதக இர கடவ"
},
"pastePrivateKey": {
"message": "இங உஙகள தனிபடட வி சரத ஒடக:",
"description": "ஒர தனிபடட வி ஒர கணக இறகமதிய"
},
"pasteSeed": {
"message": "இங உஙகளிடர ஒடடவ!"
},
"personalAddressDetected": {
"message": "தனிபடட மகவரி கணடறியபபடடத. டகன ஒபபநத மகவரி உளிடவ."
},
"pleaseReviewTransaction": {
"message": "உஙகள பரிவரதன மதியவ."
},
"popularTokens": {
"message": "பிரபலமன டகனகள"
},
"privacyMsg": {
"message": "தனிி"
},
"privateKey": {
"message": "தனிபடட வி",
"description": "ஒர கணக இறகமதிய பயனபடத இநத வககவ"
},
"privateKeyWarning": {
"message": "எசசரி: இநத வி எபிிட வ. உஙகள தனிபடட விகளட எவர உஙகள கணகி உளள எநத சகளிடல."
},
"privateNetwork": {
"message": "தனி"
},
"qrCode": {
"message": "QR கி"
},
"readdToken": {
"message": "உஙகள கணகிபஙகளி \"டகன\" எனபதனலமகள எதிலதி இநத டகனகல."
},
"readMore": {
"message": "மிக இங."
},
"readMore2": {
"message": "மிக."
},
"receive": {
"message": "பக"
},
"recipientAddress": {
"message": "பநரகவரி"
},
"refundAddress": {
"message": "உஙகள பணதிி அனகவரி"
},
"rejected": {
"message": "நிகரிகபபடடத"
},
"resetAccount": {
"message": "கணகடம"
},
"restoreFromSeed": {
"message": "விியதிிகவ"
},
"restoreVault": {
"message": "வகவ"
},
"required": {
"message": "தன"
},
"retryWithMoreGas": {
"message": "இங அதிக எரிியறிகவ"
},
"walletSeed": {
"message": "வி"
},
"revealSeedWords": {
"message": "விகளிபடத"
},
"revealSeedWordsWarning": {
"message": "உஙகளிகள ஒர இடதிக வ! உஙகள எல கணககளிட இநத வகள பயனபடதபபடல."
},
"revert": {
"message": "மியம"
},
"rinkeby": {
"message": "ரிய ட"
},
"ropsten": {
"message": "ர"
},
"currentRpc": {
"message": "தறய RPC"
},
"connectingToMainnet": {
"message": "மிய எதி இண"
},
"connectingToRopsten": {
"message": "ரடன இணிறத"
},
"connectingToKovan": {
"message": "கவனடன இணதல"
},
"connectingToRinkeby": {
"message": "ரிய டடன இணிறத"
},
"connectingToUnknown": {
"message": "தித நடன இணிறத"
},
"sampleAccountName": {
"message": "உதரணமக எனதிய கணக",
"description": "தஙகள கணகி மனிதர படிககிய பயர கர பயனரிள உதவகள"
},
"save": {
"message": "சி"
},
"reprice_title": {
"message": "ரி பரிவரதன"
},
"reprice_subtitle": {
"message": "உஙகள பரிவரதனகளயறி அதிகரிக உஙகள எரிி அதிகரிகவ"
},
"saveAsFile": {
"message": "கக சிகவ",
"description": "கணக ஏறமதியல"
},
"saveSeedAsFile": {
"message": "க என விகளிகவ"
},
"search": {
"message": "தடல"
},
"secretPhrase": {
"message": "உஙகளடகதபதறக இங உஙகள ரகசிய பனிரணடர உளிடவ."
},
"newPassword8Chars": {
"message": "பிய கடவ (கதபடசம 8 எழகள)"
},
"seedPhraseReq": {
"message": "விியஙகள 12 வகளடவ"
},
"select": {
"message": "த"
},
"selectCurrency": {
"message": "நணயத"
},
"selectService": {
"message": "சகவ"
},
"selectType": {
"message": "வக"
},
"send": {
"message": "அன"
},
"sendETH": {
"message": "ETH ஐ அன"
},
"sendTokens": {
"message": "டகனகள அனபவ"
},
"onlySendToEtherAddress": {
"message": "ETH ஐ ஒர எதரிகவரி மட அனபவ."
},
"searchTokens": {
"message": "தடலகன"
},
"sendTokensAnywhere": {
"message": "யடனகனகள அனபவ எதி கணக"
},
"settings": {
"message": "அமகள"
},
"info": {
"message": "தகவல"
},
"shapeshiftBuy": {
"message": "Shapeshift உடனகவ"
},
"showPrivateKeys": {
"message": "தனிபடட விகளி"
},
"showQRCode": {
"message": "QR கி"
},
"sign": {
"message": "உள"
},
"signed": {
"message": "கபமிடபபடட"
},
"signMessage": {
"message": "சி பதிக"
},
"signNotice": {
"message": "இநத சிிபமிடல \nஆபதன பகக விகள இரகல. \n உஙகளத கணகிக நமபகிய தளஙகளிிகள மடபமிகள. \n இநத ஆபதன ம எதில பதிி அகறறபபட."
},
"sigRequest": {
"message": "கபமி"
},
"sigRequested": {
"message": "கபமரபபடடத"
},
"spaceBetween": {
"message": "வகள இட இடி மட இரக மி"
},
"status": {
"message": "நி"
},
"stateLogs": {
"message": "மில பதிகள"
},
"stateLogsDescription": {
"message": "மில பதிகள உஙகள கணககவரிகள மற பரிறஙகள அனிளன."
},
"stateLogError": {
"message": "மில பதிகளபதிி."
},
"submit": {
"message": "சமரி"
},
"submitted": {
"message": "சமரிகபபடடத"
},
"supportCenter": {
"message": "எஙகள ஆதரவயதிடவ"
},
"symbolBetweenZeroTen": {
"message": "கி 0 மற 10 எழகள இடி இரக வ."
},
"takesTooLong": {
"message": "நட நரம எடிறத?"
},
"terms": {
"message": "பயனிிகள"
},
"testFaucet": {
"message": "சதன"
},
"to": {
"message": "பநர: "
},
"toETHviaShapeShift": {
"message": "$ 1 மதல ETH வர வடிவம",
"description": "சிடககதி வககளிிரபபபபட"
},
"tokenAddress": {
"message": "டகனகவரி"
},
"tokenAlreadyAdded": {
"message": "டகன ஏறகனவகபபடடத."
},
"tokenBalance": {
"message": "உஙகளகன இர:"
},
"tokenSelection": {
"message": "டகனகள அலலதிரபல டகனகளி படியலிிகவ."
},
"tokenSymbol": {
"message": "டகனினம"
},
"tokenWarning1": {
"message": "உஙகளடமஸ கணகடனகளிய டகனகள கணிகள. வ கணக பயனபடிகனகளிி, அநத டகனகள இங."
},
"total": {
"message": "மத"
},
"transactions": {
"message": "பரிவரதனகள"
},
"transactionError": {
"message": "பரிவரதனி. விி ஒபபநததிிிிலக."
},
"transactionMemo": {
"message": "பரிவரதனி (விபம)"
},
"transactionNumber": {
"message": "பரிவரதன எண"
},
"transfers": {
"message": "இடமறஙகள"
},
"troubleTokenBalances": {
"message": "உஙகளகனிகள ஏறவதிிகல ஏறபடடத. நகள அவரகளக மி.",
"description": "டகனிகளண ஒர இண (இங) தடர"
},
"twelveWords": {
"message": "இநத 12 வகள உஙகள கணகக ஒர வழி. \n அவற எஙவதகவ ரகசியமகவிகவ."
},
"typePassword": {
"message": "உஙகள கடவ தடடசயவ"
},
"uiWelcome": {
"message": "பிய UI (ப) க வரவி"
},
"uiWelcomeMessage": {
"message": "இபகளிய ம UI ஐ பயனபடிகள. சிகள, டகனகள அனிய அமசஙகளயறிகவ, உஙகளிடம ஏதிகல இர எஙகளியபபடதவ."
},
"unapproved": {
"message": "அஙகரிகபபடத"
},
"unavailable": {
"message": "கிகவி"
},
"unknown": {
"message": "தித"
},
"unknownNetwork": {
"message": "அறியபபடத தனி"
},
"unknownNetworkId": {
"message": "தித ந ஐடி"
},
"uriErrorMsg": {
"message": "URI கள சரின HTTP / HTTPS ம."
},
"usaOnly": {
"message": "அமி மட",
"description": "இநத பரிறத பயனபடி அமிி உளளவரகள மட இத வரயறகபபடிறத"
},
"usedByClients": {
"message": "பலிளரகள பல பயனபடிய"
},
"useOldUI": {
"message": "உஸ ஓல உய "
},
"validFileImport": {
"message": "இறகமதிய சரின கக வ."
},
"vaultCreated": {
"message": "வ உரகபபடடத"
},
"viewAccount": {
"message": "கணக"
},
"visitWebSite": {
"message": "எஙகள வலதளதிடவ"
},
"warning": {
"message": "எசசரி"
},
"welcomeBeta": {
"message": "ம வரக"
},
"whatsThis": {
"message": "இத எனன?"
},
"yourSigRequested": {
"message": "உஙகளபமரபபடிறத"
},
"youSign": {
"message": "நகளிிகள"
}
}

@ -0,0 +1,912 @@
{
"accept": {
"message": "Kabul et"
},
"account": {
"message": "Hesap"
},
"accountDetails": {
"message": "Hesap Detayları"
},
"accountName": {
"message": "Hesap İsmi"
},
"address": {
"message": "Adres"
},
"addCustomToken": {
"message": "Özel jeton ekle"
},
"addToken": {
"message": "Jeton ekle"
},
"addTokens": {
"message": "Jetonlar ekle"
},
"amount": {
"message": "Tutar"
},
"amountPlusGas": {
"message": "Tutar + Gas"
},
"appDescription": {
"message": "Ethereum Tarayıcı Uzantısı",
"description": "Uygulama açıklaması"
},
"appName": {
"message": "MetaMask",
"description": "Uygulama ismi"
},
"approved": {
"message": "Onaylandı"
},
"attemptingConnect": {
"message": "Blockchain'e bağlanmayı deniyor"
},
"attributions": {
"message": "Atıflar"
},
"available": {
"message": "Müsait"
},
"back": {
"message": "Geri"
},
"balance": {
"message": "Bakiye:"
},
"balances": {
"message": "Jeton bakiyesi"
},
"balanceIsInsufficientGas": {
"message": "Toplam gas için yetersiz bakiye"
},
"beta": {
"message": "BETA"
},
"betweenMinAndMax": {
"message": "$1'e eşit veya daha büyük olmalı ve $2'den küçük veya eşit olmalı",
"description": "Onaltılık sayının ondalık sayı olarak girişi için yardımcı"
},
"blockiesIdenticon": {
"message": "Blockies Identicon kullan"
},
"borrowDharma": {
"message": "Dharma (Beta) ile ödünç al"
},
"builtInCalifornia": {
"message": "MetaMask California'da tasarlandı ve yaratıldı"
},
"buy": {
"message": "Satın al"
},
"buyCoinbase": {
"message": "Coinbase'de satın al"
},
"buyCoinbaseExplainer": {
"message": "Coinbase bitcoin, ethereum, and litecoin alıp satmanın dünyadaki en popüler yolu"
},
"ok": {
"message": "Tamam"
},
"cancel": {
"message": "Vazgeç"
},
"classicInterface": {
"message": "Klasik arayüzü kullan"
},
"clickCopy": {
"message": "Kopyalamak için tıkla"
},
"confirm": {
"message": "Onayla"
},
"confirmed": {
"message": "Onaylandı"
},
"confirmContract": {
"message": "Sözleşmeyi onayla"
},
"confirmPassword": {
"message": "Şifreyi onayla"
},
"confirmTransaction": {
"message": "İşlemi onayla"
},
"continue": {
"message": "Devam et"
},
"continueToCoinbase": {
"message": "Coinbase'e devam et"
},
"contractDeployment": {
"message": "Sözleşme kurulumu"
},
"conversionProgress": {
"message": "Çevirim devam ediyor"
},
"copiedButton": {
"message": "Kopyalandı"
},
"copiedClipboard": {
"message": "Panoya kopyalandı"
},
"copiedExclamation": {
"message": "Kopyalandı!"
},
"copiedSafe": {
"message": "Güvenli bir yere kopyaladım"
},
"copy": {
"message": "Kopyala"
},
"copyToClipboard": {
"message": "Panoya kopyala"
},
"copyButton": {
"message": " Kopyala "
},
"copyPrivateKey": {
"message": "Bu sizin özel anahtarınız (kopyalamak için tıklayın)"
},
"create": {
"message": "Yarat"
},
"createAccount": {
"message": "Hesap Oluştur"
},
"createDen": {
"message": "Yarat"
},
"crypto": {
"message": "Kripto",
"description": "Kambiyo tipi (kripto para)"
},
"currentConversion": {
"message": "Geçerli çevirme"
},
"currentNetwork": {
"message": "Geçerli Ağ"
},
"customGas": {
"message": "Gas'i özelleştir"
},
"customToken": {
"message": "Özel Jeton"
},
"customize": {
"message": "Özelleştir"
},
"customRPC": {
"message": "Özel RPC"
},
"decimalsMustZerotoTen": {
"message": "Ondalıklar en azından 0 olmalı ve 36'dan büyük olmamalı."
},
"decimal": {
"message": "Ondalık hassasiyeti"
},
"defaultNetwork": {
"message": "Ether işlemleri için varsayılan ağ Main Net."
},
"denExplainer": {
"message": "DEN'iniz MetaMask içersinde parola-şifrelenmiş deponuzdur."
},
"deposit": {
"message": "Yatır"
},
"depositBTC": {
"message": "BTC'inizi aşağıdaki adrese yatırın:"
},
"depositCoin": {
"message": "$1'nızı aşağıdaki adrese yatırın",
"description": "Kullanıcıya hangi jetonu seçtiyse onu yatırmasını shapeshift ile söyler."
},
"depositEth": {
"message": "Eth yatır"
},
"depositEther": {
"message": "Ether yatır"
},
"depositFiat": {
"message": "Para yatır"
},
"depositFromAccount": {
"message": "Başka bir hesaptan yatır"
},
"depositShapeShift": {
"message": "ShapeShift ile yatır"
},
"depositShapeShiftExplainer": {
"message": "Eğer başka kripto paralara sahipseniz, MetaMask cüzdanınıza direk olarak Ether yatırabilirsiniz. Hesaba gerek yoktur."
},
"details": {
"message": "Ayrıntılar"
},
"directDeposit": {
"message": "Direk Yatırma"
},
"directDepositEther": {
"message": "Direk Ether Yatırma"
},
"directDepositEtherExplainer": {
"message": "Eğer çoktan Etheriniz varsa, yeni hesabınıza Ether aktarmanın en kolay yolu direk yatırmadır."
},
"done": {
"message": "Bitti"
},
"downloadStateLogs": {
"message": "Durum kayıtlarını indir"
},
"dropped": {
"message": "Bırakıldı"
},
"edit": {
"message": "Düzenle"
},
"editAccountName": {
"message": "Hesap ismini düzenle"
},
"emailUs": {
"message": "Bize e-posta atın!"
},
"encryptNewDen": {
"message": "Yeni DEN'inizi şifreleyin"
},
"enterPassword": {
"message": "Parolanızı girin"
},
"enterPasswordConfirm": {
"message": "Onaylamak için parolanızı girin"
},
"passwordNotLongEnough": {
"message": "Parola yeterince uzun değil"
},
"passwordsDontMatch": {
"message": "Parolalar eşleşmiyor"
},
"etherscanView": {
"message": "Hesabı Etherscan üzerinde izle"
},
"exchangeRate": {
"message": "Döviz kuru"
},
"exportPrivateKey": {
"message": "Özel anahtarı ver"
},
"exportPrivateKeyWarning": {
"message": "Özel anahtarınızı vermek sizin sorumluluğunuzdadır."
},
"failed": {
"message": "Başarısız oldu"
},
"fiat": {
"message": "Para",
"description": "Döviz türü"
},
"fileImportFail": {
"message": "Dosya alma çalışmıyor mu? Buraya tıklayın!",
"description": "Kullanıcıların hesaplarını JSON dosyasından almalarına yardım eder"
},
"followTwitter": {
"message": "Bizi twitter'da takip edin"
},
"from": {
"message": "Kimden"
},
"fromToSame": {
"message": "Kimden ve kime adresi aynı olamaz"
},
"fromShapeShift": {
"message": "ShapeShift'den"
},
"gas": {
"message": "Gas",
"description": "Gas maliyetinin kısa indikatörü"
},
"gasFee": {
"message": "Gas Ücreti"
},
"gasLimit": {
"message": "Gas Limiti"
},
"gasLimitCalculation": {
"message": "Önerilen gas limitini ağ başarı oranını baz alarak hesaplıyoruz."
},
"gasLimitRequired": {
"message": "Gas limiti gereklidir"
},
"gasLimitTooLow": {
"message": "Gas limiti en az 21000 olmalıdır"
},
"generatingSeed": {
"message": "Kaynak Oluşturuyor..."
},
"gasPrice": {
"message": "Gas Fiyatı (GWEI)"
},
"gasPriceCalculation": {
"message": "Önerilen gas fiyatını ağ başarı oranını baz alarak hesaplıyoruz."
},
"gasPriceRequired": {
"message": "Gas Fiyatı Gereklidir"
},
"getEther": {
"message": "Ether Al"
},
"getEtherFromFaucet": {
"message": "Musluktan $1 karşılığı Ether alın",
"description": "Ether musluğunun ağ ismini gösterir"
},
"greaterThanMin": {
"message": "must be greater than or equal to $1.",
"description": "helper for inputting hex as decimal input"
},
"here": {
"message": "burada",
"description": "daha fazla bilgi için -buraya tıklayın- (troubleTokenBalances ile gidiyor)"
},
"hereList": {
"message": "İşte bir liste!!!!"
},
"hide": {
"message": "Gizle"
},
"hideToken": {
"message": "Jetonu gizle"
},
"hideTokenPrompt": {
"message": "Jetonu gizle?"
},
"howToDeposit": {
"message": "Ether'i nasıl yatırmak istersiniz?"
},
"holdEther": {
"message": "Ether ve jeton tutmanızı sağlar ve merkezi olmayan uygulamalar ve sizin aranızda köprü vazifesi görür."
},
"import": {
"message": "Al",
"description": "Seçilen dosyadan hesap alma düğmesi. "
},
"importAccount": {
"message": "Hesap Al"
},
"importAccountMsg": {
"message":" Alınan hesaplar orjinal kaynakifadenizle yarattığınız MetaMask hesabınızla ilişkilendirilmez. Alınan hesaplar ile ilgili daha fazla bilgi edinin "
},
"importAnAccount": {
"message": "Hesap al"
},
"importDen": {
"message": "Varolan DEN al"
},
"imported": {
"message": "Alındı",
"description": "Hesabın keyringe başarı ile alındığını gösteren durum"
},
"infoHelp": {
"message": "Bilgi ve yardım"
},
"insufficientFunds": {
"message": "Yetersiz kaynak."
},
"insufficientTokens": {
"message": "Yetersiz Jeton."
},
"invalidAddress": {
"message": "Geçersiz adres"
},
"invalidAddressRecipient": {
"message": "Alıcı adresi geçersiz"
},
"invalidGasParams": {
"message": "Geçersiz gas parametreleri"
},
"invalidInput": {
"message": "Geçersiz giriş."
},
"invalidRequest": {
"message": "Geçersiz istek"
},
"invalidRPC": {
"message": "Geçersiz RPC URI"
},
"jsonFail": {
"message": "Birşeyler yanlış gitti. JSON dosyanızın düzgün derlendiğinden emin olun."
},
"jsonFile": {
"message": "JSON Dosyası",
"description": "Hesap alımı için düzenle"
},
"keepTrackTokens": {
"message": "MetaMask hesabınızla satın aldığınız jetonların kaydını tutun."
},
"kovan": {
"message": "Kovan Test Ağı"
},
"knowledgeDataBase": {
"message": "Bilgi veritabanımızı ziyaret edin"
},
"max": {
"message": "Maksimum"
},
"learnMore": {
"message": "Daha fazla bilgi."
},
"lessThanMax": {
"message": "$1'den az veya eşit olmalıdır.",
"description": "Onaltılık sayıyı ondalık olarak girmek için yardımcı"
},
"likeToAddTokens": {
"message": "Bu jetonlara adres eklemek ister misiniz?"
},
"links": {
"message": "Bağlantılar"
},
"limit": {
"message": "Limit"
},
"loading": {
"message": "Yükleniyor..."
},
"loadingTokens": {
"message": "Jetonlar yükleniyor..."
},
"localhost": {
"message": "Localhost 8545"
},
"login": {
"message": "Giriş yap"
},
"logout": {
"message": "Çıkış"
},
"loose": {
"message": "Gevşek"
},
"loweCaseWords": {
"message": "kaynak kelimeleri sadece küçük harflerden oluşabilir."
},
"mainnet": {
"message": "Main Ethereum Ağı"
},
"message": {
"message": "Mesaj"
},
"metamaskDescription": {
"message": "MetaMask Ethereum için güvenli bir kimlik kasasıdır."
},
"min": {
"message": "Minimum"
},
"myAccounts": {
"message": "Hesaplarım"
},
"mustSelectOne": {
"message": "En az bir jeton seçilmeli"
},
"needEtherInWallet": {
"message": "MetaMask kullanarak merkezi olamayan uygulamalarla etkileşmek için cüzdanınızda Ether bulunmalıdır."
},
"needImportFile": {
"message": "Almak için bir dosya seçmelisiniz.",
"description": "Kullanıcı bir hesap alır ve devam etmek içinbir dosya seçmelidir."
},
"needImportPassword": {
"message": "Seçilen dosya için bir parola girmelisiniz.",
"description": "Hesap almak için parola ve dosya gerekiyor."
},
"negativeETH": {
"message": "Negatif ETH miktarları gönderilemez."
},
"networks": {
"message": "Ağlar"
},
"newAccount": {
"message": "Yeni Hesap"
},
"newAccountNumberName": {
"message": "Hesap $1",
"description": "Hesap yaratma ekranındaki bir sonraki hesabın varsayılan ismi"
},
"newContract": {
"message": "Yeni Sözleşme"
},
"newPassword": {
"message": "Yeni Parola (min 8 karakter)"
},
"newRecipient": {
"message": "Yeni alıcı"
},
"newRPC": {
"message": "Yeni RPC URL"
},
"next": {
"message": "Sonraki"
},
"noAddressForName": {
"message": "Bu isim için bir adres tanımlanmamış."
},
"noDeposits": {
"message": "Yatırma alınmadı"
},
"noTransactionHistory": {
"message": "İşlem geçmişi yok."
},
"noTransactions": {
"message": "İşlem yok"
},
"notStarted": {
"message": "Başlamadı"
},
"oldUI": {
"message": "Eski UI"
},
"oldUIMessage": {
"message": "Eski UI'a döndünüz. Yeni UI'a üst sağ sekme menüsündeki seçenek ile dönebilirsiniz."
},
"or": {
"message": "veya",
"description": "Yeni bir hesap yaratmak veya almak arasındaki seçim"
},
"passwordCorrect": {
"message": "Lütfen parolanın doğru olduğuna emin olun."
},
"passwordMismatch": {
"message": "parolalar eşleşmiyor",
"description": "parola yaratma işleminde, iki yeni parola alanı eşleşmiyor."
},
"passwordShort": {
"message": "parola yeterince uzun değil",
"description": "parola yaratma işleminde, parola güvenli olacak kadar uzun değil."
},
"pastePrivateKey": {
"message": "Özel anahtar dizinizi buraya yapıştırın:",
"description": "Özel anahtardan hesap almak için"
},
"pasteSeed": {
"message": "Kaynak ifadenizi buraya yapıştırın!"
},
"personalAddressDetected": {
"message": "Kişisel adres tespit edilidi. Jeton sözleşme adresini girin."
},
"pleaseReviewTransaction": {
"message": "Lütfen işleminizi gözden geçirin."
},
"popularTokens": {
"message": "Popüler Jetonlar"
},
"privacyMsg": {
"message": "Gizlilik Şartları"
},
"privateKey": {
"message": "Özel Anahtar",
"description": "Hesap alırken bu tip bir dosya seçin"
},
"privateKeyWarning": {
"message": "Uyarı: Bu anahtarı kimse ile paylaşmayın. Özel anahtarlarınıza sahip herkes hesaplarınızıdaki tüm varlığınızı çalabilir."
},
"privateNetwork": {
"message": "Özel Ağ"
},
"qrCode": {
"message": "QR Kodunu göster"
},
"readdToken": {
"message": "Gelecekte Bu jetonu hesap seçenekleri menüsünde “Jeton ekle”'ye giderek geri ekleyebilirsiniz."
},
"readMore": {
"message": "Burada daha fazla okuyun."
},
"readMore2": {
"message": "Daha fazla okuyun."
},
"receive": {
"message": "Al"
},
"recipientAddress": {
"message": "Alıcı adresi"
},
"refundAddress": {
"message": "İade adresiniz"
},
"rejected": {
"message": "Rededildi"
},
"resetAccount": {
"message": "Hesabı sıfıla"
},
"restoreFromSeed": {
"message": "Kaynak ifadeden geri getir. Restore from seed phrase"
},
"restoreVault": {
"message": "Kasayı geri getir"
},
"required": {
"message": "Gerekli"
},
"retryWithMoreGas": {
"message": "Daha yüksek bir gas fiyatı ile tekrar dene"
},
"walletSeed": {
"message": "Cüzdan Kaynağı"
},
"revealSeedWords": {
"message": "Kaynak kelimelerini göster"
},
"revealSeedWordsWarning": {
"message": "Açık bir yerde kaynak kelimeliriniz geri getirmeyin! Bu kelimeler tüm hesaplarınızı çalmak için kullanılabilir."
},
"revert": {
"message": "Geri döndür"
},
"rinkeby": {
"message": "Rinkeby Test Ağı"
},
"ropsten": {
"message": "Ropsten Test Ağı"
},
"currentRpc": {
"message": "Geçerli RPC"
},
"connectingToMainnet": {
"message": "Main Ethereum Ağına bağlanıyor"
},
"connectingToRopsten": {
"message": "Ropsten Test Ağına bağlanıyor"
},
"connectingToKovan": {
"message": "Kovan Test Ağına bağlanıyor"
},
"connectingToRinkeby": {
"message": "Rinkeby Test Ağına bağlanıyor"
},
"connectingToUnknown": {
"message": "Bilinmeyen Ağa bağlanıyor"
},
"sampleAccountName": {
"message": "E.g. Yeni hesabım",
"description": "Kullanıcının hesabına okunabilir isim ekleme konseptini anlamasına yardımcı olmak."
},
"save": {
"message": "Kaydet"
},
"reprice_title": {
"message": "İşlemi Yeniden Fiyatlandır"
},
"reprice_subtitle": {
"message": "İşlemizi hızlandırmayı denemek için gas fiyatınızı yükseltin."
},
"saveAsFile": {
"message": "Dosya olarak kaydet",
"description": "Hesap verme işlemi"
},
"saveSeedAsFile": {
"message": "Kaynak Kelimelerini Dosya olarak Kaydet"
},
"search": {
"message": "Ara"
},
"secretPhrase": {
"message": "Kasanızı geri getirmek için gizli 12 kelimelik ifadenizi giriniz."
},
"newPassword8Chars": {
"message": "Yeni Parola (minumum 8 karakter)"
},
"seedPhraseReq": {
"message": "Kaynak ifadeleri 12 kelimedir."
},
"select": {
"message": "Seç"
},
"selectCurrency": {
"message": "Döviz Seç"
},
"selectService": {
"message": "Servis Seç"
},
"selectType": {
"message": "Tip Seç"
},
"send": {
"message": "Gönder"
},
"sendETH": {
"message": "ETH Gönder"
},
"sendTokens": {
"message": "Jeton Gönder"
},
"onlySendToEtherAddress": {
"message": "Ethereum adresine sadece ETH gönder."
},
"searchTokens": {
"message": "Jeton ara"
},
"sendTokensAnywhere": {
"message": "Ethereum hesabı olan birine Jeton gönder"
},
"settings": {
"message": "Ayarlar"
},
"info": {
"message": "Bilgi"
},
"shapeshiftBuy": {
"message": "Shapeshift ile satın al"
},
"showPrivateKeys": {
"message": "Özel anahtarları göster"
},
"showQRCode": {
"message": "QR Kodu göster"
},
"sign": {
"message": "İmza"
},
"signed": {
"message": "İmzalandı"
},
"signMessage": {
"message": "Mesajı İmzala"
},
"signNotice": {
"message": "Bu mesajı imzalamanın tehlikeli \nyan etkileri olabilir. Tamamen güvendiğiniz sitelerden \ngelen mesajları hesabınızla imzalayınız.\n Bu tehlikeli metod gelecek versiyonlarda çıkarılacaktır. "
},
"sigRequest": {
"message": "İmza isteği"
},
"sigRequested": {
"message": "İmza isteniyor"
},
"spaceBetween": {
"message": "Kelimeler arası sadece bir boşluk olabilir."
},
"status": {
"message": "Durum"
},
"stateLogs": {
"message": "Durum Kayıtları"
},
"stateLogsDescription": {
"message": "Durum kayıtları açık hesap adresinizi ve gönderilen işlemleri içerir."
},
"stateLogError": {
"message": "Durum kayıtlarını alma hatası"
},
"submit": {
"message": "Gönder"
},
"submitted": {
"message": "Gönderildi"
},
"supportCenter": {
"message": "Destek merkezimizi ziyaret edin"
},
"symbolBetweenZeroTen": {
"message": "Sembol 0 ve 10 karakter aralığında olmalıdır."
},
"takesTooLong": {
"message": "Çok mu uzun sürüyor?"
},
"terms": {
"message": "Kullanım şartları"
},
"testFaucet": {
"message": "Test Musluğu"
},
"to": {
"message": "Kime: "
},
"toETHviaShapeShift": {
"message": "ShapeShift üstünden $1'dan ETH'e",
"description": "system will fill in deposit type in start of message"
},
"tokenAddress": {
"message": "Jeton Adresi"
},
"tokenAlreadyAdded": {
"message": "Jeton çoktan eklenmiş."
},
"tokenBalance": {
"message": "Jeton bakiyeniz:"
},
"tokenSelection": {
"message": "Jeton arayın veya popüler jeton listemizden seçin."
},
"tokenSymbol": {
"message": "Jeton Sembolü"
},
"tokenWarning1": {
"message": "MetaMask hesabınızla aldığınız jetonların kaydını tutun. Başka bir hesapla jetonlar satın aldıysanız, o jetonlar burada gözükmeyecektir."
},
"total": {
"message": "Toplam"
},
"transactions": {
"message": "işlemler"
},
"transactionError": {
"message": "İşlem Hatası. Sözleşme kodundan kural dışı durum fırlatıldı."
},
"transactionMemo": {
"message": "İşlem notu (opsiyonel)"
},
"transactionNumber": {
"message": "İşlem numarası"
},
"transfers": {
"message": "Transferler"
},
"troubleTokenBalances": {
"message": "Jeton bakiyelerinizi yüklerken sorun yaşadık. Buradan izleyebilirsiniz ",
"description": "Jeton bakiyelerini görmek için bir link (burası) ile takip ediliyor"
},
"twelveWords": {
"message": "MetaMask hesaplarınızı geri getirmenin tek yolu bu 12 kelimedir.\nBu kelimeleri güvenli ve gizli bir yerde saklayın."
},
"typePassword": {
"message": "Parolanızı girin"
},
"uiWelcome": {
"message": "Yeni UI (Beta)'ya hoşgeldiniz"
},
"uiWelcomeMessage": {
"message": "Şu anda yeni Metamask UI kullanmaktasınız. Gözatın, jeton gönderme gibi yeni özellikleri deneyin ve herhangi bir sorunlar karşılaşırsanız bize haber verin"
},
"unapproved": {
"message": "Onaylanmadı"
},
"unavailable": {
"message": "Mevcut değil"
},
"unknown": {
"message": "Bilinmeyen"
},
"unknownNetwork": {
"message": "Bilinmeyen özel ağ"
},
"unknownNetworkId": {
"message": "Bilinmeyen ağ IDsi"
},
"uriErrorMsg": {
"message": "URIler için HTTP/HTTPS öneki gerekmektedir."
},
"usaOnly": {
"message": "Sadece ABD",
"description": "Bu dövizi sadece ABD ikamet edenler kullanabilir"
},
"usedByClients": {
"message": "Farklı istemciler tarafından kullanılmakta"
},
"useOldUI": {
"message": "Eski UI kullan"
},
"validFileImport": {
"message": "Almak için geçerli bir dosya seçmelisiniz"
},
"vaultCreated": {
"message": "Kasa Yaratıldı"
},
"viewAccount": {
"message": "Hesabı İncele"
},
"visitWebSite": {
"message": "Web sitemizi ziyaret edin"
},
"warning": {
"message": "Uyarı"
},
"welcomeBeta": {
"message": "MetaMask Beta'ya Hoşgeldiniz"
},
"whatsThis": {
"message": "Bu nedir?"
},
"yourSigRequested": {
"message": "İmzanız isteniyor"
},
"youSign": {
"message": "İmzalıyorsunuz"
}
}

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="18px" height="17px" viewBox="0 0 18 17" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: sketchtool 49.3 (51167) - http://www.bohemiancoding.com/sketch -->
<title>374E58A5-C29E-4921-83E7-889FA06D6408</title>
<desc>Created with sketchtool.</desc>
<defs></defs>
<g id="Reveal-Seedphrase" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Seed-phrase-2" transform="translate(-39.000000, -379.000000)">
<g id="Group-2">
<g id="Group-8" transform="translate(16.000000, 248.000000)">
<g id="Group-6" transform="translate(23.336478, 120.000000)">
<g id="Group-5" transform="translate(0.408805, 11.000000)">
<g id="copy-to-clipboard">
<rect id="Rectangle-18" stroke="#3098DC" stroke-width="2" x="1" y="1" width="12.0220126" height="12"></rect>
<rect id="Rectangle-18-Copy-2" fill="#FFFFFF" x="2.1572327" y="2" width="14.0220126" height="14"></rect>
<rect id="Rectangle-18-Copy" stroke="#3098DC" stroke-width="2" x="4.23584906" y="4" width="12.0220126" height="12"></rect>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

@ -1,15 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="24.088px" height="24px" viewBox="138.01 0 24.088 24" enable-background="new 138.01 0 24.088 24" xml:space="preserve" fill="#F7861C">
<g>
<polygon fill="#F7861C" points="157.551,17.075 156.55,17.075 156.55,19.149 142.569,19.149 142.569,17.075 141.568,17.075
141.568,20.145 141.955,20.145 141.955,20.15 157.006,20.15 157.006,20.145 157.551,20.145 "/>
<polygon fill="#F7861C" points="152.555,10.275 152.555,11.26 152.555,11.268 151.562,11.268 151.562,12.252 150.565,12.252
150.565,4.171 149.564,4.171 149.564,12.236 148.564,12.236 148.564,11.252 147.564,11.252 147.564,11.236 147.564,11.221
147.564,10.236 146.563,10.236 146.563,11.221 146.563,11.236 146.563,12.221 147.563,12.221 147.563,12.236 147.563,12.252
147.563,13.236 148.563,13.236 148.563,14.221 149.564,14.221 149.564,15.725 150.565,15.725 150.565,14.236 151.563,14.236
151.563,13.252 152.563,13.252 152.563,12.268 152.563,12.26 153.556,12.26 153.556,11.275 153.556,11.26 153.556,10.275 "/>
</g>
</svg>
<?xml version="1.0" encoding="UTF-8"?>
<svg width="20px" height="18px" viewBox="0 0 20 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: sketchtool 49.3 (51167) - http://www.bohemiancoding.com/sketch -->
<title>50559280-0739-419A-8E87-3CDD16A6996A</title>
<desc>Created with sketchtool.</desc>
<defs></defs>
<g id="Reveal-Seedphrase" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Seed-phrase-2" transform="translate(-212.000000, -379.000000)" stroke="#259DE5" stroke-width="2">
<g id="Group-2">
<g id="Group-8" transform="translate(16.000000, 248.000000)">
<g id="Group-6" transform="translate(23.336478, 120.000000)">
<g id="Group-3" transform="translate(174.000000, 11.000000)">
<g id="Group-4">
<g id="download">
<polyline id="Path-5" points="0 11 0 17 17 17 17 11"></polyline>
<path d="M8.5,0 L8.5,11" id="Path-6"></path>
<polyline id="Path-7" points="3.1875 7 8.5 11 13.8125 7"></polyline>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="33px" height="32px" viewBox="0 0 33 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 49.3 (51167) - http://www.bohemiancoding.com/sketch -->
<title>Group 7</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Reveal-Seedphrase" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Seed-phrase-2" transform="translate(-29.000000, -155.000000)">
<g id="Group-2" transform="translate(0.000000, 132.000000)">
<g id="Group" transform="translate(28.000000, 19.000000)">
<g id="Group-19-Copy-2" transform="translate(0.000000, 3.000000)">
<g id="Group-7">
<path d="M20.1321134,3.85444772 L32.5721829,26.6020033 C33.367162,28.0556794 32.8331826,29.8785746 31.3795065,30.6735537 C30.9381289,30.9149321 30.4431378,31.0414403 29.9400695,31.0414403 L5.05993054,31.0414403 C3.40307629,31.0414403 2.05993054,29.6982946 2.05993054,28.0414403 C2.05993054,27.538372 2.18643873,27.0433809 2.42781712,26.6020033 L14.8678866,3.85444772 C15.6628657,2.40077162 17.4857609,1.86679221 18.939437,2.66177133 C19.442875,2.93708896 19.8567958,3.35100977 20.1321134,3.85444772 Z" id="Triangle-2-Copy" stroke="#FF001F" stroke-width="2"></path>
<rect id="Rectangle-5" fill="#FF001F" x="16" y="9" width="3" height="13"></rect>
<rect id="Rectangle-5-Copy" fill="#FF001F" x="16" y="24" width="3" height="3"></rect>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

@ -1,7 +1,7 @@
{
"name": "__MSG_appName__",
"short_name": "__MSG_appName__",
"version": "4.5.2",
"version": "4.6.0",
"manifest_version": 2,
"author": "https://metamask.io",
"description": "__MSG_appDescription__",

@ -1,3 +1,7 @@
/**
* @file The entry point for the web extension singleton process.
*/
const urlUtil = require('url')
const endOfStream = require('end-of-stream')
const pump = require('pump')
@ -20,12 +24,17 @@ 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 getObjStructure = require('./lib/getObjStructure')
const {
ENVIRONMENT_TYPE_POPUP,
ENVIRONMENT_TYPE_NOTIFICATION,
ENVIRONMENT_TYPE_FULLSCREEN,
} = require('./lib/enums')
const STORAGE_KEY = 'metamask-config'
const METAMASK_DEBUG = process.env.METAMASK_DEBUG
window.log = log
log.setDefaultLevel(METAMASK_DEBUG ? 'debug' : 'warn')
log.setDefaultLevel(process.env.METAMASK_DEBUG ? 'debug' : 'warn')
const platform = new ExtensionPlatform()
const notificationManager = new NotificationManager()
@ -43,7 +52,7 @@ const isEdge = !isIE && !!window.StyleMedia
let popupIsOpen = false
let notificationIsOpen = false
let openMetamaskTabsIDs = {}
const openMetamaskTabsIDs = {}
// state persistence
const diskStore = new LocalStorageStore({ storageKey: STORAGE_KEY })
@ -56,6 +65,90 @@ initialize().catch(log.error)
// setup metamask mesh testing container
setupMetamaskMeshMetrics()
/**
* An object representing a transaction, in whatever state it is in.
* @typedef TransactionMeta
*
* @property {number} id - An internally unique tx identifier.
* @property {number} time - Time the tx was first suggested, in unix epoch time (ms).
* @property {string} status - The current transaction status (unapproved, signed, submitted, dropped, failed, rejected), as defined in `tx-state-manager.js`.
* @property {string} metamaskNetworkId - The transaction's network ID, used for EIP-155 compliance.
* @property {boolean} loadingDefaults - TODO: Document
* @property {Object} txParams - The tx params as passed to the network provider.
* @property {Object[]} history - A history of mutations to this TransactionMeta object.
* @property {boolean} gasPriceSpecified - True if the suggesting dapp specified a gas price, prevents auto-estimation.
* @property {boolean} gasLimitSpecified - True if the suggesting dapp specified a gas limit, prevents auto-estimation.
* @property {string} estimatedGas - A hex string represented the estimated gas limit required to complete the transaction.
* @property {string} origin - A string representing the interface that suggested the transaction.
* @property {Object} nonceDetails - A metadata object containing information used to derive the suggested nonce, useful for debugging nonce issues.
* @property {string} rawTx - A hex string of the final signed transaction, ready to submit to the network.
* @property {string} hash - A hex string of the transaction hash, used to identify the transaction on the network.
* @property {number} submittedTime - The time the transaction was submitted to the network, in Unix epoch time (ms).
*/
/**
* The data emitted from the MetaMaskController.store EventEmitter, also used to initialize the MetaMaskController. Available in UI on React state as state.metamask.
* @typedef MetaMaskState
* @property {boolean} isInitialized - Whether the first vault has been created.
* @property {boolean} isUnlocked - Whether the vault is currently decrypted and accounts are available for selection.
* @property {boolean} isAccountMenuOpen - Represents whether the main account selection UI is currently displayed.
* @property {boolean} isMascara - True if the current context is the extensionless MetaMascara project.
* @property {boolean} isPopup - Returns true if the current view is an externally-triggered notification.
* @property {string} rpcTarget - DEPRECATED - The URL of the current RPC provider.
* @property {Object} identities - An object matching lower-case hex addresses to Identity objects with "address" and "name" (nickname) keys.
* @property {Object} unapprovedTxs - An object mapping transaction hashes to unapproved transactions.
* @property {boolean} noActiveNotices - False if there are notices the user should confirm before using the application.
* @property {Array} frequentRpcList - A list of frequently used RPCs, including custom user-provided ones.
* @property {Array} addressBook - A list of previously sent to addresses.
* @property {address} selectedTokenAddress - Used to indicate if a token is globally selected. Should be deprecated in favor of UI-centric token selection.
* @property {Object} tokenExchangeRates - Info about current token prices.
* @property {Array} tokens - Tokens held by the current user, including their balances.
* @property {Object} send - TODO: Document
* @property {Object} coinOptions - TODO: Document
* @property {boolean} useBlockie - Indicates preferred user identicon format. True for blockie, false for Jazzicon.
* @property {Object} featureFlags - An object for optional feature flags.
* @property {string} networkEndpointType - TODO: Document
* @property {boolean} isRevealingSeedWords - True if seed words are currently being recovered, and should be shown to user.
* @property {boolean} welcomeScreen - True if welcome screen should be shown.
* @property {string} currentLocale - A locale string matching the user's preferred display language.
* @property {Object} provider - The current selected network provider.
* @property {string} provider.rpcTarget - The address for the RPC API, if using an RPC API.
* @property {string} provider.type - An identifier for the type of network selected, allows MetaMask to use custom provider strategies for known networks.
* @property {string} network - A stringified number of the current network ID.
* @property {Object} accounts - An object mapping lower-case hex addresses to objects with "balance" and "address" keys, both storing hex string values.
* @property {hex} currentBlockGasLimit - The most recently seen block gas limit, in a lower case hex prefixed string.
* @property {TransactionMeta[]} selectedAddressTxList - An array of transactions associated with the currently selected account.
* @property {Object} unapprovedMsgs - An object of messages associated with the currently selected account, mapping a unique ID to the options.
* @property {number} unapprovedMsgCount - The number of messages in unapprovedMsgs.
* @property {Object} unapprovedPersonalMsgs - An object of messages associated with the currently selected account, mapping a unique ID to the options.
* @property {number} unapprovedPersonalMsgCount - The number of messages in unapprovedPersonalMsgs.
* @property {Object} unapprovedTypedMsgs - An object of messages associated with the currently selected account, mapping a unique ID to the options.
* @property {number} unapprovedTypedMsgCount - The number of messages in unapprovedTypedMsgs.
* @property {string[]} keyringTypes - An array of unique keyring identifying strings, representing available strategies for creating accounts.
* @property {Keyring[]} keyrings - An array of keyring descriptions, summarizing the accounts that are available for use, and what keyrings they belong to.
* @property {Object} computedBalances - Maps accounts to their balances, accounting for balance changes from pending transactions.
* @property {string} currentAccountTab - A view identifying string for displaying the current displayed view, allows user to have a preferred tab in the old UI (between tokens and history).
* @property {string} selectedAddress - A lower case hex string of the currently selected address.
* @property {string} currentCurrency - A string identifying the user's preferred display currency, for use in showing conversion rates.
* @property {number} conversionRate - A number representing the current exchange rate from the user's preferred currency to Ether.
* @property {number} conversionDate - A unix epoch date (ms) for the time the current conversion rate was last retrieved.
* @property {Object} infuraNetworkStatus - An object of infura network status checks.
* @property {Block[]} recentBlocks - An array of recent blocks, used to calculate an effective but cheap gas price.
* @property {Array} shapeShiftTxList - An array of objects describing shapeshift exchange attempts.
* @property {Array} lostAccounts - TODO: Remove this feature. A leftover from the version-3 migration where our seed-phrase library changed to fix a bug where some accounts were mis-generated, but we recovered the old accounts as "lost" instead of losing them.
* @property {boolean} forgottenPassword - Returns true if the user has initiated the password recovery screen, is recovering from seed phrase.
*/
/**
* @typedef VersionedData
* @property {MetaMaskState} data - The data emitted from MetaMask controller, or used to initialize it.
* @property {Number} version - The latest migration version that has been run.
*/
/**
* Initializes the MetaMask controller, and sets up all platform configuration.
* @returns {Promise} Setup complete.
*/
async function initialize () {
const initState = await loadStateFromPersistence()
const initLangCode = await getFirstPreferredLangCode()
@ -67,6 +160,11 @@ async function initialize () {
// State and Persistence
//
/**
* Loads any stored data, prioritizing the latest storage strategy.
* Migrates that data schema in case it was last loaded on an older version.
* @returns {Promise<MetaMaskState>} Last data emitted from previous instance of MetaMask.
*/
async function loadStateFromPersistence () {
// migrations
const migrator = new Migrator({ migrations })
@ -77,6 +175,38 @@ async function loadStateFromPersistence () {
diskStore.getState() ||
migrator.generateInitialState(firstTimeState)
// check if somehow state is empty
// this should never happen but new error reporting suggests that it has
// for a small number of users
// https://github.com/metamask/metamask-extension/issues/3919
if (versionedData && !versionedData.data) {
// try to recover from diskStore incase only localStore is bad
const diskStoreState = diskStore.getState()
if (diskStoreState && diskStoreState.data) {
// we were able to recover (though it might be old)
versionedData = diskStoreState
const vaultStructure = getObjStructure(versionedData)
raven.captureMessage('MetaMask - Empty vault found - recovered from diskStore', {
// "extra" key is required by Sentry
extra: { vaultStructure },
})
} else {
// unable to recover, clear state
versionedData = migrator.generateInitialState(firstTimeState)
raven.captureMessage('MetaMask - Empty vault found - unable to recover')
}
}
// report migration errors to sentry
migrator.on('error', (err) => {
// get vault structure without secrets
const vaultStructure = getObjStructure(versionedData)
raven.captureException(err, {
// "extra" key is required by Sentry
extra: { vaultStructure },
})
})
// migrate data
versionedData = await migrator.migrateData(versionedData)
if (!versionedData) {
@ -84,12 +214,29 @@ async function loadStateFromPersistence () {
}
// write to disk
if (localStore.isSupported) localStore.set(versionedData)
if (localStore.isSupported) {
localStore.set(versionedData)
} else {
// throw in setTimeout so as to not block boot
setTimeout(() => {
throw new Error('MetaMask - Localstore not supported')
})
}
// return just the data
return versionedData.data
}
/**
* Initializes the MetaMask Controller with any initial state and default language.
* Configures platform-specific error reporting strategy.
* Streams emitted state updates to platform-specific storage strategy.
* Creates platform listeners for new Dapps/Contexts, and sets up their data connections to the controller.
*
* @param {Object} initState - The initial state to start the controller with, matches the state that is emitted from the controller.
* @param {String} initLangCode - The region code for the language preferred by the current user.
* @returns {Promise} After setup is complete.
*/
function setupController (initState, initLangCode) {
//
// MetaMask Controller
@ -114,7 +261,11 @@ function setupController (initState, initLangCode) {
controller.txController.on(`tx:status-update`, (txId, status) => {
if (status !== 'failed') return
const txMeta = controller.txController.txStateManager.getTx(txId)
reportFailedTxToSentry({ raven, txMeta })
try {
reportFailedTxToSentry({ raven, txMeta })
} catch (e) {
console.error(e)
}
})
// setup state persistence
@ -122,18 +273,29 @@ function setupController (initState, initLangCode) {
asStream(controller.store),
debounce(1000),
storeTransform(versionifyData),
storeTransform(syncDataWithExtension),
storeTransform(persistData),
(error) => {
log.error('pump hit error', error)
log.error('MetaMask - Persistence pipeline failed', error)
}
)
/**
* Assigns the given state to the versioned object (with metadata), and returns that.
* @param {Object} state - The state object as emitted by the MetaMaskController.
* @returns {VersionedData} The state object wrapped in an object that includes a metadata key.
*/
function versionifyData (state) {
versionedData.data = state
return versionedData
}
function syncDataWithExtension(state) {
function persistData (state) {
if (!state) {
throw new Error('MetaMask - updated state is missing', state)
}
if (!state.data) {
throw new Error('MetaMask - updated state does not have data', state)
}
if (localStore.isSupported) {
localStore.set(state)
.catch((err) => {
@ -146,30 +308,65 @@ function setupController (initState, initLangCode) {
//
// connect to other contexts
//
extension.runtime.onConnect.addListener(connectRemote)
const metamaskInternalProcessHash = {
[ENVIRONMENT_TYPE_POPUP]: true,
[ENVIRONMENT_TYPE_NOTIFICATION]: true,
[ENVIRONMENT_TYPE_FULLSCREEN]: true,
}
const isClientOpenStatus = () => {
return popupIsOpen || Boolean(Object.keys(openMetamaskTabsIDs).length) || notificationIsOpen
}
/**
* A runtime.Port object, as provided by the browser:
* @link https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/runtime/Port
* @typedef Port
* @type Object
*/
/**
* Connects a Port to the MetaMask controller via a multiplexed duplex stream.
* This method identifies trusted (MetaMask) interfaces, and connects them differently from untrusted (web pages).
* @param {Port} remotePort - The port provided by a new context.
*/
function connectRemote (remotePort) {
const isMetaMaskInternalProcess = remotePort.name === 'popup' || remotePort.name === 'notification'
const processName = remotePort.name
const isMetaMaskInternalProcess = metamaskInternalProcessHash[processName]
const portStream = new PortStream(remotePort)
if (isMetaMaskInternalProcess) {
// communication with popup
popupIsOpen = popupIsOpen || (remotePort.name === 'popup')
controller.isClientOpen = true
controller.setupTrustedCommunication(portStream, 'MetaMask')
// record popup as closed
if (remotePort.sender.url.match(/home.html$/)) {
openMetamaskTabsIDs[remotePort.sender.tab.id] = true
}
if (remotePort.name === 'popup') {
if (processName === ENVIRONMENT_TYPE_POPUP) {
popupIsOpen = true
endOfStream(portStream, () => {
popupIsOpen = false
if (remotePort.sender.url.match(/home.html$/)) {
openMetamaskTabsIDs[remotePort.sender.tab.id] = false
}
controller.isClientOpen = isClientOpenStatus()
})
}
if (remotePort.name === 'notification') {
if (processName === ENVIRONMENT_TYPE_NOTIFICATION) {
notificationIsOpen = true
endOfStream(portStream, () => {
notificationIsOpen = false
controller.isClientOpen = isClientOpenStatus()
})
}
if (processName === ENVIRONMENT_TYPE_FULLSCREEN) {
const tabId = remotePort.sender.tab.id
openMetamaskTabsIDs[tabId] = true
endOfStream(portStream, () => {
delete openMetamaskTabsIDs[tabId]
controller.isClientOpen = isClientOpenStatus()
})
}
} else {
@ -188,7 +385,10 @@ function setupController (initState, initLangCode) {
controller.messageManager.on('updateBadge', updateBadge)
controller.personalMessageManager.on('updateBadge', updateBadge)
// plugin badge text
/**
* Updates the Web Extension's "badge" number, on the little fox in the toolbar.
* The number reflects the current number of pending transactions or message signatures needing user approval.
*/
function updateBadge () {
var label = ''
var unapprovedTxCount = controller.txController.getUnapprovedTxCount()
@ -210,12 +410,15 @@ function setupController (initState, initLangCode) {
// Etc...
//
// popup trigger
/**
* Opens the browser popup for user confirmation
*/
function triggerUi () {
extension.tabs.query({ active: true }, (tabs) => {
const currentlyActiveMetamaskTab = tabs.find(tab => openMetamaskTabsIDs[tab.id])
if (!popupIsOpen && !currentlyActiveMetamaskTab && !notificationIsOpen) notificationManager.showPopup()
notificationIsOpen = true
extension.tabs.query({ active: true }, tabs => {
const currentlyActiveMetamaskTab = Boolean(tabs.find(tab => openMetamaskTabsIDs[tab.id]))
if (!popupIsOpen && !currentlyActiveMetamaskTab && !notificationIsOpen) {
notificationManager.showPopup()
}
})
}

@ -1,44 +0,0 @@
const MAINET_RPC_URL = 'https://mainnet.infura.io/metamask'
const ROPSTEN_RPC_URL = 'https://ropsten.infura.io/metamask'
const KOVAN_RPC_URL = 'https://kovan.infura.io/metamask'
const RINKEBY_RPC_URL = 'https://rinkeby.infura.io/metamask'
const LOCALHOST_RPC_URL = 'http://localhost:8545'
const MAINET_RPC_URL_BETA = 'https://mainnet.infura.io/metamask2'
const ROPSTEN_RPC_URL_BETA = 'https://ropsten.infura.io/metamask2'
const KOVAN_RPC_URL_BETA = 'https://kovan.infura.io/metamask2'
const RINKEBY_RPC_URL_BETA = 'https://rinkeby.infura.io/metamask2'
const DEFAULT_RPC = 'rinkeby'
const OLD_UI_NETWORK_TYPE = 'network'
const BETA_UI_NETWORK_TYPE = 'networkBeta'
global.METAMASK_DEBUG = process.env.METAMASK_DEBUG
module.exports = {
network: {
localhost: LOCALHOST_RPC_URL,
mainnet: MAINET_RPC_URL,
ropsten: ROPSTEN_RPC_URL,
kovan: KOVAN_RPC_URL,
rinkeby: RINKEBY_RPC_URL,
},
// Used for beta UI
networkBeta: {
localhost: LOCALHOST_RPC_URL,
mainnet: MAINET_RPC_URL_BETA,
ropsten: ROPSTEN_RPC_URL_BETA,
kovan: KOVAN_RPC_URL_BETA,
rinkeby: RINKEBY_RPC_URL_BETA,
},
networkNames: {
3: 'Ropsten',
4: 'Rinkeby',
42: 'Kovan',
},
enums: {
DEFAULT_RPC,
OLD_UI_NETWORK_TYPE,
BETA_UI_NETWORK_TYPE,
},
}

@ -23,6 +23,9 @@ if (shouldInjectWeb3()) {
setupStreams()
}
/**
* Creates a script tag that injects inpage.js
*/
function setupInjection () {
try {
// inject in-page script
@ -37,6 +40,10 @@ function setupInjection () {
}
}
/**
* Sets up two-way communication streams between the
* browser extension and local per-page browser context
*/
function setupStreams () {
// setup communication to page and plugin
const pageStream = new LocalMessageDuplexStream({
@ -89,17 +96,34 @@ function setupStreams () {
mux.ignoreStream('publicConfig')
}
/**
* Error handler for page to plugin stream disconnections
*
* @param {string} remoteLabel Remote stream name
* @param {Error} err Stream connection error
*/
function logStreamDisconnectWarning (remoteLabel, err) {
let warningMsg = `MetamaskContentscript - lost connection to ${remoteLabel}`
if (err) warningMsg += '\n' + err.stack
console.warn(warningMsg)
}
/**
* Determines if Web3 should be injected
*
* @returns {boolean} {@code true} if Web3 should be injected
*/
function shouldInjectWeb3 () {
return doctypeCheck() && suffixCheck()
&& documentElementCheck() && !blacklistedDomainCheck()
}
/**
* Checks the doctype of the current document if it exists
*
* @returns {boolean} {@code true} if the doctype is html or if none exists
*/
function doctypeCheck () {
const doctype = window.document.doctype
if (doctype) {
@ -109,6 +133,11 @@ function doctypeCheck () {
}
}
/**
* Checks the current document extension
*
* @returns {boolean} {@code true} if the current extension is not prohibited
*/
function suffixCheck () {
var prohibitedTypes = ['xml', 'pdf']
var currentUrl = window.location.href
@ -122,6 +151,11 @@ function suffixCheck () {
return true
}
/**
* Checks the documentElement of the current document
*
* @returns {boolean} {@code true} if the documentElement is an html node or if none exists
*/
function documentElementCheck () {
var documentElement = document.documentElement.nodeName
if (documentElement) {
@ -130,11 +164,17 @@ function documentElementCheck () {
return true
}
/**
* Checks if the current domain is blacklisted
*
* @returns {boolean} {@code true} if the current domain is blacklisted
*/
function blacklistedDomainCheck () {
var blacklistedDomains = [
'uscourts.gov',
'dropbox.com',
'webbyawards.com',
'cdn.shopify.com/s/javascripts/tricorder/xtld-read-only-frame.html',
]
var currentUrl = window.location.href
var currentRegex
@ -148,6 +188,9 @@ function blacklistedDomainCheck () {
return false
}
/**
* Redirects the current page to a phishing information page
*/
function redirectToPhishingWarning () {
console.log('MetaMask - redirecting to phishing warning')
window.location.href = 'https://metamask.io/phishing.html'

@ -4,9 +4,22 @@ const extend = require('xtend')
class AddressBookController {
// Controller in charge of managing the address book functionality from the
// recipients field on the send screen. Manages a history of all saved
// addresses and all currently owned addresses.
/**
* Controller in charge of managing the address book functionality from the
* recipients field on the send screen. Manages a history of all saved
* addresses and all currently owned addresses.
*
* @typedef {Object} AddressBookController
* @param {object} opts Overrides the defaults for the initial state of this.store
* @property {array} opts.initState initializes the the state of the AddressBookController. Can contain an
* addressBook property to initialize the addressBook array
* @param {KeyringController} keyringController (Soon to be deprecated) The keyringController used in the current
* MetamaskController. Contains the identities used in this AddressBookController.
* @property {object} store The the store of the current users address book
* @property {array} store.addressBook An array of addresses and nicknames. These are set by the user when sending
* to a new address.
*
*/
constructor (opts = {}, keyringController) {
const initState = extend({
addressBook: [],
@ -19,7 +32,14 @@ class AddressBookController {
// PUBLIC METHODS
//
// Sets a new address book in store by accepting a new address and nickname.
/**
* Sets a new address book in store by accepting a new address and nickname.
*
* @param {string} address A hex address of a new account that the user is sending to.
* @param {string} name The name the user wishes to associate with the new account
* @returns {Promise<void>} Promise resolves with undefined
*
*/
setAddressBook (address, name) {
return this._addToAddressBook(address, name)
.then((addressBook) => {
@ -30,14 +50,16 @@ class AddressBookController {
})
}
//
// PRIVATE METHODS
//
// Performs the logic to add the address and name into the address book. The
// pushed object is an object of two fields. Current behavior does not set an
// upper limit to the number of addresses.
/**
* Performs the logic to add the address and name into the address book. The pushed object is an object of two
* fields. Current behavior does not set an upper limit to the number of addresses.
*
* @private
* @param {string} address A hex address of a new account that the user is sending to.
* @param {string} name The name the user wishes to associate with the new account
* @returns {Promise<array>} Promises the updated addressBook array
*
*/
_addToAddressBook (address, name) {
const addressBook = this._getAddressBook()
const identities = this._getIdentities()
@ -62,14 +84,26 @@ class AddressBookController {
return Promise.resolve(addressBook)
}
// Internal method to get the address book. Current persistence behavior
// should not require that this method be called from the UI directly.
/**
* Internal method to get the address book. Current persistence behavior should not require that this method be
* called from the UI directly.
*
* @private
* @returns {array} The addressBook array from the store.
*
*/
_getAddressBook () {
return this.store.getState().addressBook
}
// Retrieves identities from the keyring controller in order to avoid
// duplication
/**
* Retrieves identities from the keyring controller in order to avoid
* duplication
*
* @deprecated
* @returns {array} Returns the identies array from the keyringContoller's state
*
*/
_getIdentities () {
return this.keyringController.memStore.getState().identities
}

@ -4,6 +4,24 @@ const BN = require('ethereumjs-util').BN
class BalanceController {
/**
* Controller responsible for storing and updating an account's balance.
*
* @typedef {Object} BalanceController
* @param {Object} opts Initialize various properties of the class.
* @property {string} address A base 16 hex string. The account address which has the balance managed by this
* BalanceController.
* @property {AccountTracker} accountTracker Stores and updates the users accounts
* for which this BalanceController manages balance.
* @property {TransactionController} txController Stores, tracks and manages transactions. Here used to create a listener for
* transaction updates.
* @property {BlockTracker} blockTracker Tracks updates to blocks. On new blocks, this BalanceController updates its balance
* @property {Object} store The store for the ethBalance
* @property {string} store.ethBalance A base 16 hex string. The balance for the current account.
* @property {PendingBalanceCalculator} balanceCalc Used to calculate the accounts balance with possible pending
* transaction costs taken into account.
*
*/
constructor (opts = {}) {
this._validateParams(opts)
const { address, accountTracker, txController, blockTracker } = opts
@ -26,6 +44,11 @@ class BalanceController {
this._registerUpdates()
}
/**
* Updates the ethBalance property to the current pending balance
*
* @returns {Promise<void>} Promises undefined
*/
async updateBalance () {
const balance = await this.balanceCalc.getBalance()
this.store.updateState({
@ -33,6 +56,15 @@ class BalanceController {
})
}
/**
* Sets up listeners and subscriptions which should trigger an update of ethBalance. These updates include:
* - when a transaction changes state to 'submitted', 'confirmed' or 'failed'
* - when the current account changes (i.e. a new account is selected)
* - when there is a block update
*
* @private
*
*/
_registerUpdates () {
const update = this.updateBalance.bind(this)
@ -51,6 +83,14 @@ class BalanceController {
this.blockTracker.on('block', update)
}
/**
* Gets the balance, as a base 16 hex string, of the account at this BalanceController's current address.
* If the current account has no balance, returns undefined.
*
* @returns {Promise<BN|void>} Promises a BN with a value equal to the balance of the current account, or undefined
* if the current account has no balance
*
*/
async _getBalance () {
const { accounts } = this.accountTracker.store.getState()
const entry = accounts[this.address]
@ -58,6 +98,14 @@ class BalanceController {
return balance ? new BN(balance.substring(2), 16) : undefined
}
/**
* Gets the pending transactions (i.e. those with a 'submitted' status). These are accessed from the
* TransactionController passed to this BalanceController during construction.
*
* @private
* @returns {Promise<array>} Promises an array of transaction objects.
*
*/
async _getPendingTransactions () {
const pending = this.txController.getFilteredTxList({
from: this.address,
@ -67,6 +115,14 @@ class BalanceController {
return pending
}
/**
* Validates that the passed options have all required properties.
*
* @param {Object} opts The options object to validate
* @throws {string} Throw a custom error indicating that address, accountTracker, txController and blockTracker are
* missing and at least one is required
*
*/
_validateParams (opts) {
const { address, accountTracker, txController, blockTracker } = opts
if (!address || !accountTracker || !txController || !blockTracker) {

@ -1,6 +1,7 @@
const ObservableStore = require('obs-store')
const extend = require('xtend')
const PhishingDetector = require('eth-phishing-detect/src/detector')
const log = require('loglevel')
// compute phishing lists
const PHISHING_DETECTION_CONFIG = require('eth-phishing-detect/src/config.json')
@ -9,6 +10,22 @@ const POLLING_INTERVAL = 4 * 60 * 1000
class BlacklistController {
/**
* Responsible for polling for and storing an up to date 'eth-phishing-detect' config.json file, while
* exposing a method that can check whether a given url is a phishing attempt. The 'eth-phishing-detect'
* config.json file contains a fuzzylist, whitelist and blacklist.
*
*
* @typedef {Object} BlacklistController
* @param {object} opts Overrides the defaults for the initial state of this.store
* @property {object} store The the store of the current phishing config
* @property {object} store.phishing Contains fuzzylist, whitelist and blacklist arrays. @see
* {@link https://github.com/MetaMask/eth-phishing-detect/blob/master/src/config.json}
* @property {object} _phishingDetector The PhishingDetector instantiated by passing store.phishing to
* PhishingDetector.
* @property {object} _phishingUpdateIntervalRef Id of the interval created to periodically update the blacklist
*
*/
constructor (opts = {}) {
const initState = extend({
phishing: PHISHING_DETECTION_CONFIG,
@ -21,16 +38,28 @@ class BlacklistController {
this._phishingUpdateIntervalRef = null
}
//
// PUBLIC METHODS
//
/**
* Given a url, returns the result of checking if that url is in the store.phishing blacklist
*
* @param {string} hostname The hostname portion of a url; the one that will be checked against the white and
* blacklists of store.phishing
* @returns {boolean} Whether or not the passed hostname is on our phishing blacklist
*
*/
checkForPhishing (hostname) {
if (!hostname) return false
const { result } = this._phishingDetector.check(hostname)
return result
}
/**
* Queries `https://api.infura.io/v2/blacklist` for an updated blacklist config. This is passed to this._phishingDetector
* to update our phishing detector instance, and is updated in the store. The new phishing config is returned
*
*
* @returns {Promise<object>} Promises the updated blacklist config for the phishingDetector
*
*/
async updatePhishingList () {
const response = await fetch('https://api.infura.io/v2/blacklist')
const phishing = await response.json()
@ -39,6 +68,11 @@ class BlacklistController {
return phishing
}
/**
* Initiates the updating of the local blacklist at a set interval. The update is done via this.updatePhishingList().
* Also, this method store a reference to that interval at this._phishingUpdateIntervalRef
*
*/
scheduleUpdates () {
if (this._phishingUpdateIntervalRef) return
this.updatePhishingList().catch(log.warn)
@ -47,10 +81,14 @@ class BlacklistController {
}, POLLING_INTERVAL)
}
//
// PRIVATE METHODS
//
/**
* Sets this._phishingDetector to a new PhishingDetector instance.
* @see {@link https://github.com/MetaMask/eth-phishing-detect}
*
* @private
* @param {object} config A config object like that found at {@link https://github.com/MetaMask/eth-phishing-detect/blob/master/src/config.json}
*
*/
_setupPhishingDetector (config) {
this._phishingDetector = new PhishingDetector(config)
}

@ -2,8 +2,24 @@ const ObservableStore = require('obs-store')
const extend = require('xtend')
const BalanceController = require('./balance')
class ComputedbalancesController {
/**
* @typedef {Object} ComputedBalancesOptions
* @property {Object} accountTracker Account tracker store reference
* @property {Object} txController Token controller reference
* @property {Object} blockTracker Block tracker reference
* @property {Object} initState Initial state to populate this internal store with
*/
/**
* Background controller responsible for syncing
* and computing ETH balances for all accounts
*/
class ComputedbalancesController {
/**
* Creates a new controller instance
*
* @param {ComputedBalancesOptions} [opts] Controller configuration parameters
*/
constructor (opts = {}) {
const { accountTracker, txController, blockTracker } = opts
this.accountTracker = accountTracker
@ -19,6 +35,9 @@ class ComputedbalancesController {
this._initBalanceUpdating()
}
/**
* Updates balances associated with each internal address
*/
updateAllBalances () {
Object.keys(this.balances).forEach((balance) => {
const address = balance.address
@ -26,12 +45,23 @@ class ComputedbalancesController {
})
}
/**
* Initializes internal address tracking
*
* @private
*/
_initBalanceUpdating () {
const store = this.accountTracker.store.getState()
this.syncAllAccountsFromStore(store)
this.accountTracker.store.subscribe(this.syncAllAccountsFromStore.bind(this))
}
/**
* Uses current account state to sync and track all
* addresses associated with the current account
*
* @param {{ accounts: Object }} store Account tracking state
*/
syncAllAccountsFromStore (store) {
const upstream = Object.keys(store.accounts)
const balances = Object.keys(this.balances)
@ -50,6 +80,13 @@ class ComputedbalancesController {
})
}
/**
* Conditionally establishes a new subscription
* to track an address associated with the current
* account
*
* @param {string} address Address to conditionally subscribe to
*/
trackAddressIfNotAlready (address) {
const state = this.store.getState()
if (!(address in state.computedBalances)) {
@ -57,6 +94,12 @@ class ComputedbalancesController {
}
}
/**
* Establishes a new subscription to track an
* address associated with the current account
*
* @param {string} address Address to conditionally subscribe to
*/
trackAddress (address) {
const updater = new BalanceController({
address,

@ -1,11 +1,28 @@
const ObservableStore = require('obs-store')
const ObservableStore = require('obs-store')
const extend = require('xtend')
const log = require('loglevel')
// every ten minutes
const POLLING_INTERVAL = 600000
class CurrencyController {
/**
* Controller responsible for managing data associated with the currently selected currency.
*
* @typedef {Object} CurrencyController
* @param {object} opts Overrides the defaults for the initial state of this.store
* @property {array} opts.initState initializes the the state of the CurrencyController. Can contain an
* currentCurrency, conversionRate and conversionDate properties
* @property {string} currentCurrency A 2-4 character shorthand that describes a specific currency, currently
* selected by the user
* @property {number} conversionRate The conversion rate from ETH to the selected currency.
* @property {string} conversionDate The date at which the conversion rate was set. Expressed in in milliseconds
* since midnight of January 1, 1970
* @property {number} conversionInterval The id of the interval created by the scheduleConversionInterval method.
* Used to clear an existing interval on subsequent calls of that method.
*
*/
constructor (opts = {}) {
const initState = extend({
currentCurrency: 'usd',
@ -19,30 +36,73 @@ class CurrencyController {
// PUBLIC METHODS
//
/**
* A getter for the currentCurrency property
*
* @returns {string} A 2-4 character shorthand that describes a specific currency, currently selected by the user
*
*/
getCurrentCurrency () {
return this.store.getState().currentCurrency
}
/**
* A setter for the currentCurrency property
*
* @param {string} currentCurrency The new currency to set as the currentCurrency in the store
*
*/
setCurrentCurrency (currentCurrency) {
this.store.updateState({ currentCurrency })
}
/**
* A getter for the conversionRate property
*
* @returns {string} The conversion rate from ETH to the selected currency.
*
*/
getConversionRate () {
return this.store.getState().conversionRate
}
/**
* A setter for the conversionRate property
*
* @param {number} conversionRate The new rate to set as the conversionRate in the store
*
*/
setConversionRate (conversionRate) {
this.store.updateState({ conversionRate })
}
/**
* A getter for the conversionDate property
*
* @returns {string} The date at which the conversion rate was set. Expressed in milliseconds since midnight of
* January 1, 1970
*
*/
getConversionDate () {
return this.store.getState().conversionDate
}
/**
* A setter for the conversionDate property
*
* @param {number} conversionDate The date, expressed in milliseconds since midnight of January 1, 1970, that the
* conversionRate was set
*
*/
setConversionDate (conversionDate) {
this.store.updateState({ conversionDate })
}
/**
* Updates the conversionRate and conversionDate properties associated with the currentCurrency. Updated info is
* fetched from an external API
*
*/
async updateConversionRate () {
let currentCurrency
try {
@ -58,6 +118,12 @@ class CurrencyController {
}
}
/**
* Creates a new poll, using setInterval, to periodically call updateConversionRate. The id of the interval is
* stored at the controller's conversionInterval property. If it is called and such an id already exists, the
* previous interval is clear and a new one is created.
*
*/
scheduleConversionInterval () {
if (this.conversionInterval) {
clearInterval(this.conversionInterval)

@ -1,5 +1,6 @@
const ObservableStore = require('obs-store')
const extend = require('xtend')
const log = require('loglevel')
// every ten minutes
const POLLING_INTERVAL = 10 * 60 * 1000

@ -0,0 +1,56 @@
const ROPSTEN = 'ropsten'
const RINKEBY = 'rinkeby'
const KOVAN = 'kovan'
const MAINNET = 'mainnet'
const LOCALHOST = 'localhost'
const ROPSTEN_CODE = 3
const RINKEYBY_CODE = 4
const KOVAN_CODE = 42
const ROPSTEN_DISPLAY_NAME = 'Ropsten'
const RINKEBY_DISPLAY_NAME = 'Rinkeby'
const KOVAN_DISPLAY_NAME = 'Kovan'
const MAINNET_DISPLAY_NAME = 'Main Ethereum Network'
const MAINNET_RPC_URL = 'https://mainnet.infura.io/metamask'
const ROPSTEN_RPC_URL = 'https://ropsten.infura.io/metamask'
const KOVAN_RPC_URL = 'https://kovan.infura.io/metamask'
const RINKEBY_RPC_URL = 'https://rinkeby.infura.io/metamask'
const LOCALHOST_RPC_URL = 'http://localhost:8545'
const MAINNET_RPC_URL_BETA = 'https://mainnet.infura.io/metamask2'
const ROPSTEN_RPC_URL_BETA = 'https://ropsten.infura.io/metamask2'
const KOVAN_RPC_URL_BETA = 'https://kovan.infura.io/metamask2'
const RINKEBY_RPC_URL_BETA = 'https://rinkeby.infura.io/metamask2'
const DEFAULT_NETWORK = 'rinkeby'
const OLD_UI_NETWORK_TYPE = 'network'
const BETA_UI_NETWORK_TYPE = 'networkBeta'
module.exports = {
ROPSTEN,
RINKEBY,
KOVAN,
MAINNET,
LOCALHOST,
ROPSTEN_CODE,
RINKEYBY_CODE,
KOVAN_CODE,
ROPSTEN_DISPLAY_NAME,
RINKEBY_DISPLAY_NAME,
KOVAN_DISPLAY_NAME,
MAINNET_DISPLAY_NAME,
MAINNET_RPC_URL,
ROPSTEN_RPC_URL,
KOVAN_RPC_URL,
RINKEBY_RPC_URL,
LOCALHOST_RPC_URL,
MAINNET_RPC_URL_BETA,
ROPSTEN_RPC_URL_BETA,
KOVAN_RPC_URL_BETA,
RINKEBY_RPC_URL_BETA,
DEFAULT_NETWORK,
OLD_UI_NETWORK_TYPE,
BETA_UI_NETWORK_TYPE,
}

@ -0,0 +1,2 @@
const NetworkController = require('./network')
module.exports = NetworkController

@ -1,16 +1,24 @@
const assert = require('assert')
const EventEmitter = require('events')
const createMetamaskProvider = require('web3-provider-engine/zero.js')
const SubproviderFromProvider = require('web3-provider-engine/subproviders/web3.js')
const SubproviderFromProvider = require('web3-provider-engine/subproviders/provider.js')
const createInfuraProvider = require('eth-json-rpc-infura/src/createProvider')
const ObservableStore = require('obs-store')
const ComposedStore = require('obs-store/lib/composed')
const extend = require('xtend')
const EthQuery = require('eth-query')
const createEventEmitterProxy = require('../lib/events-proxy.js')
const networkConfig = require('../config.js')
const { OLD_UI_NETWORK_TYPE, DEFAULT_RPC } = networkConfig.enums
const INFURA_PROVIDER_TYPES = ['ropsten', 'rinkeby', 'kovan', 'mainnet']
const createEventEmitterProxy = require('../../lib/events-proxy.js')
const log = require('loglevel')
const {
ROPSTEN,
RINKEBY,
KOVAN,
MAINNET,
OLD_UI_NETWORK_TYPE,
DEFAULT_NETWORK,
} = require('./enums')
const { getNetworkEndpoints } = require('./util')
const INFURA_PROVIDER_TYPES = [ROPSTEN, RINKEBY, KOVAN, MAINNET]
module.exports = class NetworkController extends EventEmitter {
@ -18,8 +26,8 @@ module.exports = class NetworkController extends EventEmitter {
super()
this._networkEndpointVersion = OLD_UI_NETWORK_TYPE
this._networkEndpoints = this.getNetworkEndpoints(OLD_UI_NETWORK_TYPE)
this._defaultRpc = this._networkEndpoints[DEFAULT_RPC]
this._networkEndpoints = getNetworkEndpoints(OLD_UI_NETWORK_TYPE)
this._defaultRpc = this._networkEndpoints[DEFAULT_NETWORK]
config.provider.rpcTarget = this.getRpcAddressForType(config.provider.type, config.provider)
this.networkStore = new ObservableStore('loading')
@ -36,17 +44,13 @@ module.exports = class NetworkController extends EventEmitter {
}
this._networkEndpointVersion = version
this._networkEndpoints = this.getNetworkEndpoints(version)
this._defaultRpc = this._networkEndpoints[DEFAULT_RPC]
this._networkEndpoints = getNetworkEndpoints(version)
this._defaultRpc = this._networkEndpoints[DEFAULT_NETWORK]
const { type } = this.getProviderConfig()
return this.setProviderType(type, true)
}
getNetworkEndpoints (version = OLD_UI_NETWORK_TYPE) {
return networkConfig[version]
}
initializeProvider (_providerParams) {
this._baseProviderParams = _providerParams
const { type, rpcTarget } = this.providerStore.getState()

@ -0,0 +1,65 @@
const {
ROPSTEN,
RINKEBY,
KOVAN,
MAINNET,
LOCALHOST,
ROPSTEN_CODE,
RINKEYBY_CODE,
KOVAN_CODE,
ROPSTEN_DISPLAY_NAME,
RINKEBY_DISPLAY_NAME,
KOVAN_DISPLAY_NAME,
MAINNET_DISPLAY_NAME,
MAINNET_RPC_URL,
ROPSTEN_RPC_URL,
KOVAN_RPC_URL,
RINKEBY_RPC_URL,
LOCALHOST_RPC_URL,
MAINNET_RPC_URL_BETA,
ROPSTEN_RPC_URL_BETA,
KOVAN_RPC_URL_BETA,
RINKEBY_RPC_URL_BETA,
OLD_UI_NETWORK_TYPE,
BETA_UI_NETWORK_TYPE,
} = require('./enums')
const networkToNameMap = {
[ROPSTEN]: ROPSTEN_DISPLAY_NAME,
[RINKEBY]: RINKEBY_DISPLAY_NAME,
[KOVAN]: KOVAN_DISPLAY_NAME,
[MAINNET]: MAINNET_DISPLAY_NAME,
[ROPSTEN_CODE]: ROPSTEN_DISPLAY_NAME,
[RINKEYBY_CODE]: RINKEBY_DISPLAY_NAME,
[KOVAN_CODE]: KOVAN_DISPLAY_NAME,
}
const networkEndpointsMap = {
[OLD_UI_NETWORK_TYPE]: {
[LOCALHOST]: LOCALHOST_RPC_URL,
[MAINNET]: MAINNET_RPC_URL,
[ROPSTEN]: ROPSTEN_RPC_URL,
[KOVAN]: KOVAN_RPC_URL,
[RINKEBY]: RINKEBY_RPC_URL,
},
[BETA_UI_NETWORK_TYPE]: {
[LOCALHOST]: LOCALHOST_RPC_URL,
[MAINNET]: MAINNET_RPC_URL_BETA,
[ROPSTEN]: ROPSTEN_RPC_URL_BETA,
[KOVAN]: KOVAN_RPC_URL_BETA,
[RINKEBY]: RINKEBY_RPC_URL_BETA,
},
}
const getNetworkDisplayName = key => networkToNameMap[key]
const getNetworkEndpoints = (networkType = OLD_UI_NETWORK_TYPE) => {
return {
...networkEndpointsMap[networkType],
}
}
module.exports = {
getNetworkDisplayName,
getNetworkEndpoints,
}

@ -4,6 +4,21 @@ const extend = require('xtend')
class PreferencesController {
/**
*
* @typedef {Object} PreferencesController
* @param {object} opts Overrides the defaults for the initial state of this.store
* @property {object} store The stored object containing a users preferences, stored in local storage
* @property {array} store.frequentRpcList A list of custom rpcs to provide the user
* @property {string} store.currentAccountTab Indicates the selected tab in the ui
* @property {array} store.tokens The tokens the user wants display in their token lists
* @property {boolean} store.useBlockie The users preference for blockie identicons within the UI
* @property {object} store.featureFlags A key-boolean map, where keys refer to features and booleans to whether the
* user wishes to see that feature
* @property {string} store.currentLocale The preferred language locale key
* @property {string} store.selectedAddress A hex string that matches the currently selected address in the app
*
*/
constructor (opts = {}) {
const initState = extend({
frequentRpcList: [],
@ -17,18 +32,43 @@ class PreferencesController {
}
// PUBLIC METHODS
/**
* Setter for the `useBlockie` property
*
* @param {boolean} val Whether or not the user prefers blockie indicators
*
*/
setUseBlockie (val) {
this.store.updateState({ useBlockie: val })
}
/**
* Getter for the `useBlockie` property
*
* @returns {boolean} this.store.useBlockie
*
*/
getUseBlockie () {
return this.store.getState().useBlockie
}
/**
* Setter for the `currentLocale` property
*
* @param {string} key he preferred language locale key
*
*/
setCurrentLocale (key) {
this.store.updateState({ currentLocale: key })
}
/**
* Setter for the `selectedAddress` property
*
* @param {string} _address A new hex address for an account
* @returns {Promise<void>} Promise resolves with undefined
*
*/
setSelectedAddress (_address) {
return new Promise((resolve, reject) => {
const address = normalizeAddress(_address)
@ -37,10 +77,37 @@ class PreferencesController {
})
}
/**
* Getter for the `selectedAddress` property
*
* @returns {string} The hex address for the currently selected account
*
*/
getSelectedAddress () {
return this.store.getState().selectedAddress
}
/**
* Contains data about tokens users add to their account.
* @typedef {Object} AddedToken
* @property {string} address - The hex address for the token contract. Will be all lower cased and hex-prefixed.
* @property {string} symbol - The symbol of the token, usually 3 or 4 capitalized letters
* {@link https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md#symbol}
* @property {boolean} decimals - The number of decimals the token uses.
* {@link https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md#decimals}
*/
/**
* Adds a new token to the token array, or updates the token if passed an address that already exists.
* Modifies the existing tokens array from the store. All objects in the tokens array array AddedToken objects.
* @see AddedToken {@link AddedToken}
*
* @param {string} rawAddress Hex address of the token contract. May or may not be a checksum address.
* @param {string} symbol The symbol of the token
* @param {number} decimals The number of decimals the token uses.
* @returns {Promise<array>} Promises the new array of AddedToken objects.
*
*/
async addToken (rawAddress, symbol, decimals) {
const address = normalizeAddress(rawAddress)
const newEntry = { address, symbol, decimals }
@ -62,6 +129,13 @@ class PreferencesController {
return Promise.resolve(tokens)
}
/**
* Removes a specified token from the tokens array.
*
* @param {string} rawAddress Hex address of the token contract to remove.
* @returns {Promise<array>} The new array of AddedToken objects
*
*/
removeToken (rawAddress) {
const tokens = this.store.getState().tokens
@ -71,10 +145,23 @@ class PreferencesController {
return Promise.resolve(updatedTokens)
}
/**
* A getter for the `tokens` property
*
* @returns {array} The current array of AddedToken objects
*
*/
getTokens () {
return this.store.getState().tokens
}
/**
* Gets an updated rpc list from this.addToFrequentRpcList() and sets the `frequentRpcList` to this update list.
*
* @param {string} _url The the new rpc url to add to the updated list
* @returns {Promise<void>} Promise resolves with undefined
*
*/
updateFrequentRpcList (_url) {
return this.addToFrequentRpcList(_url)
.then((rpcList) => {
@ -83,6 +170,13 @@ class PreferencesController {
})
}
/**
* Setter for the `currentAccountTab` property
*
* @param {string} currentAccountTab Specifies the new tab to be marked as current
* @returns {Promise<void>} Promise resolves with undefined
*
*/
setCurrentAccountTab (currentAccountTab) {
return new Promise((resolve, reject) => {
this.store.updateState({ currentAccountTab })
@ -90,6 +184,15 @@ class PreferencesController {
})
}
/**
* Returns an updated rpcList based on the passed url and the current list.
* The returned list will have a max length of 2. If the _url currently exists it the list, it will be moved to the
* end of the list. The current list is modified and returned as a promise.
*
* @param {string} _url The rpc url to add to the frequentRpcList.
* @returns {Promise<array>} The updated frequentRpcList.
*
*/
addToFrequentRpcList (_url) {
const rpcList = this.getFrequentRpcList()
const index = rpcList.findIndex((element) => { return element === _url })
@ -105,10 +208,24 @@ class PreferencesController {
return Promise.resolve(rpcList)
}
/**
* Getter for the `frequentRpcList` property.
*
* @returns {array<string>} An array of one or two rpc urls.
*
*/
getFrequentRpcList () {
return this.store.getState().frequentRpcList
}
/**
* Updates the `featureFlags` property, which is an object. One property within that object will be set to a boolean.
*
* @param {string} feature A key that corresponds to a UI feature.
* @param {boolean} activated Indicates whether or not the UI feature should be displayed
* @returns {Promise<object>} Promises a new object; the updated featureFlags object.
*
*/
setFeatureFlag (feature, activated) {
const currentFeatureFlags = this.store.getState().featureFlags
const updatedFeatureFlags = {
@ -121,6 +238,13 @@ class PreferencesController {
return Promise.resolve(updatedFeatureFlags)
}
/**
* A getter for the `featureFlags` property
*
* @returns {object} A key-boolean map, where keys refer to features and booleans to whether the
* user wishes to see that feature
*
*/
getFeatureFlags () {
return this.store.getState().featureFlags
}

@ -2,9 +2,27 @@ const ObservableStore = require('obs-store')
const extend = require('xtend')
const BN = require('ethereumjs-util').BN
const EthQuery = require('eth-query')
const log = require('loglevel')
class RecentBlocksController {
/**
* Controller responsible for storing, updating and managing the recent history of blocks. Blocks are back filled
* upon the controller's construction and then the list is updated when the given block tracker gets a 'block' event
* (indicating that there is a new block to process).
*
* @typedef {Object} RecentBlocksController
* @param {object} opts Contains objects necessary for tracking blocks and querying the blockchain
* @param {BlockTracker} opts.blockTracker Contains objects necessary for tracking blocks and querying the blockchain
* @param {BlockTracker} opts.provider The provider used to create a new EthQuery instance.
* @property {BlockTracker} blockTracker Points to the passed BlockTracker. On RecentBlocksController construction,
* listens for 'block' events so that new blocks can be processed and added to storage.
* @property {EthQuery} ethQuery Points to the EthQuery instance created with the passed provider
* @property {number} historyLength The maximum length of blocks to track
* @property {object} store Stores the recentBlocks
* @property {array} store.recentBlocks Contains all recent blocks, up to a total that is equal to this.historyLength
*
*/
constructor (opts = {}) {
const { blockTracker, provider } = opts
this.blockTracker = blockTracker
@ -20,12 +38,23 @@ class RecentBlocksController {
this.backfill()
}
/**
* Sets store.recentBlocks to an empty array
*
*/
resetState () {
this.store.updateState({
recentBlocks: [],
})
}
/**
* Receives a new block and modifies it with this.mapTransactionsToPrices. Then adds that block to the recentBlocks
* array in storage. If the recentBlocks array contains the maximum number of blocks, the oldest block is removed.
*
* @param {object} newBlock The new block to modify and add to the recentBlocks array
*
*/
processBlock (newBlock) {
const block = this.mapTransactionsToPrices(newBlock)
@ -39,6 +68,15 @@ class RecentBlocksController {
this.store.updateState(state)
}
/**
* Receives a new block and modifies it with this.mapTransactionsToPrices. Adds that block to the recentBlocks
* array in storage, but only if the recentBlocks array contains fewer than the maximum permitted.
*
* Unlike this.processBlock, backfillBlock adds the modified new block to the beginning of the recent block array.
*
* @param {object} newBlock The new block to modify and add to the beginning of the recentBlocks array
*
*/
backfillBlock (newBlock) {
const block = this.mapTransactionsToPrices(newBlock)
@ -51,6 +89,14 @@ class RecentBlocksController {
this.store.updateState(state)
}
/**
* Receives a block and gets the gasPrice of each of its transactions. These gas prices are added to the block at a
* new property, and the block's transactions are removed.
*
* @param {object} newBlock The block to modify. It's transaction array will be replaced by a gasPrices array.
* @returns {object} The modified block.
*
*/
mapTransactionsToPrices (newBlock) {
const block = extend(newBlock, {
gasPrices: newBlock.transactions.map((tx) => {
@ -61,6 +107,16 @@ class RecentBlocksController {
return block
}
/**
* On this.blockTracker's first 'block' event after this RecentBlocksController's instantiation, the store.recentBlocks
* array is populated with this.historyLength number of blocks. The block number of the this.blockTracker's first
* 'block' event is used to iteratively generate all the numbers of the previous blocks, which are obtained by querying
* the blockchain. These blocks are backfilled so that the recentBlocks array is ordered from oldest to newest.
*
* Each iteration over the block numbers is delayed by 100 milliseconds.
*
* @returns {Promise<void>} Promises undefined
*/
async backfill() {
this.blockTracker.once('block', async (block) => {
let blockNum = block.number
@ -89,12 +145,25 @@ class RecentBlocksController {
})
}
/**
* A helper for this.backfill. Provides an easy way to ensure a 100 millisecond delay using await
*
* @returns {Promise<void>} Promises undefined
*
*/
async wait () {
return new Promise((resolve) => {
setTimeout(resolve, 100)
})
}
/**
* Uses EthQuery to get a block that has a given block number.
*
* @param {number} number The number of the block to get
* @returns {Promise<object>} Promises A block with the passed number
*
*/
async getBlockByNumber (number) {
const bn = new BN(number)
return new Promise((resolve, reject) => {

@ -1,11 +1,23 @@
const ObservableStore = require('obs-store')
const extend = require('xtend')
const log = require('loglevel')
// every three seconds when an incomplete tx is waiting
const POLLING_INTERVAL = 3000
class ShapeshiftController {
/**
* Controller responsible for managing the list of shapeshift transactions. On construction, it initiates a poll
* that queries a shapeshift.io API for updates to any pending shapeshift transactions
*
* @typedef {Object} ShapeshiftController
* @param {object} opts Overrides the defaults for the initial state of this.store
* @property {array} opts.initState initializes the the state of the ShapeshiftController. Can contain an
* shapeShiftTxList array.
* @property {array} shapeShiftTxList An array of ShapeShiftTx objects
*
*/
constructor (opts = {}) {
const initState = extend({
shapeShiftTxList: [],
@ -14,21 +26,54 @@ class ShapeshiftController {
this.pollForUpdates()
}
/**
* Represents, and contains data about, a single shapeshift transaction.
* @typedef {Object} ShapeShiftTx
* @property {string} depositAddress - An address at which to send a crypto deposit, so that eth can be sent to the
* user's Metamask account
* @property {string} depositType - An abbreviation of the type of crypto currency to be deposited.
* @property {string} key - The 'shapeshift' key differentiates this from other types of txs in Metamask
* @property {number} time - The time at which the tx was created
* @property {object} response - Initiated as an empty object, which will be replaced by a Response object. @see {@link
* https://developer.mozilla.org/en-US/docs/Web/API/Response}
*/
//
// PUBLIC METHODS
//
/**
* A getter for the shapeShiftTxList property
*
* @returns {array<ShapeShiftTx>}
*
*/
getShapeShiftTxList () {
const shapeShiftTxList = this.store.getState().shapeShiftTxList
return shapeShiftTxList
}
/**
* A getter for all ShapeShiftTx in the shapeShiftTxList that have not successfully completed a deposit.
*
* @returns {array<ShapeShiftTx>} Only includes ShapeShiftTx which has a response property with a status !== complete
*
*/
getPendingTxs () {
const txs = this.getShapeShiftTxList()
const pending = txs.filter(tx => tx.response && tx.response.status !== 'complete')
return pending
}
/**
* A poll that exists as long as there are pending transactions. Each call attempts to update the data of any
* pendingTxs, and then calls itself again. If there are no pending txs, the recursive call is not made and
* the polling stops.
*
* this.updateTx is used to attempt the update to the pendingTxs in the ShapeShiftTxList, and that updated data
* is saved with saveTx.
*
*/
pollForUpdates () {
const pendingTxs = this.getPendingTxs()
@ -45,6 +90,15 @@ class ShapeshiftController {
})
}
/**
* Attempts to update a ShapeShiftTx with data from a shapeshift.io API. Both the response and time properties
* can be updated. The response property is updated with every call, but the time property is only updated when
* the response status updates to 'complete'. This will occur once the user makes a deposit as the ShapeShiftTx
* depositAddress
*
* @param {ShapeShiftTx} tx The tx to update
*
*/
async updateTx (tx) {
try {
const url = `https://shapeshift.io/txStat/${tx.depositAddress}`
@ -60,6 +114,13 @@ class ShapeshiftController {
}
}
/**
* Saves an updated to a ShapeShiftTx in the shapeShiftTxList. If the passed ShapeShiftTx is not in the
* shapeShiftTxList, nothing happens.
*
* @param {ShapeShiftTx} tx The updated tx to save, if it exists in the current shapeShiftTxList
*
*/
saveTx (tx) {
const { shapeShiftTxList } = this.store.getState()
const index = shapeShiftTxList.indexOf(tx)
@ -69,6 +130,12 @@ class ShapeshiftController {
}
}
/**
* Removes a ShapeShiftTx from the shapeShiftTxList
*
* @param {ShapeShiftTx} tx The tx to remove
*
*/
removeShapeShiftTx (tx) {
const { shapeShiftTxList } = this.store.getState()
const index = shapeShiftTxList.indexOf(index)
@ -78,6 +145,14 @@ class ShapeshiftController {
this.updateState({ shapeShiftTxList })
}
/**
* Creates a new ShapeShiftTx, adds it to the shapeShiftTxList, and initiates a new poll for updates of pending txs
*
* @param {string} depositAddress - An address at which to send a crypto deposit, so that eth can be sent to the
* user's Metamask account
* @param {string} depositType - An abbreviation of the type of crypto currency to be deposited.
*
*/
createShapeShiftTx (depositAddress, depositType) {
const state = this.store.getState()
let { shapeShiftTxList } = state

@ -0,0 +1,81 @@
const ObservableStore = require('obs-store')
const { warn } = require('loglevel')
// By default, poll every 3 minutes
const DEFAULT_INTERVAL = 180 * 1000
/**
* A controller that polls for token exchange
* rates based on a user's current token list
*/
class TokenRatesController {
/**
* Creates a TokenRatesController
*
* @param {Object} [config] - Options to configure controller
*/
constructor ({ interval = DEFAULT_INTERVAL, preferences } = {}) {
this.store = new ObservableStore()
this.preferences = preferences
this.interval = interval
}
/**
* Updates exchange rates for all tokens
*/
async updateExchangeRates () {
if (!this.isActive) { return }
const contractExchangeRates = {}
for (const i in this._tokens) {
const address = this._tokens[i].address
contractExchangeRates[address] = await this.fetchExchangeRate(address)
}
this.store.putState({ contractExchangeRates })
}
/**
* Fetches a token exchange rate by address
*
* @param {String} address - Token contract address
*/
async fetchExchangeRate (address) {
try {
const response = await fetch(`https://metamask.balanc3.net/prices?from=${address}&to=ETH&autoConversion=false&summaryOnly=true`)
const json = await response.json()
return json && json.length ? json[0].averagePrice : 0
} catch (error) {
warn(`MetaMask - TokenRatesController exchange rate fetch failed for ${address}.`, error)
return 0
}
}
/**
* @type {Number}
*/
set interval (interval) {
this._handle && clearInterval(this._handle)
if (!interval) { return }
this._handle = setInterval(() => { this.updateExchangeRates() }, interval)
}
/**
* @type {Object}
*/
set preferences (preferences) {
this._preferences && this._preferences.unsubscribe()
if (!preferences) { return }
this._preferences = preferences
this.tokens = preferences.getState().tokens
preferences.subscribe(({ tokens = [] }) => { this.tokens = tokens })
}
/**
* @type {Array}
*/
set tokens (tokens) {
this._tokens = tokens
this.updateExchangeRates()
}
}
module.exports = TokenRatesController

@ -0,0 +1,92 @@
# Transaction Controller
Transaction Controller is an aggregate of sub-controllers and trackers
exposed to the MetaMask controller.
- txStateManager
responsible for the state of a transaction and
storing the transaction
- pendingTxTracker
watching blocks for transactions to be include
and emitting confirmed events
- txGasUtil
gas calculations and safety buffering
- nonceTracker
calculating nonces
## Flow diagram of processing a transaction
![transaction-flow](../../../../docs/transaction-flow.png)
## txMeta's & txParams
A txMeta is the "meta" object it has all the random bits of info we need about a transaction on it. txParams are sacred every thing on txParams gets signed so it must
be a valid key and be hex prefixed except for the network number. Extra stuff must go on the txMeta!
Here is a txMeta too look at:
```js
txMeta = {
"id": 2828415030114568, // unique id for this txMeta used for look ups
"time": 1524094064821, // time of creation
"status": "confirmed",
"metamaskNetworkId": "1524091532133", //the network id for the transaction
"loadingDefaults": false, // used to tell the ui when we are done calculatyig gass defaults
"txParams": { // the txParams object
"from": "0x8acce2391c0d510a6c5e5d8f819a678f79b7e675",
"to": "0x8acce2391c0d510a6c5e5d8f819a678f79b7e675",
"value": "0x0",
"gasPrice": "0x3b9aca00",
"gas": "0x7b0c",
"nonce": "0x0"
},
"history": [{ //debug
"id": 2828415030114568,
"time": 1524094064821,
"status": "unapproved",
"metamaskNetworkId": "1524091532133",
"loadingDefaults": true,
"txParams": {
"from": "0x8acce2391c0d510a6c5e5d8f819a678f79b7e675",
"to": "0x8acce2391c0d510a6c5e5d8f819a678f79b7e675",
"value": "0x0"
}
},
[
{
"op": "add",
"path": "/txParams/gasPrice",
"value": "0x3b9aca00"
},
...], // I've removed most of history for this
"gasPriceSpecified": false, //whether or not the user/dapp has specified gasPrice
"gasLimitSpecified": false, //whether or not the user/dapp has specified gas
"estimatedGas": "5208",
"origin": "MetaMask", //debug
"nonceDetails": {
"params": {
"highestLocallyConfirmed": 0,
"highestSuggested": 0,
"nextNetworkNonce": 0
},
"local": {
"name": "local",
"nonce": 0,
"details": {
"startPoint": 0,
"highest": 0
}
},
"network": {
"name": "network",
"nonce": 0,
"details": {
"baseCount": 0
}
}
},
"rawTx": "0xf86980843b9aca00827b0c948acce2391c0d510a6c5e5d8f819a678f79b7e67580808602c5b5de66eea05c01a320b96ac730cb210ca56d2cb71fa360e1fc2c21fa5cf333687d18eb323fa02ed05987a6e5fd0f2459fcff80710b76b83b296454ad9a37594a0ccb4643ea90", // used for rebroadcast
"hash": "0xa45ba834b97c15e6ff4ed09badd04ecd5ce884b455eb60192cdc73bcc583972a",
"submittedTime": 1524094077902 // time of the attempt to submit the raw tx to the network, used in the ui to show the retry button
}
```

@ -3,27 +3,42 @@ const ObservableStore = require('obs-store')
const ethUtil = require('ethereumjs-util')
const Transaction = require('ethereumjs-tx')
const EthQuery = require('ethjs-query')
const TransactionStateManager = require('../lib/tx-state-manager')
const TxGasUtil = require('../lib/tx-gas-utils')
const PendingTransactionTracker = require('../lib/pending-tx-tracker')
const NonceTracker = require('../lib/nonce-tracker')
/*
const TransactionStateManager = require('./tx-state-manager')
const TxGasUtil = require('./tx-gas-utils')
const PendingTransactionTracker = require('./pending-tx-tracker')
const NonceTracker = require('./nonce-tracker')
const txUtils = require('./lib/util')
const log = require('loglevel')
/**
Transaction Controller is an aggregate of sub-controllers and trackers
composing them in a way to be exposed to the metamask controller
- txStateManager
<br>- txStateManager
responsible for the state of a transaction and
storing the transaction
- pendingTxTracker
<br>- pendingTxTracker
watching blocks for transactions to be include
and emitting confirmed events
- txGasUtil
<br>- txGasUtil
gas calculations and safety buffering
- nonceTracker
<br>- nonceTracker
calculating nonces
@class
@param {object} - opts
@param {object} opts.initState - initial transaction list default is an empty array
@param {Object} opts.networkStore - an observable store for network number
@param {Object} opts.blockTracker - An instance of eth-blocktracker
@param {Object} opts.provider - A network provider.
@param {Function} opts.signTransaction - function the signs an ethereumjs-tx
@param {Function} [opts.getGasPrice] - optional gas price calculator
@param {Function} opts.signTransaction - ethTx signer that returns a rawTx
@param {Number} [opts.txHistoryLimit] - number *optional* for limiting how many transactions are in state
@param {Object} opts.preferencesStore
*/
module.exports = class TransactionController extends EventEmitter {
class TransactionController extends EventEmitter {
constructor (opts) {
super()
this.networkStore = opts.networkStore || new ObservableStore({})
@ -37,45 +52,19 @@ module.exports = class TransactionController extends EventEmitter {
this.query = new EthQuery(this.provider)
this.txGasUtil = new TxGasUtil(this.provider)
this._mapMethods()
this.txStateManager = new TransactionStateManager({
initState: opts.initState,
txHistoryLimit: opts.txHistoryLimit,
getNetwork: this.getNetwork.bind(this),
})
this.txStateManager.getFilteredTxList({
status: 'unapproved',
loadingDefaults: true,
}).forEach((tx) => {
this.addTxDefaults(tx)
.then((txMeta) => {
txMeta.loadingDefaults = false
this.txStateManager.updateTx(txMeta, 'transactions: gas estimation for tx on boot')
}).catch((error) => {
this.txStateManager.setTxStatusFailed(tx.id, error)
})
})
this.txStateManager.getFilteredTxList({
status: 'approved',
}).forEach((txMeta) => {
const txSignError = new Error('Transaction found as "approved" during boot - possibly stuck during signing')
this.txStateManager.setTxStatusFailed(txMeta.id, txSignError)
})
this._onBootCleanUp()
this.store = this.txStateManager.store
this.txStateManager.on('tx:status-update', this.emit.bind(this, 'tx:status-update'))
this.nonceTracker = new NonceTracker({
provider: this.provider,
getPendingTransactions: this.txStateManager.getPendingTransactions.bind(this.txStateManager),
getConfirmedTransactions: (address) => {
return this.txStateManager.getFilteredTxList({
from: address,
status: 'confirmed',
err: undefined,
})
},
getConfirmedTransactions: this.txStateManager.getConfirmedTransactions.bind(this.txStateManager),
})
this.pendingTxTracker = new PendingTransactionTracker({
@ -87,60 +76,14 @@ module.exports = class TransactionController extends EventEmitter {
})
this.txStateManager.store.subscribe(() => this.emit('update:badge'))
this.pendingTxTracker.on('tx:warning', (txMeta) => {
this.txStateManager.updateTx(txMeta, 'transactions/pending-tx-tracker#event: tx:warning')
})
this.pendingTxTracker.on('tx:confirmed', (txId) => this._markNonceDuplicatesDropped(txId))
this.pendingTxTracker.on('tx:failed', this.txStateManager.setTxStatusFailed.bind(this.txStateManager))
this.pendingTxTracker.on('tx:block-update', (txMeta, latestBlockNumber) => {
if (!txMeta.firstRetryBlockNumber) {
txMeta.firstRetryBlockNumber = latestBlockNumber
this.txStateManager.updateTx(txMeta, 'transactions/pending-tx-tracker#event: tx:block-update')
}
})
this.pendingTxTracker.on('tx:retry', (txMeta) => {
if (!('retryCount' in txMeta)) txMeta.retryCount = 0
txMeta.retryCount++
this.txStateManager.updateTx(txMeta, 'transactions/pending-tx-tracker#event: tx:retry')
})
this.blockTracker.on('block', this.pendingTxTracker.checkForTxInBlock.bind(this.pendingTxTracker))
// this is a little messy but until ethstore has been either
// removed or redone this is to guard against the race condition
this.blockTracker.on('latest', this.pendingTxTracker.resubmitPendingTxs.bind(this.pendingTxTracker))
this.blockTracker.on('sync', this.pendingTxTracker.queryPendingTxs.bind(this.pendingTxTracker))
this._setupListners()
// memstore is computed from a few different stores
this._updateMemstore()
this.txStateManager.store.subscribe(() => this._updateMemstore())
this.networkStore.subscribe(() => this._updateMemstore())
this.preferencesStore.subscribe(() => this._updateMemstore())
}
getState () {
return this.memStore.getState()
}
getNetwork () {
return this.networkStore.getState()
}
getSelectedAddress () {
return this.preferencesStore.getState().selectedAddress
}
getUnapprovedTxCount () {
return Object.keys(this.txStateManager.getUnapprovedTxList()).length
}
getPendingTxCount (account) {
return this.txStateManager.getPendingTransactions(account).length
}
getFilteredTxList (opts) {
return this.txStateManager.getFilteredTxList(opts)
}
/** @returns {number} the chainId*/
getChainId () {
const networkState = this.networkStore.getState()
const getChainId = parseInt(networkState)
@ -151,16 +94,45 @@ module.exports = class TransactionController extends EventEmitter {
}
}
/**
Adds a tx to the txlist
@emits ${txMeta.id}:unapproved
*/
addTx (txMeta) {
this.txStateManager.addTx(txMeta)
this.emit(`${txMeta.id}:unapproved`, txMeta)
}
/**
Wipes the transactions for a given account
@param {string} address - hex string of the from address for txs being removed
*/
wipeTransactions (address) {
this.txStateManager.wipeTransactions(address)
}
// Adds a tx to the txlist
addTx (txMeta) {
this.txStateManager.addTx(txMeta)
this.emit(`${txMeta.id}:unapproved`, txMeta)
/**
Check if a txMeta in the list with the same nonce has been confirmed in a block
if the txParams dont have a nonce will return false
@returns {boolean} weather the nonce has been used in a transaction confirmed in a block
@param {object} txMeta - the txMeta object
*/
async isNonceTaken (txMeta) {
const { from, nonce } = txMeta.txParams
if ('nonce' in txMeta.txParams) {
const sameNonceTxList = this.txStateManager.getFilteredTxList({from, nonce, status: 'confirmed'})
return (sameNonceTxList.length >= 1)
}
return false
}
/**
add a new unapproved transaction to the pipeline
@returns {Promise<string>} the hash of the transaction after being submitted to the network
@param txParams {object} - txParams for the transaction
@param opts {object} - with the key origin to put the origin on the txMeta
*/
async newUnapprovedTransaction (txParams, opts = {}) {
log.debug(`MetaMaskController newUnapprovedTransaction ${JSON.stringify(txParams)}`)
const initialTxMeta = await this.addUnapprovedTransaction(txParams)
@ -183,16 +155,24 @@ module.exports = class TransactionController extends EventEmitter {
})
}
/**
Validates and generates a txMeta with defaults and puts it in txStateManager
store
@returns {txMeta}
*/
async addUnapprovedTransaction (txParams) {
// validate
await this.txGasUtil.validateTxParams(txParams)
const normalizedTxParams = txUtils.normalizeTxParams(txParams)
txUtils.validateTxParams(normalizedTxParams)
// construct txMeta
let txMeta = this.txStateManager.generateTxMeta({txParams})
let txMeta = this.txStateManager.generateTxMeta({ txParams: normalizedTxParams })
this.addTx(txMeta)
this.emit('newUnapprovedTx', txMeta)
// add default tx params
try {
txMeta = await this.addTxDefaults(txMeta)
txMeta = await this.addTxGasDefaults(txMeta)
} catch (error) {
console.log(error)
this.txStateManager.setTxStatusFailed(txMeta.id, error)
@ -204,22 +184,33 @@ module.exports = class TransactionController extends EventEmitter {
return txMeta
}
async addTxDefaults (txMeta) {
/**
adds the tx gas defaults: gas && gasPrice
@param txMeta {Object} - the txMeta object
@returns {Promise<object>} resolves with txMeta
*/
async addTxGasDefaults (txMeta) {
const txParams = txMeta.txParams
// ensure value
txParams.value = txParams.value ? ethUtil.addHexPrefix(txParams.value) : '0x0'
txMeta.gasPriceSpecified = Boolean(txParams.gasPrice)
let gasPrice = txParams.gasPrice
if (!gasPrice) {
gasPrice = this.getGasPrice ? this.getGasPrice() : await this.query.gasPrice()
}
txParams.gasPrice = ethUtil.addHexPrefix(gasPrice.toString(16))
txParams.value = txParams.value || '0x0'
if (txParams.to === null) delete txParams.to
// set gasLimit
return await this.txGasUtil.analyzeGasUsage(txMeta)
}
/**
Creates a new txMeta with the same txParams as the original
to allow the user to resign the transaction with a higher gas values
@param originalTxId {number} - the id of the txMeta that
you want to attempt to retry
@return {txMeta}
*/
async retryTransaction (originalTxId) {
const originalTxMeta = this.txStateManager.getTx(originalTxId)
const lastGasPrice = originalTxMeta.txParams.gasPrice
@ -233,15 +224,31 @@ module.exports = class TransactionController extends EventEmitter {
return txMeta
}
/**
updates the txMeta in the txStateManager
@param txMeta {Object} - the updated txMeta
*/
async updateTransaction (txMeta) {
this.txStateManager.updateTx(txMeta, 'confTx: user updated transaction')
}
/**
updates and approves the transaction
@param txMeta {Object}
*/
async updateAndApproveTransaction (txMeta) {
this.txStateManager.updateTx(txMeta, 'confTx: user approved transaction')
await this.approveTransaction(txMeta.id)
}
/**
sets the tx status to approved
auto fills the nonce
signs the transaction
publishes the transaction
if any of these steps fails the tx status will be set to failed
@param txId {number} - the tx's Id
*/
async approveTransaction (txId) {
let nonceLock
try {
@ -273,7 +280,11 @@ module.exports = class TransactionController extends EventEmitter {
throw err
}
}
/**
adds the chain id and signs the transaction and set the status to signed
@param txId {number} - the tx's Id
@returns - rawTx {string}
*/
async signTransaction (txId) {
const txMeta = this.txStateManager.getTx(txId)
// add network/chain id
@ -289,6 +300,12 @@ module.exports = class TransactionController extends EventEmitter {
return rawTx
}
/**
publishes the raw tx and sets the txMeta to submitted
@param txId {number} - the tx's Id
@param rawTx {string} - the hex string of the serialized signed transaction
@returns {Promise<void>}
*/
async publishTransaction (txId, rawTx) {
const txMeta = this.txStateManager.getTx(txId)
txMeta.rawTx = rawTx
@ -298,11 +315,20 @@ module.exports = class TransactionController extends EventEmitter {
this.txStateManager.setTxStatusSubmitted(txId)
}
/**
Convenience method for the ui thats sets the transaction to rejected
@param txId {number} - the tx's Id
@returns {Promise<void>}
*/
async cancelTransaction (txId) {
this.txStateManager.setTxStatusRejected(txId)
}
// receives a txHash records the tx as signed
/**
Sets the txHas on the txMeta
@param txId {number} - the tx's Id
@param txHash {string} - the hash for the txMeta
*/
setTxHash (txId, txHash) {
// Add the tx hash to the persisted meta-tx object
const txMeta = this.txStateManager.getTx(txId)
@ -313,9 +339,92 @@ module.exports = class TransactionController extends EventEmitter {
//
// PRIVATE METHODS
//
/** maps methods for convenience*/
_mapMethods () {
/** @returns the state in transaction controller */
this.getState = () => this.memStore.getState()
/** @returns the network number stored in networkStore */
this.getNetwork = () => this.networkStore.getState()
/** @returns the user selected address */
this.getSelectedAddress = () => this.preferencesStore.getState().selectedAddress
/** Returns an array of transactions whos status is unapproved */
this.getUnapprovedTxCount = () => Object.keys(this.txStateManager.getUnapprovedTxList()).length
/**
@returns a number that represents how many transactions have the status submitted
@param account {String} - hex prefixed account
*/
this.getPendingTxCount = (account) => this.txStateManager.getPendingTransactions(account).length
/** see txStateManager */
this.getFilteredTxList = (opts) => this.txStateManager.getFilteredTxList(opts)
}
/**
If transaction controller was rebooted with transactions that are uncompleted
in steps of the transaction signing or user confirmation process it will either
transition txMetas to a failed state or try to redo those tasks.
*/
_onBootCleanUp () {
this.txStateManager.getFilteredTxList({
status: 'unapproved',
loadingDefaults: true,
}).forEach((tx) => {
this.addTxGasDefaults(tx)
.then((txMeta) => {
txMeta.loadingDefaults = false
this.txStateManager.updateTx(txMeta, 'transactions: gas estimation for tx on boot')
}).catch((error) => {
this.txStateManager.setTxStatusFailed(tx.id, error)
})
})
this.txStateManager.getFilteredTxList({
status: 'approved',
}).forEach((txMeta) => {
const txSignError = new Error('Transaction found as "approved" during boot - possibly stuck during signing')
this.txStateManager.setTxStatusFailed(txMeta.id, txSignError)
})
}
/**
is called in constructor applies the listeners for pendingTxTracker txStateManager
and blockTracker
*/
_setupListners () {
this.txStateManager.on('tx:status-update', this.emit.bind(this, 'tx:status-update'))
this.pendingTxTracker.on('tx:warning', (txMeta) => {
this.txStateManager.updateTx(txMeta, 'transactions/pending-tx-tracker#event: tx:warning')
})
this.pendingTxTracker.on('tx:confirmed', (txId) => this.txStateManager.setTxStatusConfirmed(txId))
this.pendingTxTracker.on('tx:confirmed', (txId) => this._markNonceDuplicatesDropped(txId))
this.pendingTxTracker.on('tx:failed', this.txStateManager.setTxStatusFailed.bind(this.txStateManager))
this.pendingTxTracker.on('tx:block-update', (txMeta, latestBlockNumber) => {
if (!txMeta.firstRetryBlockNumber) {
txMeta.firstRetryBlockNumber = latestBlockNumber
this.txStateManager.updateTx(txMeta, 'transactions/pending-tx-tracker#event: tx:block-update')
}
})
this.pendingTxTracker.on('tx:retry', (txMeta) => {
if (!('retryCount' in txMeta)) txMeta.retryCount = 0
txMeta.retryCount++
this.txStateManager.updateTx(txMeta, 'transactions/pending-tx-tracker#event: tx:retry')
})
this.blockTracker.on('block', this.pendingTxTracker.checkForTxInBlock.bind(this.pendingTxTracker))
// this is a little messy but until ethstore has been either
// removed or redone this is to guard against the race condition
this.blockTracker.on('latest', this.pendingTxTracker.resubmitPendingTxs.bind(this.pendingTxTracker))
this.blockTracker.on('sync', this.pendingTxTracker.queryPendingTxs.bind(this.pendingTxTracker))
}
/**
Sets other txMeta statuses to dropped if the txMeta that has been confirmed has other transactions
in the list have the same nonce
@param txId {Number} - the txId of the transaction that has been confirmed in a block
*/
_markNonceDuplicatesDropped (txId) {
this.txStateManager.setTxStatusConfirmed(txId)
// get the confirmed transactions nonce and from address
const txMeta = this.txStateManager.getTx(txId)
const { nonce, from } = txMeta.txParams
@ -330,6 +439,9 @@ module.exports = class TransactionController extends EventEmitter {
})
}
/**
Updates the memStore in transaction controller
*/
_updateMemstore () {
const unapprovedTxs = this.txStateManager.getUnapprovedTxList()
const selectedAddressTxList = this.txStateManager.getFilteredTxList({
@ -339,3 +451,5 @@ module.exports = class TransactionController extends EventEmitter {
this.memStore.updateState({ unapprovedTxs, selectedAddressTxList })
}
}
module.exports = TransactionController

@ -1,6 +1,6 @@
const jsonDiffer = require('fast-json-patch')
const clone = require('clone')
/** @module*/
module.exports = {
generateHistoryEntry,
replayHistory,
@ -8,7 +8,11 @@ module.exports = {
migrateFromSnapshotsToDiffs,
}
/**
converts non-initial history entries into diffs
@param longHistory {array}
@returns {array}
*/
function migrateFromSnapshotsToDiffs (longHistory) {
return (
longHistory
@ -20,6 +24,17 @@ function migrateFromSnapshotsToDiffs (longHistory) {
)
}
/**
generates an array of history objects sense the previous state.
The object has the keys opp(the operation preformed),
path(the key and if a nested object then each key will be seperated with a `/`)
value
with the first entry having the note
@param previousState {object} - the previous state of the object
@param newState {object} - the update object
@param note {string} - a optional note for the state change
@reurns {array}
*/
function generateHistoryEntry (previousState, newState, note) {
const entry = jsonDiffer.compare(previousState, newState)
// Add a note to the first op, since it breaks if we append it to the entry
@ -27,11 +42,19 @@ function generateHistoryEntry (previousState, newState, note) {
return entry
}
/**
Recovers previous txMeta state obj
@return {object}
*/
function replayHistory (_shortHistory) {
const shortHistory = clone(_shortHistory)
return shortHistory.reduce((val, entry) => jsonDiffer.applyPatch(val, entry).newDocument)
}
/**
@param txMeta {Object}
@returns {object} a clone object of the txMeta with out history
*/
function snapshotFromTxMeta (txMeta) {
// create txMeta snapshot for history
const snapshot = clone(txMeta)

@ -0,0 +1,99 @@
const {
addHexPrefix,
isValidAddress,
} = require('ethereumjs-util')
/**
@module
*/
module.exports = {
normalizeTxParams,
validateTxParams,
validateFrom,
validateRecipient,
getFinalStates,
}
// functions that handle normalizing of that key in txParams
const normalizers = {
from: from => addHexPrefix(from).toLowerCase(),
to: to => addHexPrefix(to).toLowerCase(),
nonce: nonce => addHexPrefix(nonce),
value: value => addHexPrefix(value),
data: data => addHexPrefix(data),
gas: gas => addHexPrefix(gas),
gasPrice: gasPrice => addHexPrefix(gasPrice),
}
/**
normalizes txParams
@param txParams {object}
@returns {object} normalized txParams
*/
function normalizeTxParams (txParams) {
// apply only keys in the normalizers
const normalizedTxParams = {}
for (const key in normalizers) {
if (txParams[key]) normalizedTxParams[key] = normalizers[key](txParams[key])
}
return normalizedTxParams
}
/**
validates txParams
@param txParams {object}
*/
function validateTxParams (txParams) {
validateFrom(txParams)
validateRecipient(txParams)
if ('value' in txParams) {
const value = txParams.value.toString()
if (value.includes('-')) {
throw new Error(`Invalid transaction value of ${txParams.value} not a positive number.`)
}
if (value.includes('.')) {
throw new Error(`Invalid transaction value of ${txParams.value} number must be in wei`)
}
}
}
/**
validates the from field in txParams
@param txParams {object}
*/
function validateFrom (txParams) {
if (!(typeof txParams.from === 'string')) throw new Error(`Invalid from address ${txParams.from} not a string`)
if (!isValidAddress(txParams.from)) throw new Error('Invalid from address')
}
/**
validates the to field in txParams
@param txParams {object}
*/
function validateRecipient (txParams) {
if (txParams.to === '0x' || txParams.to === null) {
if (txParams.data) {
delete txParams.to
} else {
throw new Error('Invalid recipient address')
}
} else if (txParams.to !== undefined && !isValidAddress(txParams.to)) {
throw new Error('Invalid recipient address')
}
return txParams
}
/**
@returns an {array} of states that can be considered final
*/
function getFinalStates () {
return [
'rejected', // the user has responded no!
'confirmed', // the tx has been included in a block.
'failed', // the tx failed for some reason, included on tx data.
'dropped', // the tx nonce was already used
]
}

@ -1,7 +1,15 @@
const EthQuery = require('ethjs-query')
const assert = require('assert')
const Mutex = require('await-semaphore').Mutex
/**
@param opts {Object}
@param {Object} opts.provider a ethereum provider
@param {Function} opts.getPendingTransactions a function that returns an array of txMeta
whosee status is `submitted`
@param {Function} opts.getConfirmedTransactions a function that returns an array of txMeta
whose status is `confirmed`
@class
*/
class NonceTracker {
constructor ({ provider, getPendingTransactions, getConfirmedTransactions }) {
@ -12,6 +20,9 @@ class NonceTracker {
this.lockMap = {}
}
/**
@returns {Promise<Object>} with the key releaseLock (the gloabl mutex)
*/
async getGlobalLock () {
const globalMutex = this._lookupMutex('global')
// await global mutex free
@ -19,8 +30,20 @@ class NonceTracker {
return { releaseLock }
}
// releaseLock must be called
// releaseLock must be called after adding signed tx to pending transactions (or discarding)
/**
* @typedef NonceDetails
* @property {number} highestLocallyConfirmed - A hex string of the highest nonce on a confirmed transaction.
* @property {number} nextNetworkNonce - The next nonce suggested by the eth_getTransactionCount method.
* @property {number} highetSuggested - The maximum between the other two, the number returned.
*/
/**
this will return an object with the `nextNonce` `nonceDetails` of type NonceDetails, and the releaseLock
Note: releaseLock must be called after adding a signed tx to pending transactions (or discarding).
@param address {string} the hex string for the address whose nonce we are calculating
@returns {Promise<NonceDetails>}
*/
async getNonceLock (address) {
// await global mutex free
await this._globalMutexFree()
@ -123,6 +146,17 @@ class NonceTracker {
return highestNonce
}
/**
@typedef {object} highestContinuousFrom
@property {string} - name the name for how the nonce was calculated based on the data used
@property {number} - nonce the next suggested nonce
@property {object} - details the provided starting nonce that was used (for debugging)
*/
/**
@param txList {array} - list of txMeta's
@param startPoint {number} - the highest known locally confirmed nonce
@returns {highestContinuousFrom}
*/
_getHighestContinuousFrom (txList, startPoint) {
const nonces = txList.map((txMeta) => {
const nonce = txMeta.txParams.nonce
@ -140,6 +174,10 @@ class NonceTracker {
// this is a hotfix for the fact that the blockTracker will
// change when the network changes
/**
@returns {Object} the current blockTracker
*/
_getBlockTracker () {
return this.provider._blockTracker
}

@ -1,23 +1,24 @@
const EventEmitter = require('events')
const log = require('loglevel')
const EthQuery = require('ethjs-query')
/*
Utility class for tracking the transactions as they
go from a pending state to a confirmed (mined in a block) state
/**
Event emitter utility class for tracking the transactions as they<br>
go from a pending state to a confirmed (mined in a block) state<br>
<br>
As well as continues broadcast while in the pending state
<br>
@param config {object} - non optional configuration object consists of:
@param {Object} config.provider - A network provider.
@param {Object} config.nonceTracker see nonce tracker
@param {function} config.getPendingTransactions a function for getting an array of transactions,
@param {function} config.publishTransaction a async function for publishing raw transactions,
~config is not optional~
requires a: {
provider: //,
nonceTracker: //see nonce tracker,
getPendingTransactions: //() a function for getting an array of transactions,
publishTransaction: //(rawTx) a async function for publishing raw transactions,
}
@class
*/
module.exports = class PendingTransactionTracker extends EventEmitter {
class PendingTransactionTracker extends EventEmitter {
constructor (config) {
super()
this.query = new EthQuery(config.provider)
@ -29,8 +30,13 @@ module.exports = class PendingTransactionTracker extends EventEmitter {
this._checkPendingTxs()
}
// checks if a signed tx is in a block and
// if included sets the tx status as 'confirmed'
/**
checks if a signed tx is in a block and
if it is included emits tx status as 'confirmed'
@param block {object}, a full block
@emits tx:confirmed
@emits tx:failed
*/
checkForTxInBlock (block) {
const signedTxList = this.getPendingTransactions()
if (!signedTxList.length) return
@ -52,6 +58,11 @@ module.exports = class PendingTransactionTracker extends EventEmitter {
})
}
/**
asks the network for the transaction to see if a block number is included on it
if we have skipped/missed blocks
@param object - oldBlock newBlock
*/
queryPendingTxs ({ oldBlock, newBlock }) {
// check pending transactions on start
if (!oldBlock) {
@ -63,7 +74,11 @@ module.exports = class PendingTransactionTracker extends EventEmitter {
if (diff > 1) this._checkPendingTxs()
}
/**
Will resubmit any transactions who have not been confirmed in a block
@param block {object} - a block object
@emits tx:warning
*/
resubmitPendingTxs (block) {
const pending = this.getPendingTransactions()
// only try resubmitting if their are transactions to resubmit
@ -100,6 +115,13 @@ module.exports = class PendingTransactionTracker extends EventEmitter {
}))
}
/**
resubmits the individual txMeta used in resubmitPendingTxs
@param txMeta {Object} - txMeta object
@param latestBlockNumber {string} - hex string for the latest block number
@emits tx:retry
@returns txHash {string}
*/
async _resubmitTx (txMeta, latestBlockNumber) {
if (!txMeta.firstRetryBlockNumber) {
this.emit('tx:block-update', txMeta, latestBlockNumber)
@ -123,7 +145,13 @@ module.exports = class PendingTransactionTracker extends EventEmitter {
this.emit('tx:retry', txMeta)
return txHash
}
/**
Ask the network for the transaction to see if it has been include in a block
@param txMeta {Object} - the txMeta object
@emits tx:failed
@emits tx:confirmed
@emits tx:warning
*/
async _checkPendingTx (txMeta) {
const txHash = txMeta.hash
const txId = txMeta.id
@ -162,8 +190,9 @@ module.exports = class PendingTransactionTracker extends EventEmitter {
}
}
// checks the network for signed txs and
// if confirmed sets the tx status as 'confirmed'
/**
checks the network for signed txs and releases the nonce global lock if it is
*/
async _checkPendingTxs () {
const signedTxList = this.getPendingTransactions()
// in order to keep the nonceTracker accurate we block it while updating pending transactions
@ -171,12 +200,17 @@ module.exports = class PendingTransactionTracker extends EventEmitter {
try {
await Promise.all(signedTxList.map((txMeta) => this._checkPendingTx(txMeta)))
} catch (err) {
console.error('PendingTransactionWatcher - Error updating pending transactions')
console.error(err)
log.error('PendingTransactionWatcher - Error updating pending transactions')
log.error(err)
}
nonceGlobalLock.releaseLock()
}
/**
checks to see if a confirmed txMeta has the same nonce
@param txMeta {Object} - txMeta object
@returns {boolean}
*/
async _checkIfNonceIsTaken (txMeta) {
const address = txMeta.txParams.from
const completed = this.getCompletedTransactions(address)
@ -185,5 +219,6 @@ module.exports = class PendingTransactionTracker extends EventEmitter {
})
return sameNonce.length > 0
}
}
module.exports = PendingTransactionTracker

@ -3,22 +3,27 @@ const {
hexToBn,
BnMultiplyByFraction,
bnToHex,
} = require('./util')
const { addHexPrefix, isValidAddress } = require('ethereumjs-util')
} = require('../../lib/util')
const { addHexPrefix } = require('ethereumjs-util')
const SIMPLE_GAS_COST = '0x5208' // Hex for 21000, cost of a simple send.
/*
tx-utils are utility methods for Transaction manager
/**
tx-gas-utils are gas utility methods for Transaction manager
its passed ethquery
and used to do things like calculate gas of a tx.
@param {Object} provider - A network provider.
*/
module.exports = class TxGasUtil {
class TxGasUtil {
constructor (provider) {
this.query = new EthQuery(provider)
}
/**
@param txMeta {Object} - the txMeta object
@returns {object} the txMeta object with the gas written to the txParams
*/
async analyzeGasUsage (txMeta) {
const block = await this.query.getBlockByNumber('latest', true)
let estimatedGasHex
@ -38,6 +43,12 @@ module.exports = class TxGasUtil {
return txMeta
}
/**
Estimates the tx's gas usage
@param txMeta {Object} - the txMeta object
@param blockGasLimitHex {string} - hex string of the block's gas limit
@returns {string} the estimated gas limit as a hex string
*/
async estimateTxGas (txMeta, blockGasLimitHex) {
const txParams = txMeta.txParams
@ -70,6 +81,12 @@ module.exports = class TxGasUtil {
return await this.query.estimateGas(txParams)
}
/**
Writes the gas on the txParams in the txMeta
@param txMeta {Object} - the txMeta object to write to
@param blockGasLimitHex {string} - the block gas limit hex
@param estimatedGasHex {string} - the estimated gas hex
*/
setTxGas (txMeta, blockGasLimitHex, estimatedGasHex) {
txMeta.estimatedGas = addHexPrefix(estimatedGasHex)
const txParams = txMeta.txParams
@ -87,6 +104,13 @@ module.exports = class TxGasUtil {
return
}
/**
Adds a gas buffer with out exceeding the block gas limit
@param initialGasLimitHex {string} - the initial gas limit to add the buffer too
@param blockGasLimitHex {string} - the block gas limit
@returns {string} the buffered gas limit as a hex string
*/
addGasBuffer (initialGasLimitHex, blockGasLimitHex) {
const initialGasLimitBn = hexToBn(initialGasLimitHex)
const blockGasLimitBn = hexToBn(blockGasLimitHex)
@ -100,37 +124,6 @@ module.exports = class TxGasUtil {
// otherwise use blockGasLimit
return bnToHex(upperGasLimitBn)
}
}
async validateTxParams (txParams) {
this.validateFrom(txParams)
this.validateRecipient(txParams)
if ('value' in txParams) {
const value = txParams.value.toString()
if (value.includes('-')) {
throw new Error(`Invalid transaction value of ${txParams.value} not a positive number.`)
}
if (value.includes('.')) {
throw new Error(`Invalid transaction value of ${txParams.value} number must be in wei`)
}
}
}
validateFrom (txParams) {
if ( !(typeof txParams.from === 'string') ) throw new Error(`Invalid from address ${txParams.from} not a string`)
if (!isValidAddress(txParams.from)) throw new Error('Invalid from address')
}
validateRecipient (txParams) {
if (txParams.to === '0x' || txParams.to === null ) {
if (txParams.data) {
delete txParams.to
} else {
throw new Error('Invalid recipient address')
}
} else if ( txParams.to !== undefined && !isValidAddress(txParams.to) ) {
throw new Error('Invalid recipient address')
}
return txParams
}
}
module.exports = TxGasUtil

@ -1,22 +1,33 @@
const extend = require('xtend')
const EventEmitter = require('events')
const ObservableStore = require('obs-store')
const createId = require('./random-id')
const ethUtil = require('ethereumjs-util')
const txStateHistoryHelper = require('./tx-state-history-helper')
// STATUS METHODS
// statuses:
// - `'unapproved'` the user has not responded
// - `'rejected'` the user has responded no!
// - `'approved'` the user has approved the tx
// - `'signed'` the tx is signed
// - `'submitted'` the tx is sent to a server
// - `'confirmed'` the tx has been included in a block.
// - `'failed'` the tx failed for some reason, included on tx data.
// - `'dropped'` the tx nonce was already used
module.exports = class TransactionStateManager extends EventEmitter {
const txStateHistoryHelper = require('./lib/tx-state-history-helper')
const createId = require('../../lib/random-id')
const { getFinalStates } = require('./lib/util')
/**
TransactionStateManager is responsible for the state of a transaction and
storing the transaction
it also has some convenience methods for finding subsets of transactions
*
*STATUS METHODS
<br>statuses:
<br> - `'unapproved'` the user has not responded
<br> - `'rejected'` the user has responded no!
<br> - `'approved'` the user has approved the tx
<br> - `'signed'` the tx is signed
<br> - `'submitted'` the tx is sent to a server
<br> - `'confirmed'` the tx has been included in a block.
<br> - `'failed'` the tx failed for some reason, included on tx data.
<br> - `'dropped'` the tx nonce was already used
@param opts {object}
@param {object} [opts.initState={ transactions: [] }] initial transactions list with the key transaction {array}
@param {number} [opts.txHistoryLimit] limit for how many finished
transactions can hang around in state
@param {function} opts.getNetwork return network number
@class
*/
class TransactionStateManager extends EventEmitter {
constructor ({ initState, txHistoryLimit, getNetwork }) {
super()
@ -28,6 +39,10 @@ module.exports = class TransactionStateManager extends EventEmitter {
this.getNetwork = getNetwork
}
/**
@param opts {object} - the object to use when overwriting defaults
@returns {txMeta} the default txMeta object
*/
generateTxMeta (opts) {
return extend({
id: createId(),
@ -38,17 +53,25 @@ module.exports = class TransactionStateManager extends EventEmitter {
}, opts)
}
/**
@returns {array} of txMetas that have been filtered for only the current network
*/
getTxList () {
const network = this.getNetwork()
const fullTxList = this.getFullTxList()
return fullTxList.filter((txMeta) => txMeta.metamaskNetworkId === network)
}
/**
@returns {array} of all the txMetas in store
*/
getFullTxList () {
return this.store.getState().transactions
}
// Returns the tx list
/**
@returns {array} the tx list whos status is unapproved
*/
getUnapprovedTxList () {
const txList = this.getTxsByMetaData('status', 'unapproved')
return txList.reduce((result, tx) => {
@ -57,18 +80,37 @@ module.exports = class TransactionStateManager extends EventEmitter {
}, {})
}
/**
@param [address] {string} - hex prefixed address to sort the txMetas for [optional]
@returns {array} the tx list whos status is submitted if no address is provide
returns all txMetas who's status is submitted for the current network
*/
getPendingTransactions (address) {
const opts = { status: 'submitted' }
if (address) opts.from = address
return this.getFilteredTxList(opts)
}
/**
@param [address] {string} - hex prefixed address to sort the txMetas for [optional]
@returns {array} the tx list whos status is confirmed if no address is provide
returns all txMetas who's status is confirmed for the current network
*/
getConfirmedTransactions (address) {
const opts = { status: 'confirmed' }
if (address) opts.from = address
return this.getFilteredTxList(opts)
}
/**
Adds the txMeta to the list of transactions in the store.
if the list is over txHistoryLimit it will remove a transaction that
is in its final state
it will allso add the key `history` to the txMeta with the snap shot of the original
object
@param txMeta {Object}
@returns {object} the txMeta
*/
addTx (txMeta) {
this.once(`${txMeta.id}:signed`, function (txId) {
this.removeAllListeners(`${txMeta.id}:rejected`)
@ -92,22 +134,39 @@ module.exports = class TransactionStateManager extends EventEmitter {
// or rejected tx's.
// not tx's that are pending or unapproved
if (txCount > txHistoryLimit - 1) {
const index = transactions.findIndex((metaTx) => metaTx.status === 'confirmed' || metaTx.status === 'rejected')
transactions.splice(index, 1)
const index = transactions.findIndex((metaTx) => {
return getFinalStates().includes(metaTx.status)
})
if (index !== -1) {
transactions.splice(index, 1)
}
}
transactions.push(txMeta)
this._saveTxList(transactions)
return txMeta
}
// gets tx by Id and returns it
/**
@param txId {number}
@returns {object} the txMeta who matches the given id if none found
for the network returns undefined
*/
getTx (txId) {
const txMeta = this.getTxsByMetaData('id', txId)[0]
return txMeta
}
/**
updates the txMeta in the list and adds a history entry
@param txMeta {Object} - the txMeta to update
@param [note] {string} - a not about the update for history
*/
updateTx (txMeta, note) {
// validate txParams
if (txMeta.txParams) {
if (typeof txMeta.txParams.data === 'undefined') {
delete txMeta.txParams.data
}
this.validateTxParams(txMeta.txParams)
}
@ -128,16 +187,23 @@ module.exports = class TransactionStateManager extends EventEmitter {
}
// merges txParams obj onto txData.txParams
// use extend to ensure that all fields are filled
/**
merges txParams obj onto txMeta.txParams
use extend to ensure that all fields are filled
@param txId {number} - the id of the txMeta
@param txParams {object} - the updated txParams
*/
updateTxParams (txId, txParams) {
const txMeta = this.getTx(txId)
txMeta.txParams = extend(txMeta.txParams, txParams)
this.updateTx(txMeta, `txStateManager#updateTxParams`)
}
// validates txParams members by type
validateTxParams(txParams) {
/**
validates txParams members by type
@param txParams {object} - txParams to validate
*/
validateTxParams (txParams) {
Object.keys(txParams).forEach((key) => {
const value = txParams[key]
// validate types
@ -153,17 +219,19 @@ module.exports = class TransactionStateManager extends EventEmitter {
})
}
/*
Takes an object of fields to search for eg:
let thingsToLookFor = {
to: '0x0..',
from: '0x0..',
status: 'signed',
err: undefined,
}
and returns a list of tx with all
/**
@param opts {object} - an object of fields to search for eg:<br>
let <code>thingsToLookFor = {<br>
to: '0x0..',<br>
from: '0x0..',<br>
status: 'signed',<br>
err: undefined,<br>
}<br></code>
@param [initialList=this.getTxList()]
@returns a {array} of txMeta with all
options matching
*/
/*
****************HINT****************
| `err: undefined` is like looking |
| for a tx with no err |
@ -184,10 +252,17 @@ module.exports = class TransactionStateManager extends EventEmitter {
})
return filteredTxList
}
/**
@param key {string} - the key to check
@param value - the value your looking for
@param [txList=this.getTxList()] {array} - the list to search. default is the txList
from txStateManager#getTxList
@returns {array} a list of txMetas who matches the search params
*/
getTxsByMetaData (key, value, txList = this.getTxList()) {
return txList.filter((txMeta) => {
if (txMeta.txParams[key]) {
if (key in txMeta.txParams) {
return txMeta.txParams[key] === value
} else {
return txMeta[key] === value
@ -197,33 +272,51 @@ module.exports = class TransactionStateManager extends EventEmitter {
// get::set status
// should return the status of the tx.
/**
@param txId {number} - the txMeta Id
@return {string} the status of the tx.
*/
getTxStatus (txId) {
const txMeta = this.getTx(txId)
return txMeta.status
}
// should update the status of the tx to 'rejected'.
/**
should update the status of the tx to 'rejected'.
@param txId {number} - the txMeta Id
*/
setTxStatusRejected (txId) {
this._setTxStatus(txId, 'rejected')
}
// should update the status of the tx to 'unapproved'.
/**
should update the status of the tx to 'unapproved'.
@param txId {number} - the txMeta Id
*/
setTxStatusUnapproved (txId) {
this._setTxStatus(txId, 'unapproved')
}
// should update the status of the tx to 'approved'.
/**
should update the status of the tx to 'approved'.
@param txId {number} - the txMeta Id
*/
setTxStatusApproved (txId) {
this._setTxStatus(txId, 'approved')
}
// should update the status of the tx to 'signed'.
/**
should update the status of the tx to 'signed'.
@param txId {number} - the txMeta Id
*/
setTxStatusSigned (txId) {
this._setTxStatus(txId, 'signed')
}
// should update the status of the tx to 'submitted'.
// and add a time stamp for when it was called
/**
should update the status of the tx to 'submitted'.
and add a time stamp for when it was called
@param txId {number} - the txMeta Id
*/
setTxStatusSubmitted (txId) {
const txMeta = this.getTx(txId)
txMeta.submittedTime = (new Date()).getTime()
@ -231,17 +324,29 @@ module.exports = class TransactionStateManager extends EventEmitter {
this._setTxStatus(txId, 'submitted')
}
// should update the status of the tx to 'confirmed'.
/**
should update the status of the tx to 'confirmed'.
@param txId {number} - the txMeta Id
*/
setTxStatusConfirmed (txId) {
this._setTxStatus(txId, 'confirmed')
}
// should update the status dropped
/**
should update the status of the tx to 'dropped'.
@param txId {number} - the txMeta Id
*/
setTxStatusDropped (txId) {
this._setTxStatus(txId, 'dropped')
}
/**
should update the status of the tx to 'failed'.
and put the error on the txMeta
@param txId {number} - the txMeta Id
@param err {erroObject} - error object
*/
setTxStatusFailed (txId, err) {
const txMeta = this.getTx(txId)
txMeta.err = {
@ -252,6 +357,11 @@ module.exports = class TransactionStateManager extends EventEmitter {
this._setTxStatus(txId, 'failed')
}
/**
Removes transaction from the given address for the current network
from the txList
@param address {string} - hex string of the from address on the txParams to remove
*/
wipeTransactions (address) {
// network only tx
const txs = this.getFullTxList()
@ -267,9 +377,8 @@ module.exports = class TransactionStateManager extends EventEmitter {
// PRIVATE METHODS
//
// Should find the tx in the tx list and
// update it.
// should set the status in txData
// STATUS METHODS
// statuses:
// - `'unapproved'` the user has not responded
// - `'rejected'` the user has responded no!
// - `'approved'` the user has approved the tx
@ -277,6 +386,15 @@ module.exports = class TransactionStateManager extends EventEmitter {
// - `'submitted'` the tx is sent to a server
// - `'confirmed'` the tx has been included in a block.
// - `'failed'` the tx failed for some reason, included on tx data.
// - `'dropped'` the tx nonce was already used
/**
@param txId {number} - the txMeta Id
@param status {string} - the status to set on the txMeta
@emits tx:status-update - passes txId and status
@emits ${txMeta.id}:finished - if it is a finished state. Passes the txMeta
@emits update:badge
*/
_setTxStatus (txId, status) {
const txMeta = this.getTx(txId)
txMeta.status = status
@ -289,9 +407,14 @@ module.exports = class TransactionStateManager extends EventEmitter {
this.emit('update:badge')
}
// Saves the new/updated txList.
/**
Saves the new/updated txList.
@param transactions {array} - the list of transactions to save
*/
// Function is intended only for internal use
_saveTxList (transactions) {
this.store.updateState({ transactions })
}
}
module.exports = TransactionStateManager

@ -1,69 +1,97 @@
const asmcrypto = require('asmcrypto.js')
const Unibabel = require('browserify-unibabel')
/**
* A Microsoft Edge-specific encryption class that exposes
* the interface expected by eth-keykeyring-controller
*/
class EdgeEncryptor {
/**
* Encrypts an arbitrary object to ciphertext
*
* @param {string} password Used to generate a key to encrypt the data
* @param {Object} dataObject Data to encrypt
* @returns {Promise<string>} Promise resolving to an object with ciphertext
*/
encrypt (password, dataObject) {
var salt = this._generateSalt()
return this._keyFromPassword(password, salt)
.then(function (key) {
var data = JSON.stringify(dataObject)
var dataBuffer = Unibabel.utf8ToBuffer(data)
var vector = global.crypto.getRandomValues(new Uint8Array(16))
var resultbuffer = asmcrypto.AES_GCM.encrypt(dataBuffer, key, vector)
encrypt (password, dataObject) {
var buffer = new Uint8Array(resultbuffer)
var vectorStr = Unibabel.bufferToBase64(vector)
var vaultStr = Unibabel.bufferToBase64(buffer)
return JSON.stringify({
data: vaultStr,
iv: vectorStr,
salt: salt,
})
})
}
var salt = this._generateSalt()
return this._keyFromPassword(password, salt)
.then(function (key) {
/**
* Decrypts an arbitrary object from ciphertext
*
* @param {string} password Used to generate a key to decrypt the data
* @param {string} text Ciphertext of an encrypted object
* @returns {Promise<Object>} Promise resolving to copy of decrypted object
*/
decrypt (password, text) {
const payload = JSON.parse(text)
const salt = payload.salt
return this._keyFromPassword(password, salt)
.then(function (key) {
const encryptedData = Unibabel.base64ToBuffer(payload.data)
const vector = Unibabel.base64ToBuffer(payload.iv)
return new Promise((resolve, reject) => {
var result
try {
result = asmcrypto.AES_GCM.decrypt(encryptedData, key, vector)
} catch (err) {
return reject(new Error('Incorrect password'))
}
const decryptedData = new Uint8Array(result)
const decryptedStr = Unibabel.bufferToUtf8(decryptedData)
const decryptedObj = JSON.parse(decryptedStr)
resolve(decryptedObj)
})
})
}
var data = JSON.stringify(dataObject)
var dataBuffer = Unibabel.utf8ToBuffer(data)
var vector = global.crypto.getRandomValues(new Uint8Array(16))
var resultbuffer = asmcrypto.AES_GCM.encrypt(dataBuffer, key, vector)
/**
* Retrieves a cryptographic key using a password
*
* @private
* @param {string} password Password used to unlock a cryptographic key
* @param {string} salt Random base64 data
* @returns {Promise<Object>} Promise resolving to a derived key
*/
_keyFromPassword (password, salt) {
var buffer = new Uint8Array(resultbuffer)
var vectorStr = Unibabel.bufferToBase64(vector)
var vaultStr = Unibabel.bufferToBase64(buffer)
return JSON.stringify({
data: vaultStr,
iv: vectorStr,
salt: salt,
})
})
}
var passBuffer = Unibabel.utf8ToBuffer(password)
var saltBuffer = Unibabel.base64ToBuffer(salt)
return new Promise((resolve) => {
var key = asmcrypto.PBKDF2_HMAC_SHA256.bytes(passBuffer, saltBuffer, 10000)
resolve(key)
})
}
decrypt (password, text) {
const payload = JSON.parse(text)
const salt = payload.salt
return this._keyFromPassword(password, salt)
.then(function (key) {
const encryptedData = Unibabel.base64ToBuffer(payload.data)
const vector = Unibabel.base64ToBuffer(payload.iv)
return new Promise((resolve, reject) => {
var result
try {
result = asmcrypto.AES_GCM.decrypt(encryptedData, key, vector)
} catch (err) {
return reject(new Error('Incorrect password'))
}
const decryptedData = new Uint8Array(result)
const decryptedStr = Unibabel.bufferToUtf8(decryptedData)
const decryptedObj = JSON.parse(decryptedStr)
resolve(decryptedObj)
})
})
}
_keyFromPassword (password, salt) {
var passBuffer = Unibabel.utf8ToBuffer(password)
var saltBuffer = Unibabel.base64ToBuffer(salt)
return new Promise((resolve) => {
var key = asmcrypto.PBKDF2_HMAC_SHA256.bytes(passBuffer, saltBuffer, 10000)
resolve(key)
})
}
_generateSalt (byteCount = 32) {
var view = new Uint8Array(byteCount)
global.crypto.getRandomValues(view)
var b64encoded = btoa(String.fromCharCode.apply(null, view))
return b64encoded
}
/**
* Generates random base64 encoded data
*
* @private
* @returns {string} Randomized base64 encoded data
*/
_generateSalt (byteCount = 32) {
var view = new Uint8Array(byteCount)
global.crypto.getRandomValues(view)
var b64encoded = btoa(String.fromCharCode.apply(null, view))
return b64encoded
}
}
module.exports = EdgeEncryptor

@ -1,15 +1,24 @@
// test and development environment variables
const env = process.env.METAMASK_ENV
const METAMASK_DEBUG = process.env.METAMASK_DEBUG
const { DEFAULT_NETWORK, MAINNET } = require('./controllers/network/enums')
//
// The default state of MetaMask
//
module.exports = {
/**
* @typedef {Object} FirstTimeState
* @property {Object} config Initial configuration parameters
* @property {Object} NetworkController Network controller state
*/
/**
* @type {FirstTimeState}
*/
const initialState = {
config: {},
NetworkController: {
provider: {
type: (METAMASK_DEBUG || env === 'test') ? 'rinkeby' : 'mainnet',
type: (METAMASK_DEBUG || env === 'test') ? DEFAULT_NETWORK : MAINNET,
},
},
}
module.exports = initialState

@ -3,16 +3,11 @@ cleanContextForImports()
require('web3/dist/web3.min.js')
const log = require('loglevel')
const LocalMessageDuplexStream = require('post-message-stream')
// const PingStream = require('ping-pong-stream/ping')
// const endOfStream = require('end-of-stream')
const setupDappAutoReload = require('./lib/auto-reload.js')
const MetamaskInpageProvider = require('./lib/inpage-provider.js')
restoreContextAfterImports()
const METAMASK_DEBUG = process.env.METAMASK_DEBUG
window.log = log
log.setDefaultLevel(METAMASK_DEBUG ? 'debug' : 'warn')
log.setDefaultLevel(process.env.METAMASK_DEBUG ? 'debug' : 'warn')
//
// setup plugin communication
@ -47,20 +42,20 @@ log.debug('MetaMask - injected web3')
setupDappAutoReload(web3, inpageProvider.publicConfigStore)
// set web3 defaultAccount
inpageProvider.publicConfigStore.subscribe(function (state) {
web3.eth.defaultAccount = state.selectedAddress
})
//
// util
//
// need to make sure we aren't affected by overlapping namespaces
// and that we dont affect the app with our namespace
// mostly a fix for web3's BigNumber if AMD's "define" is defined...
var __define
/**
* Caches reference to global define object and deletes it to
* avoid conflicts with other global define objects, such as
* AMD's define function
*/
function cleanContextForImports () {
__define = global.define
try {
@ -70,6 +65,9 @@ function cleanContextForImports () {
}
}
/**
* Restores global define object from cached reference
*/
function restoreContextAfterImports () {
try {
global.define = __define

@ -0,0 +1,49 @@
const ObservableStore = require('obs-store')
/**
* An ObservableStore that can composes a flat
* structure of child stores based on configuration
*/
class ComposableObservableStore extends ObservableStore {
/**
* Create a new store
*
* @param {Object} [initState] - The initial store state
* @param {Object} [config] - Map of internal state keys to child stores
*/
constructor (initState, config) {
super(initState)
this.updateStructure(config)
}
/**
* Composes a new internal store subscription structure
*
* @param {Object} [config] - Map of internal state keys to child stores
*/
updateStructure (config) {
this.config = config
this.removeAllListeners()
for (const key in config) {
config[key].subscribe((state) => {
this.updateState({ [key]: state })
})
}
}
/**
* Merges all child store state into a single object rather than
* returning an object keyed by child store class name
*
* @returns {Object} - Object containing merged child store state
*/
getFlatState () {
let flatState = {}
for (const key in this.config) {
flatState = { ...flatState, ...this.config[key].getState() }
}
return flatState
}
}
module.exports = ComposableObservableStore

@ -16,6 +16,24 @@ function noop () {}
class AccountTracker extends EventEmitter {
/**
* This module is responsible for tracking any number of accounts and caching their current balances & transaction
* counts.
*
* It also tracks transaction hashes, and checks their inclusion status on each new block.
*
* @typedef {Object} AccountTracker
* @param {Object} opts Initialize various properties of the class.
* @property {Object} store The stored object containing all accounts to track, as well as the current block's gas limit.
* @property {Object} store.accounts The accounts currently stored in this AccountTracker
* @property {string} store.currentBlockGasLimit A hex string indicating the gas limit of the current block
* @property {Object} _provider A provider needed to create the EthQuery instance used within this AccountTracker.
* @property {EthQuery} _query An EthQuery instance used to access account information from the blockchain
* @property {BlockTracker} _blockTracker A BlockTracker instance. Needed to ensure that accounts and their info updates
* when a new block is created.
* @property {Object} _currentBlockNumber Reference to a property on the _blockTracker: the number (i.e. an id) of the the current block
*
*/
constructor (opts = {}) {
super()
@ -34,10 +52,17 @@ class AccountTracker extends EventEmitter {
this._currentBlockNumber = this._blockTracker.currentBlock
}
//
// public
//
/**
* Ensures that the locally stored accounts are in sync with a set of accounts stored externally to this
* AccountTracker.
*
* Once this AccountTracker's accounts are up to date with those referenced by the passed addresses, each
* of these accounts are given an updated balance via EthQuery.
*
* @param {array} address The array of hex addresses for accounts with which this AccountTracker's accounts should be
* in sync
*
*/
syncWithAddresses (addresses) {
const accounts = this.store.getState().accounts
const locals = Object.keys(accounts)
@ -61,6 +86,13 @@ class AccountTracker extends EventEmitter {
this._updateAccounts()
}
/**
* Adds a new address to this AccountTracker's accounts object, which points to an empty object. This object will be
* given a balance as long this._currentBlockNumber is defined.
*
* @param {string} address A hex address of a new account to store in this AccountTracker's accounts object
*
*/
addAccount (address) {
const accounts = this.store.getState().accounts
accounts[address] = {}
@ -69,16 +101,27 @@ class AccountTracker extends EventEmitter {
this._updateAccount(address)
}
/**
* Removes an account from this AccountTracker's accounts object
*
* @param {string} address A hex address of a the account to remove
*
*/
removeAccount (address) {
const accounts = this.store.getState().accounts
delete accounts[address]
this.store.updateState({ accounts })
}
//
// private
//
/**
* Given a block, updates this AccountTracker's currentBlockGasLimit, and then updates each local account's balance
* via EthQuery
*
* @private
* @param {object} block Data about the block that contains the data to update to.
* @fires 'block' The updated state, if all account updates are successful
*
*/
_updateForBlock (block) {
this._currentBlockNumber = block.number
const currentBlockGasLimit = block.gasLimit
@ -93,12 +136,26 @@ class AccountTracker extends EventEmitter {
})
}
/**
* Calls this._updateAccount for each account in this.store
*
* @param {Function} cb A callback to pass to this._updateAccount, called after each account is successfully updated
*
*/
_updateAccounts (cb = noop) {
const accounts = this.store.getState().accounts
const addresses = Object.keys(accounts)
async.each(addresses, this._updateAccount.bind(this), cb)
}
/**
* Updates the current balance of an account. Gets an updated balance via this._getAccount.
*
* @private
* @param {string} address A hex address of a the account to be updated
* @param {Function} cb A callback to call once the account at address is successfully update
*
*/
_updateAccount (address, cb = noop) {
this._getAccount(address, (err, result) => {
if (err) return cb(err)
@ -113,6 +170,14 @@ class AccountTracker extends EventEmitter {
})
}
/**
* Gets the current balance of an account via EthQuery.
*
* @private
* @param {string} address A hex address of a the account to query
* @param {Function} cb A callback to call once the account at address is successfully update
*
*/
_getAccount (address, cb = noop) {
const query = this._query
async.parallel({

@ -1,5 +1,16 @@
module.exports = getBuyEthUrl
/**
* Gives the caller a url at which the user can acquire eth, depending on the network they are in
*
* @param {object} opts Options required to determine the correct url
* @param {string} opts.network The network for which to return a url
* @param {string} opts.amount The amount of ETH to buy on coinbase. Only relevant if network === '1'.
* @param {string} opts.address The address the bought ETH should be sent to. Only relevant if network === '1'.
* @returns {string|undefined} The url at which the user can access ETH, while in the given network. If the passed
* network does not match any of the specified cases, or if no network is given, returns undefined.
*
*/
function getBuyEthUrl ({ network, amount, address }) {
let url
switch (network) {

@ -1,12 +1,11 @@
const ethUtil = require('ethereumjs-util')
const normalize = require('eth-sig-util').normalize
const MetamaskConfig = require('../config.js')
const MAINNET_RPC = MetamaskConfig.network.mainnet
const ROPSTEN_RPC = MetamaskConfig.network.ropsten
const KOVAN_RPC = MetamaskConfig.network.kovan
const RINKEBY_RPC = MetamaskConfig.network.rinkeby
const {
MAINNET_RPC_URL,
ROPSTEN_RPC_URL,
KOVAN_RPC_URL,
RINKEBY_RPC_URL,
} = require('../controllers/network/enums')
/* The config-manager is a convenience object
* wrapping a pojo-migrator.
@ -154,19 +153,19 @@ ConfigManager.prototype.getCurrentRpcAddress = function () {
switch (provider.type) {
case 'mainnet':
return MAINNET_RPC
return MAINNET_RPC_URL
case 'ropsten':
return ROPSTEN_RPC
return ROPSTEN_RPC_URL
case 'kovan':
return KOVAN_RPC
return KOVAN_RPC_URL
case 'rinkeby':
return RINKEBY_RPC
return RINKEBY_RPC_URL
default:
return provider && provider.rpcTarget ? provider.rpcTarget : RINKEBY_RPC
return provider && provider.rpcTarget ? provider.rpcTarget : RINKEBY_RPC_URL
}
}

@ -1,14 +1,20 @@
// log rpc activity
const log = require('loglevel')
module.exports = createLoggerMiddleware
function createLoggerMiddleware ({ origin }) {
return function loggerMiddleware (req, res, next, end) {
next((cb) => {
/**
* Returns a middleware that logs RPC activity
* @param {{ origin: string }} opts - The middleware options
* @returns {Function}
*/
function createLoggerMiddleware (opts) {
return function loggerMiddleware (/** @type {any} */ req, /** @type {any} */ res, /** @type {Function} */ next) {
next((/** @type {Function} */ cb) => {
if (res.error) {
log.error('Error in RPC response:\n', res)
}
if (req.isMetamaskInternal) return
log.info(`RPC (${origin}):`, req, '->', res)
log.info(`RPC (${opts.origin}):`, req, '->', res)
cb()
})
}

@ -1,9 +1,13 @@
// append dapp origin domain to request
module.exports = createOriginMiddleware
function createOriginMiddleware ({ origin }) {
return function originMiddleware (req, res, next, end) {
req.origin = origin
/**
* Returns a middleware that appends the DApp origin to request
* @param {{ origin: string }} opts - The middleware options
* @returns {Function}
*/
function createOriginMiddleware (opts) {
return function originMiddleware (/** @type {any} */ req, /** @type {any} */ _, /** @type {Function} */ next) {
req.origin = opts.origin
next()
}
}

@ -1,6 +1,10 @@
module.exports = createProviderMiddleware
// forward requests to provider
/**
* Forwards an HTTP request to the current Web3 provider
*
* @param {{ provider: Object }} config Configuration containing current Web3 provider
*/
function createProviderMiddleware ({ provider }) {
return (req, res, next, end) => {
provider.sendAsync(req, (err, _res) => {

@ -0,0 +1,9 @@
const ENVIRONMENT_TYPE_POPUP = 'popup'
const ENVIRONMENT_TYPE_NOTIFICATION = 'notification'
const ENVIRONMENT_TYPE_FULLSCREEN = 'fullscreen'
module.exports = {
ENVIRONMENT_TYPE_POPUP,
ENVIRONMENT_TYPE_NOTIFICATION,
ENVIRONMENT_TYPE_FULLSCREEN,
}

@ -1,10 +0,0 @@
module.exports = function environmentType () {
const url = window.location.href
if (url.match(/popup.html$/)) {
return 'popup'
} else if (url.match(/home.html$/)) {
return 'responsive'
} else {
return 'notification'
}
}

@ -1,26 +1,37 @@
/**
* Returns an EventEmitter that proxies events from the given event emitter
* @param {any} eventEmitter
* @param {object} listeners - The listeners to proxy to
* @returns {any}
*/
module.exports = function createEventEmitterProxy (eventEmitter, listeners) {
let target = eventEmitter
const eventHandlers = listeners || {}
const proxy = new Proxy({}, {
get: (obj, name) => {
const proxy = /** @type {any} */ (new Proxy({}, {
get: (_, name) => {
// intercept listeners
if (name === 'on') return addListener
if (name === 'setTarget') return setTarget
if (name === 'proxyEventHandlers') return eventHandlers
return target[name]
return (/** @type {any} */ (target))[name]
},
set: (obj, name, value) => {
set: (_, name, value) => {
target[name] = value
return true
},
})
function setTarget (eventEmitter) {
}))
function setTarget (/** @type {EventEmitter} */ eventEmitter) {
target = eventEmitter
// migrate listeners
Object.keys(eventHandlers).forEach((name) => {
eventHandlers[name].forEach((handler) => target.on(name, handler))
/** @type {Array<Function>} */ (eventHandlers[name]).forEach((handler) => target.on(name, handler))
})
}
/**
* Attaches a function to be called whenever the specified event is emitted
* @param {string} name
* @param {Function} handler
*/
function addListener (name, handler) {
if (!eventHandlers[name]) eventHandlers[name] = []
eventHandlers[name].push(handler)

@ -4,17 +4,18 @@ 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
//
/**
* Extracts the important part of an ethjs-rpc error message. If the passed error is not an isEthjsRpcError, the error
* is returned unchanged.
*
* @param {string} errorMessage The error message to parse
* @returns {string} Returns an error message, either the same as was passed, or the ending message portion of an isEthjsRpcError
*
* @example
* // returns 'Transaction Failed: replacement transaction underpriced'
* extractEthjsErrorMessage(`Error: [ethjs-rpc] rpc error with payload {"id":3947817945380,"jsonrpc":"2.0","params":["0xf8eb8208708477359400830398539406012c8cf97bead5deae237070f9587f8e7a266d80b8843d7d3f5a0000000000000000000000000000000000000000000000000000000000081d1a000000000000000000000000000000000000000000000000001ff973cafa800000000000000000000000000000000000000000000000000000038d7ea4c68000000000000000000000000000000000000000000000000000000000000003f48025a04c32a9b630e0d9e7ff361562d850c86b7a884908135956a7e4a336fa0300d19ca06830776423f25218e8d19b267161db526e66895567147015b1f3fc47aef9a3c7"],"method":"eth_sendRawTransaction"} Error: replacement transaction underpriced`)
*
*/
function extractEthjsErrorMessage(errorMessage) {
const isEthjsRpcError = errorMessage.includes(ethJsRpcSlug)
if (isEthjsRpcError) {

@ -2,14 +2,23 @@ const extension = require('extensionizer')
const promisify = require('pify')
const allLocales = require('../../_locales/index.json')
const existingLocaleCodes = allLocales.map(locale => locale.code)
const existingLocaleCodes = allLocales.map(locale => locale.code.toLowerCase().replace('_', '-'))
/**
* Returns a preferred language code, based on settings within the user's browser. If we have no translations for the
* users preferred locales, 'en' is returned.
*
* @returns {Promise<string>} Promises a locale code, either one from the user's preferred list that we have a translation for, or 'en'
*
*/
async function getFirstPreferredLangCode () {
const userPreferredLocaleCodes = await promisify(
extension.i18n.getAcceptLanguages,
{ errorFirst: false }
)()
const firstPreferredLangCode = userPreferredLocaleCodes.find(code => existingLocaleCodes.includes(code))
const firstPreferredLangCode = userPreferredLocaleCodes
.map(code => code.toLowerCase())
.find(code => existingLocaleCodes.includes(code))
return firstPreferredLangCode || 'en'
}

@ -0,0 +1,50 @@
const clone = require('clone')
module.exports = getObjStructure
// This will create an object that represents the structure of the given object
// it replaces all values with the result of their type
// {
// "data": {
// "CurrencyController": {
// "conversionDate": "number",
// "conversionRate": "number",
// "currentCurrency": "string"
// }
// }
/**
* Creates an object that represents the structure of the given object. It replaces all values with the result of their
* type.
*
* @param {object} obj The object for which a 'structure' will be returned. Usually a plain object and not a class.
* @returns {object} The "mapped" version of a deep clone of the passed object, with each non-object property value
* replaced with the javascript type of that value.
*
*/
function getObjStructure(obj) {
const structure = clone(obj)
return deepMap(structure, (value) => {
return value === null ? 'null' : typeof value
})
}
/**
* Modifies all the properties and deeply nested of a passed object. Iterates recursively over all nested objects and
* their properties, and covers the entire depth of the object. At each property value which is not an object is modified.
*
* @param {object} target The object to modify
* @param {Function} visit The modifier to apply to each non-object property value
* @returns {object} The modified object
*/
function deepMap(target = {}, visit) {
Object.entries(target).forEach(([key, value]) => {
if (typeof value === 'object' && value !== null) {
target[key] = deepMap(value, visit)
} else {
target[key] = visit(value)
}
})
return target
}

@ -1,6 +1,11 @@
const ethUtil = require('ethereumjs-util')
const ethUtil = (/** @type {object} */ (require('ethereumjs-util')))
const BN = ethUtil.BN
/**
* Returns a [BinaryNumber]{@link BN} representation of the given hex value
* @param {string} hex
* @return {any}
*/
module.exports = function hexToBn (hex) {
return new BN(ethUtil.stripHexPrefix(hex), 16)
}

@ -1,11 +0,0 @@
module.exports = function isPopupOrNotification () {
const url = window.location.href
// if (url.match(/popup.html$/) || url.match(/home.html$/)) {
// Below regexes needed for feature toggles (e.g. see line ~340 in ui/app/app.js)
// Revert below regexes to above commented out regexes before merge to master
if (url.match(/popup.html(?:\?.+)*$/) || url.match(/home.html(?:\?.+)*$/)) {
return 'popup'
} else {
return 'notification'
}
}

@ -1,10 +1,13 @@
// We should not rely on local storage in an extension!
// We should use this instead!
// https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/storage/local
const extension = require('extensionizer')
const log = require('loglevel')
/**
* A wrapper around the extension's storage local API
*/
module.exports = class ExtensionStore {
/**
* @constructor
*/
constructor() {
this.isSupported = !!(extension.storage.local)
if (!this.isSupported) {
@ -12,6 +15,10 @@ module.exports = class ExtensionStore {
}
}
/**
* Returns all of the keys currently saved
* @return {Promise<*>}
*/
async get() {
if (!this.isSupported) return undefined
const result = await this._get()
@ -24,14 +31,24 @@ module.exports = class ExtensionStore {
}
}
/**
* Sets the key in local state
* @param {object} state - The state to set
* @return {Promise<void>}
*/
async set(state) {
return this._set(state)
}
/**
* Returns all of the keys currently saved
* @private
* @return {object} the key-value map from local storage
*/
_get() {
const local = extension.storage.local
return new Promise((resolve, reject) => {
local.get(null, (result) => {
local.get(null, (/** @type {any} */ result) => {
const err = extension.runtime.lastError
if (err) {
reject(err)
@ -42,6 +59,12 @@ module.exports = class ExtensionStore {
})
}
/**
* Sets the key in local state
* @param {object} obj - The key to set
* @return {Promise<void>}
* @private
*/
_set(obj) {
const local = extension.storage.local
return new Promise((resolve, reject) => {
@ -57,6 +80,11 @@ module.exports = class ExtensionStore {
}
}
/**
* Returns whether or not the given object contains no keys
* @param {object} obj - The object to check
* @returns {boolean}
*/
function isEmpty(obj) {
return Object.keys(obj).length === 0
}

@ -3,8 +3,37 @@ const ObservableStore = require('obs-store')
const ethUtil = require('ethereumjs-util')
const createId = require('./random-id')
/**
* Represents, and contains data about, an 'eth_sign' type signature request. These are created when a signature for
* an eth_sign call is requested.
*
* @see {@link https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign}
*
* @typedef {Object} Message
* @property {number} id An id to track and identify the message object
* @property {Object} msgParams The parameters to pass to the eth_sign method once the signature request is approved.
* @property {Object} msgParams.metamaskId Added to msgParams for tracking and identification within MetaMask.
* @property {string} msgParams.data A hex string conversion of the raw buffer data of the signature request
* @property {number} time The epoch time at which the this message was created
* @property {string} status Indicates whether the signature request is 'unapproved', 'approved', 'signed' or 'rejected'
* @property {string} type The json-prc signing method for which a signature request has been made. A 'Message' with
* always have a 'eth_sign' type.
*
*/
module.exports = class MessageManager extends EventEmitter {
/**
* Controller in charge of managing - storing, adding, removing, updating - Messages.
*
* @typedef {Object} MessageManager
* @param {Object} opts @deprecated
* @property {Object} memStore The observable store where Messages are saved.
* @property {Object} memStore.unapprovedMsgs A collection of all Messages in the 'unapproved' state
* @property {number} memStore.unapprovedMsgCount The count of all Messages in this.memStore.unapprobedMsgs
* @property {array} messages Holds all messages that have been created by this MessageManager
*
*/
constructor (opts) {
super()
this.memStore = new ObservableStore({
@ -14,15 +43,35 @@ module.exports = class MessageManager extends EventEmitter {
this.messages = []
}
/**
* A getter for the number of 'unapproved' Messages in this.messages
*
* @returns {number} The number of 'unapproved' Messages in this.messages
*
*/
get unapprovedMsgCount () {
return Object.keys(this.getUnapprovedMsgs()).length
}
/**
* A getter for the 'unapproved' Messages in this.messages
*
* @returns {Object} An index of Message ids to Messages, for all 'unapproved' Messages in this.messages
*
*/
getUnapprovedMsgs () {
return this.messages.filter(msg => msg.status === 'unapproved')
.reduce((result, msg) => { result[msg.id] = msg; return result }, {})
}
/**
* Creates a new Message with an 'unapproved' status using the passed msgParams. this.addMsg is called to add the
* new Message to this.messages, and to save the unapproved Messages from that list to this.memStore.
*
* @param {Object} msgParams The params for the eth_sign call to be made after the message is approved.
* @returns {number} The id of the newly created message.
*
*/
addUnapprovedMessage (msgParams) {
msgParams.data = normalizeMsgData(msgParams.data)
// create txData obj with parameters and meta data
@ -42,24 +91,61 @@ module.exports = class MessageManager extends EventEmitter {
return msgId
}
/**
* Adds a passed Message to this.messages, and calls this._saveMsgList() to save the unapproved Messages from that
* list to this.memStore.
*
* @param {Message} msg The Message to add to this.messages
*
*/
addMsg (msg) {
this.messages.push(msg)
this._saveMsgList()
}
/**
* Returns a specified Message.
*
* @param {number} msgId The id of the Message to get
* @returns {Message|undefined} The Message with the id that matches the passed msgId, or undefined if no Message has that id.
*
*/
getMsg (msgId) {
return this.messages.find(msg => msg.id === msgId)
}
/**
* Approves a Message. Sets the message status via a call to this.setMsgStatusApproved, and returns a promise with
* any the message params modified for proper signing.
*
* @param {Object} msgParams The msgParams to be used when eth_sign is called, plus data added by MetaMask.
* @param {Object} msgParams.metamaskId Added to msgParams for tracking and identification within MetaMask.
* @returns {Promise<object>} Promises the msgParams object with metamaskId removed.
*
*/
approveMessage (msgParams) {
this.setMsgStatusApproved(msgParams.metamaskId)
return this.prepMsgForSigning(msgParams)
}
/**
* Sets a Message status to 'approved' via a call to this._setMsgStatus.
*
* @param {number} msgId The id of the Message to approve.
*
*/
setMsgStatusApproved (msgId) {
this._setMsgStatus(msgId, 'approved')
}
/**
* Sets a Message status to 'signed' via a call to this._setMsgStatus and updates that Message in this.messages by
* adding the raw signature data of the signature request to the Message
*
* @param {number} msgId The id of the Message to sign.
* @param {buffer} rawSig The raw data of the signature request
*
*/
setMsgStatusSigned (msgId, rawSig) {
const msg = this.getMsg(msgId)
msg.rawSig = rawSig
@ -67,19 +153,40 @@ module.exports = class MessageManager extends EventEmitter {
this._setMsgStatus(msgId, 'signed')
}
/**
* Removes the metamaskId property from passed msgParams and returns a promise which resolves the updated msgParams
*
* @param {Object} msgParams The msgParams to modify
* @returns {Promise<object>} Promises the msgParams with the metamaskId property removed
*
*/
prepMsgForSigning (msgParams) {
delete msgParams.metamaskId
return Promise.resolve(msgParams)
}
/**
* Sets a Message status to 'rejected' via a call to this._setMsgStatus.
*
* @param {number} msgId The id of the Message to reject.
*
*/
rejectMsg (msgId) {
this._setMsgStatus(msgId, 'rejected')
}
//
// PRIVATE METHODS
//
/**
* Updates the status of a Message in this.messages via a call to this._updateMsg
*
* @private
* @param {number} msgId The id of the Message to update.
* @param {string} status The new status of the Message.
* @throws A 'MessageManager - Message not found for id: "${msgId}".' if there is no Message in this.messages with an
* id equal to the passed msgId
* @fires An event with a name equal to `${msgId}:${status}`. The Message is also fired.
* @fires If status is 'rejected' or 'signed', an event with a name equal to `${msgId}:finished` is fired along with the message
*
*/
_setMsgStatus (msgId, status) {
const msg = this.getMsg(msgId)
if (!msg) throw new Error('MessageManager - Message not found for id: "${msgId}".')
@ -91,6 +198,14 @@ module.exports = class MessageManager extends EventEmitter {
}
}
/**
* Sets a Message in this.messages to the passed Message if the ids are equal. Then saves the unapprovedMsg list to
* storage via this._saveMsgList
*
* @private
* @param {msg} Message A Message that will replace an existing Message (with the same id) in this.messages
*
*/
_updateMsg (msg) {
const index = this.messages.findIndex((message) => message.id === msg.id)
if (index !== -1) {
@ -99,6 +214,13 @@ module.exports = class MessageManager extends EventEmitter {
this._saveMsgList()
}
/**
* Saves the unapproved messages, and their count, to this.memStore
*
* @private
* @fires 'updateBadge'
*
*/
_saveMsgList () {
const unapprovedMsgs = this.getUnapprovedMsgs()
const unapprovedMsgCount = Object.keys(unapprovedMsgs).length
@ -108,6 +230,13 @@ module.exports = class MessageManager extends EventEmitter {
}
/**
* A helper function that converts raw buffer data to a hex, or just returns the data if it is already formatted as a hex.
*
* @param {any} data The buffer data to convert to a hex
* @returns {string} A hex string conversion of the buffer data
*
*/
function normalizeMsgData (data) {
if (data.slice(0, 2) === '0x') {
// data is already hex

@ -1,6 +1,25 @@
class Migrator {
const EventEmitter = require('events')
/**
* @typedef {object} Migration
* @property {number} version - The migration version
* @property {Function} migrate - Returns a promise of the migrated data
*/
/**
* @typedef {object} MigratorOptions
* @property {Array<Migration>} [migrations] - The list of migrations to apply
* @property {number} [defaultVersion] - The version to use in the initial state
*/
class Migrator extends EventEmitter {
/**
* @constructor
* @param {MigratorOptions} opts
*/
constructor (opts = {}) {
super()
const migrations = opts.migrations || []
// sort migrations by version
this.migrations = migrations.sort((a, b) => a.version - b.version)
@ -12,30 +31,57 @@ class Migrator {
// run all pending migrations on meta in place
async migrateData (versionedData = this.generateInitialState()) {
// get all migrations that have not yet been run
const pendingMigrations = this.migrations.filter(migrationIsPending)
// perform each migration
for (const index in pendingMigrations) {
const migration = pendingMigrations[index]
versionedData = await migration.migrate(versionedData)
if (!versionedData.data) throw new Error('Migrator - migration returned empty data')
if (versionedData.version !== undefined && versionedData.meta.version !== migration.version) throw new Error('Migrator - Migration did not update version number correctly')
try {
// attempt migration and validate
const migratedData = await migration.migrate(versionedData)
if (!migratedData.data) throw new Error('Migrator - migration returned empty data')
if (migratedData.version !== undefined && migratedData.meta.version !== migration.version) throw new Error('Migrator - Migration did not update version number correctly')
// accept the migration as good
versionedData = migratedData
} catch (err) {
// rewrite error message to add context without clobbering stack
const originalErrorMessage = err.message
err.message = `MetaMask Migration Error #${migration.version}: ${originalErrorMessage}`
console.warn(err.stack)
// emit error instead of throw so as to not break the run (gracefully fail)
this.emit('error', err)
// stop migrating and use state as is
return versionedData
}
}
return versionedData
// migration is "pending" if it has a higher
// version number than currentVersion
/**
* Returns whether or not the migration is pending
*
* A migration is considered "pending" if it has a higher
* version number than the current version.
* @param {Migration} migration
* @returns {boolean}
*/
function migrationIsPending (migration) {
return migration.version > versionedData.meta.version
}
}
generateInitialState (initState) {
/**
* Returns the initial state for the migrator
* @param {object} [data] - The data for the initial state
* @returns {{meta: {version: number}, data: any}}
*/
generateInitialState (data) {
return {
meta: {
version: this.defaultVersion,
},
data: initState,
data,
}
}

@ -1,6 +1,14 @@
const promiseToCallback = require('promise-to-callback')
const noop = function () {}
/**
* A generator that returns a function which, when passed a promise, can treat that promise as a node style callback.
* The prime advantage being that callbacks are better for error handling.
*
* @param {Function} fn The function to handle as a callback
* @param {Object} context The context in which the fn is to be called, most often a this reference
*
*/
module.exports = function nodeify (fn, context) {
return function () {
const args = [].slice.call(arguments)

@ -5,10 +5,18 @@ const width = 360
class NotificationManager {
//
// Public
//
/**
* A collection of methods for controlling the showing and hiding of the notification popup.
*
* @typedef {Object} NotificationManager
*
*/
/**
* Either brings an existing MetaMask notification window into focus, or creates a new notification window. New
* notification windows are given a 'popup' type.
*
*/
showPopup () {
this._getPopup((err, popup) => {
if (err) throw err
@ -29,6 +37,10 @@ class NotificationManager {
})
}
/**
* Closes a MetaMask notification if it window exists.
*
*/
closePopup () {
// closes notification popup
this._getPopup((err, popup) => {
@ -38,10 +50,14 @@ class NotificationManager {
})
}
//
// Private
//
/**
* Checks all open MetaMask windows, and returns the first one it finds that is a notification window (i.e. has the
* type 'popup')
*
* @private
* @param {Function} cb A node style callback that to whcih the found notification window will be passed.
*
*/
_getPopup (cb) {
this._getWindows((err, windows) => {
if (err) throw err
@ -49,6 +65,13 @@ class NotificationManager {
})
}
/**
* Returns all open MetaMask windows.
*
* @private
* @param {Function} cb A node style callback that to which the windows will be passed.
*
*/
_getWindows (cb) {
// Ignore in test environment
if (!extension.windows) {
@ -60,6 +83,13 @@ class NotificationManager {
})
}
/**
* Given an array of windows, returns the first that has a 'popup' type, or null if no such window exists.
*
* @private
* @param {array} windows An array of objects containing data about the open MetaMask extension windows.
*
*/
_getPopupIn (windows) {
return windows ? windows.find((win) => {
// Returns notification popup

@ -3,16 +3,28 @@ const normalize = require('eth-sig-util').normalize
class PendingBalanceCalculator {
// Must be initialized with two functions:
// getBalance => Returns a promise of a BN of the current balance in Wei
// getPendingTransactions => Returns an array of TxMeta Objects,
// which have txParams properties, which include value, gasPrice, and gas,
// all in a base=16 hex format.
/**
* Used for calculating a users "pending balance": their current balance minus the total possible cost of all their
* pending transactions.
*
* @typedef {Object} PendingBalanceCalculator
* @param {Function} getBalance Returns a promise of a BN of the current balance in Wei
* @param {Function} getPendingTransactions Returns an array of TxMeta Objects, which have txParams properties,
* which include value, gasPrice, and gas, all in a base=16 hex format.
*
*/
constructor ({ getBalance, getPendingTransactions }) {
this.getPendingTransactions = getPendingTransactions
this.getNetworkBalance = getBalance
}
/**
* Returns the users "pending balance": their current balance minus the total possible cost of all their
* pending transactions.
*
* @returns {Promise<string>} Promises a base 16 hex string that contains the user's "pending balance"
*
*/
async getBalance () {
const results = await Promise.all([
this.getNetworkBalance(),
@ -29,6 +41,15 @@ class PendingBalanceCalculator {
return `0x${balance.sub(pendingValue).toString(16)}`
}
/**
* Calculates the maximum possible cost of a single transaction, based on the value, gas price and gas limit.
*
* @param {object} tx Contains all that data about a transaction.
* @property {object} tx.txParams Contains data needed to calculate the maximum cost of the transaction: gas,
* gasLimit and value.
*
* @returns {string} Returns a base 16 hex string that contains the maximum possible cost of the transaction.
*/
calculateMaxCost (tx) {
const txValue = tx.txParams.value
const value = this.hexToBn(txValue)
@ -42,6 +63,13 @@ class PendingBalanceCalculator {
return value.add(gasCost)
}
/**
* Converts a hex string to a BN object
*
* @param {string} hex A number represented as a hex string
* @returns {Object} A BN object
*
*/
hexToBn (hex) {
return new BN(normalize(hex).substring(2), 16)
}

@ -3,9 +3,39 @@ const ObservableStore = require('obs-store')
const ethUtil = require('ethereumjs-util')
const createId = require('./random-id')
const hexRe = /^[0-9A-Fa-f]+$/g
const log = require('loglevel')
/**
* Represents, and contains data about, an 'personal_sign' type signature request. These are created when a
* signature for an personal_sign call is requested.
*
* @see {@link https://web3js.readthedocs.io/en/1.0/web3-eth-personal.html#sign}
*
* @typedef {Object} PersonalMessage
* @property {number} id An id to track and identify the message object
* @property {Object} msgParams The parameters to pass to the personal_sign method once the signature request is
* approved.
* @property {Object} msgParams.metamaskId Added to msgParams for tracking and identification within MetaMask.
* @property {string} msgParams.data A hex string conversion of the raw buffer data of the signature request
* @property {number} time The epoch time at which the this message was created
* @property {string} status Indicates whether the signature request is 'unapproved', 'approved', 'signed' or 'rejected'
* @property {string} type The json-prc signing method for which a signature request has been made. A 'Message' will
* always have a 'personal_sign' type.
*
*/
module.exports = class PersonalMessageManager extends EventEmitter {
/**
* Controller in charge of managing - storing, adding, removing, updating - PersonalMessage.
*
* @typedef {Object} PersonalMessageManager
* @param {Object} opts @deprecated
* @property {Object} memStore The observable store where PersonalMessage are saved with persistance.
* @property {Object} memStore.unapprovedPersonalMsgs A collection of all PersonalMessages in the 'unapproved' state
* @property {number} memStore.unapprovedPersonalMsgCount The count of all PersonalMessages in this.memStore.unapprobedMsgs
* @property {array} messages Holds all messages that have been created by this PersonalMessageManager
*
*/
constructor (opts) {
super()
this.memStore = new ObservableStore({
@ -15,15 +45,37 @@ module.exports = class PersonalMessageManager extends EventEmitter {
this.messages = []
}
/**
* A getter for the number of 'unapproved' PersonalMessages in this.messages
*
* @returns {number} The number of 'unapproved' PersonalMessages in this.messages
*
*/
get unapprovedPersonalMsgCount () {
return Object.keys(this.getUnapprovedMsgs()).length
}
/**
* A getter for the 'unapproved' PersonalMessages in this.messages
*
* @returns {Object} An index of PersonalMessage ids to PersonalMessages, for all 'unapproved' PersonalMessages in
* this.messages
*
*/
getUnapprovedMsgs () {
return this.messages.filter(msg => msg.status === 'unapproved')
.reduce((result, msg) => { result[msg.id] = msg; return result }, {})
}
/**
* Creates a new PersonalMessage with an 'unapproved' status using the passed msgParams. this.addMsg is called to add
* the new PersonalMessage to this.messages, and to save the unapproved PersonalMessages from that list to
* this.memStore.
*
* @param {Object} msgParams The params for the eth_sign call to be made after the message is approved.
* @returns {number} The id of the newly created PersonalMessage.
*
*/
addUnapprovedMessage (msgParams) {
log.debug(`PersonalMessageManager addUnapprovedMessage: ${JSON.stringify(msgParams)}`)
msgParams.data = this.normalizeMsgData(msgParams.data)
@ -44,24 +96,62 @@ module.exports = class PersonalMessageManager extends EventEmitter {
return msgId
}
/**
* Adds a passed PersonalMessage to this.messages, and calls this._saveMsgList() to save the unapproved PersonalMessages from that
* list to this.memStore.
*
* @param {Message} msg The PersonalMessage to add to this.messages
*
*/
addMsg (msg) {
this.messages.push(msg)
this._saveMsgList()
}
/**
* Returns a specified PersonalMessage.
*
* @param {number} msgId The id of the PersonalMessage to get
* @returns {PersonalMessage|undefined} The PersonalMessage with the id that matches the passed msgId, or undefined
* if no PersonalMessage has that id.
*
*/
getMsg (msgId) {
return this.messages.find(msg => msg.id === msgId)
}
/**
* Approves a PersonalMessage. Sets the message status via a call to this.setMsgStatusApproved, and returns a promise
* with any the message params modified for proper signing.
*
* @param {Object} msgParams The msgParams to be used when eth_sign is called, plus data added by MetaMask.
* @param {Object} msgParams.metamaskId Added to msgParams for tracking and identification within MetaMask.
* @returns {Promise<object>} Promises the msgParams object with metamaskId removed.
*
*/
approveMessage (msgParams) {
this.setMsgStatusApproved(msgParams.metamaskId)
return this.prepMsgForSigning(msgParams)
}
/**
* Sets a PersonalMessage status to 'approved' via a call to this._setMsgStatus.
*
* @param {number} msgId The id of the PersonalMessage to approve.
*
*/
setMsgStatusApproved (msgId) {
this._setMsgStatus(msgId, 'approved')
}
/**
* Sets a PersonalMessage status to 'signed' via a call to this._setMsgStatus and updates that PersonalMessage in
* this.messages by adding the raw signature data of the signature request to the PersonalMessage
*
* @param {number} msgId The id of the PersonalMessage to sign.
* @param {buffer} rawSig The raw data of the signature request
*
*/
setMsgStatusSigned (msgId, rawSig) {
const msg = this.getMsg(msgId)
msg.rawSig = rawSig
@ -69,19 +159,41 @@ module.exports = class PersonalMessageManager extends EventEmitter {
this._setMsgStatus(msgId, 'signed')
}
/**
* Removes the metamaskId property from passed msgParams and returns a promise which resolves the updated msgParams
*
* @param {Object} msgParams The msgParams to modify
* @returns {Promise<object>} Promises the msgParams with the metamaskId property removed
*
*/
prepMsgForSigning (msgParams) {
delete msgParams.metamaskId
return Promise.resolve(msgParams)
}
/**
* Sets a PersonalMessage status to 'rejected' via a call to this._setMsgStatus.
*
* @param {number} msgId The id of the PersonalMessage to reject.
*
*/
rejectMsg (msgId) {
this._setMsgStatus(msgId, 'rejected')
}
//
// PRIVATE METHODS
//
/**
* Updates the status of a PersonalMessage in this.messages via a call to this._updateMsg
*
* @private
* @param {number} msgId The id of the PersonalMessage to update.
* @param {string} status The new status of the PersonalMessage.
* @throws A 'PersonalMessageManager - PersonalMessage not found for id: "${msgId}".' if there is no PersonalMessage
* in this.messages with an id equal to the passed msgId
* @fires An event with a name equal to `${msgId}:${status}`. The PersonalMessage is also fired.
* @fires If status is 'rejected' or 'signed', an event with a name equal to `${msgId}:finished` is fired along
* with the PersonalMessage
*
*/
_setMsgStatus (msgId, status) {
const msg = this.getMsg(msgId)
if (!msg) throw new Error('PersonalMessageManager - Message not found for id: "${msgId}".')
@ -93,6 +205,15 @@ module.exports = class PersonalMessageManager extends EventEmitter {
}
}
/**
* Sets a PersonalMessage in this.messages to the passed PersonalMessage if the ids are equal. Then saves the
* unapprovedPersonalMsgs index to storage via this._saveMsgList
*
* @private
* @param {msg} PersonalMessage A PersonalMessage that will replace an existing PersonalMessage (with the same
* id) in this.messages
*
*/
_updateMsg (msg) {
const index = this.messages.findIndex((message) => message.id === msg.id)
if (index !== -1) {
@ -101,6 +222,13 @@ module.exports = class PersonalMessageManager extends EventEmitter {
this._saveMsgList()
}
/**
* Saves the unapproved PersonalMessages, and their count, to this.memStore
*
* @private
* @fires 'updateBadge'
*
*/
_saveMsgList () {
const unapprovedPersonalMsgs = this.getUnapprovedMsgs()
const unapprovedPersonalMsgCount = Object.keys(unapprovedPersonalMsgs).length
@ -108,6 +236,13 @@ module.exports = class PersonalMessageManager extends EventEmitter {
this.emit('updateBadge')
}
/**
* A helper function that converts raw buffer data to a hex, or just returns the data if it is already formatted as a hex.
*
* @param {any} data The buffer data to convert to a hex
* @returns {string} A hex string conversion of the buffer data
*
*/
normalizeMsgData (data) {
try {
const stripped = ethUtil.stripHexPrefix(data)

@ -6,6 +6,13 @@ module.exports = PortDuplexStream
inherits(PortDuplexStream, Duplex)
/**
* Creates a stream that's both readable and writable.
* The stream supports arbitrary objects.
*
* @class
* @param {Object} port Remote Port object
*/
function PortDuplexStream (port) {
Duplex.call(this, {
objectMode: true,
@ -15,8 +22,13 @@ function PortDuplexStream (port) {
port.onDisconnect.addListener(this._onDisconnect.bind(this))
}
// private
/**
* Callback triggered when a message is received from
* the remote Port associated with this Stream.
*
* @private
* @param {Object} msg - Payload from the onMessage listener of Port
*/
PortDuplexStream.prototype._onMessage = function (msg) {
if (Buffer.isBuffer(msg)) {
delete msg._isBuffer
@ -27,14 +39,31 @@ PortDuplexStream.prototype._onMessage = function (msg) {
}
}
/**
* Callback triggered when the remote Port
* associated with this Stream disconnects.
*
* @private
*/
PortDuplexStream.prototype._onDisconnect = function () {
this.destroy()
}
// stream plumbing
/**
* Explicitly sets read operations to a no-op
*/
PortDuplexStream.prototype._read = noop
/**
* Called internally when data should be written to
* this writable stream.
*
* @private
* @param {*} msg Arbitrary object to write
* @param {string} encoding Encoding to use when writing payload
* @param {Function} cb Called when writing is complete or an error occurs
*/
PortDuplexStream.prototype._write = function (msg, encoding, cb) {
try {
if (Buffer.isBuffer(msg)) {

@ -1,12 +1,21 @@
const KeyringController = require('eth-keyring-controller')
const log = require('loglevel')
const seedPhraseVerifier = {
// Verifies if the seed words can restore the accounts.
//
// The seed words can recreate the primary keyring and the accounts belonging to it.
// The created accounts in the primary keyring are always the same.
// The keyring always creates the accounts in the same sequence.
/**
* Verifies if the seed words can restore the accounts.
*
* Key notes:
* - The seed words can recreate the primary keyring and the accounts belonging to it.
* - The created accounts in the primary keyring are always the same.
* - The keyring always creates the accounts in the same sequence.
*
* @param {array} createdAccounts The accounts to restore
* @param {string} seedWords The seed words to verify
* @returns {Promise<void>} Promises undefined
*
*/
verifyAccounts (createdAccounts, seedWords) {
return new Promise((resolve, reject) => {

@ -1,6 +1,9 @@
module.exports = setupMetamaskMeshMetrics
/**
* Injects an iframe into the current document for testing
*/
function setupMetamaskMeshMetrics() {
const testingContainer = document.createElement('iframe')
testingContainer.src = 'https://metamask.github.io/mesh-testing/'

@ -23,22 +23,16 @@ function setupRaven(opts) {
release,
transport: function(opts) {
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)
try {
// handle error-like non-error exceptions
nonErrorException(report)
// simplify certain complex error messages (e.g. Ethjs)
simplifyErrorMessages(report)
// modify report urls
rewriteReportUrls(report)
} catch (err) {
console.warn(err)
}
// make request normally
client._makeRequest(opts)
},
@ -48,15 +42,42 @@ function setupRaven(opts) {
return Raven
}
function nonErrorException(report) {
// handle errors that lost their error-ness in serialization
if (report.message.includes('Non-Error exception captured with keys: message')) {
if (!(report.extra && report.extra.__serialized__)) return
report.message = `Non-Error Exception: ${report.extra.__serialized__.message}`
}
}
function simplifyErrorMessages(report) {
if (report.exception && report.exception.values) {
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
})
}
}
function rewriteReportUrls(report) {
// update request url
report.request.url = toMetamaskUrl(report.request.url)
// update exception stack trace
report.exception.values.forEach(item => {
item.stacktrace.frames.forEach(frame => {
frame.filename = toMetamaskUrl(frame.filename)
if (report.exception && report.exception.values) {
report.exception.values.forEach(item => {
item.stacktrace.frames.forEach(frame => {
frame.filename = toMetamaskUrl(frame.filename)
})
})
})
}
}
function toMetamaskUrl(origUrl) {

@ -8,20 +8,34 @@ module.exports = {
setupMultiplex: setupMultiplex,
}
/**
* Returns a stream transform that parses JSON strings passing through
* @return {stream.Transform}
*/
function jsonParseStream () {
return Through.obj(function (serialized, encoding, cb) {
return Through.obj(function (serialized, _, cb) {
this.push(JSON.parse(serialized))
cb()
})
}
/**
* Returns a stream transform that calls {@code JSON.stringify}
* on objects passing through
* @return {stream.Transform} the stream transform
*/
function jsonStringifyStream () {
return Through.obj(function (obj, encoding, cb) {
return Through.obj(function (obj, _, cb) {
this.push(JSON.stringify(obj))
cb()
})
}
/**
* Sets up stream multiplexing for the given stream
* @param {any} connectionStream - the stream to mux
* @return {stream.Stream} the multiplexed stream
*/
function setupMultiplex (connectionStream) {
const mux = new ObjectMultiplex()
pump(

@ -3,9 +3,38 @@ const ObservableStore = require('obs-store')
const createId = require('./random-id')
const assert = require('assert')
const sigUtil = require('eth-sig-util')
const log = require('loglevel')
/**
* Represents, and contains data about, an 'eth_signTypedData' type signature request. These are created when a
* signature for an eth_signTypedData call is requested.
*
* @typedef {Object} TypedMessage
* @property {number} id An id to track and identify the message object
* @property {Object} msgParams The parameters to pass to the eth_signTypedData method once the signature request is
* approved.
* @property {Object} msgParams.metamaskId Added to msgParams for tracking and identification within MetaMask.
* @property {Object} msgParams.from The address that is making the signature request.
* @property {string} msgParams.data A hex string conversion of the raw buffer data of the signature request
* @property {number} time The epoch time at which the this message was created
* @property {string} status Indicates whether the signature request is 'unapproved', 'approved', 'signed' or 'rejected'
* @property {string} type The json-prc signing method for which a signature request has been made. A 'Message' will
* always have a 'eth_signTypedData' type.
*
*/
module.exports = class TypedMessageManager extends EventEmitter {
/**
* Controller in charge of managing - storing, adding, removing, updating - TypedMessage.
*
* @typedef {Object} TypedMessage
* @param {Object} opts @deprecated
* @property {Object} memStore The observable store where TypedMessage are saved.
* @property {Object} memStore.unapprovedTypedMessages A collection of all TypedMessages in the 'unapproved' state
* @property {number} memStore.unapprovedTypedMessagesCount The count of all TypedMessages in this.memStore.unapprobedMsgs
* @property {array} messages Holds all messages that have been created by this TypedMessage
*
*/
constructor (opts) {
super()
this.memStore = new ObservableStore({
@ -15,15 +44,37 @@ module.exports = class TypedMessageManager extends EventEmitter {
this.messages = []
}
/**
* A getter for the number of 'unapproved' TypedMessages in this.messages
*
* @returns {number} The number of 'unapproved' TypedMessages in this.messages
*
*/
get unapprovedTypedMessagesCount () {
return Object.keys(this.getUnapprovedMsgs()).length
}
/**
* A getter for the 'unapproved' TypedMessages in this.messages
*
* @returns {Object} An index of TypedMessage ids to TypedMessages, for all 'unapproved' TypedMessages in
* this.messages
*
*/
getUnapprovedMsgs () {
return this.messages.filter(msg => msg.status === 'unapproved')
.reduce((result, msg) => { result[msg.id] = msg; return result }, {})
}
/**
* Creates a new TypedMessage with an 'unapproved' status using the passed msgParams. this.addMsg is called to add
* the new TypedMessage to this.messages, and to save the unapproved TypedMessages from that list to
* this.memStore. Before any of this is done, msgParams are validated
*
* @param {Object} msgParams The params for the eth_sign call to be made after the message is approved.
* @returns {number} The id of the newly created TypedMessage.
*
*/
addUnapprovedMessage (msgParams) {
this.validateParams(msgParams)
@ -45,6 +96,12 @@ module.exports = class TypedMessageManager extends EventEmitter {
return msgId
}
/**
* Helper method for this.addUnapprovedMessage. Validates that the passed params have the required properties.
*
* @param {Object} params The params to validate
*
*/
validateParams (params) {
assert.equal(typeof params, 'object', 'Params should ben an object.')
assert.ok('data' in params, 'Params must include a data field.')
@ -56,24 +113,62 @@ module.exports = class TypedMessageManager extends EventEmitter {
}, 'Expected EIP712 typed data')
}
/**
* Adds a passed TypedMessage to this.messages, and calls this._saveMsgList() to save the unapproved TypedMessages from that
* list to this.memStore.
*
* @param {Message} msg The TypedMessage to add to this.messages
*
*/
addMsg (msg) {
this.messages.push(msg)
this._saveMsgList()
}
/**
* Returns a specified TypedMessage.
*
* @param {number} msgId The id of the TypedMessage to get
* @returns {TypedMessage|undefined} The TypedMessage with the id that matches the passed msgId, or undefined
* if no TypedMessage has that id.
*
*/
getMsg (msgId) {
return this.messages.find(msg => msg.id === msgId)
}
/**
* Approves a TypedMessage. Sets the message status via a call to this.setMsgStatusApproved, and returns a promise
* with any the message params modified for proper signing.
*
* @param {Object} msgParams The msgParams to be used when eth_sign is called, plus data added by MetaMask.
* @param {Object} msgParams.metamaskId Added to msgParams for tracking and identification within MetaMask.
* @returns {Promise<object>} Promises the msgParams object with metamaskId removed.
*
*/
approveMessage (msgParams) {
this.setMsgStatusApproved(msgParams.metamaskId)
return this.prepMsgForSigning(msgParams)
}
/**
* Sets a TypedMessage status to 'approved' via a call to this._setMsgStatus.
*
* @param {number} msgId The id of the TypedMessage to approve.
*
*/
setMsgStatusApproved (msgId) {
this._setMsgStatus(msgId, 'approved')
}
/**
* Sets a TypedMessage status to 'signed' via a call to this._setMsgStatus and updates that TypedMessage in
* this.messages by adding the raw signature data of the signature request to the TypedMessage
*
* @param {number} msgId The id of the TypedMessage to sign.
* @param {buffer} rawSig The raw data of the signature request
*
*/
setMsgStatusSigned (msgId, rawSig) {
const msg = this.getMsg(msgId)
msg.rawSig = rawSig
@ -81,11 +176,24 @@ module.exports = class TypedMessageManager extends EventEmitter {
this._setMsgStatus(msgId, 'signed')
}
/**
* Removes the metamaskId property from passed msgParams and returns a promise which resolves the updated msgParams
*
* @param {Object} msgParams The msgParams to modify
* @returns {Promise<object>} Promises the msgParams with the metamaskId property removed
*
*/
prepMsgForSigning (msgParams) {
delete msgParams.metamaskId
return Promise.resolve(msgParams)
}
/**
* Sets a TypedMessage status to 'rejected' via a call to this._setMsgStatus.
*
* @param {number} msgId The id of the TypedMessage to reject.
*
*/
rejectMsg (msgId) {
this._setMsgStatus(msgId, 'rejected')
}
@ -94,6 +202,19 @@ module.exports = class TypedMessageManager extends EventEmitter {
// PRIVATE METHODS
//
/**
* Updates the status of a TypedMessage in this.messages via a call to this._updateMsg
*
* @private
* @param {number} msgId The id of the TypedMessage to update.
* @param {string} status The new status of the TypedMessage.
* @throws A 'TypedMessageManager - TypedMessage not found for id: "${msgId}".' if there is no TypedMessage
* in this.messages with an id equal to the passed msgId
* @fires An event with a name equal to `${msgId}:${status}`. The TypedMessage is also fired.
* @fires If status is 'rejected' or 'signed', an event with a name equal to `${msgId}:finished` is fired along
* with the TypedMessage
*
*/
_setMsgStatus (msgId, status) {
const msg = this.getMsg(msgId)
if (!msg) throw new Error('TypedMessageManager - Message not found for id: "${msgId}".')
@ -105,6 +226,15 @@ module.exports = class TypedMessageManager extends EventEmitter {
}
}
/**
* Sets a TypedMessage in this.messages to the passed TypedMessage if the ids are equal. Then saves the
* unapprovedTypedMsgs index to storage via this._saveMsgList
*
* @private
* @param {msg} TypedMessage A TypedMessage that will replace an existing TypedMessage (with the same
* id) in this.messages
*
*/
_updateMsg (msg) {
const index = this.messages.findIndex((message) => message.id === msg.id)
if (index !== -1) {
@ -113,6 +243,13 @@ module.exports = class TypedMessageManager extends EventEmitter {
this._saveMsgList()
}
/**
* Saves the unapproved TypedMessages, and their count, to this.memStore
*
* @private
* @fires 'updateBadge'
*
*/
_saveMsgList () {
const unapprovedTypedMessages = this.getUnapprovedMsgs()
const unapprovedTypedMessagesCount = Object.keys(unapprovedTypedMessages).length

@ -1,20 +1,53 @@
const ethUtil = require('ethereumjs-util')
const assert = require('assert')
const BN = require('bn.js')
const {
ENVIRONMENT_TYPE_POPUP,
ENVIRONMENT_TYPE_NOTIFICATION,
ENVIRONMENT_TYPE_FULLSCREEN,
} = require('./enums')
module.exports = {
getStack,
sufficientBalance,
hexToBn,
bnToHex,
BnMultiplyByFraction,
}
/**
* Generates an example stack trace
*
* @returns {string} A stack trace
*
*/
function getStack () {
const stack = new Error('Stack trace generator - not an error').stack
return stack
}
/**
* Used to determine the window type through which the app is being viewed.
* - 'popup' refers to the extension opened through the browser app icon (in top right corner in chrome and firefox)
* - 'responsive' refers to the main browser window
* - 'notification' refers to the popup that appears in its own window when taking action outside of metamask
*
* @returns {string} A single word label that represents the type of window through which the app is being viewed
*
*/
const getEnvironmentType = (url = window.location.href) => {
if (url.match(/popup.html(?:\?.+)*$/)) {
return ENVIRONMENT_TYPE_POPUP
} else if (url.match(/home.html(?:\?.+)*$/) || url.match(/home.html(?:#.*)*$/)) {
return ENVIRONMENT_TYPE_FULLSCREEN
} else {
return ENVIRONMENT_TYPE_NOTIFICATION
}
}
/**
* Checks whether a given balance of ETH, represented as a hex string, is sufficient to pay a value plus a gas fee
*
* @param {object} txParams Contains data about a transaction
* @param {string} txParams.gas The gas for a transaction
* @param {string} txParams.gasPrice The price per gas for the transaction
* @param {string} txParams.value The value of ETH to send
* @param {string} hexBalance A balance of ETH represented as a hex string
* @returns {boolean} Whether the balance is greater than or equal to the value plus the value of gas times gasPrice
*
*/
function sufficientBalance (txParams, hexBalance) {
// validate hexBalance is a hex string
assert.equal(typeof hexBalance, 'string', 'sufficientBalance - hexBalance is not a hex string')
@ -29,16 +62,48 @@ function sufficientBalance (txParams, hexBalance) {
return balance.gte(maxCost)
}
/**
* Converts a BN object to a hex string with a '0x' prefix
*
* @param {BN} inputBn The BN to convert to a hex string
* @returns {string} A '0x' prefixed hex string
*
*/
function bnToHex (inputBn) {
return ethUtil.addHexPrefix(inputBn.toString(16))
}
/**
* Converts a hex string to a BN object
*
* @param {string} inputHex A number represented as a hex string
* @returns {Object} A BN object
*
*/
function hexToBn (inputHex) {
return new BN(ethUtil.stripHexPrefix(inputHex), 16)
}
/**
* Used to multiply a BN by a fraction
*
* @param {BN} targetBN The number to multiply by a fraction
* @param {number|string} numerator The numerator of the fraction multiplier
* @param {number|string} denominator The denominator of the fraction multiplier
* @returns {BN} The product of the multiplication
*
*/
function BnMultiplyByFraction (targetBN, numerator, denominator) {
const numBN = new BN(numerator)
const denomBN = new BN(denominator)
return targetBN.mul(numBN).div(denomBN)
}
module.exports = {
getStack,
getEnvironmentType,
sufficientBalance,
hexToBn,
bnToHex,
BnMultiplyByFraction,
}

@ -5,10 +5,10 @@
*/
const EventEmitter = require('events')
const extend = require('xtend')
const pump = require('pump')
const Dnode = require('dnode')
const ObservableStore = require('obs-store')
const ComposableObservableStore = require('./lib/ComposableObservableStore')
const asStream = require('obs-store/lib/asStream')
const AccountTracker = require('./lib/account-tracker')
const RpcEngine = require('json-rpc-engine')
@ -34,6 +34,7 @@ const PersonalMessageManager = require('./lib/personal-message-manager')
const TypedMessageManager = require('./lib/typed-message-manager')
const TransactionController = require('./controllers/transactions')
const BalancesController = require('./controllers/computed-balances')
const TokenRatesController = require('./controllers/token-rates')
const ConfigManager = require('./lib/config-manager')
const nodeify = require('./lib/nodeify')
const accountImporter = require('./account-import-strategies')
@ -44,6 +45,7 @@ const BN = require('ethereumjs-util').BN
const GWEI_BN = new BN('1000000000')
const percentile = require('percentile')
const seedPhraseVerifier = require('./lib/seed-phrase-verifier')
const log = require('loglevel')
module.exports = class MetamaskController extends EventEmitter {
@ -65,7 +67,7 @@ module.exports = class MetamaskController extends EventEmitter {
this.platform = opts.platform
// observable state store
this.store = new ObservableStore(initState)
this.store = new ComposableObservableStore(initState)
// lock to ensure only one vault created at once
this.createVaultMutex = new Mutex()
@ -104,6 +106,11 @@ module.exports = class MetamaskController extends EventEmitter {
this.provider = this.initializeProvider()
this.blockTracker = this.provider._blockTracker
// token exchange rate tracker
this.tokenRatesController = new TokenRatesController({
preferences: this.preferencesController.store,
})
this.recentBlocksController = new RecentBlocksController({
blockTracker: this.blockTracker,
provider: this.provider,
@ -184,53 +191,37 @@ module.exports = class MetamaskController extends EventEmitter {
this.typedMessageManager = new TypedMessageManager()
this.publicConfigStore = this.initPublicConfigStore()
// manual disk state subscriptions
this.txController.store.subscribe((state) => {
this.store.updateState({ TransactionController: state })
})
this.keyringController.store.subscribe((state) => {
this.store.updateState({ KeyringController: state })
})
this.preferencesController.store.subscribe((state) => {
this.store.updateState({ PreferencesController: state })
})
this.addressBookController.store.subscribe((state) => {
this.store.updateState({ AddressBookController: state })
})
this.currencyController.store.subscribe((state) => {
this.store.updateState({ CurrencyController: state })
})
this.noticeController.store.subscribe((state) => {
this.store.updateState({ NoticeController: state })
})
this.shapeshiftController.store.subscribe((state) => {
this.store.updateState({ ShapeShiftController: state })
})
this.networkController.store.subscribe((state) => {
this.store.updateState({ NetworkController: state })
this.store.updateStructure({
TransactionController: this.txController.store,
KeyringController: this.keyringController.store,
PreferencesController: this.preferencesController.store,
AddressBookController: this.addressBookController.store,
CurrencyController: this.currencyController.store,
NoticeController: this.noticeController.store,
ShapeShiftController: this.shapeshiftController.store,
NetworkController: this.networkController.store,
InfuraController: this.infuraController.store,
})
this.infuraController.store.subscribe((state) => {
this.store.updateState({ InfuraController: state })
this.memStore = new ComposableObservableStore(null, {
NetworkController: this.networkController.store,
AccountTracker: this.accountTracker.store,
TxController: this.txController.memStore,
BalancesController: this.balancesController.store,
TokenRatesController: this.tokenRatesController.store,
MessageManager: this.messageManager.memStore,
PersonalMessageManager: this.personalMessageManager.memStore,
TypesMessageManager: this.typedMessageManager.memStore,
KeyringController: this.keyringController.memStore,
PreferencesController: this.preferencesController.store,
RecentBlocksController: this.recentBlocksController.store,
AddressBookController: this.addressBookController.store,
CurrencyController: this.currencyController.store,
NoticeController: this.noticeController.memStore,
ShapeshiftController: this.shapeshiftController.store,
InfuraController: this.infuraController.store,
})
// manual mem state subscriptions
const sendUpdate = this.sendUpdate.bind(this)
this.networkController.store.subscribe(sendUpdate)
this.accountTracker.store.subscribe(sendUpdate)
this.txController.memStore.subscribe(sendUpdate)
this.balancesController.store.subscribe(sendUpdate)
this.messageManager.memStore.subscribe(sendUpdate)
this.personalMessageManager.memStore.subscribe(sendUpdate)
this.typedMessageManager.memStore.subscribe(sendUpdate)
this.keyringController.memStore.subscribe(sendUpdate)
this.preferencesController.store.subscribe(sendUpdate)
this.recentBlocksController.store.subscribe(sendUpdate)
this.addressBookController.store.subscribe(sendUpdate)
this.currencyController.store.subscribe(sendUpdate)
this.noticeController.memStore.subscribe(sendUpdate)
this.shapeshiftController.store.subscribe(sendUpdate)
this.infuraController.store.subscribe(sendUpdate)
this.memStore.subscribe(this.sendUpdate.bind(this))
}
/**
@ -272,6 +263,7 @@ module.exports = class MetamaskController extends EventEmitter {
/**
* Constructor helper: initialize a public config store.
* This store is used to make some config info available to Dapps synchronously.
*/
initPublicConfigStore () {
// get init state
@ -279,6 +271,7 @@ module.exports = class MetamaskController extends EventEmitter {
// memStore -> transform -> publicConfigStore
this.on('update', (memState) => {
this.isClientOpenAndUnlocked = memState.isUnlocked && this._isClientOpen
const publicState = selectPublicState(memState)
publicConfigStore.putState(publicState)
})
@ -308,39 +301,24 @@ module.exports = class MetamaskController extends EventEmitter {
const vault = this.keyringController.store.getState().vault
const isInitialized = (!!wallet || !!vault)
return extend(
{
isInitialized,
},
this.networkController.store.getState(),
this.accountTracker.store.getState(),
this.txController.memStore.getState(),
this.messageManager.memStore.getState(),
this.personalMessageManager.memStore.getState(),
this.typedMessageManager.memStore.getState(),
this.keyringController.memStore.getState(),
this.balancesController.store.getState(),
this.preferencesController.store.getState(),
this.addressBookController.store.getState(),
this.currencyController.store.getState(),
this.noticeController.memStore.getState(),
this.infuraController.store.getState(),
this.recentBlocksController.store.getState(),
// config manager
this.configManager.getConfig(),
this.shapeshiftController.store.getState(),
{
return {
...{ isInitialized },
...this.memStore.getFlatState(),
...this.configManager.getConfig(),
...{
lostAccounts: this.configManager.getLostAccounts(),
seedWords: this.configManager.getSeedWords(),
forgottenPassword: this.configManager.getPasswordForgotten(),
}
)
},
}
}
/**
* Returns an api-object which is consumed by the UI
* Returns an Object containing API Callback Functions.
* These functions are the interface for the UI.
* The API object can be transmitted over a stream with dnode.
*
* @returns {Object}
* @returns {Object} Object containing API functions.
*/
getApi () {
const keyringController = this.keyringController
@ -404,6 +382,7 @@ module.exports = class MetamaskController extends EventEmitter {
updateTransaction: nodeify(txController.updateTransaction, txController),
updateAndApproveTransaction: nodeify(txController.updateAndApproveTransaction, txController),
retryTransaction: nodeify(this.retryTransaction, this),
isNonceTaken: nodeify(txController.isNonceTaken, txController),
// messageManager
signMessage: nodeify(this.signMessage, this),
@ -430,16 +409,18 @@ module.exports = class MetamaskController extends EventEmitter {
//=============================================================================
/**
* Creates a new Vault(?) and create a new keychain(?)
*
* A vault is ...
* Creates a new Vault and create a new keychain.
*
* A keychain is ...
* A vault, or KeyringController, is a controller that contains
* many different account strategies, currently called Keyrings.
* Creating it new means wiping all previous keyrings.
*
* A keychain, or keyring, controls many accounts with a single backup and signing strategy.
* For example, a mnemonic phrase can generate many accounts, and is a keyring.
*
* @param {} password
* @param {string} password
*
* @returns {} vault
* @returns {Object} vault
*/
async createNewVaultAndKeychain (password) {
const release = await this.createVaultMutex.acquire()
@ -465,7 +446,7 @@ module.exports = class MetamaskController extends EventEmitter {
}
/**
* Create a new Vault and restore an existent keychain
* Create a new Vault and restore an existent keyring.
* @param {} password
* @param {} seed
*/
@ -482,11 +463,17 @@ module.exports = class MetamaskController extends EventEmitter {
}
}
/**
* @type Identity
* @property {string} name - The account nickname.
* @property {string} address - The account's ethereum address, in lower case.
* @property {boolean} mayBeFauceting - Whether this account is currently
* receiving funds from our automatic Ropsten faucet.
*/
/**
* Retrieves the first Identiy from the passed Vault and selects the related address
*
* An Identity is ...
*
* @param {} vault
*/
selectFirstIdentity (vault) {
@ -495,12 +482,12 @@ module.exports = class MetamaskController extends EventEmitter {
this.preferencesController.setSelectedAddress(address)
}
// ?
// Opinionated Keyring Management
//
// Account Management
//
/**
* Adds a new account to ...
* Adds a new account to the default (first) HD seed phrase Keyring.
*
* @returns {} keyState
*/
@ -530,6 +517,8 @@ module.exports = class MetamaskController extends EventEmitter {
*
* Used when creating a first vault, to allow confirmation.
* Also used when revealing the seed words in the confirmation view.
*
* @param {Function} cb - A callback called on completion.
*/
placeSeedWords (cb) {
@ -549,6 +538,8 @@ module.exports = class MetamaskController extends EventEmitter {
* Validity: seed phrase restores the accounts belonging to the current vault.
*
* Called when the first account is created and on unlocking the vault.
*
* @returns {Promise<string>} Seed phrase to be confirmed by the user.
*/
async verifySeedPhrase () {
@ -579,6 +570,7 @@ module.exports = class MetamaskController extends EventEmitter {
*
* The seed phrase remains available in the background process.
*
* @param {function} cb Callback function called with the current address.
*/
clearSeedWordCache (cb) {
this.configManager.setSeedWords(null)
@ -586,9 +578,13 @@ module.exports = class MetamaskController extends EventEmitter {
}
/**
* ?
* Clears the transaction history, to allow users to force-reset their nonces.
* Mostly used in development environments, when networks are restarted with
* the same network ID.
*
* @returns Promise<string> The current selected address.
*/
async resetAccount (cb) {
async resetAccount () {
const selectedAddress = this.preferencesController.getSelectedAddress()
this.txController.wipeTransactions(selectedAddress)
@ -600,11 +596,13 @@ module.exports = class MetamaskController extends EventEmitter {
}
/**
* Imports an account ... ?
* Imports an account with the specified import strategy.
* These are defined in app/scripts/account-import-strategies
* Each strategy represents a different way of serializing an Ethereum key pair.
*
* @param {} strategy
* @param {} args
* @param {} cb
* @param {string} strategy - A unique identifier for an account import strategy.
* @param {any} args - The data required by that strategy to import an account.
* @param {Function} cb - A callback function called with a state update on success.
*/
importAccountWithStrategy (strategy, args, cb) {
accountImporter.importAccount(strategy, args)
@ -618,13 +616,42 @@ module.exports = class MetamaskController extends EventEmitter {
}
// ---------------------------------------------------------------------------
// Identity Management (sign)
// Identity Management (signature operations)
// eth_sign methods:
/**
* Called when a Dapp uses the eth_sign method, to request user approval.
* eth_sign is a pure signature of arbitrary data. It is on a deprecation
* path, since this data can be a transaction, or can leak private key
* information.
*
* @param {Object} msgParams - The params passed to eth_sign.
* @param {Function} cb = The callback function called with the signature.
*/
newUnsignedMessage (msgParams, cb) {
const msgId = this.messageManager.addUnapprovedMessage(msgParams)
this.sendUpdate()
this.opts.showUnconfirmedMessage()
this.messageManager.once(`${msgId}:finished`, (data) => {
switch (data.status) {
case 'signed':
return cb(null, data.rawSig)
case 'rejected':
return cb(new Error('MetaMask Message Signature: User denied message signature.'))
default:
return cb(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
}
})
}
/**
* @param {} msgParams
* @param {} cb
* Signifies user intent to complete an eth_sign method.
*
* @param {Object} msgParams The params passed to eth_call.
* @returns {Promise<Object>} Full state update.
*/
signMessage (msgParams, cb) {
signMessage (msgParams) {
log.info('MetaMaskController - signMessage')
const msgId = msgParams.metamaskId
@ -643,14 +670,37 @@ module.exports = class MetamaskController extends EventEmitter {
})
}
// Prefixed Style Message Signing Methods:
/**
* Used to cancel a message submitted via eth_sign.
*
* @param {string} msgId - The id of the message to cancel.
*/
cancelMessage (msgId, cb) {
const messageManager = this.messageManager
messageManager.rejectMsg(msgId)
if (cb && typeof cb === 'function') {
cb(null, this.getState())
}
}
// personal_sign methods:
/**
* Called when a dapp uses the personal_sign method.
* This is identical to the Geth eth_sign method, and may eventually replace
* eth_sign.
*
* @param {} msgParams
* @param {} cb
* We currently define our eth_sign and personal_sign mostly for legacy Dapps.
*
* @param {Object} msgParams - The params of the message to sign & return to the Dapp.
* @param {Function} cb - The callback function called with the signature.
* Passed back to the requesting Dapp.
*/
approvePersonalMessage (msgParams, cb) {
newUnsignedPersonalMessage (msgParams, cb) {
if (!msgParams.from) {
return cb(new Error('MetaMask Message Signature: from field is required.'))
}
const msgId = this.personalMessageManager.addUnapprovedMessage(msgParams)
this.sendUpdate()
this.opts.showUnconfirmedMessage()
@ -659,7 +709,7 @@ module.exports = class MetamaskController extends EventEmitter {
case 'signed':
return cb(null, data.rawSig)
case 'rejected':
return cb(new Error('MetaMask Message Signature: User denied transaction signature.'))
return cb(new Error('MetaMask Message Signature: User denied message signature.'))
default:
return cb(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
}
@ -667,7 +717,11 @@ module.exports = class MetamaskController extends EventEmitter {
}
/**
* @param {} msgParams
* Signifies a user's approval to sign a personal_sign message in queue.
* Triggers signing, and the callback function from newUnsignedPersonalMessage.
*
* @param {Object} msgParams - The params of the message to sign & return to the Dapp.
* @returns {Promise<Object>} - A full state update.
*/
signPersonalMessage (msgParams) {
log.info('MetaMaskController - signPersonalMessage')
@ -688,7 +742,54 @@ module.exports = class MetamaskController extends EventEmitter {
}
/**
* @param {} msgParams
* Used to cancel a personal_sign type message.
* @param {string} msgId - The ID of the message to cancel.
* @param {Function} cb - The callback function called with a full state update.
*/
cancelPersonalMessage (msgId, cb) {
const messageManager = this.personalMessageManager
messageManager.rejectMsg(msgId)
if (cb && typeof cb === 'function') {
cb(null, this.getState())
}
}
// eth_signTypedData methods
/**
* Called when a dapp uses the eth_signTypedData method, per EIP 712.
*
* @param {Object} msgParams - The params passed to eth_signTypedData.
* @param {Function} cb - The callback function, called with the signature.
*/
newUnsignedTypedMessage (msgParams, cb) {
let msgId
try {
msgId = this.typedMessageManager.addUnapprovedMessage(msgParams)
this.sendUpdate()
this.opts.showUnconfirmedMessage()
} catch (e) {
return cb(e)
}
this.typedMessageManager.once(`${msgId}:finished`, (data) => {
switch (data.status) {
case 'signed':
return cb(null, data.rawSig)
case 'rejected':
return cb(new Error('MetaMask Message Signature: User denied message signature.'))
default:
return cb(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
}
})
}
/**
* The method for a user approving a call to eth_signTypedData, per EIP 712.
* Triggers the callback in newUnsignedTypedMessage.
*
* @param {Object} msgParams - The params passed to eth_signTypedData.
* @returns {Object} Full state update.
*/
signTypedMessage (msgParams) {
log.info('MetaMaskController - signTypedMessage')
@ -708,12 +809,30 @@ module.exports = class MetamaskController extends EventEmitter {
})
}
/**
* Used to cancel a eth_signTypedData type message.
* @param {string} msgId - The ID of the message to cancel.
* @param {Function} cb - The callback function called with a full state update.
*/
cancelTypedMessage (msgId, cb) {
const messageManager = this.typedMessageManager
messageManager.rejectMsg(msgId)
if (cb && typeof cb === 'function') {
cb(null, this.getState())
}
}
// ---------------------------------------------------------------------------
// Account Restauration
// MetaMask Version 3 Migration Account Restauration Methods
/**
* ?
* A legacy method (probably dead code) that was used when we swapped out our
* key management library that we depended on.
*
* Described in:
* https://medium.com/metamask/metamask-3-migration-guide-914b79533cdd
*
* @deprecated
* @param {} migratorOutput
*/
restoreOldVaultAccounts (migratorOutput) {
@ -723,8 +842,26 @@ module.exports = class MetamaskController extends EventEmitter {
}
/**
* ?
* A legacy method used to record user confirmation that they understand
* that some of their accounts have been recovered but should be backed up.
*
* @deprecated
* @param {Function} cb - A callback function called with a full state update.
*/
markAccountsFound (cb) {
this.configManager.setLostAccounts([])
this.sendUpdate()
cb(null, this.getState())
}
/**
* A legacy method (probably dead code) that was used when we swapped out our
* key management library that we depended on.
*
* Described in:
* https://medium.com/metamask/metamask-3-migration-guide-914b79533cdd
*
* @deprecated
* @param {} migratorOutput
*/
restoreOldLostAccounts (migratorOutput) {
@ -737,12 +874,23 @@ module.exports = class MetamaskController extends EventEmitter {
}
/**
* Import (lost) Accounts
* An account object
* @typedef Account
* @property string privateKey - The private key of the account.
*/
/**
* Probably no longer needed, related to the Version 3 migration.
* Imports a hash of accounts to private keys into the vault.
*
* @param {Object} {lostAccounts} @Array accounts <{ address, privateKey }>
* Described in:
* https://medium.com/metamask/metamask-3-migration-guide-914b79533cdd
*
* Uses the array's private keys to create a new Simple Key Pair keychain
* and add it to the keyring controller.
* @deprecated
* @param {Account[]} lostAccounts -
* @returns {Keyring[]} An array of the restored keyrings.
*/
importLostAccounts ({ lostAccounts }) {
const privKeys = lostAccounts.map(acct => acct.privateKey)
@ -756,113 +904,37 @@ module.exports = class MetamaskController extends EventEmitter {
// END (VAULT / KEYRING RELATED METHODS)
//=============================================================================
//
//=============================================================================
// MESSAGES
//=============================================================================
/**
* Allows a user to try to speed up a transaction by retrying it
* with higher gas.
*
* @param {string} txId - The ID of the transaction to speed up.
* @param {Function} cb - The callback function called with a full state update.
*/
async retryTransaction (txId, cb) {
await this.txController.retryTransaction(txId)
const state = await this.getState()
return state
}
//=============================================================================
// PASSWORD MANAGEMENT
//=============================================================================
newUnsignedMessage (msgParams, cb) {
const msgId = this.messageManager.addUnapprovedMessage(msgParams)
this.sendUpdate()
this.opts.showUnconfirmedMessage()
this.messageManager.once(`${msgId}:finished`, (data) => {
switch (data.status) {
case 'signed':
return cb(null, data.rawSig)
case 'rejected':
return cb(new Error('MetaMask Message Signature: User denied message signature.'))
default:
return cb(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
}
})
}
newUnsignedPersonalMessage (msgParams, cb) {
if (!msgParams.from) {
return cb(new Error('MetaMask Message Signature: from field is required.'))
}
const msgId = this.personalMessageManager.addUnapprovedMessage(msgParams)
this.sendUpdate()
this.opts.showUnconfirmedMessage()
this.personalMessageManager.once(`${msgId}:finished`, (data) => {
switch (data.status) {
case 'signed':
return cb(null, data.rawSig)
case 'rejected':
return cb(new Error('MetaMask Message Signature: User denied message signature.'))
default:
return cb(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
}
})
}
newUnsignedTypedMessage (msgParams, cb) {
let msgId
try {
msgId = this.typedMessageManager.addUnapprovedMessage(msgParams)
this.sendUpdate()
this.opts.showUnconfirmedMessage()
} catch (e) {
return cb(e)
}
this.typedMessageManager.once(`${msgId}:finished`, (data) => {
switch (data.status) {
case 'signed':
return cb(null, data.rawSig)
case 'rejected':
return cb(new Error('MetaMask Message Signature: User denied message signature.'))
default:
return cb(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
}
})
}
cancelMessage (msgId, cb) {
const messageManager = this.messageManager
messageManager.rejectMsg(msgId)
if (cb && typeof cb === 'function') {
cb(null, this.getState())
}
}
cancelPersonalMessage (msgId, cb) {
const messageManager = this.personalMessageManager
messageManager.rejectMsg(msgId)
if (cb && typeof cb === 'function') {
cb(null, this.getState())
}
}
cancelTypedMessage (msgId, cb) {
const messageManager = this.typedMessageManager
messageManager.rejectMsg(msgId)
if (cb && typeof cb === 'function') {
cb(null, this.getState())
}
}
markAccountsFound (cb) {
this.configManager.setLostAccounts([])
this.sendUpdate()
cb(null, this.getState())
}
/**
* Allows a user to begin the seed phrase recovery process.
* @param {Function} cb - A callback function called when complete.
*/
markPasswordForgotten(cb) {
this.configManager.setPasswordForgotten(true)
this.sendUpdate()
cb()
}
/**
* Allows a user to end the seed phrase recovery process.
* @param {Function} cb - A callback function called when complete.
*/
unMarkPasswordForgotten(cb) {
this.configManager.setPasswordForgotten(false)
this.sendUpdate()
@ -873,6 +945,13 @@ module.exports = class MetamaskController extends EventEmitter {
// SETUP
//=============================================================================
/**
* Used to create a multiplexed stream for connecting to an untrusted context
* like a Dapp or other extension.
* @param {*} connectionStream - The Duplex stream to connect to.
* @param {string} originDomain - The domain requesting the stream, which
* may trigger a blacklist reload.
*/
setupUntrustedCommunication (connectionStream, originDomain) {
// Check if new connection is blacklisted
if (this.blacklistController.checkForPhishing(originDomain)) {
@ -888,6 +967,16 @@ module.exports = class MetamaskController extends EventEmitter {
this.setupPublicConfig(mux.createStream('publicConfig'))
}
/**
* Used to create a multiplexed stream for connecting to a trusted context,
* like our own user interfaces, which have the provider APIs, but also
* receive the exported API from this controller, which includes trusted
* functions, like the ability to approve transactions or sign messages.
*
* @param {*} connectionStream - The duplex stream to connect to.
* @param {string} originDomain - The domain requesting the connection,
* used in logging and error reporting.
*/
setupTrustedCommunication (connectionStream, originDomain) {
// setup multiplexing
const mux = setupMultiplex(connectionStream)
@ -896,12 +985,25 @@ module.exports = class MetamaskController extends EventEmitter {
this.setupProviderConnection(mux.createStream('provider'), originDomain)
}
/**
* Called when we detect a suspicious domain. Requests the browser redirects
* to our anti-phishing page.
*
* @private
* @param {*} connectionStream - The duplex stream to the per-page script,
* for sending the reload attempt to.
* @param {string} hostname - The URL that triggered the suspicion.
*/
sendPhishingWarning (connectionStream, hostname) {
const mux = setupMultiplex(connectionStream)
const phishingStream = mux.createStream('phishing')
phishingStream.write({ hostname })
}
/**
* A method for providing our API over a stream using Dnode.
* @param {*} outStream - The stream to provide our API over.
*/
setupControllerConnection (outStream) {
const api = this.getApi()
const dnode = Dnode(api)
@ -920,6 +1022,11 @@ module.exports = class MetamaskController extends EventEmitter {
})
}
/**
* A method for serving our ethereum provider over a given stream.
* @param {*} outStream - The stream to provide over.
* @param {string} origin - The URI of the requesting resource.
*/
setupProviderConnection (outStream, origin) {
// setup json rpc engine stack
const engine = new RpcEngine()
@ -949,6 +1056,16 @@ module.exports = class MetamaskController extends EventEmitter {
)
}
/**
* A method for providing our public config info over a stream.
* This includes info we like to be synchronous if possible, like
* the current selected account, and network ID.
*
* Since synchronous methods have been deprecated in web3,
* this is a good candidate for deprecation.
*
* @param {*} outStream - The stream to provide public config over.
*/
setupPublicConfig (outStream) {
pump(
asStream(this.publicConfigStore),
@ -959,10 +1076,21 @@ module.exports = class MetamaskController extends EventEmitter {
)
}
/**
* A method for emitting the full MetaMask state to all registered listeners.
* @private
*/
privateSendUpdate () {
this.emit('update', this.getState())
}
/**
* A method for estimating a good gas price at recent prices.
* Returns the lowest price that would have been included in
* 50% of recent blocks.
*
* @returns {string} A hex representation of the suggested wei gas price.
*/
getGasPrice () {
const { recentBlocksController } = this
const { recentBlocks } = recentBlocksController.store.getState()
@ -996,6 +1124,11 @@ module.exports = class MetamaskController extends EventEmitter {
// Log blocks
/**
* A method for setting the user's preferred display currency.
* @param {string} currencyCode - The code of the preferred currency.
* @param {Function} cb - A callback function returning currency info.
*/
setCurrentCurrency (currencyCode, cb) {
try {
this.currencyController.setCurrentCurrency(currencyCode)
@ -1011,6 +1144,13 @@ module.exports = class MetamaskController extends EventEmitter {
}
}
/**
* A method for forwarding the user to the easiest way to obtain ether,
* or the network "gas" currency, for the current selected network.
*
* @param {string} address - The address to fund.
* @param {string} amount - The amount of ether desired, as a base 10 string.
*/
buyEth (address, amount) {
if (!amount) amount = '5'
const network = this.networkController.getNetworkState()
@ -1018,18 +1158,33 @@ module.exports = class MetamaskController extends EventEmitter {
if (url) this.platform.openWindow({ url })
}
/**
* A method for triggering a shapeshift currency transfer.
* @param {string} depositAddress - The address to deposit to.
* @property {string} depositType - An abbreviation of the type of crypto currency to be deposited.
*/
createShapeShiftTx (depositAddress, depositType) {
this.shapeshiftController.createShapeShiftTx(depositAddress, depositType)
}
// network
async setCustomRpc (rpcTarget, rpcList) {
/**
* A method for selecting a custom URL for an ethereum RPC provider.
* @param {string} rpcTarget - A URL for a valid Ethereum RPC API.
* @returns {Promise<String>} - The RPC Target URL confirmed.
*/
async setCustomRpc (rpcTarget) {
this.networkController.setRpcTarget(rpcTarget)
await this.preferencesController.updateFrequentRpcList(rpcTarget)
return rpcTarget
}
/**
* Sets whether or not to use the blockie identicon format.
* @param {boolean} val - True for bockie, false for jazzicon.
* @param {Function} cb - A callback function called when complete.
*/
setUseBlockie (val, cb) {
try {
this.preferencesController.setUseBlockie(val)
@ -1039,6 +1194,11 @@ module.exports = class MetamaskController extends EventEmitter {
}
}
/**
* A method for setting a user's current locale, affecting the language rendered.
* @param {string} key - Locale identifier.
* @param {Function} cb - A callback function called when complete.
*/
setCurrentLocale (key, cb) {
try {
this.preferencesController.setCurrentLocale(key)
@ -1048,6 +1208,11 @@ module.exports = class MetamaskController extends EventEmitter {
}
}
/**
* A method for initializing storage the first time.
* @param {Object} initState - The default state to initialize with.
* @private
*/
recordFirstTimeInfo (initState) {
if (!('firstTimeInfo' in initState)) {
initState.firstTimeInfo = {
@ -1057,4 +1222,22 @@ module.exports = class MetamaskController extends EventEmitter {
}
}
/**
* A method for recording whether the MetaMask user interface is open or not.
* @private
* @param {boolean} open
*/
set isClientOpen (open) {
this._isClientOpen = open
this.isClientOpenAndUnlocked = this.getState().isUnlocked && open
}
/**
* A method for activating the retrieval of price data, which should only be fetched when the UI is visible.
* @private
* @param {boolean} active - True if price data should be getting fetched.
*/
set isClientOpenAndUnlocked (active) {
this.tokenRatesController.isActive = active
}
}

@ -27,8 +27,11 @@ module.exports = {
function transformState (state) {
const newState = state
if (newState.config.provider.type === 'testnet') {
newState.config.provider.type = 'ropsten'
const { config } = newState
if ( config && config.provider ) {
if (config.provider.type === 'testnet') {
newState.config.provider.type = 'ropsten'
}
}
return newState
}

@ -28,11 +28,14 @@ module.exports = {
function transformState (state) {
const newState = state
const transactions = newState.TransactionController.transactions
newState.TransactionController.transactions = transactions.map((txMeta) => {
if (!txMeta.err) return txMeta
else if (txMeta.err.message === 'Gave up submitting tx.') txMeta.status = 'failed'
return txMeta
})
const { TransactionController } = newState
if (TransactionController && TransactionController.transactions) {
const transactions = TransactionController.transactions
newState.TransactionController.transactions = transactions.map((txMeta) => {
if (!txMeta.err) return txMeta
else if (txMeta.err.message === 'Gave up submitting tx.') txMeta.status = 'failed'
return txMeta
})
}
return newState
}

@ -28,14 +28,18 @@ module.exports = {
function transformState (state) {
const newState = state
const transactions = newState.TransactionController.transactions
newState.TransactionController.transactions = transactions.map((txMeta) => {
if (!txMeta.err) return txMeta
if (txMeta.err === 'transaction with the same hash was already imported.') {
txMeta.status = 'submitted'
delete txMeta.err
}
return txMeta
})
const { TransactionController } = newState
if (TransactionController && TransactionController.transactions) {
const transactions = newState.TransactionController.transactions
newState.TransactionController.transactions = transactions.map((txMeta) => {
if (!txMeta.err) return txMeta
if (txMeta.err === 'transaction with the same hash was already imported.') {
txMeta.status = 'submitted'
delete txMeta.err
}
return txMeta
})
}
return newState
}

@ -27,14 +27,17 @@ module.exports = {
function transformState (state) {
const newState = state
const transactions = newState.TransactionController.transactions
newState.TransactionController.transactions = transactions.map((txMeta) => {
if (!txMeta.status === 'failed') return txMeta
if (txMeta.retryCount > 0 && txMeta.retryCount < 2) {
txMeta.status = 'submitted'
delete txMeta.err
}
return txMeta
})
const { TransactionController } = newState
if (TransactionController && TransactionController.transactions) {
const transactions = newState.TransactionController.transactions
newState.TransactionController.transactions = transactions.map((txMeta) => {
if (!txMeta.status === 'failed') return txMeta
if (txMeta.retryCount > 0 && txMeta.retryCount < 2) {
txMeta.status = 'submitted'
delete txMeta.err
}
return txMeta
})
}
return newState
}

@ -7,7 +7,7 @@ This migration updates "transaction state history" to diffs style
*/
const clone = require('clone')
const txStateHistoryHelper = require('../lib/tx-state-history-helper')
const txStateHistoryHelper = require('../controllers/transactions/lib/tx-state-history-helper')
module.exports = {
@ -29,24 +29,27 @@ module.exports = {
function transformState (state) {
const newState = state
const transactions = newState.TransactionController.transactions
newState.TransactionController.transactions = transactions.map((txMeta) => {
// no history: initialize
if (!txMeta.history || txMeta.history.length === 0) {
const snapshot = txStateHistoryHelper.snapshotFromTxMeta(txMeta)
txMeta.history = [snapshot]
const { TransactionController } = newState
if (TransactionController && TransactionController.transactions) {
const transactions = newState.TransactionController.transactions
newState.TransactionController.transactions = transactions.map((txMeta) => {
// no history: initialize
if (!txMeta.history || txMeta.history.length === 0) {
const snapshot = txStateHistoryHelper.snapshotFromTxMeta(txMeta)
txMeta.history = [snapshot]
return txMeta
}
// has history: migrate
const newHistory = (
txStateHistoryHelper.migrateFromSnapshotsToDiffs(txMeta.history)
// remove empty diffs
.filter((entry) => {
return !Array.isArray(entry) || entry.length > 0
})
)
txMeta.history = newHistory
return txMeta
}
// has history: migrate
const newHistory = (
txStateHistoryHelper.migrateFromSnapshotsToDiffs(txMeta.history)
// remove empty diffs
.filter((entry) => {
return !Array.isArray(entry) || entry.length > 0
})
)
txMeta.history = newHistory
return txMeta
})
})
}
return newState
}

@ -29,32 +29,36 @@ module.exports = {
function transformState (state) {
const newState = state
const transactions = newState.TransactionController.transactions
const { TransactionController } = newState
if (TransactionController && TransactionController.transactions) {
newState.TransactionController.transactions = transactions.map((txMeta, _, txList) => {
if (txMeta.status !== 'submitted') return txMeta
const transactions = newState.TransactionController.transactions
const confirmedTxs = txList.filter((tx) => tx.status === 'confirmed')
.filter((tx) => tx.txParams.from === txMeta.txParams.from)
.filter((tx) => tx.metamaskNetworkId.from === txMeta.metamaskNetworkId.from)
const highestConfirmedNonce = getHighestNonce(confirmedTxs)
newState.TransactionController.transactions = transactions.map((txMeta, _, txList) => {
if (txMeta.status !== 'submitted') return txMeta
const pendingTxs = txList.filter((tx) => tx.status === 'submitted')
.filter((tx) => tx.txParams.from === txMeta.txParams.from)
.filter((tx) => tx.metamaskNetworkId.from === txMeta.metamaskNetworkId.from)
const highestContinuousNonce = getHighestContinuousFrom(pendingTxs, highestConfirmedNonce)
const confirmedTxs = txList.filter((tx) => tx.status === 'confirmed')
.filter((tx) => tx.txParams.from === txMeta.txParams.from)
.filter((tx) => tx.metamaskNetworkId.from === txMeta.metamaskNetworkId.from)
const highestConfirmedNonce = getHighestNonce(confirmedTxs)
const maxNonce = Math.max(highestContinuousNonce, highestConfirmedNonce)
const pendingTxs = txList.filter((tx) => tx.status === 'submitted')
.filter((tx) => tx.txParams.from === txMeta.txParams.from)
.filter((tx) => tx.metamaskNetworkId.from === txMeta.metamaskNetworkId.from)
const highestContinuousNonce = getHighestContinuousFrom(pendingTxs, highestConfirmedNonce)
if (parseInt(txMeta.txParams.nonce, 16) > maxNonce + 1) {
txMeta.status = 'failed'
txMeta.err = {
message: 'nonce too high',
note: 'migration 019 custom error',
const maxNonce = Math.max(highestContinuousNonce, highestConfirmedNonce)
if (parseInt(txMeta.txParams.nonce, 16) > maxNonce + 1) {
txMeta.status = 'failed'
txMeta.err = {
message: 'nonce too high',
note: 'migration 019 custom error',
}
}
}
return txMeta
})
return txMeta
})
}
return newState
}

@ -28,12 +28,15 @@ module.exports = {
function transformState (state) {
const newState = state
const transactions = newState.TransactionController.transactions
newState.TransactionController.transactions = transactions.map((txMeta) => {
if (txMeta.status !== 'submitted' || txMeta.submittedTime) return txMeta
txMeta.submittedTime = (new Date()).getTime()
return txMeta
})
const { TransactionController } = newState
if (TransactionController && TransactionController.transactions) {
const transactions = newState.TransactionController.transactions
newState.TransactionController.transactions = transactions.map((txMeta) => {
if (txMeta.status !== 'submitted' || txMeta.submittedTime) return txMeta
txMeta.submittedTime = (new Date()).getTime()
return txMeta
})
}
return newState
}

@ -28,23 +28,27 @@ module.exports = {
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()
const { TransactionController } = newState
if (TransactionController && TransactionController.transactions) {
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
}

@ -0,0 +1,41 @@
const version = 24
/*
This migration ensures that the from address in txParams is to lower case for
all unapproved transactions
*/
const clone = require('clone')
module.exports = {
version,
migrate: async function (originalVersionedData) {
const versionedData = clone(originalVersionedData)
versionedData.meta.version = version
const state = versionedData.data
const newState = transformState(state)
versionedData.data = newState
return versionedData
},
}
function transformState (state) {
const newState = state
if (!newState.TransactionController) return newState
const transactions = newState.TransactionController.transactions
newState.TransactionController.transactions = transactions.map((txMeta, _, txList) => {
if (
txMeta.status === 'unapproved' &&
txMeta.txParams &&
txMeta.txParams.from
) {
txMeta.txParams.from = txMeta.txParams.from.toLowerCase()
}
return txMeta
})
return newState
}

@ -0,0 +1,61 @@
// next version number
const version = 25
/*
normalizes txParams on unconfirmed txs
*/
const ethUtil = require('ethereumjs-util')
const clone = require('clone')
module.exports = {
version,
migrate: async function (originalVersionedData) {
const versionedData = clone(originalVersionedData)
versionedData.meta.version = version
const state = versionedData.data
const newState = transformState(state)
versionedData.data = newState
return versionedData
},
}
function transformState (state) {
const newState = state
if (newState.TransactionController) {
if (newState.TransactionController.transactions) {
const transactions = newState.TransactionController.transactions
newState.TransactionController.transactions = transactions.map((txMeta) => {
if (txMeta.status !== 'unapproved') return txMeta
txMeta.txParams = normalizeTxParams(txMeta.txParams)
return txMeta
})
}
}
return newState
}
function normalizeTxParams (txParams) {
// functions that handle normalizing of that key in txParams
const whiteList = {
from: from => ethUtil.addHexPrefix(from).toLowerCase(),
to: to => ethUtil.addHexPrefix(txParams.to).toLowerCase(),
nonce: nonce => ethUtil.addHexPrefix(nonce),
value: value => ethUtil.addHexPrefix(value),
data: data => ethUtil.addHexPrefix(data),
gas: gas => ethUtil.addHexPrefix(gas),
gasPrice: gasPrice => ethUtil.addHexPrefix(gasPrice),
}
// apply only keys in the whiteList
const normalizedTxParams = {}
Object.keys(whiteList).forEach((key) => {
if (txParams[key]) normalizedTxParams[key] = whiteList[key](txParams[key])
})
return normalizedTxParams
}

@ -34,4 +34,6 @@ module.exports = [
require('./021'),
require('./022'),
require('./023'),
require('./024'),
require('./025'),
]

@ -0,0 +1,29 @@
// next version number
const version = 0
/*
description of migration and what it does
*/
const clone = require('clone')
module.exports = {
version,
migrate: async function (originalVersionedData) {
const versionedData = clone(originalVersionedData)
versionedData.meta.version = version
const state = versionedData.data
const newState = transformState(state)
versionedData.data = newState
return versionedData
},
}
function transformState (state) {
const newState = state
// transform state here
return newState
}

@ -1,20 +1,25 @@
class SwPlatform {
//
// Public
//
/**
* Reloads the platform
*/
reload () {
// you cant actually do this
global.location.reload()
// TODO: you can't actually do this
/** @type {any} */ (global).location.reload()
}
openWindow ({ url }) {
// this doesnt actually work
global.open(url, '_blank')
/**
* Opens a window
* @param {{url: string}} opts - The window options
*/
openWindow (opts) {
// TODO: this doesn't actually work
/** @type {any} */ (global).open(opts.url, '_blank')
}
/**
* Returns the platform version
* @returns {string}
*/
getVersion () {
return '<unable to read version>'
}

@ -1,18 +1,23 @@
class WindowPlatform {
//
// Public
//
/**
* Reload the platform
*/
reload () {
global.location.reload()
/** @type {any} */ (global).location.reload()
}
openWindow ({ url }) {
global.open(url, '_blank')
/**
* Opens a window
* @param {{url: string}} opts - The window options
*/
openWindow (opts) {
/** @type {any} */ (global).open(opts.url, '_blank')
}
/**
* Returns the platform version
* @returns {string}
*/
getVersion () {
return '<unable to read version>'
}

@ -7,10 +7,14 @@ const launchMetamaskUi = require('../../ui')
const StreamProvider = require('web3-stream-provider')
const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex
module.exports = initializePopup
/**
* Asynchronously initializes the MetaMask popup UI
*
* @param {{ container: Element, connectionStream: * }} config Popup configuration object
* @param {Function} cb Called when initialization is complete
*/
function initializePopup ({ container, connectionStream }, cb) {
// setup app
async.waterfall([
@ -19,6 +23,12 @@ function initializePopup ({ container, connectionStream }, cb) {
], cb)
}
/**
* Establishes streamed connections to background scripts and a Web3 provider
*
* @param {PortDuplexStream} connectionStream PortStream instance establishing a background connection
* @param {Function} cb Called when controller connection is established
*/
function connectToAccountManager (connectionStream, cb) {
// setup communication with background
// setup multiplexing
@ -28,6 +38,11 @@ function connectToAccountManager (connectionStream, cb) {
setupWeb3Connection(mx.createStream('provider'))
}
/**
* Establishes a streamed connection to a Web3 provider
*
* @param {PortDuplexStream} connectionStream PortStream instance establishing a background connection
*/
function setupWeb3Connection (connectionStream) {
var providerStream = new StreamProvider()
providerStream.pipe(connectionStream).pipe(providerStream)
@ -38,6 +53,12 @@ function setupWeb3Connection (connectionStream) {
global.eth = new Eth(providerStream)
}
/**
* Establishes a streamed connection to the background account manager
*
* @param {PortDuplexStream} connectionStream PortStream instance establishing a background connection
* @param {Function} cb Called when the remote account manager connection is established
*/
function setupControllerConnection (connectionStream, cb) {
// this is a really sneaky way of adding EventEmitter api
// to a bi-directional dnode instance

@ -3,12 +3,14 @@ const OldMetaMaskUiCss = require('../../old-ui/css')
const NewMetaMaskUiCss = require('../../ui/css')
const startPopup = require('./popup-core')
const PortStream = require('./lib/port-stream.js')
const isPopupOrNotification = require('./lib/is-popup-or-notification')
const { getEnvironmentType } = require('./lib/util')
const { ENVIRONMENT_TYPE_NOTIFICATION } = require('./lib/enums')
const extension = require('extensionizer')
const ExtensionPlatform = require('./platforms/extension')
const NotificationManager = require('./lib/notification-manager')
const notificationManager = new NotificationManager()
const setupRaven = require('./lib/setupRaven')
const log = require('loglevel')
start().catch(log.error)
@ -26,7 +28,7 @@ async function start() {
// injectCss(css)
// identify window type (popup, notification)
const windowType = isPopupOrNotification()
const windowType = getEnvironmentType(window.location.href)
global.METAMASK_UI_TYPE = windowType
closePopupIfOpen(windowType)
@ -68,7 +70,7 @@ async function start() {
function closePopupIfOpen (windowType) {
if (windowType !== 'notification') {
if (windowType !== ENVIRONMENT_TYPE_NOTIFICATION) {
// should close only chrome popup
notificationManager.closePopup()
}

@ -36,15 +36,28 @@ log.setLevel('debug')
//
const qs = require('qs')
let queryString = qs.parse(window.location.href.split('#')[1])
let selectedView = queryString.view || 'first time'
const routerPath = window.location.href.split('#')[1]
let queryString = {}
let selectedView
if (routerPath) {
queryString = qs.parse(routerPath.split('?')[1])
}
selectedView = queryString.view || 'first time'
const firstState = states[selectedView]
updateQueryParams(selectedView)
function updateQueryParams(newView) {
function updateQueryParams (newView) {
queryString.view = newView
const params = qs.stringify(queryString)
window.location.href = window.location.href.split('#')[0] + `#${params}`
const locationPaths = window.location.href.split('#')
const routerPath = locationPaths[1] || ''
const newPath = locationPaths[0] + '#' + routerPath.split('?')[0] + `?${params}`
if (window.location.href !== newPath) {
window.location.href = newPath
}
}
//

@ -0,0 +1,49 @@
const fs = require('fs')
const { SourceMapConsumer } = require('source-map')
//
// Utility to help check if sourcemaps are working
//
// searches `dist/chrome/inpage.js` for "new Error" statements
// and prints their source lines using the sourcemaps.
// if not working it may error or print minified garbage
//
start()
async function start() {
const rawBuild = fs.readFileSync(__dirname + '/../dist/chrome/inpage.js', 'utf8')
const rawSourceMap = fs.readFileSync(__dirname + '/../dist/sourcemaps/inpage.js.map', 'utf8')
const consumer = await new SourceMapConsumer(rawSourceMap)
console.log('hasContentsOfAllSources:', consumer.hasContentsOfAllSources(), '\n')
console.log('sources:')
consumer.sources.map((sourcePath) => console.log(sourcePath))
console.log('\nexamining "new Error" statements:\n')
const sourceLines = rawBuild.split('\n')
sourceLines.map(line => indicesOf('new Error', line))
.forEach((errorIndices, lineIndex) => {
// if (errorIndex === null) return console.log('line does not contain "new Error"')
errorIndices.forEach((errorIndex) => {
const position = { line: lineIndex + 1, column: errorIndex }
const result = consumer.originalPositionFor(position)
if (!result.source) return console.warn(`!! missing source for position: ${position}`)
// filter out deps distributed minified without sourcemaps
if (result.source === 'node_modules/browserify/node_modules/browser-pack/_prelude.js') return // minified mess
if (result.source === 'node_modules/web3/dist/web3.min.js') return // minified mess
const sourceContent = consumer.sourceContentFor(result.source)
const sourceLines = sourceContent.split('\n')
const line = sourceLines[result.line-1]
console.log(`\n========================== ${result.source} ====================================\n`)
console.log(line)
console.log(`\n==============================================================================\n`)
})
})
}
function indicesOf(substring, string) {
var a=[],i=-1;
while((i=string.indexOf(substring,i+1)) >= 0) a.push(i);
return a;
}

@ -0,0 +1,134 @@
{
"metamask": {
"isInitialized": true,
"isUnlocked": true,
"featureFlags": {"betaUI": true},
"rpcTarget": "https://rawtestrpc.metamask.io/",
"identities": {
"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825": {
"address": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825",
"name": "Send Account 1"
},
"0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb": {
"address": "0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb",
"name": "Send Account 2"
},
"0x2f8d4a878cfa04a6e60d46362f5644deab66572d": {
"address": "0x2f8d4a878cfa04a6e60d46362f5644deab66572d",
"name": "Send Account 3"
},
"0xd85a4b6a394794842887b8284293d69163007bbb": {
"address": "0xd85a4b6a394794842887b8284293d69163007bbb",
"name": "Send Account 4"
}
},
"unapprovedTxs": {},
"currentCurrency": "USD",
"conversionRate": 19855,
"conversionDate": 1489013762,
"noActiveNotices": true,
"frequentRpcList": [],
"network": "3",
"accounts": {
"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825": {
"code": "0x",
"balance": "0x47c9d71831c76efe",
"nonce": "0x1b",
"address": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825"
},
"0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb": {
"code": "0x",
"balance": "0x37452b1315889f80",
"nonce": "0xa",
"address": "0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb"
},
"0x2f8d4a878cfa04a6e60d46362f5644deab66572d": {
"code": "0x",
"balance": "0x30c9d71831c76efe",
"nonce": "0x1c",
"address": "0x2f8d4a878cfa04a6e60d46362f5644deab66572d"
},
"0xd85a4b6a394794842887b8284293d69163007bbb": {
"code": "0x",
"balance": "0x0",
"nonce": "0x0",
"address": "0xd85a4b6a394794842887b8284293d69163007bbb"
}
},
"addressBook": [
{
"address": "0x06195827297c7a80a443b6894d3bdb8824b43896",
"name": "Address Book Account 1"
}
],
"tokens": [],
"transactions": {},
"selectedAddressTxList": [],
"unapprovedMsgs": {},
"unapprovedMsgCount": 0,
"unapprovedPersonalMsgs": {},
"unapprovedPersonalMsgCount": 0,
"keyringTypes": [
"Simple Key Pair",
"HD Key Tree"
],
"keyrings": [
{
"type": "HD Key Tree",
"accounts": [
"fdea65c8e26263f6d9a1b5de9555d2931a33b825",
"c5b8dbac4c1d3f152cdeb400e2313f309c410acb",
"2f8d4a878cfa04a6e60d46362f5644deab66572d"
]
},
{
"type": "Simple Key Pair",
"accounts": [
"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825"
]
}
],
"selectedAddress": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825",
"currentCurrency": "PHP",
"provider": {
"type": "testnet"
},
"shapeShiftTxList": [],
"lostAccounts": [],
"send": {
"gasLimit": null,
"gasPrice": null,
"gasTotal": "0xb451dc41b578",
"tokenBalance": null,
"from": "",
"to": "",
"amount": "0x0",
"memo": "",
"errors": {},
"maxModeOn": false,
"editingTransactionId": null
},
"currentLocale": "en"
},
"appState": {
"menuOpen": false,
"currentView": {
"name": "accountDetail",
"detailView": null,
"context": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc"
},
"accountDetail": {
"subview": "transactions"
},
"modal": {
"modalState": {},
"previousModalState": {}
},
"transForward": true,
"isLoading": false,
"warning": null,
"scrollToBottom": false,
"forgottenPassword": null
},
"identities": {}
}

@ -0,0 +1,25 @@
{
"tags": {
"allowUnknownTags": false
},
"source": {
"include": "app/scripts/",
"includePattern": ".js$",
"excludePattern": "(node_modules/|docs)"
},
"plugins": [
"plugins/markdown"
],
"opts": {
"template": "node_modules/radgrad-jsdoc-template/",
"encoding": "utf8",
"destination": "docs/jsdocs",
"recurse": true,
"verbose": true
},
"templates": {
"cleverLinks": false,
"monospaceLinks": false
}
}

@ -0,0 +1,15 @@
# Development Tools & Configurations
This folder contains configuration files which are used by the the different
development-tools, like e.g. JsDoc.
## Appveyor
https://www.appveyor.com/docs/build-configuration/#alternative-yaml-file-location
Withtin the configuration, point to a weblocation of a txt config file:
https://ci.appveyor.com/project/lazaridiscom/mm-vault/settings
https://raw.githubusercontent.com/lazaridiscom/mm-vault/master/dev/tools/appveyor.txt

@ -0,0 +1,21 @@
# Test against the latest version of this Node.js version
environment:
nodejs_version: "8"
# Install scripts. (runs after repo cloning)
install:
# Get the latest stable version of Node.js or io.js
- ps: Install-Product node $env:nodejs_version
# install modules
- npm install
# Post-install test scripts.
test_script:
# Output useful info for debugging.
- node --version
- npm --version
# run tests
- npm test
# Don't actually build.
build: off

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

Loading…
Cancel
Save