mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
Merge remote-tracking branch 'upstream/develop' into develop
This commit is contained in:
commit
8c77e998e0
@ -448,4 +448,4 @@ jobs:
|
||||
steps:
|
||||
- run:
|
||||
name: All Tests Passed
|
||||
command: echo 'weew - everything passed!'
|
||||
command: echo 'weew - everything passed!'
|
@ -2,7 +2,11 @@
|
||||
|
||||
## Current Master
|
||||
|
||||
- Remove rejected transactions from transaction history
|
||||
- Add new tokens auto detection
|
||||
- Remove rejected transactions from transaction history
|
||||
- Add Trezor Support
|
||||
- Allow to remove accounts (Imported and Hardware Wallets)
|
||||
- [#4840](https://github.com/MetaMask/metamask-extension/pull/4840): Now shows notifications when transactions are completed.
|
||||
|
||||
## 4.8.0 Thur Jun 14 2018
|
||||
|
||||
|
@ -81,6 +81,7 @@ To write tests that will be run in the browser using QUnit, add your test files
|
||||
- [How to add new networks to the Provider Menu](./docs/adding-new-networks.md)
|
||||
- [How to manage notices that appear when the app starts up](./docs/notices.md)
|
||||
- [How to port MetaMask to a new platform](./docs/porting_to_new_environment.md)
|
||||
- [How to use the TREZOR emulator](./docs/trezor-emulator.md)
|
||||
- [How to generate a visualization of this repository's development](./docs/development-visualization.md)
|
||||
|
||||
[1]: http://www.nomnoml.com/#view/%5B%3Cactor%3Euser%5D%0A%0A%5Bmetamask-ui%7C%0A%20%20%20%5Btools%7C%0A%20%20%20%20%20react%0A%20%20%20%20%20redux%0A%20%20%20%20%20thunk%0A%20%20%20%20%20ethUtils%0A%20%20%20%20%20jazzicon%0A%20%20%20%5D%0A%20%20%20%5Bcomponents%7C%0A%20%20%20%20%20app%0A%20%20%20%20%20account-detail%0A%20%20%20%20%20accounts%0A%20%20%20%20%20locked-screen%0A%20%20%20%20%20restore-vault%0A%20%20%20%20%20identicon%0A%20%20%20%20%20config%0A%20%20%20%20%20info%0A%20%20%20%5D%0A%20%20%20%5Breducers%7C%0A%20%20%20%20%20app%0A%20%20%20%20%20metamask%0A%20%20%20%20%20identities%0A%20%20%20%5D%0A%20%20%20%5Bactions%7C%0A%20%20%20%20%20%5BaccountManager%5D%0A%20%20%20%5D%0A%20%20%20%5Bcomponents%5D%3A-%3E%5Bactions%5D%0A%20%20%20%5Bactions%5D%3A-%3E%5Breducers%5D%0A%20%20%20%5Breducers%5D%3A-%3E%5Bcomponents%5D%0A%5D%0A%0A%5Bweb%20dapp%7C%0A%20%20%5Bui%20code%5D%0A%20%20%5Bweb3%5D%0A%20%20%5Bmetamask-inpage%5D%0A%20%20%0A%20%20%5B%3Cactor%3Eui%20developer%5D%0A%20%20%5Bui%20developer%5D-%3E%5Bui%20code%5D%0A%20%20%5Bui%20code%5D%3C-%3E%5Bweb3%5D%0A%20%20%5Bweb3%5D%3C-%3E%5Bmetamask-inpage%5D%0A%5D%0A%0A%5Bmetamask-background%7C%0A%20%20%5Bprovider-engine%5D%0A%20%20%5Bhooked%20wallet%20subprovider%5D%0A%20%20%5Bid%20store%5D%0A%20%20%0A%20%20%5Bprovider-engine%5D%3C-%3E%5Bhooked%20wallet%20subprovider%5D%0A%20%20%5Bhooked%20wallet%20subprovider%5D%3C-%3E%5Bid%20store%5D%0A%20%20%5Bconfig%20manager%7C%0A%20%20%20%20%5Brpc%20configuration%5D%0A%20%20%20%20%5Bencrypted%20keys%5D%0A%20%20%20%20%5Bwallet%20nicknames%5D%0A%20%20%5D%0A%20%20%0A%20%20%5Bprovider-engine%5D%3C-%5Bconfig%20manager%5D%0A%20%20%5Bid%20store%5D%3C-%3E%5Bconfig%20manager%5D%0A%5D%0A%0A%5Buser%5D%3C-%3E%5Bmetamask-ui%5D%0A%0A%5Buser%5D%3C%3A--%3A%3E%5Bweb%20dapp%5D%0A%0A%5Bmetamask-contentscript%7C%0A%20%20%5Bplugin%20restart%20detector%5D%0A%20%20%5Brpc%20passthrough%5D%0A%5D%0A%0A%5Brpc%20%7C%0A%20%20%5Bethereum%20blockchain%20%7C%0A%20%20%20%20%5Bcontracts%5D%0A%20%20%20%20%5Baccounts%5D%0A%20%20%5D%0A%5D%0A%0A%5Bweb%20dapp%5D%3C%3A--%3A%3E%5Bmetamask-contentscript%5D%0A%5Bmetamask-contentscript%5D%3C-%3E%5Bmetamask-background%5D%0A%5Bmetamask-background%5D%3C-%3E%5Bmetamask-ui%5D%0A%5Bmetamask-background%5D%3C-%3E%5Brpc%5D%0A
|
||||
|
@ -138,7 +138,7 @@ Notwithstanding the parties' decision to resolve all disputes through arbitratio
|
||||
|
||||
### 13.6 30-Day Right to Opt Out ###
|
||||
|
||||
You have the right to opt-out and not be bound by the arbitration and class action waiver provisions set forth above by sending written notice of your decision to opt-out to the following address: MetaMask ℅ ConsenSys, 49 Bogart Street, Brooklyn NY 11206 and via email at legal-opt@metamask.io. The notice must be sent within 30 days of September 6, 2016 or your first use of the Service, whichever is later, otherwise you shall be bound to arbitrate disputes in accordance with the terms of those paragraphs. If you opt-out of these arbitration provisions, MetaMask also will not be bound by them.
|
||||
You have the right to opt-out and not be bound by the arbitration and class action waiver provisions set forth above by sending written notice of your decision to opt-out to the following address: MetaMask ℅ ConsenSys, 49 Bogart Street, Brooklyn NY 11206 and via email at support@metamask.io. The notice must be sent within 30 days of September 6, 2016 or your first use of the Service, whichever is later, otherwise you shall be bound to arbitrate disputes in accordance with the terms of those paragraphs. If you opt-out of these arbitration provisions, MetaMask also will not be bound by them.
|
||||
|
||||
### 13.7 Changes to This Section ###
|
||||
|
||||
|
@ -11,6 +11,9 @@
|
||||
"accountName": {
|
||||
"message": "Account Name"
|
||||
},
|
||||
"accountSelectionRequired": {
|
||||
"message": "You need to select an account!"
|
||||
},
|
||||
"address": {
|
||||
"message": "Address"
|
||||
},
|
||||
@ -80,6 +83,9 @@
|
||||
"borrowDharma": {
|
||||
"message": "Borrow With Dharma (Beta)"
|
||||
},
|
||||
"browserNotSupported": {
|
||||
"message": "Your Browser is not supported..."
|
||||
},
|
||||
"builtInCalifornia": {
|
||||
"message": "MetaMask is designed and built in California."
|
||||
},
|
||||
@ -110,6 +116,9 @@
|
||||
"close": {
|
||||
"message": "Close"
|
||||
},
|
||||
"chromeRequiredForTrezor":{
|
||||
"message": "You need to use Metamask on Google Chrome in order to connect to your TREZOR device."
|
||||
},
|
||||
"confirm": {
|
||||
"message": "Confirm"
|
||||
},
|
||||
@ -125,6 +134,24 @@
|
||||
"confirmTransaction": {
|
||||
"message": "Confirm Transaction"
|
||||
},
|
||||
"connectHardwareWallet": {
|
||||
"message": "Connect Hardware Wallet"
|
||||
},
|
||||
"connect": {
|
||||
"message": "Connect"
|
||||
},
|
||||
"connecting": {
|
||||
"message": "Connecting..."
|
||||
},
|
||||
"connectToTrezor": {
|
||||
"message": "Connect to Trezor"
|
||||
},
|
||||
"connectToTrezorHelp": {
|
||||
"message": "Metamask is able to access your TREZOR ethereum accounts. First make sure your device is connected and unlocked."
|
||||
},
|
||||
"connectToTrezorTrouble": {
|
||||
"message": "If you are having trouble, please make sure you are using the latest version of the TREZOR firmware."
|
||||
},
|
||||
"continue": {
|
||||
"message": "Continue"
|
||||
},
|
||||
@ -253,9 +280,15 @@
|
||||
"done": {
|
||||
"message": "Done"
|
||||
},
|
||||
"downloadGoogleChrome": {
|
||||
"message": "Download Google Chrome"
|
||||
},
|
||||
"downloadStateLogs": {
|
||||
"message": "Download State Logs"
|
||||
},
|
||||
"dontHaveATrezorWallet": {
|
||||
"message": "Don't have a TREZOR hardware wallet?"
|
||||
},
|
||||
"dropped": {
|
||||
"message": "Dropped"
|
||||
},
|
||||
@ -321,6 +354,9 @@
|
||||
"followTwitter": {
|
||||
"message": "Follow us on Twitter"
|
||||
},
|
||||
"forgetDevice": {
|
||||
"message": "Forget this device"
|
||||
},
|
||||
"from": {
|
||||
"message": "From"
|
||||
},
|
||||
@ -374,10 +410,28 @@
|
||||
"message": "Get Ether from a faucet for the $1",
|
||||
"description": "Displays network name for Ether faucet"
|
||||
},
|
||||
"getHelp": {
|
||||
"message": "Get Help."
|
||||
},
|
||||
"greaterThanMin": {
|
||||
"message": "must be greater than or equal to $1.",
|
||||
"description": "helper for inputting hex as decimal input"
|
||||
},
|
||||
"hardware": {
|
||||
"message": "hardware"
|
||||
},
|
||||
"hardwareWalletConnected": {
|
||||
"message": "Hardware wallet connected"
|
||||
},
|
||||
"hardwareSupport": {
|
||||
"message": "Hardware Support"
|
||||
},
|
||||
"hardwareSupportMsg": {
|
||||
"message": "You can now view your Hardware accounts in MetaMask! Scroll down and read how it works."
|
||||
},
|
||||
"havingTroubleConnecting": {
|
||||
"message": "Having trouble connecting?"
|
||||
},
|
||||
"here": {
|
||||
"message": "here",
|
||||
"description": "as in -click here- for more information (goes with troubleTokenBalances)"
|
||||
@ -476,7 +530,7 @@
|
||||
"message": "Max"
|
||||
},
|
||||
"learnMore": {
|
||||
"message": "Learn more."
|
||||
"message": "Learn more"
|
||||
},
|
||||
"lessThanMax": {
|
||||
"message": "must be less than or equal to $1.",
|
||||
@ -584,12 +638,18 @@
|
||||
"noDeposits": {
|
||||
"message": "No deposits received"
|
||||
},
|
||||
"noConversionRateAvailable":{
|
||||
"message": "No Conversion Rate Available"
|
||||
},
|
||||
"noTransactionHistory": {
|
||||
"message": "No transaction history."
|
||||
},
|
||||
"noTransactions": {
|
||||
"message": "No Transactions"
|
||||
},
|
||||
"notFound": {
|
||||
"message": "Not Found"
|
||||
},
|
||||
"notStarted": {
|
||||
"message": "Not Started"
|
||||
},
|
||||
@ -639,6 +699,9 @@
|
||||
"popularTokens": {
|
||||
"message": "Popular Tokens"
|
||||
},
|
||||
"prev": {
|
||||
"message": "Prev"
|
||||
},
|
||||
"privacyMsg": {
|
||||
"message": "Privacy Policy"
|
||||
},
|
||||
@ -724,6 +787,18 @@
|
||||
"revert": {
|
||||
"message": "Revert"
|
||||
},
|
||||
"remove": {
|
||||
"message": "remove"
|
||||
},
|
||||
"removeAccount": {
|
||||
"message": "Remove account"
|
||||
},
|
||||
"removeAccountDescription": {
|
||||
"message": "This account will be removed from your wallet. Please make sure you have the original seed phrase or private key for this imported account before continuing. You can import or create accounts again from the account drop-down. "
|
||||
},
|
||||
"readyToConnect": {
|
||||
"message": "Ready to Connect?"
|
||||
},
|
||||
"rinkeby": {
|
||||
"message": "Rinkeby Test Network"
|
||||
},
|
||||
@ -820,15 +895,45 @@
|
||||
"message": "Only send $1 to an Ethereum account address.",
|
||||
"description": "displays token symbol"
|
||||
},
|
||||
"orderOneHere": {
|
||||
"message": "Order one here."
|
||||
},
|
||||
"searchTokens": {
|
||||
"message": "Search Tokens"
|
||||
},
|
||||
"selectAnAddress": {
|
||||
"message": "Select an Address"
|
||||
},
|
||||
"selectAnAccount": {
|
||||
"message": "Select an Account"
|
||||
},
|
||||
"selectAnAccountHelp": {
|
||||
"message": "These are the accounts available in your hardware wallet. Select the one you’d like to use in MetaMask."
|
||||
},
|
||||
"sendTokensAnywhere": {
|
||||
"message": "Send Tokens to anyone with an Ethereum account"
|
||||
},
|
||||
"settings": {
|
||||
"message": "Settings"
|
||||
},
|
||||
"step1HardwareWallet": {
|
||||
"message": "1. Connect Hardware Wallet"
|
||||
},
|
||||
"step1HardwareWalletMsg": {
|
||||
"message": "Connect your hardware wallet directly to your computer."
|
||||
},
|
||||
"step2HardwareWallet": {
|
||||
"message": "2. Select an Account"
|
||||
},
|
||||
"step2HardwareWalletMsg": {
|
||||
"message": "Select the account you want to view. You can only choose one at a time."
|
||||
},
|
||||
"step3HardwareWallet": {
|
||||
"message": "3. Start using dApps and more!"
|
||||
},
|
||||
"step3HardwareWalletMsg": {
|
||||
"message": "Use your hardware account like you would with any Ethereum account. Log in to dApps, send Eth, buy and store ERC20 tokens and Non-Fungible tokens like CryptoKitties."
|
||||
},
|
||||
"info": {
|
||||
"message": "Info"
|
||||
},
|
||||
@ -944,6 +1049,9 @@
|
||||
"transfers": {
|
||||
"message": "Transfers"
|
||||
},
|
||||
"trezorHardwareWallet": {
|
||||
"message": "TREZOR Hardware Wallet"
|
||||
},
|
||||
"troubleTokenBalances": {
|
||||
"message": "We had trouble loading your token balances. You can view them ",
|
||||
"description": "Followed by a link (here) to view token balances"
|
||||
@ -969,12 +1077,18 @@
|
||||
"unknown": {
|
||||
"message": "Unknown"
|
||||
},
|
||||
"unknownFunction": {
|
||||
"message": "Unknown Function"
|
||||
},
|
||||
"unknownNetwork": {
|
||||
"message": "Unknown Private Network"
|
||||
},
|
||||
"unknownNetworkId": {
|
||||
"message": "Unknown network ID"
|
||||
},
|
||||
"unlock": {
|
||||
"message": "Unlock"
|
||||
},
|
||||
"unlockMessage": {
|
||||
"message": "The decentralized web awaits"
|
||||
},
|
||||
|
11
app/images/connect-icon.svg
Normal file
11
app/images/connect-icon.svg
Normal file
@ -0,0 +1,11 @@
|
||||
<svg width="288" height="288" xmlns="http://www.w3.org/2000/svg">
|
||||
|
||||
<g>
|
||||
<title>background</title>
|
||||
<rect fill="none" id="canvas_background" height="402" width="582" y="-1" x="-1"/>
|
||||
</g>
|
||||
<g>
|
||||
<title>Layer 1</title>
|
||||
<path fill="#ffffff" id="svg_1" d="m122,25l15,-21c4,-5 10,-5 14,0l16,22c4,5 2,10 -5,10l-12,0l0,118c0,3 3,3 5,1l25,-25c4,-4 6,-10 6,-16l0,-24c-7,0 -12,-5 -12,-12l0,-12c0,-6 5,-12 12,-12l12,0c7,0 12,5 12,12l0,12c0,7 -5,12 -12,12l0,24c0,10 -3,18 -10,25l-31,31c-4,4 -7,6 -7,16l0,49c12,3 21,13 21,26c0,15 -12,27 -27,27s-27,-12 -27,-27c0,-13 9,-23 21,-26l0,-13c0,-10 -3,-13 -7,-17l-31,-31c-6,-6 -10,-14 -10,-24l0,-25c-7,-2 -12,-9 -12,-17c0,-10 8,-18 18,-18s18,8 18,18c0,8 -5,15 -12,17l0,25c0,7 3,12 7,16l25,25c2,2 4,2 4,-1l0,-154l-12,0c-7,0 -9,-5 -4,-11z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 786 B |
44
app/images/hardware-wallet-step-1.svg
Normal file
44
app/images/hardware-wallet-step-1.svg
Normal file
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="213px" height="78px" viewBox="0 0 213 78" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: sketchtool 50.2 (55047) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>2981A924-C7CB-4957-87AD-8C680802DAD7</title>
|
||||
<desc>Created with sketchtool.</desc>
|
||||
<defs></defs>
|
||||
<g id="Import-account" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="hardware-connect" transform="translate(-406.000000, -602.000000)">
|
||||
<g id="Group-9" transform="translate(356.000000, 522.000000)">
|
||||
<g id="connect-hardware" transform="translate(51.000000, 81.000000)">
|
||||
<path d="M4,9 L70,9 L70,17 L4,17 C1.790861,17 2.705415e-16,15.209139 0,13 L0,13 C-2.705415e-16,10.790861 1.790861,9 4,9 Z" id="Rectangle" fill="#D9F0FF"></path>
|
||||
<g id="Group-4-Copy">
|
||||
<g id="Group-2" transform="translate(91.000000, 31.000000)" stroke="#3098DC">
|
||||
<polyline id="Stroke-10" points="7.33333333 0 13.4253333 5.29042105 7.33333333 10.5802632"></polyline>
|
||||
<path d="M0,5.21052632 L13.5,5.21052632" id="Stroke-11"></path>
|
||||
</g>
|
||||
<g id="Group-3" transform="translate(109.000000, 0.000000)">
|
||||
<path d="M92.535988,75.1897419 L9.16167665,75.1897419 C7.13816766,75.1897419 5.49700599,73.5434839 5.49700599,71.5123226 L5.49700599,3.67741935 C5.49700599,1.64625806 7.13816766,0 9.16167665,0 L92.535988,0 C94.5601078,0 96.2006587,1.64625806 96.2006587,3.67741935 L96.2006587,71.5123226 C96.2006587,73.5434839 94.5601078,75.1897419 92.535988,75.1897419" id="Fill-12" fill="#FEFEFE"></path>
|
||||
<path d="M92.535988,75.1897419 L9.16167665,75.1897419 C7.13816766,75.1897419 5.49700599,73.5434839 5.49700599,71.5123226 L5.49700599,3.67741935 C5.49700599,1.64625806 7.13816766,0 9.16167665,0 L92.535988,0 C94.5601078,0 96.2006587,1.64625806 96.2006587,3.67741935 L96.2006587,71.5123226 C96.2006587,73.5434839 94.5601078,75.1897419 92.535988,75.1897419 Z" id="Stroke-13" stroke="#3098DC"></path>
|
||||
<path d="M100.70576,75.6298065 L1.22155689,75.6298065 C0.546646707,75.6298065 0,75.0812581 0,74.404 L0,69.8709677 C0,69.1937097 0.546646707,68.6451613 1.22155689,68.6451613 L100.70576,68.6451613 C101.38006,68.6451613 101.927317,69.1937097 101.927317,69.8709677 L101.927317,74.404 C101.927317,75.0812581 101.38006,75.6298065 100.70576,75.6298065" id="Fill-14" fill="#D9F0FF"></path>
|
||||
<path d="M100.70576,75.6298065 L1.22155689,75.6298065 C0.546646707,75.6298065 0,75.0812581 0,74.404 L0,69.8709677 C0,69.1937097 0.546646707,68.6451613 1.22155689,68.6451613 L100.70576,68.6451613 C101.38006,68.6451613 101.927317,69.1937097 101.927317,69.8709677 L101.927317,74.404 C101.927317,75.0812581 101.38006,75.6298065 100.70576,75.6298065 Z" id="Stroke-15" stroke="#3098DC"></path>
|
||||
<polygon id="Fill-16" fill="#FEFEFE" points="9.77245509 63.6953548 92.1554731 63.6953548 92.1554731 4.90322581 9.77245509 4.90322581"></polygon>
|
||||
<polygon id="Stroke-17" stroke="#3098DC" points="9.77245509 63.6953548 92.1554731 63.6953548 92.1554731 4.90322581 9.77245509 4.90322581"></polygon>
|
||||
<path d="M53.4327111,51.4764454 L48.3815734,51.4764454 C48.2930105,51.4764454 48.2081123,51.4494776 48.1354296,51.3986067 L45.1462799,49.3073809 L43.8318847,48.2207035 L36.536747,50.2488002 C36.3101482,50.3113164 36.0719446,50.1770906 36.0059805,49.9490906 L33.8908548,42.6077357 C33.8664237,42.523768 33.8676452,42.4361228 33.8939087,42.352768 L36.1409626,35.2823164 L34.7923638,33.6826389 C34.7141841,33.5900906 34.6775374,33.4675099 34.6921961,33.346768 C34.7068548,33.226026 34.7709865,33.1157035 34.8693219,33.0446067 L35.1105793,32.8693164 L34.4368907,32.2484454 C34.3428308,32.1608002 34.2915255,32.0376067 34.2958009,31.9095099 C34.3006871,31.7808002 34.3611542,31.6612841 34.4607111,31.5822196 L34.8406153,31.2806712 L34.2218967,30.8044454 C34.1150105,30.7223164 34.0508787,30.5905422 34.0521003,30.4544776 C34.0533219,30.3178002 34.1180644,30.1872518 34.2273937,30.1057357 L34.6818129,29.7655744 L33.6019566,24.5289293 C33.5860763,24.4541551 33.5909626,24.3744776 33.6160045,24.3003164 L35.2620524,19.299026 C35.2993099,19.1862518 35.3805434,19.0930906 35.4862081,19.0428325 C35.5918728,18.9919615 35.7140284,18.9864454 35.8233578,19.0275099 L46.4826632,23.0506067 L55.3316213,23.0506067 L65.9903159,19.0275099 C66.0996452,18.9858325 66.2224117,18.9919615 66.3280763,19.0428325 C66.4343518,19.0937035 66.5155853,19.1868647 66.552232,19.299026 L68.1988907,24.3021551 C68.2227111,24.3732518 68.2275973,24.4517035 68.2123278,24.5277035 L67.1440763,29.7674131 L67.5911662,30.1081873 C67.6998847,30.1909293 67.7621841,30.3178002 67.7627949,30.4550906 C67.7634057,30.5905422 67.6998847,30.7210906 67.5936093,30.8038325 L66.9742799,31.2806712 L67.3535734,31.5822196 C67.453741,31.661897 67.5135973,31.7814131 67.5178728,31.9095099 C67.522759,32.0382196 67.4714536,32.1614131 67.3773937,32.2478325 L66.7037051,32.8693164 L66.9455734,33.0452196 C67.0432979,33.1157035 67.1074296,33.226026 67.1220883,33.3473809 C67.136747,33.4681228 67.0994895,33.5907035 67.0213099,33.6832518 L65.6739326,35.2817035 L67.9332021,42.3515422 C67.9600763,42.4336712 67.9612979,42.5225422 67.9374775,42.6071228 L65.8076931,49.9497035 C65.7423398,50.1770906 65.5035255,50.3100906 65.2775374,50.2488002 L57.9823997,48.2207035 L56.6283039,49.3368002 L53.6788548,51.3986067 C53.6061722,51.4494776 53.5206632,51.4764454 53.4327111,51.4764454" id="Fill-18" fill="#FEFEFE"></path>
|
||||
<path d="M53.4327111,51.4764454 L48.3815734,51.4764454 C48.2930105,51.4764454 48.2081123,51.4494776 48.1354296,51.3986067 L45.1462799,49.3073809 L43.8318847,48.2207035 L36.536747,50.2488002 C36.3101482,50.3113164 36.0719446,50.1770906 36.0059805,49.9490906 L33.8908548,42.6077357 C33.8664237,42.523768 33.8676452,42.4361228 33.8939087,42.352768 L36.1409626,35.2823164 L34.7923638,33.6826389 C34.7141841,33.5900906 34.6775374,33.4675099 34.6921961,33.346768 C34.7068548,33.226026 34.7709865,33.1157035 34.8693219,33.0446067 L35.1105793,32.8693164 L34.4368907,32.2484454 C34.3428308,32.1608002 34.2915255,32.0376067 34.2958009,31.9095099 C34.3006871,31.7808002 34.3611542,31.6612841 34.4607111,31.5822196 L34.8406153,31.2806712 L34.2218967,30.8044454 C34.1150105,30.7223164 34.0508787,30.5905422 34.0521003,30.4544776 C34.0533219,30.3178002 34.1180644,30.1872518 34.2273937,30.1057357 L34.6818129,29.7655744 L33.6019566,24.5289293 C33.5860763,24.4541551 33.5909626,24.3744776 33.6160045,24.3003164 L35.2620524,19.299026 C35.2993099,19.1862518 35.3805434,19.0930906 35.4862081,19.0428325 C35.5918728,18.9919615 35.7140284,18.9864454 35.8233578,19.0275099 L46.4826632,23.0506067 L55.3316213,23.0506067 L65.9903159,19.0275099 C66.0996452,18.9858325 66.2224117,18.9919615 66.3280763,19.0428325 C66.4343518,19.0937035 66.5155853,19.1868647 66.552232,19.299026 L68.1988907,24.3021551 C68.2227111,24.3732518 68.2275973,24.4517035 68.2123278,24.5277035 L67.1440763,29.7674131 L67.5911662,30.1081873 C67.6998847,30.1909293 67.7621841,30.3178002 67.7627949,30.4550906 C67.7634057,30.5905422 67.6998847,30.7210906 67.5936093,30.8038325 L66.9742799,31.2806712 L67.3535734,31.5822196 C67.453741,31.661897 67.5135973,31.7814131 67.5178728,31.9095099 C67.522759,32.0382196 67.4714536,32.1614131 67.3773937,32.2478325 L66.7037051,32.8693164 L66.9455734,33.0452196 C67.0432979,33.1157035 67.1074296,33.226026 67.1220883,33.3473809 C67.136747,33.4681228 67.0994895,33.5907035 67.0213099,33.6832518 L65.6739326,35.2817035 L67.9332021,42.3515422 C67.9600763,42.4336712 67.9612979,42.5225422 67.9374775,42.6071228 L65.8076931,49.9497035 C65.7423398,50.1770906 65.5035255,50.3100906 65.2775374,50.2488002 L57.9823997,48.2207035 L56.6283039,49.3368002 L53.6788548,51.3986067 C53.6061722,51.4494776 53.5206632,51.4764454 53.4327111,51.4764454 Z" id="Stroke-19" stroke="#3098DC"></path>
|
||||
<polygon id="Fill-20" fill="#3098DC" points="52.0480958 46.5806452 49.4779401 46.5806452 49.0320719 46.9355161 48.8622754 49.0745484 52.6637605 49.0745484 52.4933533 46.9355161"></polygon>
|
||||
<path d="M54.8341371,38.1394234 L53.7713826,40.485617 C53.6852628,40.675617 53.8562808,40.8809396 54.0505083,40.8208751 L57.6742569,39.7017138 C57.8807,39.6379718 57.9014664,39.3425525 57.7054066,39.2493912 L55.1444125,38.0223589 C55.0277539,37.9665847 54.8891072,38.0186815 54.8341371,38.1394234" id="Fill-21" fill="#3098DC"></path>
|
||||
<path d="M46.6690624,38.0223713 L44.1117331,39.2487906 C43.916284,39.3425648 43.9364397,39.6373713 44.1434936,39.7017261 L47.7666313,40.8208874 C47.9608589,40.8809519 48.1318768,40.6750164 48.0457571,40.4850164 L46.9793379,38.1388229 C46.9243678,38.0186939 46.7857211,37.9665971 46.6690624,38.0223713" id="Fill-22" fill="#3098DC"></path>
|
||||
</g>
|
||||
<g id="Group" transform="translate(0.000000, 9.000000)">
|
||||
<path d="M66.9571429,59 L3.68571429,59 C1.65058571,59 0,57.3318526 0,55.2736842 L0,3.72631579 C0,1.66876842 1.65058571,0 3.68571429,0 L66.9571429,0 C68.9922714,0 70.6428571,1.66876842 70.6428571,3.72631579 L70.6428571,55.2736842 C70.6428571,57.3318526 68.9922714,59 66.9571429,59 Z" id="Stroke-1" stroke="#3098DC"></path>
|
||||
<path d="M66.9571429,7.45263158 L3.68571429,7.45263158 C1.65058571,7.45263158 0,5.78448421 0,3.72631579 C0,1.66876842 1.65058571,0 3.68571429,0 L66.9571429,0 C68.9922714,0 70.6428571,1.66876842 70.6428571,3.72631579" id="Stroke-3" stroke="#3098DC"></path>
|
||||
<path d="M66.9571429,7.45263158 C68.9922714,7.45263158 70.6428571,9.1214 70.6428571,11.1789474" id="Stroke-5" stroke="#3098DC"></path>
|
||||
<polygon id="Stroke-7" stroke="#3098DC" points="70.6428571 23.5987579 85.5319143 23.5987579 85.5319143 19.8736842 70.6428571 19.8736842"></polygon>
|
||||
<polygon id="Stroke-9" stroke="#3098DC" points="70.6428571 38.6530737 85.5319143 38.6530737 85.5319143 23.6 70.6428571 23.6"></polygon>
|
||||
<path d="M35.2784286,22.3578947 L28.9666429,32.8356737 L35.2784286,36.5682 L41.5902143,32.8387789 L35.2784286,22.3578947 Z M35.1832143,37.7631053 L28.8714286,34.0336842 L35.1832143,42.9321263 L41.4986857,34.0336842 L35.1819857,37.7631053 L35.1832143,37.7631053 Z" id="Fill-23" fill="#3098DC"></path>
|
||||
<path d="M50.4672571,32.9642316 C50.4672571,24.3626526 43.5700571,17.3894737 35.0622,17.3894737 C26.5543429,17.3894737 19.6571429,24.3626526 19.6571429,32.9642316 C19.6571429,41.5664316 26.5543429,48.5389895 35.0622,48.5389895 C43.5700571,48.5389895 50.4672571,41.5664316 50.4672571,32.9642316 Z" id="Stroke-24" stroke="#3098DC"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 11 KiB |
81
app/images/hardware-wallet-step-2.svg
Normal file
81
app/images/hardware-wallet-step-2.svg
Normal file
@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="302px" height="98px" viewBox="0 0 302 98" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: sketchtool 50.2 (55047) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>27B850D0-B3BA-4F98-8BB4-B542D8BFDE3B</title>
|
||||
<desc>Created with sketchtool.</desc>
|
||||
<defs>
|
||||
<rect id="path-1" x="0" y="0" width="294" height="32"></rect>
|
||||
<filter x="-2.4%" y="-15.6%" width="104.8%" height="143.8%" filterUnits="objectBoundingBox" id="filter-2">
|
||||
<feOffset dx="0" dy="2" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset>
|
||||
<feGaussianBlur stdDeviation="2" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
|
||||
<feComposite in="shadowBlurOuter1" in2="SourceAlpha" operator="out" result="shadowBlurOuter1"></feComposite>
|
||||
<feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.123075181 0" type="matrix" in="shadowBlurOuter1"></feColorMatrix>
|
||||
</filter>
|
||||
</defs>
|
||||
<g id="Import-account" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="hardware-connect" transform="translate(-361.000000, -797.000000)">
|
||||
<g id="Group-10" transform="translate(356.000000, 717.000000)">
|
||||
<g id="accounts" transform="translate(9.000000, 80.000000)">
|
||||
<g id="Group-5" transform="translate(21.000000, 0.000000)">
|
||||
<g id="Group-7" transform="translate(0.000000, 45.000000)">
|
||||
<rect id="Rectangle-6-Copy" stroke="#AFDFFF" fill="#FFFFFF" x="0.5" y="0.5" width="250" height="26"></rect>
|
||||
<text id="3" font-family="Roboto-Regular, Roboto" font-size="12" font-weight="normal" fill="#ABB4BB">
|
||||
<tspan x="31" y="19">3</tspan>
|
||||
</text>
|
||||
<text id="OXz3…T3A4" font-family="Roboto-Regular, Roboto" font-size="12" font-weight="normal" fill="#ABB4BB">
|
||||
<tspan x="50" y="19">OXz3…T3A4</tspan>
|
||||
</text>
|
||||
<text id="0.020000-ETH" font-family="Roboto-Regular, Roboto" font-size="12" font-weight="normal" fill="#ABB4BB">
|
||||
<tspan x="142" y="19">0.020000 ETH</tspan>
|
||||
</text>
|
||||
<circle id="Oval-Copy" stroke="#AFDFFF" stroke-width="2" cx="16.5" cy="14.5" r="6.5"></circle>
|
||||
</g>
|
||||
<g id="Group-7-Copy">
|
||||
<rect id="Rectangle-6-Copy" stroke="#AFDFFF" fill="#FFFFFF" x="0.5" y="0.5" width="250" height="26"></rect>
|
||||
<text id="1" font-family="Roboto-Regular, Roboto" font-size="12" font-weight="normal" fill="#ABB4BB">
|
||||
<tspan x="31" y="19">1</tspan>
|
||||
</text>
|
||||
<text id="OXa4…s0a2" font-family="Roboto-Regular, Roboto" font-size="12" font-weight="normal" fill="#ABB4BB">
|
||||
<tspan x="50" y="19">OXa4…s0a2</tspan>
|
||||
</text>
|
||||
<text id="0.01500-ETH" font-family="Roboto-Regular, Roboto" font-size="12" font-weight="normal" fill="#ABB4BB">
|
||||
<tspan x="142" y="19">0.01500 ETH</tspan>
|
||||
</text>
|
||||
<circle id="Oval-Copy" stroke="#AFDFFF" stroke-width="2" cx="16.5" cy="14.5" r="6.5"></circle>
|
||||
</g>
|
||||
<g id="Group-8" transform="translate(0.000000, 71.000000)">
|
||||
<rect id="Rectangle-6-Copy-2" stroke="#AFDFFF" fill="#FFFFFF" x="0.5" y="0.5" width="250" height="26"></rect>
|
||||
<text id="4" font-family="Roboto-Regular, Roboto" font-size="12" font-weight="normal" fill="#ABB4BB">
|
||||
<tspan x="31" y="18">4</tspan>
|
||||
</text>
|
||||
<text id="OXd2…D0V4" font-family="Roboto-Regular, Roboto" font-size="12" font-weight="normal" fill="#ABB4BB">
|
||||
<tspan x="50" y="18">OXd2…D0V4</tspan>
|
||||
</text>
|
||||
<text id="0.030000-ETH" font-family="Roboto-Regular, Roboto" font-size="12" font-weight="normal" fill="#ABB4BB">
|
||||
<tspan x="142" y="18">0.030000 ETH</tspan>
|
||||
</text>
|
||||
<circle id="Oval-Copy-2" stroke="#AFDFFF" stroke-width="2" cx="16.5" cy="13.5" r="6.5"></circle>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Group-4" transform="translate(0.000000, 21.000000)">
|
||||
<g id="Rectangle-6">
|
||||
<use fill="black" fill-opacity="1" filter="url(#filter-2)" xlink:href="#path-1"></use>
|
||||
<rect stroke="#3098DC" stroke-width="1" stroke-linejoin="square" fill="#D9F0FF" fill-rule="evenodd" x="0.5" y="0.5" width="293" height="31"></rect>
|
||||
</g>
|
||||
<text id="2" font-family="Roboto-Regular, Roboto" font-size="16" font-weight="normal" fill="#4A4A4A">
|
||||
<tspan x="36" y="22">2</tspan>
|
||||
</text>
|
||||
<text id="OXe7…B0a1" font-family="Roboto-Regular, Roboto" font-size="16" font-weight="normal" fill="#4A4A4A">
|
||||
<tspan x="58" y="22">OXe7…B0a1</tspan>
|
||||
</text>
|
||||
<text id="0.041000-ETH" font-family="Roboto-Regular, Roboto" font-size="16" font-weight="normal" fill="#4A4A4A">
|
||||
<tspan x="166" y="22">0.041000 ETH</tspan>
|
||||
</text>
|
||||
<circle id="Oval" stroke="#3098DC" stroke-width="2" cx="19.5" cy="16.5" r="7.5"></circle>
|
||||
<polyline id="Path-5" stroke="#3098DC" stroke-width="2" points="15 17 17.5495098 19.5495098 24 13.9042921"></polyline>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 6.1 KiB |
42
app/images/hardware-wallet-step-3.svg
Normal file
42
app/images/hardware-wallet-step-3.svg
Normal file
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="108px" height="85px" viewBox="0 0 108 85" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: sketchtool 50.2 (55047) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>CEB55C41-7BCE-405E-83CD-834B388B495F</title>
|
||||
<desc>Created with sketchtool.</desc>
|
||||
<defs></defs>
|
||||
<g id="Import-account" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="hardware-connect" transform="translate(-457.000000, -1057.000000)">
|
||||
<g id="Group-11" transform="translate(356.000000, 929.000000)">
|
||||
<g id="use-dapps" transform="translate(102.000000, 129.000000)">
|
||||
<g id="Group-3">
|
||||
<path d="M96.2021481,83 L9.79785192,83 C7.70080469,83 6,81.2922121 6,79.1851351 L6,8.81486493 C6,6.70778787 7.70080469,5 9.79785192,5 L96.2021481,5 C98.2998283,5 100,6.70778787 100,8.81486493 L100,79.1851351 C100,81.2922121 98.2998283,83 96.2021481,83" id="Fill-12" fill="#FEFEFE"></path>
|
||||
<path d="M96.2021481,83 L9.79785192,83 C7.70080469,83 6,81.2922121 6,79.1851351 L6,8.81486493 C6,6.70778787 7.70080469,5 9.79785192,5 L96.2021481,5 C98.2998283,5 100,6.70778787 100,8.81486493 L100,79.1851351 C100,81.2922121 98.2998283,83 96.2021481,83 Z" id="Stroke-13" stroke="#3098DC"></path>
|
||||
<path d="M104.729634,83 L1.27036631,83 C0.568488923,83 0,82.4502457 0,81.7714988 L0,77.2285012 C0,76.5497543 0.568488923,76 1.27036631,76 L104.729634,76 C105.430876,76 106,76.5497543 106,77.2285012 L106,81.7714988 C106,82.4502457 105.430876,83 104.729634,83" id="Fill-14" fill="#D9F0FF"></path>
|
||||
<path d="M104.729634,83 L1.27036631,83 C0.568488923,83 0,82.4502457 0,81.7714988 L0,77.2285012 C0,76.5497543 0.568488923,76 1.27036631,76 L104.729634,76 C105.430876,76 106,76.5497543 106,77.2285012 L106,81.7714988 C106,82.4502457 105.430876,83 104.729634,83 Z" id="Stroke-15" stroke="#3098DC"></path>
|
||||
<polygon id="Fill-16" fill="#FEFEFE" points="10 71 96 71 96 10 10 10"></polygon>
|
||||
<polygon id="Stroke-17" stroke="#3098DC" points="10 71 96 71 96 10 10 10"></polygon>
|
||||
<rect id="Rectangle-2" stroke="#3098DC" fill="#FFFFFF" x="14.5" y="14.5" width="77" height="53" rx="2"></rect>
|
||||
<path d="M14.5,21.5 L91.5,21.5 L91.5,16 C91.5,15.1715729 90.8284271,14.5 90,14.5 L16,14.5 C15.1715729,14.5 14.5,15.1715729 14.5,16 L14.5,21.5 Z" id="Rectangle-3" stroke="#3098DC" fill="#FFFFFF"></path>
|
||||
<g id="Group-6" transform="translate(17.000000, 17.000000)" fill="#D9F0FF" stroke="#3098DC">
|
||||
<circle id="Oval-2" cx="1" cy="1" r="1"></circle>
|
||||
<circle id="Oval-2" cx="5.76923077" cy="1" r="1"></circle>
|
||||
<circle id="Oval-2" cx="10.5384615" cy="1" r="1"></circle>
|
||||
</g>
|
||||
<g id="metamask-outline" transform="translate(73.000000, 0.000000)">
|
||||
<g id="Group-6">
|
||||
<path d="M19.2986136,29.0578722 L14.6471457,29.0578722 C14.5655903,29.0578722 14.4874097,29.0337432 14.420478,28.988227 L11.6678439,27.1171303 L10.4574498,26.1448399 L3.73953772,27.9594528 C3.53086848,28.0153883 3.31151268,27.8952915 3.250768,27.6912915 L1.30300094,21.1227109 C1.28050291,21.0475819 1.28162782,20.9691625 1.3058132,20.8945819 L3.37506962,14.5683883 L2.1331783,13.137098 C2.0611846,13.0542915 2.02743755,12.9446141 2.04093637,12.8365819 C2.05443519,12.7285496 2.11349252,12.6298399 2.20404709,12.566227 L2.42621515,12.4093883 L1.80583194,11.8538722 C1.71921452,11.7754528 1.67196866,11.665227 1.67590581,11.5506141 C1.68040542,11.4354528 1.73608805,11.3285174 1.82776752,11.2577754 L2.17761191,10.987969 L1.60784927,10.5618722 C1.50942038,10.4883883 1.45036305,10.3704851 1.45148795,10.2487432 C1.45261285,10.1264528 1.51223264,10.0096464 1.61291132,9.9367109 L2.0313747,9.63235606 L1.03696173,4.94693671 C1.02233801,4.88003348 1.02683761,4.80874316 1.04989809,4.74238832 L2.56570295,0.267549611 C2.60001244,0.166646385 2.6748184,0.0832915464 2.77212238,0.0383238044 C2.86942637,-0.00719232461 2.98191652,-0.0121278085 3.08259521,0.024614127 L12.8984862,3.62422703 L21.0472731,3.62422703 L30.8626017,0.024614127 C30.9632804,-0.0126761956 31.076333,-0.00719232461 31.173637,0.0383238044 C31.2715034,0.0838399335 31.3463093,0.167194772 31.3800564,0.267549611 L32.8964237,4.74403348 C32.9183593,4.80764639 32.9228589,4.87783993 32.9087976,4.94583993 L31.9250712,9.63400122 L32.3367852,9.93890445 C32.4369014,10.0129367 32.4942714,10.1264528 32.4948338,10.2492915 C32.4953963,10.3704851 32.4369014,10.4872915 32.339035,10.5613238 L31.7687099,10.987969 L32.1179918,11.2577754 C32.2102337,11.3290657 32.2653539,11.4360012 32.2692911,11.5506141 C32.2737907,11.6657754 32.2265448,11.7760012 32.1399274,11.8533238 L31.5195442,12.4093883 L31.7422747,12.5667754 C31.8322668,12.6298399 31.8913241,12.7285496 31.904823,12.8371303 C31.9183218,12.9451625 31.8840123,13.0548399 31.8120186,13.1376464 L30.5712522,14.5678399 L32.6517576,20.8934851 C32.6765054,20.966969 32.6776303,21.0464851 32.6556948,21.1221625 L30.6944289,27.6918399 C30.6342467,27.8952915 30.4143284,28.0142915 30.2062216,27.9594528 L23.4883095,26.1448399 L22.2413561,27.1434528 L19.5252813,28.988227 C19.4583497,29.0337432 19.3796066,29.0578722 19.2986136,29.0578722 Z" id="Stroke-19" stroke="#3098DC" fill="#FFFFFF"></path>
|
||||
<polygon id="Fill-20" fill="#3098DC" points="18.0235556 24.6774194 15.6567628 24.6774194 15.2461737 24.9949355 15.0898124 26.9088065 18.590506 26.9088065 18.4335823 24.9949355"></polygon>
|
||||
<path d="M20.5891522,17.1247473 L19.6104879,19.2239731 C19.5311823,19.3939731 19.6886685,19.5776828 19.8675279,19.5239408 L23.2045484,18.522586 C23.3946567,18.4655537 23.4137801,18.2012312 23.2332334,18.1178763 L20.8748772,17.0200054 C20.7674491,16.9701021 20.6397728,17.016715 20.5891522,17.1247473" id="Fill-21" fill="#3098DC"></path>
|
||||
<path d="M13.0701367,17.0200164 L10.7151553,18.117339 C10.535171,18.2012422 10.5537319,18.4650164 10.7444027,18.5225971 L14.0808608,19.5239519 C14.2597201,19.5776938 14.4172063,19.3934358 14.3379008,19.2234358 L13.3558617,17.12421 C13.3052411,17.0167261 13.1775648,16.9701132 13.0701367,17.0200164" id="Fill-22" fill="#3098DC"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<text id="LOGIN-WITH-METAMASK" font-family="RobotoMono-Bold, Roboto Mono" font-size="10" font-weight="bold" fill="#3098DC">
|
||||
<tspan x="24.4951172" y="43">LOGIN WITH </tspan>
|
||||
<tspan x="30.4960938" y="56">METAMASK</tspan>
|
||||
</text>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 6.8 KiB |
@ -62,7 +62,9 @@
|
||||
"https://*.infura.io/",
|
||||
"activeTab",
|
||||
"webRequest",
|
||||
"*://*.eth/"
|
||||
"*://*.eth/",
|
||||
"*://*.test/",
|
||||
"notifications"
|
||||
],
|
||||
"web_accessible_resources": [
|
||||
"inpage.js"
|
||||
|
@ -44,8 +44,8 @@ const notificationManager = new NotificationManager()
|
||||
global.METAMASK_NOTIFIER = notificationManager
|
||||
|
||||
// setup sentry error reporting
|
||||
const release = platform.getVersion()
|
||||
const raven = setupRaven({ release })
|
||||
const releaseVersion = platform.getVersion()
|
||||
const raven = setupRaven({ releaseVersion })
|
||||
|
||||
// browser check if it is Edge - https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
|
||||
// Internet Explorer 6-11
|
||||
@ -53,6 +53,7 @@ const isIE = !!document.documentMode
|
||||
// Edge 20+
|
||||
const isEdge = !isIE && !!window.StyleMedia
|
||||
|
||||
let ipfsHandle
|
||||
let popupIsOpen = false
|
||||
let notificationIsOpen = false
|
||||
const openMetamaskTabsIDs = {}
|
||||
@ -158,7 +159,7 @@ async function initialize () {
|
||||
const initLangCode = await getFirstPreferredLangCode()
|
||||
await setupController(initState, initLangCode)
|
||||
log.debug('MetaMask initialization complete.')
|
||||
ipfsContent(initState.NetworkController.provider)
|
||||
ipfsHandle = ipfsContent(initState.NetworkController.provider)
|
||||
}
|
||||
|
||||
//
|
||||
@ -262,6 +263,10 @@ function setupController (initState, initLangCode) {
|
||||
})
|
||||
global.metamaskController = controller
|
||||
|
||||
controller.networkController.on('networkDidChange', () => {
|
||||
ipfsHandle && ipfsHandle.remove()
|
||||
ipfsHandle = ipfsContent(controller.networkController.providerStore.getState())
|
||||
})
|
||||
|
||||
// report failed transactions to Sentry
|
||||
controller.txController.on(`tx:status-update`, (txId, status) => {
|
||||
|
@ -178,6 +178,7 @@ function blacklistedDomainCheck () {
|
||||
'adyen.com',
|
||||
'gravityforms.com',
|
||||
'harbourair.com',
|
||||
'blueskybooking.com',
|
||||
]
|
||||
var currentUrl = window.location.href
|
||||
var currentRegex
|
||||
|
123
app/scripts/controllers/detect-tokens.js
Normal file
123
app/scripts/controllers/detect-tokens.js
Normal file
@ -0,0 +1,123 @@
|
||||
const Web3 = require('web3')
|
||||
const contracts = require('eth-contract-metadata')
|
||||
const { warn } = require('loglevel')
|
||||
const { MAINNET } = require('./network/enums')
|
||||
// By default, poll every 3 minutes
|
||||
const DEFAULT_INTERVAL = 180 * 1000
|
||||
const ERC20_ABI = [{'constant': true, 'inputs': [{'name': '_owner', 'type': 'address'}], 'name': 'balanceOf', 'outputs': [{'name': 'balance', 'type': 'uint256'}], 'payable': false, 'type': 'function'}]
|
||||
|
||||
/**
|
||||
* A controller that polls for token exchange
|
||||
* rates based on a user's current token list
|
||||
*/
|
||||
class DetectTokensController {
|
||||
/**
|
||||
* Creates a DetectTokensController
|
||||
*
|
||||
* @param {Object} [config] - Options to configure controller
|
||||
*/
|
||||
constructor ({ interval = DEFAULT_INTERVAL, preferences, network, keyringMemStore } = {}) {
|
||||
this.preferences = preferences
|
||||
this.interval = interval
|
||||
this.network = network
|
||||
this.keyringMemStore = keyringMemStore
|
||||
}
|
||||
|
||||
/**
|
||||
* For each token in eth-contract-metada, find check selectedAddress balance.
|
||||
*
|
||||
*/
|
||||
async detectNewTokens () {
|
||||
if (!this.isActive) { return }
|
||||
if (this._network.store.getState().provider.type !== MAINNET) { return }
|
||||
this.web3.setProvider(this._network._provider)
|
||||
for (const contractAddress in contracts) {
|
||||
if (contracts[contractAddress].erc20 && !(this.tokenAddresses.includes(contractAddress.toLowerCase()))) {
|
||||
this.detectTokenBalance(contractAddress)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find if selectedAddress has tokens with contract in contractAddress.
|
||||
*
|
||||
* @param {string} contractAddress Hex address of the token contract to explore.
|
||||
* @returns {boolean} If balance is detected, token is added.
|
||||
*
|
||||
*/
|
||||
async detectTokenBalance (contractAddress) {
|
||||
const ethContract = this.web3.eth.contract(ERC20_ABI).at(contractAddress)
|
||||
ethContract.balanceOf(this.selectedAddress, (error, result) => {
|
||||
if (!error) {
|
||||
if (!result.isZero()) {
|
||||
this._preferences.addToken(contractAddress, contracts[contractAddress].symbol, contracts[contractAddress].decimals)
|
||||
}
|
||||
} else {
|
||||
warn(`MetaMask - DetectTokensController balance fetch failed for ${contractAddress}.`, error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Restart token detection polling period and call detectNewTokens
|
||||
* in case of address change or user session initialization.
|
||||
*
|
||||
*/
|
||||
restartTokenDetection () {
|
||||
if (this.isActive && this.selectedAddress) {
|
||||
this.detectNewTokens()
|
||||
this.interval = DEFAULT_INTERVAL
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {Number}
|
||||
*/
|
||||
set interval (interval) {
|
||||
this._handle && clearInterval(this._handle)
|
||||
if (!interval) { return }
|
||||
this._handle = setInterval(() => { this.detectNewTokens() }, interval)
|
||||
}
|
||||
|
||||
/**
|
||||
* In setter when selectedAddress is changed, detectNewTokens and restart polling
|
||||
* @type {Object}
|
||||
*/
|
||||
set preferences (preferences) {
|
||||
if (!preferences) { return }
|
||||
this._preferences = preferences
|
||||
preferences.store.subscribe(({ tokens }) => { this.tokenAddresses = tokens.map((obj) => { return obj.address }) })
|
||||
preferences.store.subscribe(({ selectedAddress }) => {
|
||||
if (this.selectedAddress !== selectedAddress) {
|
||||
this.selectedAddress = selectedAddress
|
||||
this.restartTokenDetection()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {Object}
|
||||
*/
|
||||
set network (network) {
|
||||
if (!network) { return }
|
||||
this._network = network
|
||||
this.web3 = new Web3(network._provider)
|
||||
}
|
||||
|
||||
/**
|
||||
* In setter when isUnlocked is updated to true, detectNewTokens and restart polling
|
||||
* @type {Object}
|
||||
*/
|
||||
set keyringMemStore (keyringMemStore) {
|
||||
if (!keyringMemStore) { return }
|
||||
this._keyringMemStore = keyringMemStore
|
||||
this._keyringMemStore.subscribe(({ isUnlocked }) => {
|
||||
if (this.isUnlocked !== isUnlocked) {
|
||||
if (isUnlocked) { this.restartTokenDetection() }
|
||||
this.isUnlocked = isUnlocked
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DetectTokensController
|
@ -85,6 +85,30 @@ class PreferencesController {
|
||||
this.store.updateState({ identities })
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an address from state
|
||||
*
|
||||
* @param {string} address A hex address
|
||||
* @returns {string} the address that was removed
|
||||
*/
|
||||
removeAddress (address) {
|
||||
const identities = this.store.getState().identities
|
||||
if (!identities[address]) {
|
||||
throw new Error(`${address} can't be deleted cause it was not found`)
|
||||
}
|
||||
delete identities[address]
|
||||
this.store.updateState({ identities })
|
||||
|
||||
// If the selected account is no longer valid,
|
||||
// select an arbitrary other account:
|
||||
if (address === this.getSelectedAddress()) {
|
||||
const selected = Object.keys(identities)[0]
|
||||
this.setSelectedAddress(selected)
|
||||
}
|
||||
return address
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds addresses to the identities object without removing identities
|
||||
*
|
||||
|
@ -2,39 +2,43 @@ const extension = require('extensionizer')
|
||||
const resolver = require('./resolver.js')
|
||||
|
||||
module.exports = function (provider) {
|
||||
extension.webRequest.onBeforeRequest.addListener(details => {
|
||||
const urlhttpreplace = details.url.replace(/\w+?:\/\//, '')
|
||||
const url = urlhttpreplace.replace(/[\\/].*/g, '') // eslint-disable-line no-useless-escape
|
||||
let domainhtml = urlhttpreplace.match(/[\\/].*/g) // eslint-disable-line no-useless-escape
|
||||
let clearTime = null
|
||||
const name = url.replace(/\/$/g, '')
|
||||
if (domainhtml === null) domainhtml = ['']
|
||||
extension.tabs.getSelected(null, tab => {
|
||||
extension.tabs.update(tab.id, { url: 'loading.html' })
|
||||
function ipfsContent (details) {
|
||||
const name = details.url.substring(7, details.url.length - 1)
|
||||
let clearTime = null
|
||||
extension.tabs.getSelected(null, tab => {
|
||||
extension.tabs.update(tab.id, { url: 'loading.html' })
|
||||
|
||||
clearTime = setTimeout(() => {
|
||||
return extension.tabs.update(tab.id, { url: '404.html' })
|
||||
}, 60000)
|
||||
clearTime = setTimeout(() => {
|
||||
return extension.tabs.update(tab.id, { url: '404.html' })
|
||||
}, 60000)
|
||||
|
||||
resolver.resolve(name, provider).then(ipfsHash => {
|
||||
clearTimeout(clearTime)
|
||||
let url = 'https://ipfs.infura.io/ipfs/' + ipfsHash + domainhtml[0]
|
||||
return fetch(url, { method: 'HEAD' }).then(response => response.status).then(statusCode => {
|
||||
if (statusCode !== 200) return extension.tabs.update(tab.id, { url: '404.html' })
|
||||
extension.tabs.update(tab.id, { url: url })
|
||||
})
|
||||
.catch(err => {
|
||||
url = 'https://ipfs.infura.io/ipfs/' + ipfsHash + domainhtml[0]
|
||||
extension.tabs.update(tab.id, {url: url})
|
||||
return err
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
clearTimeout(clearTime)
|
||||
const url = err === 'unsupport' ? 'unsupport' : 'error'
|
||||
extension.tabs.update(tab.id, {url: `${url}.html?name=${name}`})
|
||||
})
|
||||
})
|
||||
return { cancel: true }
|
||||
}, {urls: ['*://*.eth/', '*://*.eth/*']})
|
||||
resolver.resolve(name, provider).then(ipfsHash => {
|
||||
clearTimeout(clearTime)
|
||||
let url = 'https://ipfs.infura.io/ipfs/' + ipfsHash
|
||||
return fetch(url, { method: 'HEAD' }).then(response => response.status).then(statusCode => {
|
||||
if (statusCode !== 200) return extension.tabs.update(tab.id, { url: '404.html' })
|
||||
extension.tabs.update(tab.id, { url: url })
|
||||
})
|
||||
.catch(err => {
|
||||
url = 'https://ipfs.infura.io/ipfs/' + ipfsHash
|
||||
extension.tabs.update(tab.id, {url: url})
|
||||
return err
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
clearTimeout(clearTime)
|
||||
const url = err === 'unsupport' ? 'unsupport' : 'error'
|
||||
extension.tabs.update(tab.id, {url: `${url}.html?name=${name}`})
|
||||
})
|
||||
})
|
||||
return { cancel: true }
|
||||
}
|
||||
|
||||
extension.webRequest.onBeforeRequest.addListener(ipfsContent, {urls: ['*://*.eth/', '*://*.test/']})
|
||||
|
||||
return {
|
||||
remove () {
|
||||
extension.webRequest.onBeforeRequest.removeListener(ipfsContent)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -60,8 +60,8 @@ function getRegistrar (type) {
|
||||
|
||||
module.exports.resolve = function (name, provider) {
|
||||
const path = name.split('.')
|
||||
const tld = path[path.length - 1]
|
||||
if (tld === 'eth') {
|
||||
const topLevelDomain = path[path.length - 1]
|
||||
if (topLevelDomain === 'eth' || topLevelDomain === 'test') {
|
||||
return ens(name, provider)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
@ -8,8 +8,10 @@ module.exports = setupRaven
|
||||
|
||||
// Setup raven / sentry remote error reporting
|
||||
function setupRaven (opts) {
|
||||
const { release } = opts
|
||||
const { releaseVersion } = opts
|
||||
let ravenTarget
|
||||
// detect brave
|
||||
const isBrave = Boolean(window.chrome.ipcRenderer)
|
||||
|
||||
if (METAMASK_DEBUG) {
|
||||
console.log('Setting up Sentry Remote Error Reporting: DEV')
|
||||
@ -20,9 +22,11 @@ function setupRaven (opts) {
|
||||
}
|
||||
|
||||
const client = Raven.config(ravenTarget, {
|
||||
release,
|
||||
releaseVersion,
|
||||
transport: function (opts) {
|
||||
opts.data.extra.isBrave = isBrave
|
||||
const report = opts.data
|
||||
|
||||
try {
|
||||
// handle error-like non-error exceptions
|
||||
rewriteErrorLikeExceptions(report)
|
||||
|
@ -28,7 +28,7 @@ function getStack () {
|
||||
*
|
||||
*/
|
||||
const getEnvironmentType = (url = window.location.href) => {
|
||||
if (url.match(/popup.html(?:\?.+)*$/)) {
|
||||
if (url.match(/popup.html(?:#.*)*$/)) {
|
||||
return ENVIRONMENT_TYPE_POPUP
|
||||
} else if (url.match(/home.html(?:\?.+)*$/) || url.match(/home.html(?:#.*)*$/)) {
|
||||
return ENVIRONMENT_TYPE_FULLSCREEN
|
||||
|
@ -35,6 +35,7 @@ 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 DetectTokensController = require('./controllers/detect-tokens')
|
||||
const ConfigManager = require('./lib/config-manager')
|
||||
const nodeify = require('./lib/nodeify')
|
||||
const accountImporter = require('./account-import-strategies')
|
||||
@ -47,6 +48,7 @@ const percentile = require('percentile')
|
||||
const seedPhraseVerifier = require('./lib/seed-phrase-verifier')
|
||||
const cleanErrorStack = require('./lib/cleanErrorStack')
|
||||
const log = require('loglevel')
|
||||
const TrezorKeyring = require('eth-trezor-keyring')
|
||||
|
||||
module.exports = class MetamaskController extends EventEmitter {
|
||||
|
||||
@ -124,7 +126,9 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||
})
|
||||
|
||||
// key mgmt
|
||||
const additionalKeyrings = [TrezorKeyring]
|
||||
this.keyringController = new KeyringController({
|
||||
keyringTypes: additionalKeyrings,
|
||||
initState: initState.KeyringController,
|
||||
getNetwork: this.networkController.getNetworkState.bind(this.networkController),
|
||||
encryptor: opts.encryptor || undefined,
|
||||
@ -144,6 +148,13 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||
this.accountTracker.syncWithAddresses(addresses)
|
||||
})
|
||||
|
||||
// detect tokens controller
|
||||
this.detectTokensController = new DetectTokensController({
|
||||
preferences: this.preferencesController,
|
||||
network: this.networkController,
|
||||
keyringMemStore: this.keyringController.memStore,
|
||||
})
|
||||
|
||||
// address book controller
|
||||
this.addressBookController = new AddressBookController({
|
||||
initState: initState.AddressBookController,
|
||||
@ -164,6 +175,13 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||
})
|
||||
this.txController.on('newUnapprovedTx', opts.showUnapprovedTx.bind(opts))
|
||||
|
||||
this.txController.on(`tx:status-update`, (txId, status) => {
|
||||
if (status === 'confirmed' || status === 'failed') {
|
||||
const txMeta = this.txController.txStateManager.getTx(txId)
|
||||
this.platform.showTransactionNotification(txMeta)
|
||||
}
|
||||
})
|
||||
|
||||
// computed balances (accounting for pending transactions)
|
||||
this.balancesController = new BalancesController({
|
||||
accountTracker: this.accountTracker,
|
||||
@ -351,8 +369,17 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||
verifySeedPhrase: nodeify(this.verifySeedPhrase, this),
|
||||
clearSeedWordCache: this.clearSeedWordCache.bind(this),
|
||||
resetAccount: nodeify(this.resetAccount, this),
|
||||
removeAccount: nodeify(this.removeAccount, this),
|
||||
importAccountWithStrategy: nodeify(this.importAccountWithStrategy, this),
|
||||
|
||||
// hardware wallets
|
||||
connectHardware: nodeify(this.connectHardware, this),
|
||||
forgetDevice: nodeify(this.forgetDevice, this),
|
||||
checkHardwareStatus: nodeify(this.checkHardwareStatus, this),
|
||||
|
||||
// TREZOR
|
||||
unlockTrezorAccount: nodeify(this.unlockTrezorAccount, this),
|
||||
|
||||
// vault management
|
||||
submitPassword: nodeify(this.submitPassword, this),
|
||||
|
||||
@ -508,6 +535,127 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||
this.preferencesController.setSelectedAddress(address)
|
||||
}
|
||||
|
||||
//
|
||||
// Hardware
|
||||
//
|
||||
|
||||
/**
|
||||
* Fetch account list from a trezor device.
|
||||
*
|
||||
* @returns [] accounts
|
||||
*/
|
||||
async connectHardware (deviceName, page) {
|
||||
|
||||
switch (deviceName) {
|
||||
case 'trezor':
|
||||
const keyringController = this.keyringController
|
||||
const oldAccounts = await keyringController.getAccounts()
|
||||
let keyring = await keyringController.getKeyringsByType(
|
||||
'Trezor Hardware'
|
||||
)[0]
|
||||
if (!keyring) {
|
||||
keyring = await this.keyringController.addNewKeyring('Trezor Hardware')
|
||||
}
|
||||
let accounts = []
|
||||
|
||||
switch (page) {
|
||||
case -1:
|
||||
accounts = await keyring.getPreviousPage()
|
||||
break
|
||||
case 1:
|
||||
accounts = await keyring.getNextPage()
|
||||
break
|
||||
default:
|
||||
accounts = await keyring.getFirstPage()
|
||||
}
|
||||
|
||||
// Merge with existing accounts
|
||||
// and make sure addresses are not repeated
|
||||
const accountsToTrack = [...new Set(oldAccounts.concat(accounts.map(a => a.address.toLowerCase())))]
|
||||
this.accountTracker.syncWithAddresses(accountsToTrack)
|
||||
return accounts
|
||||
|
||||
default:
|
||||
throw new Error('MetamaskController:connectHardware - Unknown device')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the device is unlocked
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
async checkHardwareStatus (deviceName) {
|
||||
|
||||
switch (deviceName) {
|
||||
case 'trezor':
|
||||
const keyringController = this.keyringController
|
||||
const keyring = await keyringController.getKeyringsByType(
|
||||
'Trezor Hardware'
|
||||
)[0]
|
||||
if (!keyring) {
|
||||
return false
|
||||
}
|
||||
return keyring.isUnlocked()
|
||||
default:
|
||||
throw new Error('MetamaskController:checkHardwareStatus - Unknown device')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
async forgetDevice (deviceName) {
|
||||
|
||||
switch (deviceName) {
|
||||
case 'trezor':
|
||||
const keyringController = this.keyringController
|
||||
const keyring = await keyringController.getKeyringsByType(
|
||||
'Trezor Hardware'
|
||||
)[0]
|
||||
if (!keyring) {
|
||||
throw new Error('MetamaskController:forgetDevice - Trezor Hardware keyring not found')
|
||||
}
|
||||
keyring.forgetDevice()
|
||||
return true
|
||||
default:
|
||||
throw new Error('MetamaskController:forgetDevice - Unknown device')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports an account from a trezor device.
|
||||
*
|
||||
* @returns {} keyState
|
||||
*/
|
||||
async unlockTrezorAccount (index) {
|
||||
const keyringController = this.keyringController
|
||||
const keyring = await keyringController.getKeyringsByType(
|
||||
'Trezor Hardware'
|
||||
)[0]
|
||||
if (!keyring) {
|
||||
throw new Error('MetamaskController - No Trezor Hardware Keyring found')
|
||||
}
|
||||
|
||||
keyring.setAccountToUnlock(index)
|
||||
const oldAccounts = await keyringController.getAccounts()
|
||||
const keyState = await keyringController.addNewAccount(keyring)
|
||||
const newAccounts = await keyringController.getAccounts()
|
||||
this.preferencesController.setAddresses(newAccounts)
|
||||
newAccounts.forEach(address => {
|
||||
if (!oldAccounts.includes(address)) {
|
||||
this.preferencesController.setAccountLabel(address, `TREZOR #${parseInt(index, 10) + 1}`)
|
||||
this.preferencesController.setSelectedAddress(address)
|
||||
}
|
||||
})
|
||||
|
||||
const { identities } = this.preferencesController.store.getState()
|
||||
return { ...keyState, identities }
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Account Management
|
||||
//
|
||||
@ -620,6 +768,23 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||
return selectedAddress
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an account from state / storage.
|
||||
*
|
||||
* @param {string[]} address A hex address
|
||||
*
|
||||
*/
|
||||
async removeAccount (address) {
|
||||
// Remove account from the preferences controller
|
||||
this.preferencesController.removeAddress(address)
|
||||
// Remove account from the account tracker controller
|
||||
this.accountTracker.removeAccount(address)
|
||||
// Remove account from the keyring
|
||||
await this.keyringController.removeAccount(address)
|
||||
return address
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Imports an account with the specified import strategy.
|
||||
* These are defined in app/scripts/account-import-strategies
|
||||
@ -1270,11 +1435,13 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||
}
|
||||
|
||||
/**
|
||||
* A method for activating the retrieval of price data, which should only be fetched when the UI is visible.
|
||||
* A method for activating the retrieval of price data and auto detect tokens,
|
||||
* 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
|
||||
this.detectTokensController.isActive = active
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
const extension = require('extensionizer')
|
||||
const explorerLink = require('etherscan-link').createExplorerLink
|
||||
|
||||
class ExtensionPlatform {
|
||||
|
||||
@ -17,8 +18,11 @@ class ExtensionPlatform {
|
||||
return extension.runtime.getManifest().version
|
||||
}
|
||||
|
||||
openExtensionInBrowser () {
|
||||
const extensionURL = extension.runtime.getURL('home.html')
|
||||
openExtensionInBrowser (route = null) {
|
||||
let extensionURL = extension.runtime.getURL('home.html')
|
||||
if (route) {
|
||||
extensionURL += `#${route}`
|
||||
}
|
||||
this.openWindow({ url: extensionURL })
|
||||
}
|
||||
|
||||
@ -31,6 +35,59 @@ class ExtensionPlatform {
|
||||
cb(e)
|
||||
}
|
||||
}
|
||||
|
||||
showTransactionNotification (txMeta) {
|
||||
|
||||
const status = txMeta.status
|
||||
if (status === 'confirmed') {
|
||||
this._showConfirmedTransaction(txMeta)
|
||||
} else if (status === 'failed') {
|
||||
this._showFailedTransaction(txMeta)
|
||||
}
|
||||
}
|
||||
|
||||
_showConfirmedTransaction (txMeta) {
|
||||
|
||||
this._subscribeToNotificationClicked()
|
||||
|
||||
const url = explorerLink(txMeta.hash, parseInt(txMeta.metamaskNetworkId))
|
||||
const nonce = parseInt(txMeta.txParams.nonce, 16)
|
||||
|
||||
const title = 'Confirmed transaction'
|
||||
const message = `Transaction ${nonce} confirmed! View on EtherScan`
|
||||
this._showNotification(title, message, url)
|
||||
}
|
||||
|
||||
_showFailedTransaction (txMeta) {
|
||||
|
||||
const nonce = parseInt(txMeta.txParams.nonce, 16)
|
||||
const title = 'Failed transaction'
|
||||
const message = `Transaction ${nonce} failed! ${txMeta.err.message}`
|
||||
this._showNotification(title, message)
|
||||
}
|
||||
|
||||
_showNotification (title, message, url) {
|
||||
extension.notifications.create(
|
||||
url,
|
||||
{
|
||||
'type': 'basic',
|
||||
'title': title,
|
||||
'iconUrl': extension.extension.getURL('../../images/icon-64.png'),
|
||||
'message': message,
|
||||
})
|
||||
}
|
||||
|
||||
_subscribeToNotificationClicked () {
|
||||
if (!extension.notifications.onClicked.hasListener(this._viewOnEtherScan)) {
|
||||
extension.notifications.onClicked.addListener(this._viewOnEtherScan)
|
||||
}
|
||||
}
|
||||
|
||||
_viewOnEtherScan (txId) {
|
||||
if (txId.startsWith('http://')) {
|
||||
global.metamaskController.platform.openWindow({ url: txId })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ExtensionPlatform
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
25
docs/trezor-emulator.md
Normal file
25
docs/trezor-emulator.md
Normal file
@ -0,0 +1,25 @@
|
||||
# Using the TREZOR simulator
|
||||
|
||||
You can install the TREZOR emulator and use it with Metamask.
|
||||
Here is how:
|
||||
|
||||
## 1 - Install the TREZOR Bridge
|
||||
|
||||
Download the corresponding bridge for your platform from [this url](https://wallet.trezor.io/data/bridge/latest/index.html)
|
||||
|
||||
## 2 - Download and build the simulator
|
||||
|
||||
Follow this instructions: https://github.com/trezor/trezor-core/blob/master/docs/build.md
|
||||
|
||||
## 3 - Restart the bridge with emulator support (Mac OSx instructions)
|
||||
|
||||
`
|
||||
# stop any existing instance of trezord
|
||||
killall trezord
|
||||
|
||||
# start the bridge for the simulator
|
||||
/Applications/Utilities/TREZOR\ Bridge/trezord -e 21324 >> /dev/null 2>&1 &
|
||||
|
||||
# launch the emulator
|
||||
~/trezor-core/emu.sh
|
||||
`
|
@ -138,7 +138,7 @@ Notwithstanding the parties' decision to resolve all disputes through arbitratio
|
||||
|
||||
### 13.6 30-Day Right to Opt Out ###
|
||||
|
||||
You have the right to opt-out and not be bound by the arbitration and class action waiver provisions set forth above by sending written notice of your decision to opt-out to the following address: MetaMask ℅ ConsenSys, 49 Bogart Street, Brooklyn NY 11206 and via email at legal-opt@metamask.io. The notice must be sent within 30 days of September 6, 2016 or your first use of the Service, whichever is later, otherwise you shall be bound to arbitrate disputes in accordance with the terms of those paragraphs. If you opt-out of these arbitration provisions, MetaMask also will not be bound by them.
|
||||
You have the right to opt-out and not be bound by the arbitration and class action waiver provisions set forth above by sending written notice of your decision to opt-out to the following address: MetaMask ℅ ConsenSys, 49 Bogart Street, Brooklyn NY 11206 and via email at support@metamask.io. The notice must be sent within 30 days of September 6, 2016 or your first use of the Service, whichever is later, otherwise you shall be bound to arbitrate disputes in accordance with the terms of those paragraphs. If you opt-out of these arbitration provisions, MetaMask also will not be bound by them.
|
||||
|
||||
### 13.7 Changes to This Section ###
|
||||
|
||||
@ -177,4 +177,3 @@ Users with questions, complaints or claims with respect to the Service may conta
|
||||
**[Privacy](https://metamask.io/privacy.html)**
|
||||
|
||||
**[Attributions](https://metamask.io/attributions.html)**
|
||||
|
||||
|
463
package-lock.json
generated
463
package-lock.json
generated
@ -4224,6 +4224,7 @@
|
||||
"version": "2.10.1",
|
||||
"resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz",
|
||||
"integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"hoek": "2.x.x"
|
||||
},
|
||||
@ -4231,7 +4232,8 @@
|
||||
"hoek": {
|
||||
"version": "2.16.3",
|
||||
"resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz",
|
||||
"integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0="
|
||||
"integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -6154,6 +6156,8 @@
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz",
|
||||
"integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"boom": "2.x.x"
|
||||
}
|
||||
@ -6852,9 +6856,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"yauzl": {
|
||||
"version": "2.9.2",
|
||||
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.9.2.tgz",
|
||||
"integrity": "sha1-T7G8euH8L1cDe1SvasyP4QMcW3c=",
|
||||
"version": "2.10.0",
|
||||
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz",
|
||||
"integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"buffer-crc32": "~0.2.3",
|
||||
@ -8368,22 +8372,42 @@
|
||||
}
|
||||
},
|
||||
"eth-hd-keyring": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/eth-hd-keyring/-/eth-hd-keyring-1.2.2.tgz",
|
||||
"integrity": "sha1-rV9HkHRDapO0ObC5XHkJXCh5GII=",
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/eth-hd-keyring/-/eth-hd-keyring-2.0.0.tgz",
|
||||
"integrity": "sha512-lTeANNPNj/j08sWU7LUQZTsx9NUJaUsiOdVxeP0UI5kke7L+Sd7zJWBmCShudEVG8PkqKLE1KJo08o430sl6rw==",
|
||||
"requires": {
|
||||
"bip39": "^2.2.0",
|
||||
"eth-sig-util": "^1.4.2",
|
||||
"eth-sig-util": "^2.0.1",
|
||||
"ethereumjs-abi": "^0.6.5",
|
||||
"ethereumjs-util": "^5.1.1",
|
||||
"ethereumjs-wallet": "^0.6.0",
|
||||
"events": "^1.1.1",
|
||||
"xtend": "^4.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"eth-sig-util": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-2.0.1.tgz",
|
||||
"integrity": "sha512-lxHZOQspexk3DaGj4RBbWy4C/qNOWRnxpaJzNnYD3WEmC8shcJ4tHs7Xv878rzvILfJnSFSCCiKQhng1m80oBQ==",
|
||||
"requires": {
|
||||
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||
"ethereumjs-util": "^5.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"ethereumjs-abi": {
|
||||
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
||||
"requires": {
|
||||
"bn.js": "^4.10.0",
|
||||
"ethereumjs-util": "^5.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ethereumjs-util": {
|
||||
"version": "5.1.4",
|
||||
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.1.4.tgz",
|
||||
"integrity": "sha512-wbeTc5prEzIWFSQUcEsCAZbqubtJKy6yS+oZMY1cGG6GLYzLjm4YhC2RNrWIg8hRYnclWpnZmx2zkiufQkmd3w==",
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz",
|
||||
"integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==",
|
||||
"requires": {
|
||||
"bn.js": "^4.11.0",
|
||||
"create-hash": "^1.1.2",
|
||||
@ -8454,17 +8478,17 @@
|
||||
}
|
||||
},
|
||||
"eth-keyring-controller": {
|
||||
"version": "3.1.4",
|
||||
"resolved": "https://registry.npmjs.org/eth-keyring-controller/-/eth-keyring-controller-3.1.4.tgz",
|
||||
"integrity": "sha512-NNlVB/TBc8p9CblwECjPlUR+7MNQKiBa7tEFxIzZ9MjjNCEYPWDXTm0vJZzuDtVmFxYwIA53UD0QEn0QNxWNEQ==",
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/eth-keyring-controller/-/eth-keyring-controller-4.0.0.tgz",
|
||||
"integrity": "sha512-D3Uj0b97vzEl/zXvrwYjFUYsz5gB4tnl/iMWqOm8jsvaREuHHbxRkm3iU/LG4fT8NGwS+fG8sLRPNBPu2/wRsA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"bip39": "^2.4.0",
|
||||
"bluebird": "^3.5.0",
|
||||
"browser-passworder": "^2.0.3",
|
||||
"eth-hd-keyring": "^1.2.2",
|
||||
"eth-hd-keyring": "^2.0.0",
|
||||
"eth-sig-util": "^1.4.0",
|
||||
"eth-simple-keyring": "^1.2.2",
|
||||
"eth-simple-keyring": "^2.0.0",
|
||||
"ethereumjs-util": "^5.1.2",
|
||||
"loglevel": "^1.5.0",
|
||||
"obs-store": "^2.4.1",
|
||||
@ -8679,18 +8703,40 @@
|
||||
}
|
||||
},
|
||||
"eth-simple-keyring": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/eth-simple-keyring/-/eth-simple-keyring-1.2.2.tgz",
|
||||
"integrity": "sha512-uQVBYshHUOaXVoat1BpLA/QNMCr4hgdFBgwIB7rRmQ+m3vQQAseUsOM+biPDYzq6end+6LjcccElLpQaIZe6dg==",
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/eth-simple-keyring/-/eth-simple-keyring-2.0.0.tgz",
|
||||
"integrity": "sha512-4dMbkIy2k1qotDTjWINvXG+7tBmofp0YUhlXgcG0+I3w684V46+MAHEkBtD2Y09iEeIB07RDXrezKP9WxOpynA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"eth-sig-util": "^1.4.2",
|
||||
"eth-sig-util": "^2.0.1",
|
||||
"ethereumjs-abi": "^0.6.5",
|
||||
"ethereumjs-util": "^5.1.1",
|
||||
"ethereumjs-wallet": "^0.6.0",
|
||||
"events": "^1.1.1",
|
||||
"xtend": "^4.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"eth-sig-util": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-2.0.1.tgz",
|
||||
"integrity": "sha512-lxHZOQspexk3DaGj4RBbWy4C/qNOWRnxpaJzNnYD3WEmC8shcJ4tHs7Xv878rzvILfJnSFSCCiKQhng1m80oBQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||
"ethereumjs-util": "^5.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"ethereumjs-abi": {
|
||||
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"bn.js": "^4.10.0",
|
||||
"ethereumjs-util": "^5.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ethereumjs-util": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz",
|
||||
@ -8877,6 +8923,63 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"eth-trezor-keyring": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/eth-trezor-keyring/-/eth-trezor-keyring-0.1.0.tgz",
|
||||
"integrity": "sha512-7ynDXiXGQOh9CslksJSmGGK726lV9fTnIp2QQnjbZJgR4zJIoSUYQYKvT2wXcxLhVrTUl2hLjwKN9QGqDCMVwA==",
|
||||
"requires": {
|
||||
"eth-sig-util": "^1.4.2",
|
||||
"ethereumjs-tx": "^1.3.4",
|
||||
"ethereumjs-util": "^5.1.5",
|
||||
"events": "^2.0.0",
|
||||
"hdkey": "0.8.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ethereum-common": {
|
||||
"version": "0.0.18",
|
||||
"resolved": "https://registry.npmjs.org/ethereum-common/-/ethereum-common-0.0.18.tgz",
|
||||
"integrity": "sha1-L9w1dvIykDNYl26znaeDIT/5Uj8="
|
||||
},
|
||||
"ethereumjs-tx": {
|
||||
"version": "1.3.6",
|
||||
"resolved": "https://registry.npmjs.org/ethereumjs-tx/-/ethereumjs-tx-1.3.6.tgz",
|
||||
"integrity": "sha512-wzsEs0mCSLqdDjqSDg6AWh1hyL8H3R/pyZxehkcCXq5MJEFXWz+eJ2jSv+3yEaLy6tXrNP7dmqS3Kyb3zAONkg==",
|
||||
"requires": {
|
||||
"ethereum-common": "^0.0.18",
|
||||
"ethereumjs-util": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"ethereumjs-util": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz",
|
||||
"integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==",
|
||||
"requires": {
|
||||
"bn.js": "^4.11.0",
|
||||
"create-hash": "^1.1.2",
|
||||
"ethjs-util": "^0.1.3",
|
||||
"keccak": "^1.0.2",
|
||||
"rlp": "^2.0.0",
|
||||
"safe-buffer": "^5.1.1",
|
||||
"secp256k1": "^3.0.1"
|
||||
}
|
||||
},
|
||||
"events": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/events/-/events-2.1.0.tgz",
|
||||
"integrity": "sha512-3Zmiobend8P9DjmKAty0Era4jV8oJ0yGYe2nJJAxgymF9+N8F2m0hhZiMoWtcfepExzNKZumFU3ksdQbInGWCg=="
|
||||
},
|
||||
"hdkey": {
|
||||
"version": "0.8.0",
|
||||
"resolved": "https://registry.npmjs.org/hdkey/-/hdkey-0.8.0.tgz",
|
||||
"integrity": "sha512-oYsdlK22eobT68N5faWI3776f6tOLyqxLLYwxMx+TP0rkWzuCs0oiOm2VbLWcxdpHFP4LtiRR8udaIX8VkEaZQ==",
|
||||
"requires": {
|
||||
"coinstring": "^2.0.0",
|
||||
"safe-buffer": "^5.1.1",
|
||||
"secp256k1": "^3.0.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"eth-tx-summary": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/eth-tx-summary/-/eth-tx-summary-3.2.1.tgz",
|
||||
@ -11795,9 +11898,9 @@
|
||||
}
|
||||
},
|
||||
"ganache-core": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ganache-core/-/ganache-core-2.1.3.tgz",
|
||||
"integrity": "sha512-fHDXzzcaB+jZC4q3HnQdcSj/otcVnQ6ddyqmtFtcyv29ET/44nXL5++3MmYBmAn3iLxV8PUgL+meUpm1aim9kg==",
|
||||
"version": "2.1.5",
|
||||
"resolved": "https://registry.npmjs.org/ganache-core/-/ganache-core-2.1.5.tgz",
|
||||
"integrity": "sha512-PuHUfISgrQknb7JpspxSzhpoYfqBWoOdTBHQj/81gu6YypRUHzD2Z6gZmFDxDzG30MFElEHp8JtexaGdgq9iYw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"abstract-leveldown": "^3.0.0",
|
||||
@ -11809,7 +11912,7 @@
|
||||
"clone": "^2.1.1",
|
||||
"ethereumjs-account": "~2.0.4",
|
||||
"ethereumjs-block": "~1.2.2",
|
||||
"ethereumjs-tx": "^1.3.0",
|
||||
"ethereumjs-tx": "1.3.4",
|
||||
"ethereumjs-util": "^5.2.0",
|
||||
"ethereumjs-vm": "2.3.5",
|
||||
"ethereumjs-wallet": "~0.6.0",
|
||||
@ -11966,6 +12069,24 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"ethereumjs-tx": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/ethereumjs-tx/-/ethereumjs-tx-1.3.4.tgz",
|
||||
"integrity": "sha512-kOgUd5jC+0tgV7t52UDECMMz9Uf+Lro+6fSpCvzWemtXfMEcwI3EOxf5mVPMRbTFkMMhuERokNNVF3jItAjidg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ethereum-common": "^0.0.18",
|
||||
"ethereumjs-util": "^5.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ethereum-common": {
|
||||
"version": "0.0.18",
|
||||
"resolved": "https://registry.npmjs.org/ethereum-common/-/ethereum-common-0.0.18.tgz",
|
||||
"integrity": "sha1-L9w1dvIykDNYl26znaeDIT/5Uj8=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"ethereumjs-util": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz",
|
||||
@ -12130,9 +12251,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"ws": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-5.2.1.tgz",
|
||||
"integrity": "sha512-2NkHdPKjDBj3CHdnAGNpmlliryKqF+n9MYXX7/wsVC4yqYocKreKNjydPDvT3wShAZnndlM0RytEfTALCDvz7A==",
|
||||
"version": "5.2.2",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-5.2.2.tgz",
|
||||
"integrity": "sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"async-limiter": "~1.0.0"
|
||||
@ -12307,12 +12428,16 @@
|
||||
"generate-function": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz",
|
||||
"integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ="
|
||||
"integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"generate-object-property": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz",
|
||||
"integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"is-property": "^1.0.0"
|
||||
}
|
||||
@ -13298,21 +13423,6 @@
|
||||
"resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz",
|
||||
"integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA="
|
||||
},
|
||||
"assert-plus": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz",
|
||||
"integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ="
|
||||
},
|
||||
"aws-sign2": {
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz",
|
||||
"integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8="
|
||||
},
|
||||
"caseless": {
|
||||
"version": "0.11.0",
|
||||
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz",
|
||||
"integrity": "sha1-cVuW6phBWTzDMGeSP17GDr2k99c="
|
||||
},
|
||||
"chalk": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.2.tgz",
|
||||
@ -13341,79 +13451,16 @@
|
||||
"is-extendable": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"form-data": {
|
||||
"version": "2.1.4",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz",
|
||||
"integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=",
|
||||
"requires": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.5",
|
||||
"mime-types": "^2.1.12"
|
||||
}
|
||||
},
|
||||
"get-stdin": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz",
|
||||
"integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4="
|
||||
},
|
||||
"har-validator": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz",
|
||||
"integrity": "sha1-zcvAgYgmWtEZtqWnyKtw7s+10n0=",
|
||||
"requires": {
|
||||
"chalk": "^1.1.1",
|
||||
"commander": "^2.9.0",
|
||||
"is-my-json-valid": "^2.12.4",
|
||||
"pinkie-promise": "^2.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-styles": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
|
||||
"integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4="
|
||||
},
|
||||
"chalk": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
|
||||
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
|
||||
"requires": {
|
||||
"ansi-styles": "^2.2.1",
|
||||
"escape-string-regexp": "^1.0.2",
|
||||
"has-ansi": "^2.0.0",
|
||||
"strip-ansi": "^3.0.0",
|
||||
"supports-color": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"strip-ansi": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
|
||||
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"supports-color": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
|
||||
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc="
|
||||
}
|
||||
}
|
||||
},
|
||||
"has-flag": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
|
||||
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0="
|
||||
},
|
||||
"http-signature": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz",
|
||||
"integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=",
|
||||
"requires": {
|
||||
"assert-plus": "^0.2.0",
|
||||
"jsprim": "^1.2.2",
|
||||
"sshpk": "^1.7.0"
|
||||
}
|
||||
},
|
||||
"is-extendable": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz",
|
||||
@ -13428,9 +13475,9 @@
|
||||
"integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA=="
|
||||
},
|
||||
"node-sass": {
|
||||
"version": "4.9.0",
|
||||
"resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.9.0.tgz",
|
||||
"integrity": "sha512-QFHfrZl6lqRU3csypwviz2XLgGNOoWQbo2GOvtsfQqOfL4cy1BtWnhx/XUeAO9LT3ahBzSRXcEO6DdvAH9DzSg==",
|
||||
"version": "4.9.1",
|
||||
"resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.9.1.tgz",
|
||||
"integrity": "sha512-m6H1I6cHXsHsJ7BIWdnJsz9S9gVMyh+/H2cOTXgl2/2WqyyWlBcl4PHJcqrXo5RZVCfCUFqOtjPN0+0XbVHR5Q==",
|
||||
"requires": {
|
||||
"async-foreach": "^0.1.3",
|
||||
"chalk": "^1.1.1",
|
||||
@ -13447,7 +13494,7 @@
|
||||
"nan": "^2.10.0",
|
||||
"node-gyp": "^3.3.1",
|
||||
"npmlog": "^4.0.0",
|
||||
"request": "~2.79.0",
|
||||
"request": "2.87.0",
|
||||
"sass-graph": "^2.2.4",
|
||||
"stdout-stream": "^1.4.0",
|
||||
"true-case-path": "^1.0.2"
|
||||
@ -13496,38 +13543,6 @@
|
||||
"extend-shallow": "^3.0.2"
|
||||
}
|
||||
},
|
||||
"qs": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.3.2.tgz",
|
||||
"integrity": "sha1-51vV9uJoEioqDgvaYwslUMFmUCw="
|
||||
},
|
||||
"request": {
|
||||
"version": "2.79.0",
|
||||
"resolved": "https://registry.npmjs.org/request/-/request-2.79.0.tgz",
|
||||
"integrity": "sha1-Tf5b9r6LjNw3/Pk+BLZVd3InEN4=",
|
||||
"requires": {
|
||||
"aws-sign2": "~0.6.0",
|
||||
"aws4": "^1.2.1",
|
||||
"caseless": "~0.11.0",
|
||||
"combined-stream": "~1.0.5",
|
||||
"extend": "~3.0.0",
|
||||
"forever-agent": "~0.6.1",
|
||||
"form-data": "~2.1.1",
|
||||
"har-validator": "~2.0.6",
|
||||
"hawk": "~3.1.3",
|
||||
"http-signature": "~1.1.0",
|
||||
"is-typedarray": "~1.0.0",
|
||||
"isstream": "~0.1.2",
|
||||
"json-stringify-safe": "~5.0.1",
|
||||
"mime-types": "~2.1.7",
|
||||
"oauth-sign": "~0.8.1",
|
||||
"qs": "~6.3.0",
|
||||
"stringstream": "~0.0.4",
|
||||
"tough-cookie": "~2.3.0",
|
||||
"tunnel-agent": "~0.4.1",
|
||||
"uuid": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"strip-ansi": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
|
||||
@ -13550,16 +13565,6 @@
|
||||
"requires": {
|
||||
"has-flag": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"tunnel-agent": {
|
||||
"version": "0.4.3",
|
||||
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.3.tgz",
|
||||
"integrity": "sha1-Y3PbdpCf5XDgjXNYM2Xtgop07us="
|
||||
},
|
||||
"uuid": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz",
|
||||
"integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA=="
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -14541,6 +14546,8 @@
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz",
|
||||
"integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"boom": "2.x.x",
|
||||
"cryptiles": "2.x.x",
|
||||
@ -14551,7 +14558,9 @@
|
||||
"hoek": {
|
||||
"version": "2.16.3",
|
||||
"resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz",
|
||||
"integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0="
|
||||
"integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -15848,12 +15857,16 @@
|
||||
"is-my-ip-valid": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-my-ip-valid/-/is-my-ip-valid-1.0.0.tgz",
|
||||
"integrity": "sha512-gmh/eWXROncUzRnIa1Ubrt5b8ep/MGSnfAUI3aRp+sqTCs1tv1Isl8d8F6JmkN3dXKc3ehZMrtiPN9eL03NuaQ=="
|
||||
"integrity": "sha512-gmh/eWXROncUzRnIa1Ubrt5b8ep/MGSnfAUI3aRp+sqTCs1tv1Isl8d8F6JmkN3dXKc3ehZMrtiPN9eL03NuaQ==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"is-my-json-valid": {
|
||||
"version": "2.17.2",
|
||||
"resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.17.2.tgz",
|
||||
"integrity": "sha512-IBhBslgngMQN8DDSppmgDv7RNrlFotuuDsKcrCP3+HbFaVivIBU7u9oiiErw8sH4ynx3+gOGQ3q2otkgiSi6kg==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"generate-function": "^2.0.0",
|
||||
"generate-object-property": "^1.1.0",
|
||||
@ -15977,7 +15990,9 @@
|
||||
"is-property": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz",
|
||||
"integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ="
|
||||
"integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"is-redirect": {
|
||||
"version": "1.0.0",
|
||||
@ -16945,7 +16960,9 @@
|
||||
"jsonpointer": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz",
|
||||
"integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk="
|
||||
"integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"jsprim": {
|
||||
"version": "1.4.1",
|
||||
@ -17855,9 +17872,9 @@
|
||||
}
|
||||
},
|
||||
"level-sublevel": {
|
||||
"version": "6.6.2",
|
||||
"resolved": "https://registry.npmjs.org/level-sublevel/-/level-sublevel-6.6.2.tgz",
|
||||
"integrity": "sha512-+hptqmFYPKFju9QG4F6scvx3ZXkhrSmmhYui+hPzRn/jiC3DJ6VNZRKsIhGMpeajVBWfRV7XiysUThrJ/7PgXQ==",
|
||||
"version": "6.6.5",
|
||||
"resolved": "https://registry.npmjs.org/level-sublevel/-/level-sublevel-6.6.5.tgz",
|
||||
"integrity": "sha512-SBSR60x+dghhwGUxPKS+BvV1xNqnwsEUBKmnFepPaHJ6VkBXyPK9SImGc3K2BkwBfpxlt7GKkBNlCnrdufsejA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"bytewise": "~1.1.0",
|
||||
@ -18690,9 +18707,9 @@
|
||||
}
|
||||
},
|
||||
"log4js": {
|
||||
"version": "2.10.0",
|
||||
"resolved": "https://registry.npmjs.org/log4js/-/log4js-2.10.0.tgz",
|
||||
"integrity": "sha512-NnhN9PjFF9zhxinAjlmDYvkqqrIW+yA3LLJAoTJ3fs6d1zru86OqQHfsxiUcc1kRq3z+faGR4DeyXUfiNbVxKQ==",
|
||||
"version": "2.11.0",
|
||||
"resolved": "https://registry.npmjs.org/log4js/-/log4js-2.11.0.tgz",
|
||||
"integrity": "sha512-z1XdwyGFg8/WGkOyF6DPJjivCWNLKrklGdViywdYnSKOvgtEBo2UyEMZS5sD2mZrQlU3TvO8wDWLc8mzE1ncBQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"amqplib": "^0.5.2",
|
||||
@ -18711,9 +18728,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"circular-json": {
|
||||
"version": "0.5.4",
|
||||
"resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.5.4.tgz",
|
||||
"integrity": "sha512-vnJA8KS0BfOihugYEUkLRcnmq21FbuivbxgzDLXNs3zIk4KllV4Mx4UuTzBXht9F00C7QfD1YqMXg1zP6EXpig==",
|
||||
"version": "0.5.5",
|
||||
"resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.5.5.tgz",
|
||||
"integrity": "sha512-13YaR6kiz0kBNmIVM87Io8Hp7bWOo4r61vkEANy8iH9R9bc6avud/1FT0SBpqR1RpIQADOh/Q+yHZDA1iL6ysA==",
|
||||
"dev": true
|
||||
},
|
||||
"debug": {
|
||||
@ -20641,9 +20658,9 @@
|
||||
}
|
||||
},
|
||||
"node-sass": {
|
||||
"version": "4.9.0",
|
||||
"resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.9.0.tgz",
|
||||
"integrity": "sha512-QFHfrZl6lqRU3csypwviz2XLgGNOoWQbo2GOvtsfQqOfL4cy1BtWnhx/XUeAO9LT3ahBzSRXcEO6DdvAH9DzSg==",
|
||||
"version": "4.9.1",
|
||||
"resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.9.1.tgz",
|
||||
"integrity": "sha512-m6H1I6cHXsHsJ7BIWdnJsz9S9gVMyh+/H2cOTXgl2/2WqyyWlBcl4PHJcqrXo5RZVCfCUFqOtjPN0+0XbVHR5Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"async-foreach": "^0.1.3",
|
||||
@ -20661,30 +20678,12 @@
|
||||
"nan": "^2.10.0",
|
||||
"node-gyp": "^3.3.1",
|
||||
"npmlog": "^4.0.0",
|
||||
"request": "~2.79.0",
|
||||
"request": "2.87.0",
|
||||
"sass-graph": "^2.2.4",
|
||||
"stdout-stream": "^1.4.0",
|
||||
"true-case-path": "^1.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"assert-plus": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz",
|
||||
"integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=",
|
||||
"dev": true
|
||||
},
|
||||
"aws-sign2": {
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz",
|
||||
"integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=",
|
||||
"dev": true
|
||||
},
|
||||
"caseless": {
|
||||
"version": "0.11.0",
|
||||
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz",
|
||||
"integrity": "sha1-cVuW6phBWTzDMGeSP17GDr2k99c=",
|
||||
"dev": true
|
||||
},
|
||||
"cross-spawn": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-3.0.1.tgz",
|
||||
@ -20695,97 +20694,17 @@
|
||||
"which": "^1.2.9"
|
||||
}
|
||||
},
|
||||
"form-data": {
|
||||
"version": "2.1.4",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz",
|
||||
"integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.5",
|
||||
"mime-types": "^2.1.12"
|
||||
}
|
||||
},
|
||||
"get-stdin": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz",
|
||||
"integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=",
|
||||
"dev": true
|
||||
},
|
||||
"har-validator": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz",
|
||||
"integrity": "sha1-zcvAgYgmWtEZtqWnyKtw7s+10n0=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chalk": "^1.1.1",
|
||||
"commander": "^2.9.0",
|
||||
"is-my-json-valid": "^2.12.4",
|
||||
"pinkie-promise": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"http-signature": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz",
|
||||
"integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"assert-plus": "^0.2.0",
|
||||
"jsprim": "^1.2.2",
|
||||
"sshpk": "^1.7.0"
|
||||
}
|
||||
},
|
||||
"nan": {
|
||||
"version": "2.10.0",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz",
|
||||
"integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==",
|
||||
"dev": true
|
||||
},
|
||||
"qs": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.3.2.tgz",
|
||||
"integrity": "sha1-51vV9uJoEioqDgvaYwslUMFmUCw=",
|
||||
"dev": true
|
||||
},
|
||||
"request": {
|
||||
"version": "2.79.0",
|
||||
"resolved": "https://registry.npmjs.org/request/-/request-2.79.0.tgz",
|
||||
"integrity": "sha1-Tf5b9r6LjNw3/Pk+BLZVd3InEN4=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"aws-sign2": "~0.6.0",
|
||||
"aws4": "^1.2.1",
|
||||
"caseless": "~0.11.0",
|
||||
"combined-stream": "~1.0.5",
|
||||
"extend": "~3.0.0",
|
||||
"forever-agent": "~0.6.1",
|
||||
"form-data": "~2.1.1",
|
||||
"har-validator": "~2.0.6",
|
||||
"hawk": "~3.1.3",
|
||||
"http-signature": "~1.1.0",
|
||||
"is-typedarray": "~1.0.0",
|
||||
"isstream": "~0.1.2",
|
||||
"json-stringify-safe": "~5.0.1",
|
||||
"mime-types": "~2.1.7",
|
||||
"oauth-sign": "~0.8.1",
|
||||
"qs": "~6.3.0",
|
||||
"stringstream": "~0.0.4",
|
||||
"tough-cookie": "~2.3.0",
|
||||
"tunnel-agent": "~0.4.1",
|
||||
"uuid": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"tunnel-agent": {
|
||||
"version": "0.4.3",
|
||||
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.3.tgz",
|
||||
"integrity": "sha1-Y3PbdpCf5XDgjXNYM2Xtgop07us=",
|
||||
"dev": true
|
||||
},
|
||||
"uuid": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz",
|
||||
"integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -28232,6 +28151,8 @@
|
||||
"version": "1.0.9",
|
||||
"resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz",
|
||||
"integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"hoek": "2.x.x"
|
||||
},
|
||||
@ -28239,7 +28160,9 @@
|
||||
"hoek": {
|
||||
"version": "2.16.3",
|
||||
"resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz",
|
||||
"integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0="
|
||||
"integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -29005,7 +28928,9 @@
|
||||
"stringstream": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.6.tgz",
|
||||
"integrity": "sha512-87GEBAkegbBcweToUrdzf3eLhWNg06FJTebl4BVJz/JgWy8CvEr9dRtX5qWphiynMSQlxxi+QqN0z5T32SLlhA=="
|
||||
"integrity": "sha512-87GEBAkegbBcweToUrdzf3eLhWNg06FJTebl4BVJz/JgWy8CvEr9dRtX5qWphiynMSQlxxi+QqN0z5T32SLlhA==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"strip-ansi": {
|
||||
"version": "3.0.1",
|
||||
|
@ -94,7 +94,7 @@
|
||||
"eslint-plugin-react": "^7.4.0",
|
||||
"eth-bin-to-ops": "^1.0.1",
|
||||
"eth-contract-metadata": "github:MetaMask/eth-contract-metadata#master",
|
||||
"eth-hd-keyring": "^1.2.1",
|
||||
"eth-hd-keyring": "^2.0.0",
|
||||
"eth-json-rpc-filters": "^1.2.6",
|
||||
"eth-json-rpc-infura": "^3.0.0",
|
||||
"eth-method-registry": "^1.0.0",
|
||||
@ -102,6 +102,7 @@
|
||||
"eth-query": "^2.1.2",
|
||||
"eth-sig-util": "^1.4.2",
|
||||
"eth-token-tracker": "^1.1.4",
|
||||
"eth-trezor-keyring": "^0.1.0",
|
||||
"ethereumjs-abi": "^0.6.4",
|
||||
"ethereumjs-tx": "^1.3.0",
|
||||
"ethereumjs-util": "github:ethereumjs/ethereumjs-util#ac5d0908536b447083ea422b435da27f26615de9",
|
||||
@ -233,11 +234,11 @@
|
||||
"eslint-plugin-mocha": "^5.0.0",
|
||||
"eslint-plugin-react": "^7.4.0",
|
||||
"eth-json-rpc-middleware": "^1.6.0",
|
||||
"eth-keyring-controller": "^3.1.4",
|
||||
"eth-keyring-controller": "^4.0.0",
|
||||
"file-loader": "^1.1.11",
|
||||
"fs-promise": "^2.0.3",
|
||||
"ganache-cli": "^6.1.0",
|
||||
"ganache-core": "^2.1.3",
|
||||
"ganache-core": "^2.1.5",
|
||||
"geckodriver": "^1.11.0",
|
||||
"gh-pages": "^1.2.0",
|
||||
"gifencoder": "^1.1.0",
|
||||
@ -273,7 +274,7 @@
|
||||
"mocha-jsdom": "^1.1.0",
|
||||
"mocha-sinon": "^2.0.0",
|
||||
"nock": "^9.0.14",
|
||||
"node-sass": "^4.9.0",
|
||||
"node-sass": "^4.9.1",
|
||||
"nsp": "^3.2.1",
|
||||
"nyc": "^13.0.0",
|
||||
"open": "0.0.5",
|
||||
|
@ -321,4 +321,51 @@ describe('Using MetaMask with an existing account', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('Connects to a Hardware wallet', () => {
|
||||
it('choose Connect Hardware Wallet from the account menu', async () => {
|
||||
await driver.findElement(By.css('.account-menu__icon')).click()
|
||||
await delay(regularDelayMs)
|
||||
|
||||
const [connectAccount] = await findElements(driver, By.xpath(`//div[contains(text(), 'Connect Hardware Wallet')]`))
|
||||
await connectAccount.click()
|
||||
await delay(regularDelayMs)
|
||||
})
|
||||
|
||||
it('should open the TREZOR Connect popup', async () => {
|
||||
const connectButtons = await findElements(driver, By.xpath(`//button[contains(text(), 'Connect to Trezor')]`))
|
||||
await connectButtons[0].click()
|
||||
await delay(regularDelayMs)
|
||||
const allWindows = await driver.getAllWindowHandles()
|
||||
switch (process.env.SELENIUM_BROWSER) {
|
||||
case 'chrome':
|
||||
assert.equal(allWindows.length, 2)
|
||||
break
|
||||
default:
|
||||
assert.equal(allWindows.length, 1)
|
||||
}
|
||||
})
|
||||
|
||||
it('should show the "Browser not supported" screen for non Chrome browsers', async () => {
|
||||
if (process.env.SELENIUM_BROWSER !== 'chrome') {
|
||||
const title = await findElements(driver, By.xpath(`//h3[contains(text(), 'Your Browser is not supported...')]`))
|
||||
assert.equal(title.length, 1)
|
||||
|
||||
const downloadChromeButtons = await findElements(driver, By.xpath(`//button[contains(text(), 'Download Google Chrome')]`))
|
||||
assert.equal(downloadChromeButtons.length, 1)
|
||||
|
||||
await downloadChromeButtons[0].click()
|
||||
await delay(regularDelayMs)
|
||||
|
||||
const [newUITab, downloadChromeTab] = await driver.getAllWindowHandles()
|
||||
|
||||
await driver.switchTo().window(downloadChromeTab)
|
||||
await delay(regularDelayMs)
|
||||
const tabUrl = await driver.getCurrentUrl()
|
||||
assert.equal(tabUrl, 'https://www.google.com/chrome/')
|
||||
await driver.close()
|
||||
await delay(regularDelayMs)
|
||||
await driver.switchTo().window(newUITab)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -513,7 +513,7 @@ describe('MetaMask', function () {
|
||||
it('displays the contract creation data', async () => {
|
||||
const dataTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Data')]`))
|
||||
dataTab.click()
|
||||
await (regularDelayMs)
|
||||
await delay(regularDelayMs)
|
||||
|
||||
await findElement(driver, By.xpath(`//div[contains(text(), '127.0.0.1')]`))
|
||||
|
||||
@ -523,7 +523,7 @@ describe('MetaMask', function () {
|
||||
|
||||
const detailsTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Details')]`))
|
||||
detailsTab.click()
|
||||
await (regularDelayMs)
|
||||
await delay(regularDelayMs)
|
||||
})
|
||||
|
||||
it('confirms a deploy contract transaction', async () => {
|
||||
@ -548,7 +548,7 @@ describe('MetaMask', function () {
|
||||
await delay(regularDelayMs)
|
||||
|
||||
await driver.switchTo().window(extension)
|
||||
await delay(regularDelayMs)
|
||||
await delay(largeDelayMs)
|
||||
|
||||
await findElements(driver, By.css('.tx-list-pending-item-container'))
|
||||
const [txListValue] = await findElements(driver, By.css('.tx-list-value'))
|
||||
@ -741,7 +741,7 @@ describe('MetaMask', function () {
|
||||
it('displays the token transfer data', async () => {
|
||||
const dataTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Data')]`))
|
||||
dataTab.click()
|
||||
await (regularDelayMs)
|
||||
await delay(regularDelayMs)
|
||||
|
||||
const functionType = await findElement(driver, By.css('.confirm-page-container-content__function-type'))
|
||||
const functionTypeText = await functionType.getText()
|
||||
@ -753,7 +753,7 @@ describe('MetaMask', function () {
|
||||
|
||||
const detailsTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Details')]`))
|
||||
detailsTab.click()
|
||||
await (regularDelayMs)
|
||||
await delay(regularDelayMs)
|
||||
})
|
||||
|
||||
it('submits the transaction', async function () {
|
||||
@ -901,7 +901,7 @@ describe('MetaMask', function () {
|
||||
it('displays the token approval data', async () => {
|
||||
const dataTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Data')]`))
|
||||
dataTab.click()
|
||||
await (regularDelayMs)
|
||||
await delay(regularDelayMs)
|
||||
|
||||
const functionType = await findElement(driver, By.css('.confirm-page-container-content__function-type'))
|
||||
const functionTypeText = await functionType.getText()
|
||||
@ -913,12 +913,12 @@ describe('MetaMask', function () {
|
||||
|
||||
const detailsTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Details')]`))
|
||||
detailsTab.click()
|
||||
await (regularDelayMs)
|
||||
await delay(regularDelayMs)
|
||||
|
||||
const approvalWarning = await findElement(driver, By.css('.confirm-page-container-warning__warning'))
|
||||
const approvalWarningText = await approvalWarning.getText()
|
||||
assert(approvalWarningText.match(/By approving this/))
|
||||
await (regularDelayMs)
|
||||
await delay(regularDelayMs)
|
||||
})
|
||||
|
||||
it('opens the gas edit modal', async () => {
|
||||
|
@ -31,8 +31,8 @@ async function runTxListItemsTest (assert, done) {
|
||||
assert.equal($(unapprovedTx).hasClass('tx-list-pending-item-container'), true, 'unapprovedTx has the correct class')
|
||||
|
||||
const retryTx = txListItems[1]
|
||||
const retryTxLink = await findAsync($(retryTx), '.tx-list-item-retry-link')
|
||||
assert.equal(retryTxLink[0].textContent, 'Increase the gas price on your transaction', 'retryTx has expected link')
|
||||
const retryTxLink = await findAsync($(retryTx), '.tx-list-item-retry-container span')
|
||||
assert.equal(retryTxLink[0].textContent, 'Taking too long? Increase the gas price on your transaction', 'retryTx has expected link')
|
||||
|
||||
const approvedTx = txListItems[2]
|
||||
const approvedTxRenderedStatus = await findAsync($(approvedTx), '.tx-list-status')
|
||||
|
File diff suppressed because one or more lines are too long
120
test/unit/app/controllers/detect-tokens-test.js
Normal file
120
test/unit/app/controllers/detect-tokens-test.js
Normal file
@ -0,0 +1,120 @@
|
||||
const assert = require('assert')
|
||||
const sinon = require('sinon')
|
||||
const ObservableStore = require('obs-store')
|
||||
const DetectTokensController = require('../../../../app/scripts/controllers/detect-tokens')
|
||||
const NetworkController = require('../../../../app/scripts/controllers/network/network')
|
||||
const PreferencesController = require('../../../../app/scripts/controllers/preferences')
|
||||
|
||||
describe('DetectTokensController', () => {
|
||||
const sandbox = sinon.createSandbox()
|
||||
let clock
|
||||
let keyringMemStore
|
||||
before(async () => {
|
||||
keyringMemStore = new ObservableStore({ isUnlocked: false})
|
||||
})
|
||||
after(() => {
|
||||
sandbox.restore()
|
||||
})
|
||||
|
||||
it('should poll on correct interval', async () => {
|
||||
const stub = sinon.stub(global, 'setInterval')
|
||||
new DetectTokensController({ interval: 1337 }) // eslint-disable-line no-new
|
||||
assert.strictEqual(stub.getCall(0).args[1], 1337)
|
||||
stub.restore()
|
||||
})
|
||||
|
||||
it('should be called on every polling period', async () => {
|
||||
clock = sandbox.useFakeTimers()
|
||||
const network = new NetworkController()
|
||||
network.setProviderType('mainnet')
|
||||
const preferences = new PreferencesController()
|
||||
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
|
||||
controller.isActive = true
|
||||
|
||||
var stub = sandbox.stub(controller, 'detectNewTokens')
|
||||
|
||||
clock.tick(1)
|
||||
sandbox.assert.notCalled(stub)
|
||||
clock.tick(180000)
|
||||
sandbox.assert.called(stub)
|
||||
clock.tick(180000)
|
||||
sandbox.assert.calledTwice(stub)
|
||||
clock.tick(180000)
|
||||
sandbox.assert.calledThrice(stub)
|
||||
})
|
||||
|
||||
it('should not check tokens while in test network', async () => {
|
||||
const network = new NetworkController()
|
||||
network.setProviderType('rinkeby')
|
||||
const preferences = new PreferencesController()
|
||||
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
|
||||
controller.isActive = true
|
||||
|
||||
var stub = sandbox.stub(controller, 'detectTokenBalance')
|
||||
.withArgs('0x0D262e5dC4A06a0F1c90cE79C7a60C09DfC884E4').returns(true)
|
||||
.withArgs('0xBC86727E770de68B1060C91f6BB6945c73e10388').returns(true)
|
||||
|
||||
await controller.detectNewTokens()
|
||||
sandbox.assert.notCalled(stub)
|
||||
})
|
||||
|
||||
it('should only check and add tokens while in main network', async () => {
|
||||
const network = new NetworkController()
|
||||
network.setProviderType('mainnet')
|
||||
const preferences = new PreferencesController()
|
||||
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
|
||||
controller.isActive = true
|
||||
|
||||
sandbox.stub(controller, 'detectTokenBalance')
|
||||
.withArgs('0x0D262e5dC4A06a0F1c90cE79C7a60C09DfC884E4')
|
||||
.returns(preferences.addToken('0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', 'J8T', 8))
|
||||
.withArgs('0xBC86727E770de68B1060C91f6BB6945c73e10388')
|
||||
.returns(preferences.addToken('0xbc86727e770de68b1060c91f6bb6945c73e10388', 'XNK', 18))
|
||||
|
||||
await controller.detectNewTokens()
|
||||
assert.deepEqual(preferences.store.getState().tokens, [{address: '0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', decimals: 8, symbol: 'J8T'},
|
||||
{address: '0xbc86727e770de68b1060c91f6bb6945c73e10388', decimals: 18, symbol: 'XNK'}])
|
||||
})
|
||||
|
||||
it('should not detect same token while in main network', async () => {
|
||||
const network = new NetworkController()
|
||||
network.setProviderType('mainnet')
|
||||
const preferences = new PreferencesController()
|
||||
preferences.addToken('0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', 'J8T', 8)
|
||||
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
|
||||
controller.isActive = true
|
||||
|
||||
sandbox.stub(controller, 'detectTokenBalance')
|
||||
.withArgs('0x0D262e5dC4A06a0F1c90cE79C7a60C09DfC884E4')
|
||||
.returns(preferences.addToken('0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', 'J8T', 8))
|
||||
.withArgs('0xBC86727E770de68B1060C91f6BB6945c73e10388')
|
||||
.returns(preferences.addToken('0xbc86727e770de68b1060c91f6bb6945c73e10388', 'XNK', 18))
|
||||
|
||||
await controller.detectNewTokens()
|
||||
assert.deepEqual(preferences.store.getState().tokens, [{address: '0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', decimals: 8, symbol: 'J8T'},
|
||||
{address: '0xbc86727e770de68b1060c91f6bb6945c73e10388', decimals: 18, symbol: 'XNK'}])
|
||||
})
|
||||
|
||||
it('should trigger detect new tokens when change address', async () => {
|
||||
const network = new NetworkController()
|
||||
network.setProviderType('mainnet')
|
||||
const preferences = new PreferencesController()
|
||||
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
|
||||
controller.isActive = true
|
||||
var stub = sandbox.stub(controller, 'detectNewTokens')
|
||||
await preferences.setSelectedAddress('0xbc86727e770de68b1060c91f6bb6945c73e10388')
|
||||
sandbox.assert.called(stub)
|
||||
})
|
||||
|
||||
it('should trigger detect new tokens when submit password', async () => {
|
||||
const network = new NetworkController()
|
||||
network.setProviderType('mainnet')
|
||||
const preferences = new PreferencesController()
|
||||
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
|
||||
controller.isActive = true
|
||||
controller.selectedAddress = '0x0'
|
||||
var stub = sandbox.stub(controller, 'detectNewTokens')
|
||||
await controller._keyringMemStore.updateState({ isUnlocked: true })
|
||||
sandbox.assert.called(stub)
|
||||
})
|
||||
})
|
@ -222,6 +222,129 @@ describe('MetaMaskController', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('connectHardware', function () {
|
||||
|
||||
it('should throw if it receives an unknown device name', async function () {
|
||||
try {
|
||||
await metamaskController.connectHardware('Some random device name', 0)
|
||||
} catch (e) {
|
||||
assert.equal(e, 'Error: MetamaskController:connectHardware - Unknown device')
|
||||
}
|
||||
})
|
||||
|
||||
it('should add the Trezor Hardware keyring', async function () {
|
||||
sinon.spy(metamaskController.keyringController, 'addNewKeyring')
|
||||
await metamaskController.connectHardware('trezor', 0).catch((e) => null)
|
||||
const keyrings = await metamaskController.keyringController.getKeyringsByType(
|
||||
'Trezor Hardware'
|
||||
)
|
||||
assert.equal(metamaskController.keyringController.addNewKeyring.getCall(0).args, 'Trezor Hardware')
|
||||
assert.equal(keyrings.length, 1)
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
describe('checkHardwareStatus', function () {
|
||||
it('should throw if it receives an unknown device name', async function () {
|
||||
try {
|
||||
await metamaskController.checkHardwareStatus('Some random device name')
|
||||
} catch (e) {
|
||||
assert.equal(e, 'Error: MetamaskController:checkHardwareStatus - Unknown device')
|
||||
}
|
||||
})
|
||||
|
||||
it('should be locked by default', async function () {
|
||||
await metamaskController.connectHardware('trezor', 0).catch((e) => null)
|
||||
const status = await metamaskController.checkHardwareStatus('trezor')
|
||||
assert.equal(status, false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('forgetDevice', function () {
|
||||
it('should throw if it receives an unknown device name', async function () {
|
||||
try {
|
||||
await metamaskController.forgetDevice('Some random device name')
|
||||
} catch (e) {
|
||||
assert.equal(e, 'Error: MetamaskController:forgetDevice - Unknown device')
|
||||
}
|
||||
})
|
||||
|
||||
it('should wipe all the keyring info', async function () {
|
||||
await metamaskController.connectHardware('trezor', 0).catch((e) => null)
|
||||
await metamaskController.forgetDevice('trezor')
|
||||
const keyrings = await metamaskController.keyringController.getKeyringsByType(
|
||||
'Trezor Hardware'
|
||||
)
|
||||
|
||||
assert.deepEqual(keyrings[0].accounts, [])
|
||||
assert.deepEqual(keyrings[0].page, 0)
|
||||
assert.deepEqual(keyrings[0].isUnlocked(), false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('unlockTrezorAccount', function () {
|
||||
let accountToUnlock
|
||||
let windowOpenStub
|
||||
let addNewAccountStub
|
||||
let getAccountsStub
|
||||
beforeEach(async function () {
|
||||
accountToUnlock = 10
|
||||
windowOpenStub = sinon.stub(window, 'open')
|
||||
windowOpenStub.returns(noop)
|
||||
|
||||
addNewAccountStub = sinon.stub(metamaskController.keyringController, 'addNewAccount')
|
||||
addNewAccountStub.returns({})
|
||||
|
||||
getAccountsStub = sinon.stub(metamaskController.keyringController, 'getAccounts')
|
||||
// Need to return different address to mock the behavior of
|
||||
// adding a new account from the keyring
|
||||
getAccountsStub.onCall(0).returns(Promise.resolve(['0x1']))
|
||||
getAccountsStub.onCall(1).returns(Promise.resolve(['0x2']))
|
||||
getAccountsStub.onCall(2).returns(Promise.resolve(['0x3']))
|
||||
getAccountsStub.onCall(3).returns(Promise.resolve(['0x4']))
|
||||
sinon.spy(metamaskController.preferencesController, 'setAddresses')
|
||||
sinon.spy(metamaskController.preferencesController, 'setSelectedAddress')
|
||||
sinon.spy(metamaskController.preferencesController, 'setAccountLabel')
|
||||
await metamaskController.connectHardware('trezor', 0).catch((e) => null)
|
||||
await metamaskController.unlockTrezorAccount(accountToUnlock).catch((e) => null)
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
metamaskController.keyringController.addNewAccount.restore()
|
||||
window.open.restore()
|
||||
})
|
||||
|
||||
it('should set accountToUnlock in the keyring', async function () {
|
||||
const keyrings = await metamaskController.keyringController.getKeyringsByType(
|
||||
'Trezor Hardware'
|
||||
)
|
||||
assert.equal(keyrings[0].unlockedAccount, accountToUnlock)
|
||||
})
|
||||
|
||||
|
||||
it('should call keyringController.addNewAccount', async function () {
|
||||
assert(metamaskController.keyringController.addNewAccount.calledOnce)
|
||||
})
|
||||
|
||||
it('should call keyringController.getAccounts ', async function () {
|
||||
assert(metamaskController.keyringController.getAccounts.called)
|
||||
})
|
||||
|
||||
it('should call preferencesController.setAddresses', async function () {
|
||||
assert(metamaskController.preferencesController.setAddresses.calledOnce)
|
||||
})
|
||||
|
||||
it('should call preferencesController.setSelectedAddress', async function () {
|
||||
assert(metamaskController.preferencesController.setSelectedAddress.calledOnce)
|
||||
})
|
||||
|
||||
it('should call preferencesController.setAccountLabel', async function () {
|
||||
assert(metamaskController.preferencesController.setAccountLabel.calledOnce)
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
||||
describe('#setCustomRpc', function () {
|
||||
const customRPC = 'https://custom.rpc/'
|
||||
let rpcTarget
|
||||
@ -362,6 +485,39 @@ describe('MetaMaskController', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('#removeAccount', function () {
|
||||
let ret
|
||||
const addressToRemove = '0x1'
|
||||
|
||||
beforeEach(async function () {
|
||||
sinon.stub(metamaskController.preferencesController, 'removeAddress')
|
||||
sinon.stub(metamaskController.accountTracker, 'removeAccount')
|
||||
sinon.stub(metamaskController.keyringController, 'removeAccount')
|
||||
|
||||
ret = await metamaskController.removeAccount(addressToRemove)
|
||||
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
metamaskController.keyringController.removeAccount.restore()
|
||||
metamaskController.accountTracker.removeAccount.restore()
|
||||
metamaskController.preferencesController.removeAddress.restore()
|
||||
})
|
||||
|
||||
it('should call preferencesController.removeAddress', async function () {
|
||||
assert(metamaskController.preferencesController.removeAddress.calledWith(addressToRemove))
|
||||
})
|
||||
it('should call accountTracker.removeAccount', async function () {
|
||||
assert(metamaskController.accountTracker.removeAccount.calledWith(addressToRemove))
|
||||
})
|
||||
it('should call keyringController.removeAccount', async function () {
|
||||
assert(metamaskController.keyringController.removeAccount.calledWith(addressToRemove))
|
||||
})
|
||||
it('should return address', async function () {
|
||||
assert.equal(ret, '0x1')
|
||||
})
|
||||
})
|
||||
|
||||
describe('#clearSeedWordCache', function () {
|
||||
|
||||
it('should have set seed words', function () {
|
||||
|
@ -52,6 +52,31 @@ describe('preferences controller', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('removeAddress', function () {
|
||||
it('should remove an address from state', function () {
|
||||
preferencesController.setAddresses([
|
||||
'0xda22le',
|
||||
'0x7e57e2',
|
||||
])
|
||||
|
||||
preferencesController.removeAddress('0xda22le')
|
||||
|
||||
assert.equal(preferencesController.store.getState().identities['0xda22le'], undefined)
|
||||
})
|
||||
|
||||
it('should switch accounts if the selected address is removed', function () {
|
||||
preferencesController.setAddresses([
|
||||
'0xda22le',
|
||||
'0x7e57e2',
|
||||
])
|
||||
|
||||
preferencesController.setSelectedAddress('0x7e57e2')
|
||||
preferencesController.removeAddress('0x7e57e2')
|
||||
|
||||
assert.equal(preferencesController.getSelectedAddress(), '0xda22le')
|
||||
})
|
||||
})
|
||||
|
||||
describe('setAccountLabel', function () {
|
||||
it('should update a label for the given account', function () {
|
||||
preferencesController.setAddresses([
|
||||
|
@ -1,67 +0,0 @@
|
||||
const assert = require('assert')
|
||||
const h = require('react-hyperscript')
|
||||
const PendingTx = require('../../../ui/app/components/pending-tx')
|
||||
const ethUtil = require('ethereumjs-util')
|
||||
|
||||
const { createMockStore } = require('redux-test-utils')
|
||||
const { shallowWithStore } = require('../../lib/shallow-with-store')
|
||||
|
||||
const identities = { abc: {}, def: {} }
|
||||
const mockState = {
|
||||
metamask: {
|
||||
accounts: { abc: {} },
|
||||
identities,
|
||||
conversionRate: 10,
|
||||
selectedAddress: 'abc',
|
||||
},
|
||||
}
|
||||
|
||||
describe('PendingTx', function () {
|
||||
const gasPrice = '0x4A817C800' // 20 Gwei
|
||||
const txData = {
|
||||
'id': 5021615666270214,
|
||||
'time': 1494458763011,
|
||||
'status': 'unapproved',
|
||||
'metamaskNetworkId': '1494442339676',
|
||||
'txParams': {
|
||||
'from': '0xfdea65c8e26263f6d9a1b5de9555d2931a33b826',
|
||||
'to': '0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb',
|
||||
'value': '0xde0b6b3a7640000',
|
||||
gasPrice,
|
||||
'gas': '0x7b0c',
|
||||
},
|
||||
'gasLimitSpecified': false,
|
||||
'estimatedGas': '0x5208',
|
||||
}
|
||||
const newGasPrice = '0x77359400'
|
||||
|
||||
const computedBalances = {}
|
||||
computedBalances[Object.keys(identities)[0]] = {
|
||||
ethBalance: '0x00000000000000056bc75e2d63100000',
|
||||
}
|
||||
const props = {
|
||||
txData,
|
||||
computedBalances,
|
||||
sendTransaction: (txMeta, event) => {
|
||||
// Assert changes:
|
||||
const result = ethUtil.addHexPrefix(txMeta.txParams.gasPrice)
|
||||
assert.notEqual(result, gasPrice, 'gas price should change')
|
||||
assert.equal(result, newGasPrice, 'gas price assigned.')
|
||||
},
|
||||
}
|
||||
|
||||
let pendingTxComponent
|
||||
let store
|
||||
let component
|
||||
beforeEach(function () {
|
||||
store = createMockStore(mockState)
|
||||
component = shallowWithStore(h(PendingTx, props), store)
|
||||
pendingTxComponent = component
|
||||
})
|
||||
|
||||
it('should render correctly', function (done) {
|
||||
assert.equal(pendingTxComponent.props().identities, identities)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
@ -6,7 +6,7 @@ const {
|
||||
calcGasTotal,
|
||||
calcTokenBalance,
|
||||
estimateGas,
|
||||
} = require('./components/send_/send.utils')
|
||||
} = require('./components/send/send.utils')
|
||||
const ethUtil = require('ethereumjs-util')
|
||||
const { fetchLocale } = require('../i18n-helper')
|
||||
const log = require('loglevel')
|
||||
@ -26,6 +26,11 @@ var actions = {
|
||||
SIDEBAR_CLOSE: 'UI_SIDEBAR_CLOSE',
|
||||
showSidebar: showSidebar,
|
||||
hideSidebar: hideSidebar,
|
||||
// sidebar state
|
||||
ALERT_OPEN: 'UI_ALERT_OPEN',
|
||||
ALERT_CLOSE: 'UI_ALERT_CLOSE',
|
||||
showAlert: showAlert,
|
||||
hideAlert: hideAlert,
|
||||
// network dropdown open
|
||||
NETWORK_DROPDOWN_OPEN: 'UI_NETWORK_DROPDOWN_OPEN',
|
||||
NETWORK_DROPDOWN_CLOSE: 'UI_NETWORK_DROPDOWN_CLOSE',
|
||||
@ -78,9 +83,14 @@ var actions = {
|
||||
addNewKeyring,
|
||||
importNewAccount,
|
||||
addNewAccount,
|
||||
connectHardware,
|
||||
checkHardwareStatus,
|
||||
forgetDevice,
|
||||
unlockTrezorAccount,
|
||||
NEW_ACCOUNT_SCREEN: 'NEW_ACCOUNT_SCREEN',
|
||||
navigateToNewAccountScreen,
|
||||
resetAccount,
|
||||
removeAccount,
|
||||
showNewVaultSeed: showNewVaultSeed,
|
||||
showInfoPage: showInfoPage,
|
||||
CLOSE_WELCOME_SCREEN: 'CLOSE_WELCOME_SCREEN',
|
||||
@ -164,6 +174,7 @@ var actions = {
|
||||
UPDATE_GAS_PRICE: 'UPDATE_GAS_PRICE',
|
||||
UPDATE_GAS_TOTAL: 'UPDATE_GAS_TOTAL',
|
||||
UPDATE_SEND_FROM: 'UPDATE_SEND_FROM',
|
||||
UPDATE_SEND_HEX_DATA: 'UPDATE_SEND_HEX_DATA',
|
||||
UPDATE_SEND_TOKEN_BALANCE: 'UPDATE_SEND_TOKEN_BALANCE',
|
||||
UPDATE_SEND_TO: 'UPDATE_SEND_TO',
|
||||
UPDATE_SEND_AMOUNT: 'UPDATE_SEND_AMOUNT',
|
||||
@ -183,6 +194,7 @@ var actions = {
|
||||
setSendTokenBalance,
|
||||
updateSendTokenBalance,
|
||||
updateSendFrom,
|
||||
updateSendHexData,
|
||||
updateSendTo,
|
||||
updateSendAmount,
|
||||
updateSendMemo,
|
||||
@ -533,6 +545,26 @@ function resetAccount () {
|
||||
}
|
||||
}
|
||||
|
||||
function removeAccount (address) {
|
||||
return dispatch => {
|
||||
dispatch(actions.showLoadingIndication())
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
background.removeAccount(address, (err, account) => {
|
||||
dispatch(actions.hideLoadingIndication())
|
||||
if (err) {
|
||||
dispatch(actions.displayWarning(err.message))
|
||||
return reject(err)
|
||||
}
|
||||
|
||||
log.info('Account removed: ' + account)
|
||||
dispatch(actions.showAccountsPage())
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function addNewKeyring (type, opts) {
|
||||
return (dispatch) => {
|
||||
dispatch(actions.showLoadingIndication())
|
||||
@ -599,6 +631,88 @@ function addNewAccount () {
|
||||
}
|
||||
}
|
||||
|
||||
function checkHardwareStatus (deviceName) {
|
||||
log.debug(`background.checkHardwareStatus`, deviceName)
|
||||
return (dispatch, getState) => {
|
||||
dispatch(actions.showLoadingIndication())
|
||||
return new Promise((resolve, reject) => {
|
||||
background.checkHardwareStatus(deviceName, (err, unlocked) => {
|
||||
if (err) {
|
||||
log.error(err)
|
||||
dispatch(actions.displayWarning(err.message))
|
||||
return reject(err)
|
||||
}
|
||||
|
||||
dispatch(actions.hideLoadingIndication())
|
||||
|
||||
forceUpdateMetamaskState(dispatch)
|
||||
return resolve(unlocked)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function forgetDevice (deviceName) {
|
||||
log.debug(`background.forgetDevice`, deviceName)
|
||||
return (dispatch, getState) => {
|
||||
dispatch(actions.showLoadingIndication())
|
||||
return new Promise((resolve, reject) => {
|
||||
background.forgetDevice(deviceName, (err, response) => {
|
||||
if (err) {
|
||||
log.error(err)
|
||||
dispatch(actions.displayWarning(err.message))
|
||||
return reject(err)
|
||||
}
|
||||
|
||||
dispatch(actions.hideLoadingIndication())
|
||||
|
||||
forceUpdateMetamaskState(dispatch)
|
||||
return resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function connectHardware (deviceName, page) {
|
||||
log.debug(`background.connectHardware`, deviceName, page)
|
||||
return (dispatch, getState) => {
|
||||
dispatch(actions.showLoadingIndication())
|
||||
return new Promise((resolve, reject) => {
|
||||
background.connectHardware(deviceName, page, (err, accounts) => {
|
||||
if (err) {
|
||||
log.error(err)
|
||||
dispatch(actions.displayWarning(err.message))
|
||||
return reject(err)
|
||||
}
|
||||
|
||||
dispatch(actions.hideLoadingIndication())
|
||||
|
||||
forceUpdateMetamaskState(dispatch)
|
||||
return resolve(accounts)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function unlockTrezorAccount (index) {
|
||||
log.debug(`background.unlockTrezorAccount`, index)
|
||||
return (dispatch, getState) => {
|
||||
dispatch(actions.showLoadingIndication())
|
||||
return new Promise((resolve, reject) => {
|
||||
background.unlockTrezorAccount(index, (err, accounts) => {
|
||||
if (err) {
|
||||
log.error(err)
|
||||
dispatch(actions.displayWarning(err.message))
|
||||
return reject(err)
|
||||
}
|
||||
|
||||
dispatch(actions.hideLoadingIndication())
|
||||
return resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function showInfoPage () {
|
||||
return {
|
||||
type: actions.SHOW_INFO_PAGE,
|
||||
@ -838,6 +952,13 @@ function updateSendFrom (from) {
|
||||
}
|
||||
}
|
||||
|
||||
function updateSendHexData (value) {
|
||||
return {
|
||||
type: actions.UPDATE_SEND_HEX_DATA,
|
||||
value,
|
||||
}
|
||||
}
|
||||
|
||||
function updateSendTo (to, nickname = '') {
|
||||
return {
|
||||
type: actions.UPDATE_SEND_TO,
|
||||
@ -1617,6 +1738,19 @@ function hideSidebar () {
|
||||
}
|
||||
}
|
||||
|
||||
function showAlert (msg) {
|
||||
return {
|
||||
type: actions.ALERT_OPEN,
|
||||
value: msg,
|
||||
}
|
||||
}
|
||||
|
||||
function hideAlert () {
|
||||
return {
|
||||
type: actions.ALERT_CLOSE,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function showLoadingIndication (message) {
|
||||
return {
|
||||
|
@ -11,7 +11,7 @@ const log = require('loglevel')
|
||||
// init
|
||||
const InitializeScreen = require('../../mascara/src/app/first-time').default
|
||||
// accounts
|
||||
const SendTransactionScreen = require('./components/send_/send.container')
|
||||
const SendTransactionScreen = require('./components/send/send.container')
|
||||
const ConfirmTransaction = require('./components/pages/confirm-transaction')
|
||||
|
||||
// slideout menu
|
||||
@ -36,6 +36,8 @@ const AccountMenu = require('./components/account-menu')
|
||||
|
||||
// Global Modals
|
||||
const Modal = require('./components/modals/index').Modal
|
||||
// Global Alert
|
||||
const Alert = require('./components/alert')
|
||||
|
||||
const AppHeader = require('./components/app-header')
|
||||
|
||||
@ -93,6 +95,7 @@ class App extends Component {
|
||||
render () {
|
||||
const {
|
||||
isLoading,
|
||||
alertMessage,
|
||||
loadingMessage,
|
||||
network,
|
||||
isMouseUser,
|
||||
@ -126,6 +129,9 @@ class App extends Component {
|
||||
// global modal
|
||||
h(Modal, {}, []),
|
||||
|
||||
// global alert
|
||||
h(Alert, {visible: this.props.alertOpen, msg: alertMessage}),
|
||||
|
||||
h(AppHeader),
|
||||
|
||||
// sidebar
|
||||
@ -149,14 +155,6 @@ class App extends Component {
|
||||
)
|
||||
}
|
||||
|
||||
renderGlobalModal () {
|
||||
return h(Modal, {
|
||||
ref: 'modalRef',
|
||||
}, [
|
||||
// h(BuyOptions, {}, []),
|
||||
])
|
||||
}
|
||||
|
||||
renderSidebar () {
|
||||
return h('div', [
|
||||
h('style', `
|
||||
@ -265,11 +263,13 @@ App.propTypes = {
|
||||
setCurrentCurrencyToUSD: PropTypes.func,
|
||||
isLoading: PropTypes.bool,
|
||||
loadingMessage: PropTypes.string,
|
||||
alertMessage: PropTypes.string,
|
||||
network: PropTypes.string,
|
||||
provider: PropTypes.object,
|
||||
frequentRpcList: PropTypes.array,
|
||||
currentView: PropTypes.object,
|
||||
sidebarOpen: PropTypes.bool,
|
||||
alertOpen: PropTypes.bool,
|
||||
hideSidebar: PropTypes.func,
|
||||
isMascara: PropTypes.bool,
|
||||
isOnboarding: PropTypes.bool,
|
||||
@ -305,6 +305,8 @@ function mapStateToProps (state) {
|
||||
const {
|
||||
networkDropdownOpen,
|
||||
sidebarOpen,
|
||||
alertOpen,
|
||||
alertMessage,
|
||||
isLoading,
|
||||
loadingMessage,
|
||||
} = appState
|
||||
@ -330,6 +332,8 @@ function mapStateToProps (state) {
|
||||
// state from plugin
|
||||
networkDropdownOpen,
|
||||
sidebarOpen,
|
||||
alertOpen,
|
||||
alertMessage,
|
||||
isLoading,
|
||||
loadingMessage,
|
||||
noActiveNotices,
|
||||
|
@ -9,11 +9,17 @@ const actions = require('../../actions')
|
||||
const { Menu, Item, Divider, CloseArea } = require('../dropdowns/components/menu')
|
||||
const Identicon = require('../identicon')
|
||||
const { formatBalance } = require('../../util')
|
||||
const { ENVIRONMENT_TYPE_POPUP } = require('../../../../app/scripts/lib/enums')
|
||||
const { getEnvironmentType } = require('../../../../app/scripts/lib/util')
|
||||
const Tooltip = require('../tooltip')
|
||||
|
||||
|
||||
const {
|
||||
SETTINGS_ROUTE,
|
||||
INFO_ROUTE,
|
||||
NEW_ACCOUNT_ROUTE,
|
||||
IMPORT_ACCOUNT_ROUTE,
|
||||
CONNECT_HARDWARE_ROUTE,
|
||||
DEFAULT_ROUTE,
|
||||
} = require('../../routes')
|
||||
|
||||
@ -63,6 +69,9 @@ function mapDispatchToProps (dispatch) {
|
||||
dispatch(actions.hideSidebar())
|
||||
dispatch(actions.toggleAccountMenu())
|
||||
},
|
||||
showRemoveAccountConfirmationModal: (identity) => {
|
||||
return dispatch(actions.showModal({ name: 'CONFIRM_REMOVE_ACCOUNT', identity }))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,6 +115,18 @@ AccountMenu.prototype.render = function () {
|
||||
icon: h('img.account-menu__item-icon', { src: 'images/import-account.svg' }),
|
||||
text: this.context.t('importAccount'),
|
||||
}),
|
||||
h(Item, {
|
||||
onClick: () => {
|
||||
toggleAccountMenu()
|
||||
if (getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_POPUP) {
|
||||
global.platform.openExtensionInBrowser(CONNECT_HARDWARE_ROUTE)
|
||||
} else {
|
||||
history.push(CONNECT_HARDWARE_ROUTE)
|
||||
}
|
||||
},
|
||||
icon: h('img.account-menu__item-icon', { src: 'images/connect-icon.svg' }),
|
||||
text: this.context.t('connectHardwareWallet'),
|
||||
}),
|
||||
h(Divider),
|
||||
h(Item, {
|
||||
onClick: () => {
|
||||
@ -136,7 +157,8 @@ AccountMenu.prototype.renderAccounts = function () {
|
||||
} = this.props
|
||||
|
||||
const accountOrder = keyrings.reduce((list, keyring) => list.concat(keyring.accounts), [])
|
||||
return accountOrder.map((address) => {
|
||||
return accountOrder.filter(address => !!identities[address]).map((address) => {
|
||||
|
||||
const identity = identities[address]
|
||||
const isSelected = identity.address === selectedAddress
|
||||
|
||||
@ -170,16 +192,53 @@ AccountMenu.prototype.renderAccounts = function () {
|
||||
h('div.account-menu__balance', formattedBalance),
|
||||
]),
|
||||
|
||||
this.indicateIfLoose(keyring),
|
||||
this.renderKeyringType(keyring),
|
||||
this.renderRemoveAccount(keyring, identity),
|
||||
],
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
AccountMenu.prototype.indicateIfLoose = function (keyring) {
|
||||
AccountMenu.prototype.renderRemoveAccount = function (keyring, identity) {
|
||||
// Any account that's not from the HD wallet Keyring can be removed
|
||||
const type = keyring.type
|
||||
const isRemovable = type !== 'HD Key Tree'
|
||||
if (isRemovable) {
|
||||
return h(Tooltip, {
|
||||
title: this.context.t('removeAccount'),
|
||||
position: 'bottom',
|
||||
}, [
|
||||
h('a.remove-account-icon', {
|
||||
onClick: (e) => this.removeAccount(e, identity),
|
||||
}, ''),
|
||||
])
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
AccountMenu.prototype.removeAccount = function (e, identity) {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
const { showRemoveAccountConfirmationModal } = this.props
|
||||
showRemoveAccountConfirmationModal(identity)
|
||||
}
|
||||
|
||||
AccountMenu.prototype.renderKeyringType = function (keyring) {
|
||||
try { // Sometimes keyrings aren't loaded yet:
|
||||
const type = keyring.type
|
||||
const isLoose = type !== 'HD Key Tree'
|
||||
return isLoose ? h('.keyring-label.allcaps', this.context.t('imported')) : null
|
||||
let label
|
||||
switch (type) {
|
||||
case 'Trezor Hardware':
|
||||
label = this.context.t('hardware')
|
||||
break
|
||||
case 'Simple Key Pair':
|
||||
label = this.context.t('imported')
|
||||
break
|
||||
default:
|
||||
label = ''
|
||||
}
|
||||
|
||||
return label !== '' ? h('.keyring-label.allcaps', label) : null
|
||||
|
||||
} catch (e) { return }
|
||||
}
|
||||
|
22
ui/app/components/alert/index.js
Normal file
22
ui/app/components/alert/index.js
Normal file
@ -0,0 +1,22 @@
|
||||
const { Component } = require('react')
|
||||
const PropTypes = require('prop-types')
|
||||
const h = require('react-hyperscript')
|
||||
|
||||
class Alert extends Component {
|
||||
|
||||
render () {
|
||||
const className = `.global-alert${this.props.visible ? '.visible' : '.hidden'}`
|
||||
return (
|
||||
h(`div${className}`, {},
|
||||
h('a.msg', {}, this.props.msg)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Alert.propTypes = {
|
||||
visible: PropTypes.bool.isRequired,
|
||||
msg: PropTypes.string,
|
||||
}
|
||||
module.exports = Alert
|
||||
|
@ -5,10 +5,10 @@ import classnames from 'classnames'
|
||||
const ConfirmDetailRow = props => {
|
||||
const {
|
||||
label,
|
||||
fiatFee,
|
||||
ethFee,
|
||||
fiatText,
|
||||
ethText,
|
||||
onHeaderClick,
|
||||
fiatFeeColor,
|
||||
fiatTextColor,
|
||||
headerText,
|
||||
headerTextClassName,
|
||||
} = props
|
||||
@ -27,12 +27,12 @@ const ConfirmDetailRow = props => {
|
||||
</div>
|
||||
<div
|
||||
className="confirm-detail-row__fiat"
|
||||
style={{ color: fiatFeeColor }}
|
||||
style={{ color: fiatTextColor }}
|
||||
>
|
||||
{ fiatFee }
|
||||
{ fiatText }
|
||||
</div>
|
||||
<div className="confirm-detail-row__eth">
|
||||
{ `\u2666 ${ethFee}` }
|
||||
{ ethText }
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -41,9 +41,9 @@ const ConfirmDetailRow = props => {
|
||||
|
||||
ConfirmDetailRow.propTypes = {
|
||||
label: PropTypes.string,
|
||||
fiatFee: PropTypes.string,
|
||||
ethFee: PropTypes.string,
|
||||
fiatFeeColor: PropTypes.string,
|
||||
fiatText: PropTypes.string,
|
||||
ethText: PropTypes.string,
|
||||
fiatTextColor: PropTypes.string,
|
||||
onHeaderClick: PropTypes.func,
|
||||
headerText: PropTypes.string,
|
||||
headerTextClassName: PropTypes.string,
|
||||
|
@ -16,11 +16,11 @@ const {
|
||||
MIN_GAS_PRICE_DEC,
|
||||
MIN_GAS_LIMIT_DEC,
|
||||
MIN_GAS_PRICE_GWEI,
|
||||
} = require('../send_/send.constants')
|
||||
} = require('../send/send.constants')
|
||||
|
||||
const {
|
||||
isBalanceSufficient,
|
||||
} = require('../send_/send.utils')
|
||||
} = require('../send/send.utils')
|
||||
|
||||
const {
|
||||
conversionUtil,
|
||||
@ -45,7 +45,7 @@ const {
|
||||
const {
|
||||
getGasPrice,
|
||||
getGasLimit,
|
||||
} = require('../send_/send.selectors')
|
||||
} = require('../send/send.selectors')
|
||||
|
||||
function mapStateToProps (state) {
|
||||
const selectedToken = getSelectedToken(state)
|
||||
|
@ -1,7 +1,7 @@
|
||||
const Component = require('react').Component
|
||||
const h = require('react-hyperscript')
|
||||
const inherits = require('util').inherits
|
||||
const AccountListItem = require('../send_/account-list-item/account-list-item.component').default
|
||||
const AccountListItem = require('../send/account-list-item/account-list-item.component').default
|
||||
|
||||
module.exports = AccountDropdownMini
|
||||
|
||||
|
@ -10,7 +10,7 @@ const networkMap = require('ethjs-ens/lib/network-map.json')
|
||||
const ensRE = /.+\..+$/
|
||||
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
|
||||
const connect = require('react-redux').connect
|
||||
const ToAutoComplete = require('./send/to-autocomplete.component').default
|
||||
const ToAutoComplete = require('./send/to-autocomplete').default
|
||||
const log = require('loglevel')
|
||||
const { isValidENSAddress } = require('../util')
|
||||
|
||||
|
@ -0,0 +1,93 @@
|
||||
import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import Button from '../../button'
|
||||
import { addressSummary } from '../../../util'
|
||||
import Identicon from '../../identicon'
|
||||
import genAccountLink from '../../../../lib/account-link'
|
||||
|
||||
class ConfirmRemoveAccount extends Component {
|
||||
static propTypes = {
|
||||
hideModal: PropTypes.func.isRequired,
|
||||
removeAccount: PropTypes.func.isRequired,
|
||||
identity: PropTypes.object.isRequired,
|
||||
network: PropTypes.string.isRequired,
|
||||
}
|
||||
|
||||
static contextTypes = {
|
||||
t: PropTypes.func,
|
||||
}
|
||||
|
||||
handleRemove () {
|
||||
this.props.removeAccount(this.props.identity.address)
|
||||
.then(() => this.props.hideModal())
|
||||
}
|
||||
|
||||
renderSelectedAccount () {
|
||||
const { identity } = this.props
|
||||
return (
|
||||
<div className="modal-container__account">
|
||||
<div className="modal-container__account__identicon">
|
||||
<Identicon
|
||||
address={identity.address}
|
||||
diameter={32}
|
||||
/>
|
||||
</div>
|
||||
<div className="modal-container__account__name">
|
||||
<span className="modal-container__account__label">Name</span>
|
||||
<span className="account_value">{identity.name}</span>
|
||||
</div>
|
||||
<div className="modal-container__account__address">
|
||||
<span className="modal-container__account__label">Public Address</span>
|
||||
<span className="account_value">{ addressSummary(identity.address, 4, 4) }</span>
|
||||
</div>
|
||||
<div className="modal-container__account__link">
|
||||
<a
|
||||
className=""
|
||||
href={genAccountLink(identity.address, this.props.network)}
|
||||
target={'_blank'}
|
||||
title={this.context.t('etherscanView')}
|
||||
>
|
||||
<img src="images/popout.svg" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
render () {
|
||||
const { t } = this.context
|
||||
|
||||
return (
|
||||
<div className="modal-container">
|
||||
<div className="modal-container__content">
|
||||
<div className="modal-container__title">
|
||||
{ `${t('removeAccount')}` }?
|
||||
</div>
|
||||
{ this.renderSelectedAccount() }
|
||||
<div className="modal-container__description">
|
||||
{ t('removeAccountDescription') }
|
||||
<a className="modal-container__link" rel="noopener noreferrer" target="_blank" href="https://consensys.zendesk.com/hc/en-us/articles/360004180111-What-are-imported-accounts-New-UI-">{ t('learnMore') }</a>
|
||||
</div>
|
||||
</div>
|
||||
<div className="modal-container__footer">
|
||||
<Button
|
||||
type="default"
|
||||
className="modal-container__footer-button"
|
||||
onClick={() => this.props.hideModal()}
|
||||
>
|
||||
{ t('nevermind') }
|
||||
</Button>
|
||||
<Button
|
||||
type="secondary"
|
||||
className="modal-container__footer-button"
|
||||
onClick={() => this.handleRemove()}
|
||||
>
|
||||
{ t('remove') }
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default ConfirmRemoveAccount
|
@ -0,0 +1,20 @@
|
||||
import { connect } from 'react-redux'
|
||||
import ConfirmRemoveAccount from './confirm-remove-account.component'
|
||||
|
||||
const { hideModal, removeAccount } = require('../../../actions')
|
||||
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
identity: state.appState.modal.modalState.props.identity,
|
||||
network: state.metamask.network,
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
hideModal: () => dispatch(hideModal()),
|
||||
removeAccount: (address) => dispatch(removeAccount(address)),
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(ConfirmRemoveAccount)
|
2
ui/app/components/modals/confirm-remove-account/index.js
Normal file
2
ui/app/components/modals/confirm-remove-account/index.js
Normal file
@ -0,0 +1,2 @@
|
||||
import ConfirmRemoveAccount from './confirm-remove-account.container'
|
||||
module.exports = ConfirmRemoveAccount
|
@ -1,7 +1,7 @@
|
||||
import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import GasModalCard from '../../customize-gas-modal/gas-modal-card'
|
||||
import { MIN_GAS_PRICE_GWEI } from '../../send_/send.constants'
|
||||
import { MIN_GAS_PRICE_GWEI } from '../../send/send.constants'
|
||||
|
||||
import {
|
||||
getDecimalGasLimit,
|
||||
|
@ -20,6 +20,58 @@
|
||||
font-size: .875rem;
|
||||
}
|
||||
|
||||
&__account {
|
||||
border: 1px solid #b7b7b7;
|
||||
border-radius: 4px;
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 20px;
|
||||
width: 100%;
|
||||
|
||||
&__identicon {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
&__name,
|
||||
&__address {
|
||||
margin-right: 10px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
&__name {
|
||||
width: 100px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
&__label {
|
||||
font-size: 11px;
|
||||
display: block;
|
||||
color: #9b9b9b;
|
||||
}
|
||||
|
||||
&__link {
|
||||
margin-top: 14px;
|
||||
|
||||
img {
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 575px) {
|
||||
&__name {
|
||||
width: 90px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&__link {
|
||||
color: #2f9ae0;
|
||||
}
|
||||
|
||||
&__content {
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
|
@ -20,6 +20,7 @@ const HideTokenConfirmationModal = require('./hide-token-confirmation-modal')
|
||||
const CustomizeGasModal = require('../customize-gas-modal')
|
||||
const NotifcationModal = require('./notification-modal')
|
||||
const ConfirmResetAccount = require('./confirm-reset-account')
|
||||
const ConfirmRemoveAccount = require('./confirm-remove-account')
|
||||
const TransactionConfirmed = require('./transaction-confirmed')
|
||||
const WelcomeBeta = require('./welcome-beta')
|
||||
const Notification = require('./notification')
|
||||
@ -243,6 +244,19 @@ const MODALS = {
|
||||
},
|
||||
},
|
||||
|
||||
CONFIRM_REMOVE_ACCOUNT: {
|
||||
contents: h(ConfirmRemoveAccount),
|
||||
mobileModalStyle: {
|
||||
...modalContainerMobileStyle,
|
||||
},
|
||||
laptopModalStyle: {
|
||||
...modalContainerLaptopStyle,
|
||||
},
|
||||
contentStyle: {
|
||||
borderRadius: '8px',
|
||||
},
|
||||
},
|
||||
|
||||
NEW_ACCOUNT: {
|
||||
contents: [
|
||||
h(NewAccountModal, {}, []),
|
||||
|
@ -9,7 +9,7 @@
|
||||
height: 25px;
|
||||
|
||||
&--mainnet {
|
||||
background-color: lighten($blue-lagoon, 45%);
|
||||
background-color: lighten($blue-lagoon, 68%);
|
||||
}
|
||||
|
||||
&--ropsten {
|
||||
@ -17,11 +17,11 @@
|
||||
}
|
||||
|
||||
&--kovan {
|
||||
background-color: lighten($purple, 45%);
|
||||
background-color: lighten($purple, 65%);
|
||||
}
|
||||
|
||||
&--rinkeby {
|
||||
background-color: lighten($tulip-tree, 45%);
|
||||
background-color: lighten($tulip-tree, 35%);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,29 +1,20 @@
|
||||
import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import ConfirmTransactionBase from '../confirm-transaction-base'
|
||||
import ConfirmTokenTransactionBase from '../confirm-token-transaction-base'
|
||||
|
||||
export default class ConfirmApprove extends Component {
|
||||
static contextTypes = {
|
||||
t: PropTypes.func,
|
||||
}
|
||||
|
||||
static propTypes = {
|
||||
tokenAddress: PropTypes.string,
|
||||
toAddress: PropTypes.string,
|
||||
tokenAmount: PropTypes.string,
|
||||
tokenAmount: PropTypes.number,
|
||||
tokenSymbol: PropTypes.string,
|
||||
}
|
||||
|
||||
render () {
|
||||
const { toAddress, tokenAddress, tokenAmount, tokenSymbol } = this.props
|
||||
const { tokenAmount, tokenSymbol } = this.props
|
||||
|
||||
return (
|
||||
<ConfirmTransactionBase
|
||||
toAddress={toAddress}
|
||||
identiconAddress={tokenAddress}
|
||||
title={`${tokenAmount} ${tokenSymbol}`}
|
||||
<ConfirmTokenTransactionBase
|
||||
tokenAmount={tokenAmount}
|
||||
warning={`By approving this action, you grant permission for this contract to spend up to ${tokenAmount} of your ${tokenSymbol}.`}
|
||||
hideSubtitle
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
@ -1,25 +1,12 @@
|
||||
import { connect } from 'react-redux'
|
||||
import ConfirmApprove from './confirm-approve.component'
|
||||
import { approveTokenAmountAndToAddressSelector } from '../../../selectors/confirm-transaction'
|
||||
|
||||
const mapStateToProps = state => {
|
||||
const { confirmTransaction } = state
|
||||
const {
|
||||
tokenData = {},
|
||||
txData: { txParams: { to: tokenAddress } = {} } = {},
|
||||
tokenProps: { tokenSymbol } = {},
|
||||
} = confirmTransaction
|
||||
const { params = [] } = tokenData
|
||||
|
||||
let toAddress = ''
|
||||
let tokenAmount = ''
|
||||
|
||||
if (params && params.length === 2) {
|
||||
[{ value: toAddress }, { value: tokenAmount }] = params
|
||||
}
|
||||
const { confirmTransaction: { tokenProps: { tokenSymbol } = {} } } = state
|
||||
const { tokenAmount } = approveTokenAmountAndToAddressSelector(state)
|
||||
|
||||
return {
|
||||
toAddress,
|
||||
tokenAddress,
|
||||
tokenAmount,
|
||||
tokenSymbol,
|
||||
}
|
||||
|
@ -1,20 +1,13 @@
|
||||
import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import ConfirmTransactionBase from '../confirm-transaction-base'
|
||||
import ConfirmTokenTransactionBase from '../confirm-token-transaction-base'
|
||||
import { SEND_ROUTE } from '../../../routes'
|
||||
|
||||
export default class ConfirmSendToken extends Component {
|
||||
static contextTypes = {
|
||||
t: PropTypes.func,
|
||||
}
|
||||
|
||||
static propTypes = {
|
||||
history: PropTypes.object,
|
||||
tokenAddress: PropTypes.string,
|
||||
toAddress: PropTypes.string,
|
||||
numberOfTokens: PropTypes.number,
|
||||
tokenSymbol: PropTypes.string,
|
||||
editTransaction: PropTypes.func,
|
||||
tokenAmount: PropTypes.number,
|
||||
}
|
||||
|
||||
handleEdit (confirmTransactionData) {
|
||||
@ -24,15 +17,12 @@ export default class ConfirmSendToken extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
const { toAddress, tokenAddress, tokenSymbol, numberOfTokens } = this.props
|
||||
const { tokenAmount } = this.props
|
||||
|
||||
return (
|
||||
<ConfirmTransactionBase
|
||||
toAddress={toAddress}
|
||||
identiconAddress={tokenAddress}
|
||||
title={`${numberOfTokens} ${tokenSymbol}`}
|
||||
<ConfirmTokenTransactionBase
|
||||
onEdit={confirmTransactionData => this.handleEdit(confirmTransactionData)}
|
||||
hideSubtitle
|
||||
tokenAmount={tokenAmount}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
@ -2,36 +2,16 @@ import { connect } from 'react-redux'
|
||||
import { compose } from 'recompose'
|
||||
import { withRouter } from 'react-router-dom'
|
||||
import ConfirmSendToken from './confirm-send-token.component'
|
||||
import { calcTokenAmount } from '../../../token-util'
|
||||
import { clearConfirmTransaction } from '../../../ducks/confirm-transaction.duck'
|
||||
import { setSelectedToken, updateSend, showSendTokenPage } from '../../../actions'
|
||||
import { conversionUtil } from '../../../conversion-util'
|
||||
import { sendTokenTokenAmountAndToAddressSelector } from '../../../selectors/confirm-transaction'
|
||||
|
||||
const mapStateToProps = state => {
|
||||
const { confirmTransaction } = state
|
||||
const {
|
||||
tokenData = {},
|
||||
tokenProps: { tokenSymbol, tokenDecimals } = {},
|
||||
txData: { txParams: { to: tokenAddress } = {} } = {},
|
||||
} = confirmTransaction
|
||||
const { params = [] } = tokenData
|
||||
|
||||
let toAddress = ''
|
||||
let tokenAmount = ''
|
||||
|
||||
if (params && params.length === 2) {
|
||||
[{ value: toAddress }, { value: tokenAmount }] = params
|
||||
}
|
||||
|
||||
const numberOfTokens = tokenAmount && tokenDecimals
|
||||
? calcTokenAmount(tokenAmount, tokenDecimals)
|
||||
: 0
|
||||
const { tokenAmount } = sendTokenTokenAmountAndToAddressSelector(state)
|
||||
|
||||
return {
|
||||
toAddress,
|
||||
tokenAddress,
|
||||
tokenSymbol,
|
||||
numberOfTokens,
|
||||
tokenAmount,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,19 +0,0 @@
|
||||
.confirm-send-token {
|
||||
&__title {
|
||||
padding: 4px 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&__identicon {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
&__title-text {
|
||||
font-size: 2.25rem;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
padding-left: 8px;
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import ConfirmTransactionBase from '../confirm-transaction-base'
|
||||
import {
|
||||
formatCurrency,
|
||||
convertTokenToFiat,
|
||||
addFiat,
|
||||
} from '../../../helpers/confirm-transaction/util'
|
||||
|
||||
export default class ConfirmTokenTransactionBase extends Component {
|
||||
static contextTypes = {
|
||||
t: PropTypes.func,
|
||||
}
|
||||
|
||||
static propTypes = {
|
||||
tokenAddress: PropTypes.string,
|
||||
toAddress: PropTypes.string,
|
||||
tokenAmount: PropTypes.number,
|
||||
tokenSymbol: PropTypes.string,
|
||||
fiatTransactionTotal: PropTypes.string,
|
||||
ethTransactionTotal: PropTypes.string,
|
||||
contractExchangeRate: PropTypes.number,
|
||||
conversionRate: PropTypes.number,
|
||||
currentCurrency: PropTypes.string,
|
||||
}
|
||||
|
||||
getFiatTransactionAmount () {
|
||||
const { tokenAmount, currentCurrency, conversionRate, contractExchangeRate } = this.props
|
||||
|
||||
return convertTokenToFiat({
|
||||
value: tokenAmount,
|
||||
toCurrency: currentCurrency,
|
||||
conversionRate,
|
||||
contractExchangeRate,
|
||||
})
|
||||
}
|
||||
|
||||
getSubtitle () {
|
||||
const { currentCurrency, contractExchangeRate } = this.props
|
||||
|
||||
if (typeof contractExchangeRate === 'undefined') {
|
||||
return this.context.t('noConversionRateAvailable')
|
||||
} else {
|
||||
const fiatTransactionAmount = this.getFiatTransactionAmount()
|
||||
return formatCurrency(fiatTransactionAmount, currentCurrency)
|
||||
}
|
||||
}
|
||||
|
||||
getFiatTotalTextOverride () {
|
||||
const { fiatTransactionTotal, currentCurrency, contractExchangeRate } = this.props
|
||||
|
||||
if (typeof contractExchangeRate === 'undefined') {
|
||||
return formatCurrency(fiatTransactionTotal, currentCurrency)
|
||||
} else {
|
||||
const fiatTransactionAmount = this.getFiatTransactionAmount()
|
||||
const fiatTotal = addFiat(fiatTransactionAmount, fiatTransactionTotal)
|
||||
return formatCurrency(fiatTotal, currentCurrency)
|
||||
}
|
||||
}
|
||||
|
||||
render () {
|
||||
const {
|
||||
toAddress,
|
||||
tokenAddress,
|
||||
tokenSymbol,
|
||||
tokenAmount,
|
||||
ethTransactionTotal,
|
||||
...restProps
|
||||
} = this.props
|
||||
|
||||
const tokensText = `${tokenAmount} ${tokenSymbol}`
|
||||
|
||||
return (
|
||||
<ConfirmTransactionBase
|
||||
toAddress={toAddress}
|
||||
identiconAddress={tokenAddress}
|
||||
title={tokensText}
|
||||
subtitle={this.getSubtitle()}
|
||||
ethTotalTextOverride={`${tokensText} + \u2666 ${ethTransactionTotal}`}
|
||||
fiatTotalTextOverride={this.getFiatTotalTextOverride()}
|
||||
{...restProps}
|
||||
/>
|
||||
)
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
import { connect } from 'react-redux'
|
||||
import ConfirmTokenTransactionBase from './confirm-token-transaction-base.component'
|
||||
import {
|
||||
tokenAmountAndToAddressSelector,
|
||||
contractExchangeRateSelector,
|
||||
} from '../../../selectors/confirm-transaction'
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
const { tokenAmount: ownTokenAmount } = ownProps
|
||||
const { confirmTransaction, metamask: { currentCurrency, conversionRate } } = state
|
||||
const {
|
||||
txData: { txParams: { to: tokenAddress } = {} } = {},
|
||||
tokenProps: { tokenSymbol } = {},
|
||||
fiatTransactionTotal,
|
||||
ethTransactionTotal,
|
||||
} = confirmTransaction
|
||||
|
||||
const { tokenAmount, toAddress } = tokenAmountAndToAddressSelector(state)
|
||||
const contractExchangeRate = contractExchangeRateSelector(state)
|
||||
|
||||
return {
|
||||
toAddress,
|
||||
tokenAddress,
|
||||
tokenAmount: typeof ownTokenAmount !== 'undefined' ? ownTokenAmount : tokenAmount,
|
||||
tokenSymbol,
|
||||
currentCurrency,
|
||||
conversionRate,
|
||||
contractExchangeRate,
|
||||
fiatTransactionTotal,
|
||||
ethTransactionTotal,
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps)(ConfirmTokenTransactionBase)
|
@ -0,0 +1,2 @@
|
||||
export { default } from './confirm-token-transaction-base.container'
|
||||
export { default as ConfirmTokenTransactionBase } from './confirm-token-transaction-base.component'
|
@ -2,7 +2,7 @@ import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import ConfirmPageContainer, { ConfirmDetailRow } from '../../confirm-page-container'
|
||||
import { formatCurrency } from '../../../helpers/confirm-transaction/util'
|
||||
import { isBalanceSufficient } from '../../send_/send.utils'
|
||||
import { isBalanceSufficient } from '../../send/send.utils'
|
||||
import { DEFAULT_ROUTE } from '../../../routes'
|
||||
import {
|
||||
INSUFFICIENT_FUNDS_ERROR_KEY,
|
||||
@ -54,6 +54,8 @@ export default class ConfirmTransactionBase extends Component {
|
||||
detailsComponent: PropTypes.node,
|
||||
errorKey: PropTypes.string,
|
||||
errorMessage: PropTypes.string,
|
||||
ethTotalTextOverride: PropTypes.string,
|
||||
fiatTotalTextOverride: PropTypes.string,
|
||||
hideData: PropTypes.bool,
|
||||
hideDetails: PropTypes.bool,
|
||||
hideSubtitle: PropTypes.bool,
|
||||
@ -146,6 +148,8 @@ export default class ConfirmTransactionBase extends Component {
|
||||
currentCurrency,
|
||||
fiatTransactionTotal,
|
||||
ethTransactionTotal,
|
||||
fiatTotalTextOverride,
|
||||
ethTotalTextOverride,
|
||||
hideDetails,
|
||||
} = this.props
|
||||
|
||||
@ -153,14 +157,16 @@ export default class ConfirmTransactionBase extends Component {
|
||||
return null
|
||||
}
|
||||
|
||||
const formattedCurrency = formatCurrency(fiatTransactionTotal, currentCurrency)
|
||||
|
||||
return (
|
||||
detailsComponent || (
|
||||
<div className="confirm-page-container-content__details">
|
||||
<div className="confirm-page-container-content__gas-fee">
|
||||
<ConfirmDetailRow
|
||||
label="Gas Fee"
|
||||
fiatFee={formatCurrency(fiatTransactionFee, currentCurrency)}
|
||||
ethFee={ethTransactionFee}
|
||||
fiatText={formatCurrency(fiatTransactionFee, currentCurrency)}
|
||||
ethText={`\u2666 ${ethTransactionFee}`}
|
||||
headerText="Edit"
|
||||
headerTextClassName="confirm-detail-row__header-text--edit"
|
||||
onHeaderClick={() => this.handleEditGas()}
|
||||
@ -169,11 +175,11 @@ export default class ConfirmTransactionBase extends Component {
|
||||
<div>
|
||||
<ConfirmDetailRow
|
||||
label="Total"
|
||||
fiatFee={formatCurrency(fiatTransactionTotal, currentCurrency)}
|
||||
ethFee={ethTransactionTotal}
|
||||
fiatText={fiatTotalTextOverride || formattedCurrency}
|
||||
ethText={ethTotalTextOverride || `\u2666 ${ethTransactionTotal}`}
|
||||
headerText="Amount + Gas Fee"
|
||||
headerTextClassName="confirm-detail-row__header-text--total"
|
||||
fiatFeeColor="#2f9ae0"
|
||||
fiatTextColor="#2f9ae0"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -206,17 +212,21 @@ export default class ConfirmTransactionBase extends Component {
|
||||
<div className="confirm-page-container-content__data-box-label">
|
||||
{`${t('functionType')}:`}
|
||||
<span className="confirm-page-container-content__function-type">
|
||||
{ name }
|
||||
{ name || t('notFound') }
|
||||
</span>
|
||||
</div>
|
||||
<div className="confirm-page-container-content__data-box">
|
||||
<div className="confirm-page-container-content__data-field-label">
|
||||
{ `${t('parameters')}:` }
|
||||
</div>
|
||||
<div>
|
||||
<pre>{ JSON.stringify(params, null, 2) }</pre>
|
||||
</div>
|
||||
</div>
|
||||
{
|
||||
params && (
|
||||
<div className="confirm-page-container-content__data-box">
|
||||
<div className="confirm-page-container-content__data-field-label">
|
||||
{ `${t('parameters')}:` }
|
||||
</div>
|
||||
<div>
|
||||
<pre>{ JSON.stringify(params, null, 2) }</pre>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
<div className="confirm-page-container-content__data-box-label">
|
||||
{`${t('hexData')}:`}
|
||||
</div>
|
||||
@ -297,7 +307,7 @@ export default class ConfirmTransactionBase extends Component {
|
||||
toName={toName}
|
||||
toAddress={toAddress}
|
||||
showEdit={onEdit && !isTxReprice}
|
||||
action={action || name}
|
||||
action={action || name || this.context.t('unknownFunction')}
|
||||
title={title || `${fiatConvertedAmount} ${currentCurrency.toUpperCase()}`}
|
||||
subtitle={subtitle || `\u2666 ${ethTransactionAmount}`}
|
||||
hideSubtitle={hideSubtitle}
|
||||
|
@ -2,6 +2,7 @@ import { connect } from 'react-redux'
|
||||
import { compose } from 'recompose'
|
||||
import { withRouter } from 'react-router-dom'
|
||||
import R from 'ramda'
|
||||
import contractMap from 'eth-contract-metadata'
|
||||
import ConfirmTransactionBase from './confirm-transaction-base.component'
|
||||
import {
|
||||
clearConfirmTransaction,
|
||||
@ -13,9 +14,17 @@ import {
|
||||
GAS_LIMIT_TOO_LOW_ERROR_KEY,
|
||||
} from '../../../constants/error-keys'
|
||||
import { getHexGasTotal } from '../../../helpers/confirm-transaction/util'
|
||||
import { isBalanceSufficient } from '../../send_/send.utils'
|
||||
import { isBalanceSufficient } from '../../send/send.utils'
|
||||
import { conversionGreaterThan } from '../../../conversion-util'
|
||||
import { MIN_GAS_LIMIT_DEC } from '../../send_/send.constants'
|
||||
import { MIN_GAS_LIMIT_DEC } from '../../send/send.constants'
|
||||
import { addressSlicer } from '../../../util'
|
||||
|
||||
const casedContractMap = Object.keys(contractMap).reduce((acc, base) => {
|
||||
return {
|
||||
...acc,
|
||||
[base.toLowerCase()]: contractMap[base],
|
||||
}
|
||||
}, {})
|
||||
|
||||
const mapStateToProps = (state, props) => {
|
||||
const { toAddress: propsToAddress } = props
|
||||
@ -48,7 +57,10 @@ const mapStateToProps = (state, props) => {
|
||||
const { balance } = accounts[selectedAddress]
|
||||
const { name: fromName } = identities[selectedAddress]
|
||||
const toAddress = propsToAddress || txParamsToAddress
|
||||
const toName = identities[toAddress] && identities[toAddress].name
|
||||
const toName = identities[toAddress]
|
||||
? identities[toAddress].name
|
||||
: casedContractMap[toAddress] ? casedContractMap[toAddress].name : addressSlicer(toAddress)
|
||||
|
||||
const isTxReprice = Boolean(lastGasPrice)
|
||||
|
||||
const transaction = R.find(({ id }) => id === transactionId)(selectedAddressTxList)
|
||||
|
@ -8,11 +8,16 @@ import {
|
||||
CONFIRM_SEND_ETHER_PATH,
|
||||
CONFIRM_SEND_TOKEN_PATH,
|
||||
CONFIRM_APPROVE_PATH,
|
||||
CONFIRM_TRANSFER_FROM_PATH,
|
||||
CONFIRM_TOKEN_METHOD_PATH,
|
||||
SIGNATURE_REQUEST_PATH,
|
||||
} from '../../../routes'
|
||||
import { isConfirmDeployContract } from './confirm-transaction-switch.util'
|
||||
import { TOKEN_METHOD_TRANSFER, TOKEN_METHOD_APPROVE } from './confirm-transaction-switch.constants'
|
||||
import {
|
||||
TOKEN_METHOD_TRANSFER,
|
||||
TOKEN_METHOD_APPROVE,
|
||||
TOKEN_METHOD_TRANSFER_FROM,
|
||||
} from './confirm-transaction-switch.constants'
|
||||
|
||||
export default class ConfirmTransactionSwitch extends Component {
|
||||
static propTypes = {
|
||||
@ -27,8 +32,7 @@ export default class ConfirmTransactionSwitch extends Component {
|
||||
methodData: { name },
|
||||
fetchingMethodData,
|
||||
} = this.props
|
||||
const { id } = txData
|
||||
|
||||
const { id, txParams: { data } = {} } = txData
|
||||
|
||||
if (isConfirmDeployContract(txData)) {
|
||||
const pathname = `${CONFIRM_TRANSACTION_ROUTE}/${id}${CONFIRM_DEPLOY_CONTRACT_PATH}`
|
||||
@ -39,10 +43,10 @@ export default class ConfirmTransactionSwitch extends Component {
|
||||
return <Loading />
|
||||
}
|
||||
|
||||
if (name) {
|
||||
const methodName = name.toLowerCase()
|
||||
if (data) {
|
||||
const methodName = name && name.toLowerCase()
|
||||
|
||||
switch (methodName.toLowerCase()) {
|
||||
switch (methodName) {
|
||||
case TOKEN_METHOD_TRANSFER: {
|
||||
const pathname = `${CONFIRM_TRANSACTION_ROUTE}/${id}${CONFIRM_SEND_TOKEN_PATH}`
|
||||
return <Redirect to={{ pathname }} />
|
||||
@ -51,6 +55,10 @@ export default class ConfirmTransactionSwitch extends Component {
|
||||
const pathname = `${CONFIRM_TRANSACTION_ROUTE}/${id}${CONFIRM_APPROVE_PATH}`
|
||||
return <Redirect to={{ pathname }} />
|
||||
}
|
||||
case TOKEN_METHOD_TRANSFER_FROM: {
|
||||
const pathname = `${CONFIRM_TRANSACTION_ROUTE}/${id}${CONFIRM_TRANSFER_FROM_PATH}`
|
||||
return <Redirect to={{ pathname }} />
|
||||
}
|
||||
default: {
|
||||
const pathname = `${CONFIRM_TRANSACTION_ROUTE}/${id}${CONFIRM_TOKEN_METHOD_PATH}`
|
||||
return <Redirect to={{ pathname }} />
|
||||
|
@ -1,2 +1,3 @@
|
||||
export const TOKEN_METHOD_TRANSFER = 'transfer'
|
||||
export const TOKEN_METHOD_APPROVE = 'approve'
|
||||
export const TOKEN_METHOD_TRANSFER_FROM = 'transferfrom'
|
||||
|
@ -8,6 +8,7 @@ import ConfirmSendEther from '../confirm-send-ether'
|
||||
import ConfirmSendToken from '../confirm-send-token'
|
||||
import ConfirmDeployContract from '../confirm-deploy-contract'
|
||||
import ConfirmApprove from '../confirm-approve'
|
||||
import ConfirmTokenTransactionBase from '../confirm-token-transaction-base'
|
||||
import ConfTx from '../../../conf-tx'
|
||||
import {
|
||||
DEFAULT_ROUTE,
|
||||
@ -16,6 +17,7 @@ import {
|
||||
CONFIRM_SEND_ETHER_PATH,
|
||||
CONFIRM_SEND_TOKEN_PATH,
|
||||
CONFIRM_APPROVE_PATH,
|
||||
CONFIRM_TRANSFER_FROM_PATH,
|
||||
CONFIRM_TOKEN_METHOD_PATH,
|
||||
SIGNATURE_REQUEST_PATH,
|
||||
} from '../../../routes'
|
||||
@ -137,6 +139,11 @@ export default class ConfirmTransaction extends Component {
|
||||
path={`${CONFIRM_TRANSACTION_ROUTE}/:id?${CONFIRM_APPROVE_PATH}`}
|
||||
component={ConfirmApprove}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`${CONFIRM_TRANSACTION_ROUTE}/:id?${CONFIRM_TRANSFER_FROM_PATH}`}
|
||||
component={ConfirmTokenTransactionBase}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`${CONFIRM_TRANSACTION_ROUTE}/:id?${SIGNATURE_REQUEST_PATH}`}
|
||||
|
@ -0,0 +1,143 @@
|
||||
const { Component } = require('react')
|
||||
const PropTypes = require('prop-types')
|
||||
const h = require('react-hyperscript')
|
||||
const genAccountLink = require('../../../../../lib/account-link.js')
|
||||
|
||||
class AccountList extends Component {
|
||||
constructor (props, context) {
|
||||
super(props)
|
||||
}
|
||||
|
||||
renderHeader () {
|
||||
return (
|
||||
h('div.hw-connect', [
|
||||
h('h3.hw-connect__title', {}, this.context.t('selectAnAccount')),
|
||||
h('p.hw-connect__msg', {}, this.context.t('selectAnAccountHelp')),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
renderAccounts () {
|
||||
return h('div.hw-account-list', [
|
||||
this.props.accounts.map((a, i) => {
|
||||
|
||||
return h('div.hw-account-list__item', { key: a.address }, [
|
||||
h('div.hw-account-list__item__radio', [
|
||||
h('input', {
|
||||
type: 'radio',
|
||||
name: 'selectedAccount',
|
||||
id: `address-${i}`,
|
||||
value: a.index,
|
||||
onChange: (e) => this.props.onAccountChange(e.target.value),
|
||||
checked: this.props.selectedAccount === a.index.toString(),
|
||||
}),
|
||||
h(
|
||||
'label.hw-account-list__item__label',
|
||||
{
|
||||
htmlFor: `address-${i}`,
|
||||
},
|
||||
[
|
||||
h('span.hw-account-list__item__index', a.index + 1),
|
||||
`${a.address.slice(0, 4)}...${a.address.slice(-4)}`,
|
||||
h('span.hw-account-list__item__balance', `${a.balance}`),
|
||||
]),
|
||||
]),
|
||||
h(
|
||||
'a.hw-account-list__item__link',
|
||||
{
|
||||
href: genAccountLink(a.address, this.props.network),
|
||||
target: '_blank',
|
||||
title: this.context.t('etherscanView'),
|
||||
},
|
||||
h('img', { src: 'images/popout.svg' })
|
||||
),
|
||||
])
|
||||
}),
|
||||
])
|
||||
}
|
||||
|
||||
renderPagination () {
|
||||
return h('div.hw-list-pagination', [
|
||||
h(
|
||||
'button.hw-list-pagination__button',
|
||||
{
|
||||
onClick: () => this.props.getPage(-1),
|
||||
},
|
||||
`< ${this.context.t('prev')}`
|
||||
),
|
||||
|
||||
h(
|
||||
'button.hw-list-pagination__button',
|
||||
{
|
||||
onClick: () => this.props.getPage(1),
|
||||
},
|
||||
`${this.context.t('next')} >`
|
||||
),
|
||||
])
|
||||
}
|
||||
|
||||
renderButtons () {
|
||||
const disabled = this.props.selectedAccount === null
|
||||
const buttonProps = {}
|
||||
if (disabled) {
|
||||
buttonProps.disabled = true
|
||||
}
|
||||
|
||||
return h('div.new-account-connect-form__buttons', {}, [
|
||||
h(
|
||||
'button.btn-default.btn--large.new-account-connect-form__button',
|
||||
{
|
||||
onClick: this.props.onCancel.bind(this),
|
||||
},
|
||||
[this.context.t('cancel')]
|
||||
),
|
||||
|
||||
h(
|
||||
`button.btn-primary.btn--large.new-account-connect-form__button.unlock ${disabled ? '.btn-primary--disabled' : ''}`,
|
||||
{
|
||||
onClick: this.props.onUnlockAccount.bind(this),
|
||||
...buttonProps,
|
||||
},
|
||||
[this.context.t('unlock')]
|
||||
),
|
||||
])
|
||||
}
|
||||
|
||||
renderForgetDevice () {
|
||||
return h('div.hw-forget-device-container', {}, [
|
||||
h('a', {
|
||||
onClick: this.props.onForgetDevice.bind(this),
|
||||
}, this.context.t('forgetDevice')),
|
||||
])
|
||||
}
|
||||
|
||||
render () {
|
||||
return h('div.new-account-connect-form.account-list', {}, [
|
||||
this.renderHeader(),
|
||||
this.renderAccounts(),
|
||||
this.renderPagination(),
|
||||
this.renderButtons(),
|
||||
this.renderForgetDevice(),
|
||||
])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
AccountList.propTypes = {
|
||||
accounts: PropTypes.array.isRequired,
|
||||
onAccountChange: PropTypes.func.isRequired,
|
||||
onForgetDevice: PropTypes.func.isRequired,
|
||||
getPage: PropTypes.func.isRequired,
|
||||
network: PropTypes.string,
|
||||
selectedAccount: PropTypes.string,
|
||||
history: PropTypes.object,
|
||||
onUnlockAccount: PropTypes.func,
|
||||
onCancel: PropTypes.func,
|
||||
}
|
||||
|
||||
AccountList.contextTypes = {
|
||||
t: PropTypes.func,
|
||||
}
|
||||
|
||||
module.exports = AccountList
|
@ -0,0 +1,149 @@
|
||||
const { Component } = require('react')
|
||||
const PropTypes = require('prop-types')
|
||||
const h = require('react-hyperscript')
|
||||
|
||||
class ConnectScreen extends Component {
|
||||
constructor (props, context) {
|
||||
super(props)
|
||||
}
|
||||
|
||||
renderUnsupportedBrowser () {
|
||||
return (
|
||||
h('div.new-account-connect-form.unsupported-browser', {}, [
|
||||
h('div.hw-connect', [
|
||||
h('h3.hw-connect__title', {}, this.context.t('browserNotSupported')),
|
||||
h('p.hw-connect__msg', {}, this.context.t('chromeRequiredForTrezor')),
|
||||
]),
|
||||
h(
|
||||
'button.btn-primary.btn--large',
|
||||
{
|
||||
onClick: () => global.platform.openWindow({
|
||||
url: 'https://google.com/chrome',
|
||||
}),
|
||||
},
|
||||
this.context.t('downloadGoogleChrome')
|
||||
),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
renderHeader () {
|
||||
return (
|
||||
h('div.hw-connect__header', {}, [
|
||||
h('h3.hw-connect__header__title', {}, this.context.t(`hardwareSupport`)),
|
||||
h('p.hw-connect__header__msg', {}, this.context.t(`hardwareSupportMsg`)),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
renderTrezorAffiliateLink () {
|
||||
return h('div.hw-connect__get-trezor', {}, [
|
||||
h('p.hw-connect__get-trezor__msg', {}, this.context.t(`dontHaveATrezorWallet`)),
|
||||
h('a.hw-connect__get-trezor__link', {
|
||||
href: 'https://shop.trezor.io/?a=metamask',
|
||||
target: '_blank',
|
||||
}, this.context.t('orderOneHere')),
|
||||
])
|
||||
}
|
||||
|
||||
renderConnectToTrezorButton () {
|
||||
return h(
|
||||
'button.btn-primary.btn--large',
|
||||
{ onClick: this.props.connectToTrezor.bind(this) },
|
||||
this.props.btnText
|
||||
)
|
||||
}
|
||||
|
||||
scrollToTutorial = (e) => {
|
||||
if (this.referenceNode) this.referenceNode.scrollIntoView({behavior: 'smooth'})
|
||||
}
|
||||
|
||||
renderLearnMore () {
|
||||
return (
|
||||
h('p.hw-connect__learn-more', {
|
||||
onClick: this.scrollToTutorial,
|
||||
}, [
|
||||
this.context.t('learnMore'),
|
||||
h('img.hw-connect__learn-more__arrow', { src: 'images/caret-right.svg'}),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
renderTutorialSteps () {
|
||||
const steps = [
|
||||
{
|
||||
asset: 'hardware-wallet-step-1',
|
||||
dimensions: {width: '225px', height: '75px'},
|
||||
},
|
||||
{
|
||||
asset: 'hardware-wallet-step-2',
|
||||
dimensions: {width: '300px', height: '100px'},
|
||||
},
|
||||
{
|
||||
asset: 'hardware-wallet-step-3',
|
||||
dimensions: {width: '120px', height: '90px'},
|
||||
},
|
||||
]
|
||||
|
||||
return h('.hw-tutorial', {
|
||||
ref: node => { this.referenceNode = node },
|
||||
},
|
||||
steps.map((step, i) => (
|
||||
h('div.hw-connect', {}, [
|
||||
h('h3.hw-connect__title', {}, this.context.t(`step${i + 1}HardwareWallet`)),
|
||||
h('p.hw-connect__msg', {}, this.context.t(`step${i + 1}HardwareWalletMsg`)),
|
||||
h('img.hw-connect__step-asset', { src: `images/${step.asset}.svg`, ...step.dimensions }),
|
||||
])
|
||||
))
|
||||
)
|
||||
}
|
||||
|
||||
renderFooter () {
|
||||
return (
|
||||
h('div.hw-connect__footer', {}, [
|
||||
h('h3.hw-connect__footer__title', {}, this.context.t(`readyToConnect`)),
|
||||
this.renderConnectToTrezorButton(),
|
||||
h('p.hw-connect__footer__msg', {}, [
|
||||
this.context.t(`havingTroubleConnecting`),
|
||||
h('a.hw-connect__footer__link', {
|
||||
href: 'https://support.metamask.io/',
|
||||
target: '_blank',
|
||||
}, this.context.t('getHelp')),
|
||||
]),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
renderConnectScreen () {
|
||||
return (
|
||||
h('div.new-account-connect-form', {}, [
|
||||
this.renderHeader(),
|
||||
this.renderTrezorAffiliateLink(),
|
||||
this.renderConnectToTrezorButton(),
|
||||
this.renderLearnMore(),
|
||||
this.renderTutorialSteps(),
|
||||
this.renderFooter(),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
render () {
|
||||
if (this.props.browserSupported) {
|
||||
return this.renderConnectScreen()
|
||||
}
|
||||
return this.renderUnsupportedBrowser()
|
||||
}
|
||||
}
|
||||
|
||||
ConnectScreen.propTypes = {
|
||||
connectToTrezor: PropTypes.func.isRequired,
|
||||
btnText: PropTypes.string.isRequired,
|
||||
browserSupported: PropTypes.bool.isRequired,
|
||||
}
|
||||
|
||||
ConnectScreen.contextTypes = {
|
||||
t: PropTypes.func,
|
||||
}
|
||||
|
||||
module.exports = ConnectScreen
|
||||
|
234
ui/app/components/pages/create-account/connect-hardware/index.js
Normal file
234
ui/app/components/pages/create-account/connect-hardware/index.js
Normal file
@ -0,0 +1,234 @@
|
||||
const { Component } = require('react')
|
||||
const PropTypes = require('prop-types')
|
||||
const h = require('react-hyperscript')
|
||||
const connect = require('react-redux').connect
|
||||
const actions = require('../../../../actions')
|
||||
const ConnectScreen = require('./connect-screen')
|
||||
const AccountList = require('./account-list')
|
||||
const { DEFAULT_ROUTE } = require('../../../../routes')
|
||||
const { formatBalance } = require('../../../../util')
|
||||
|
||||
class ConnectHardwareForm extends Component {
|
||||
constructor (props, context) {
|
||||
super(props)
|
||||
this.state = {
|
||||
error: null,
|
||||
btnText: context.t('connectToTrezor'),
|
||||
selectedAccount: null,
|
||||
accounts: [],
|
||||
browserSupported: true,
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps (nextProps) {
|
||||
const { accounts } = nextProps
|
||||
const newAccounts = this.state.accounts.map(a => {
|
||||
const normalizedAddress = a.address.toLowerCase()
|
||||
const balanceValue = accounts[normalizedAddress] && accounts[normalizedAddress].balance || null
|
||||
a.balance = balanceValue ? formatBalance(balanceValue, 6) : '...'
|
||||
return a
|
||||
})
|
||||
this.setState({accounts: newAccounts})
|
||||
}
|
||||
|
||||
|
||||
async componentDidMount () {
|
||||
const unlocked = await this.props.checkHardwareStatus('trezor')
|
||||
if (unlocked) {
|
||||
this.getPage(0)
|
||||
}
|
||||
}
|
||||
|
||||
connectToTrezor = () => {
|
||||
if (this.state.accounts.length) {
|
||||
return null
|
||||
}
|
||||
this.setState({ btnText: this.context.t('connecting')})
|
||||
this.getPage(0)
|
||||
}
|
||||
|
||||
onAccountChange = (account) => {
|
||||
this.setState({selectedAccount: account.toString(), error: null})
|
||||
}
|
||||
|
||||
showTemporaryAlert () {
|
||||
this.props.showAlert(this.context.t('hardwareWalletConnected'))
|
||||
// Autohide the alert after 5 seconds
|
||||
setTimeout(_ => {
|
||||
this.props.hideAlert()
|
||||
}, 5000)
|
||||
}
|
||||
|
||||
getPage = (page) => {
|
||||
this.props
|
||||
.connectHardware('trezor', page)
|
||||
.then(accounts => {
|
||||
if (accounts.length) {
|
||||
|
||||
// If we just loaded the accounts for the first time
|
||||
// show the global alert
|
||||
if (this.state.accounts.length === 0) {
|
||||
this.showTemporaryAlert()
|
||||
}
|
||||
|
||||
const newState = {}
|
||||
// Default to the first account
|
||||
if (this.state.selectedAccount === null) {
|
||||
accounts.forEach((a, i) => {
|
||||
if (a.address.toLowerCase() === this.props.address) {
|
||||
newState.selectedAccount = a.index.toString()
|
||||
}
|
||||
})
|
||||
// If the page doesn't contain the selected account, let's deselect it
|
||||
} else if (!accounts.filter(a => a.index.toString() === this.state.selectedAccount).length) {
|
||||
newState.selectedAccount = null
|
||||
}
|
||||
|
||||
|
||||
// Map accounts with balances
|
||||
newState.accounts = accounts.map(account => {
|
||||
const normalizedAddress = account.address.toLowerCase()
|
||||
const balanceValue = this.props.accounts[normalizedAddress] && this.props.accounts[normalizedAddress].balance || null
|
||||
account.balance = balanceValue ? formatBalance(balanceValue, 6) : '...'
|
||||
return account
|
||||
})
|
||||
|
||||
this.setState(newState)
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
if (e === 'Window blocked') {
|
||||
this.setState({ browserSupported: false })
|
||||
}
|
||||
this.setState({ btnText: this.context.t('connectToTrezor') })
|
||||
})
|
||||
}
|
||||
|
||||
onForgetDevice = () => {
|
||||
this.props.forgetDevice('trezor')
|
||||
.then(_ => {
|
||||
this.setState({
|
||||
error: null,
|
||||
btnText: this.context.t('connectToTrezor'),
|
||||
selectedAccount: null,
|
||||
accounts: [],
|
||||
})
|
||||
}).catch(e => {
|
||||
this.setState({ error: e.toString() })
|
||||
})
|
||||
}
|
||||
|
||||
onUnlockAccount = () => {
|
||||
|
||||
if (this.state.selectedAccount === null) {
|
||||
this.setState({ error: this.context.t('accountSelectionRequired') })
|
||||
}
|
||||
|
||||
this.props.unlockTrezorAccount(this.state.selectedAccount)
|
||||
.then(_ => {
|
||||
this.props.history.push(DEFAULT_ROUTE)
|
||||
}).catch(e => {
|
||||
this.setState({ error: e.toString() })
|
||||
})
|
||||
}
|
||||
|
||||
onCancel = () => {
|
||||
this.props.history.push(DEFAULT_ROUTE)
|
||||
}
|
||||
|
||||
renderError () {
|
||||
return this.state.error
|
||||
? h('span.error', { style: { marginBottom: 40 } }, this.state.error)
|
||||
: null
|
||||
}
|
||||
|
||||
renderContent () {
|
||||
if (!this.state.accounts.length) {
|
||||
return h(ConnectScreen, {
|
||||
connectToTrezor: this.connectToTrezor,
|
||||
btnText: this.state.btnText,
|
||||
browserSupported: this.state.browserSupported,
|
||||
})
|
||||
}
|
||||
|
||||
return h(AccountList, {
|
||||
accounts: this.state.accounts,
|
||||
selectedAccount: this.state.selectedAccount,
|
||||
onAccountChange: this.onAccountChange,
|
||||
network: this.props.network,
|
||||
getPage: this.getPage,
|
||||
history: this.props.history,
|
||||
onUnlockAccount: this.onUnlockAccount,
|
||||
onForgetDevice: this.onForgetDevice,
|
||||
onCancel: this.onCancel,
|
||||
})
|
||||
}
|
||||
|
||||
render () {
|
||||
return h('div', [
|
||||
this.renderError(),
|
||||
this.renderContent(),
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
ConnectHardwareForm.propTypes = {
|
||||
hideModal: PropTypes.func,
|
||||
showImportPage: PropTypes.func,
|
||||
showConnectPage: PropTypes.func,
|
||||
connectHardware: PropTypes.func,
|
||||
checkHardwareStatus: PropTypes.func,
|
||||
forgetDevice: PropTypes.func,
|
||||
showAlert: PropTypes.func,
|
||||
hideAlert: PropTypes.func,
|
||||
unlockTrezorAccount: PropTypes.func,
|
||||
numberOfExistingAccounts: PropTypes.number,
|
||||
history: PropTypes.object,
|
||||
t: PropTypes.func,
|
||||
network: PropTypes.string,
|
||||
accounts: PropTypes.object,
|
||||
address: PropTypes.string,
|
||||
}
|
||||
|
||||
const mapStateToProps = state => {
|
||||
const {
|
||||
metamask: { network, selectedAddress, identities = {}, accounts = [] },
|
||||
} = state
|
||||
const numberOfExistingAccounts = Object.keys(identities).length
|
||||
|
||||
return {
|
||||
network,
|
||||
accounts,
|
||||
address: selectedAddress,
|
||||
numberOfExistingAccounts,
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
connectHardware: (deviceName, page) => {
|
||||
return dispatch(actions.connectHardware(deviceName, page))
|
||||
},
|
||||
checkHardwareStatus: (deviceName) => {
|
||||
return dispatch(actions.checkHardwareStatus(deviceName))
|
||||
},
|
||||
forgetDevice: (deviceName) => {
|
||||
return dispatch(actions.forgetDevice(deviceName))
|
||||
},
|
||||
unlockTrezorAccount: index => {
|
||||
return dispatch(actions.unlockTrezorAccount(index))
|
||||
},
|
||||
showImportPage: () => dispatch(actions.showImportPage()),
|
||||
showConnectPage: () => dispatch(actions.showConnectPage()),
|
||||
showAlert: (msg) => dispatch(actions.showAlert(msg)),
|
||||
hideAlert: () => dispatch(actions.hideAlert()),
|
||||
}
|
||||
}
|
||||
|
||||
ConnectHardwareForm.contextTypes = {
|
||||
t: PropTypes.func,
|
||||
}
|
||||
|
||||
module.exports = connect(mapStateToProps, mapDispatchToProps)(
|
||||
ConnectHardwareForm
|
||||
)
|
@ -8,7 +8,12 @@ const { getCurrentViewContext } = require('../../../selectors')
|
||||
const classnames = require('classnames')
|
||||
const NewAccountCreateForm = require('./new-account')
|
||||
const NewAccountImportForm = require('./import-account')
|
||||
const { NEW_ACCOUNT_ROUTE, IMPORT_ACCOUNT_ROUTE } = require('../../../routes')
|
||||
const ConnectHardwareForm = require('./connect-hardware')
|
||||
const {
|
||||
NEW_ACCOUNT_ROUTE,
|
||||
IMPORT_ACCOUNT_ROUTE,
|
||||
CONNECT_HARDWARE_ROUTE,
|
||||
} = require('../../../routes')
|
||||
|
||||
class CreateAccountPage extends Component {
|
||||
renderTabs () {
|
||||
@ -36,6 +41,19 @@ class CreateAccountPage extends Component {
|
||||
}, [
|
||||
this.context.t('import'),
|
||||
]),
|
||||
h(
|
||||
'div.new-account__tabs__tab',
|
||||
{
|
||||
className: classnames('new-account__tabs__tab', {
|
||||
'new-account__tabs__selected': matchPath(location.pathname, {
|
||||
path: CONNECT_HARDWARE_ROUTE,
|
||||
exact: true,
|
||||
}),
|
||||
}),
|
||||
onClick: () => history.push(CONNECT_HARDWARE_ROUTE),
|
||||
},
|
||||
this.context.t('connect')
|
||||
),
|
||||
])
|
||||
}
|
||||
|
||||
@ -57,6 +75,11 @@ class CreateAccountPage extends Component {
|
||||
path: IMPORT_ACCOUNT_ROUTE,
|
||||
component: NewAccountImportForm,
|
||||
}),
|
||||
h(Route, {
|
||||
exact: true,
|
||||
path: CONNECT_HARDWARE_ROUTE,
|
||||
component: ConnectHardwareForm,
|
||||
}),
|
||||
]),
|
||||
]),
|
||||
])
|
||||
|
@ -62,6 +62,7 @@ class NewAccountCreateForm extends Component {
|
||||
NewAccountCreateForm.propTypes = {
|
||||
hideModal: PropTypes.func,
|
||||
showImportPage: PropTypes.func,
|
||||
showConnectPage: PropTypes.func,
|
||||
createAccount: PropTypes.func,
|
||||
numberOfExistingAccounts: PropTypes.number,
|
||||
history: PropTypes.object,
|
||||
@ -92,6 +93,7 @@ const mapDispatchToProps = dispatch => {
|
||||
})
|
||||
},
|
||||
showImportPage: () => dispatch(actions.showImportPage()),
|
||||
showConnectPage: () => dispatch(actions.showConnectPage()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,5 +3,3 @@
|
||||
@import './add-token/index';
|
||||
|
||||
@import './confirm-add-token/index';
|
||||
|
||||
@import './confirm-send-token/index';
|
||||
|
@ -1,358 +0,0 @@
|
||||
const { Component } = require('react')
|
||||
const connect = require('react-redux').connect
|
||||
const h = require('react-hyperscript')
|
||||
const PropTypes = require('prop-types')
|
||||
const actions = require('../../actions')
|
||||
const clone = require('clone')
|
||||
const ethUtil = require('ethereumjs-util')
|
||||
const BN = ethUtil.BN
|
||||
const hexToBn = require('../../../../app/scripts/lib/hex-to-bn')
|
||||
const { conversionUtil } = require('../../conversion-util')
|
||||
const SenderToRecipient = require('../sender-to-recipient')
|
||||
const NetworkDisplay = require('../network-display')
|
||||
|
||||
const { MIN_GAS_PRICE_HEX } = require('../send_/send.constants')
|
||||
|
||||
class ConfirmDeployContract extends Component {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
|
||||
this.state = {
|
||||
valid: false,
|
||||
submitting: false,
|
||||
}
|
||||
}
|
||||
|
||||
onSubmit (event) {
|
||||
event.preventDefault()
|
||||
const txMeta = this.gatherTxMeta()
|
||||
const valid = this.checkValidity()
|
||||
this.setState({ valid, submitting: true })
|
||||
|
||||
if (valid && this.verifyGasParams()) {
|
||||
this.props.sendTransaction(txMeta, event)
|
||||
} else {
|
||||
this.props.displayWarning(this.context.t('invalidGasParams'))
|
||||
this.setState({ submitting: false })
|
||||
}
|
||||
}
|
||||
|
||||
cancel (event, txMeta) {
|
||||
event.preventDefault()
|
||||
this.props.cancelTransaction(txMeta)
|
||||
}
|
||||
|
||||
checkValidity () {
|
||||
const form = this.getFormEl()
|
||||
const valid = form.checkValidity()
|
||||
return valid
|
||||
}
|
||||
|
||||
getFormEl () {
|
||||
const form = document.querySelector('form#pending-tx-form')
|
||||
// Stub out form for unit tests:
|
||||
if (!form) {
|
||||
return { checkValidity () { return true } }
|
||||
}
|
||||
return form
|
||||
}
|
||||
|
||||
// After a customizable state value has been updated,
|
||||
gatherTxMeta () {
|
||||
const props = this.props
|
||||
const state = this.state
|
||||
const txData = clone(state.txData) || clone(props.txData)
|
||||
|
||||
// log.debug(`UI has defaulted to tx meta ${JSON.stringify(txData)}`)
|
||||
return txData
|
||||
}
|
||||
|
||||
verifyGasParams () {
|
||||
// We call this in case the gas has not been modified at all
|
||||
if (!this.state) { return true }
|
||||
return (
|
||||
this._notZeroOrEmptyString(this.state.gas) &&
|
||||
this._notZeroOrEmptyString(this.state.gasPrice)
|
||||
)
|
||||
}
|
||||
|
||||
_notZeroOrEmptyString (obj) {
|
||||
return obj !== '' && obj !== '0x0'
|
||||
}
|
||||
|
||||
bnMultiplyByFraction (targetBN, numerator, denominator) {
|
||||
const numBN = new BN(numerator)
|
||||
const denomBN = new BN(denominator)
|
||||
return targetBN.mul(numBN).div(denomBN)
|
||||
}
|
||||
|
||||
getData () {
|
||||
const { identities } = this.props
|
||||
const txMeta = this.gatherTxMeta()
|
||||
const txParams = txMeta.txParams || {}
|
||||
|
||||
return {
|
||||
from: {
|
||||
address: txParams.from,
|
||||
name: identities[txParams.from].name,
|
||||
},
|
||||
memo: txParams.memo || '',
|
||||
}
|
||||
}
|
||||
|
||||
getAmount () {
|
||||
const { conversionRate, currentCurrency } = this.props
|
||||
const txMeta = this.gatherTxMeta()
|
||||
const txParams = txMeta.txParams || {}
|
||||
|
||||
const FIAT = conversionUtil(txParams.value, {
|
||||
fromNumericBase: 'hex',
|
||||
toNumericBase: 'dec',
|
||||
fromCurrency: 'ETH',
|
||||
toCurrency: currentCurrency,
|
||||
numberOfDecimals: 2,
|
||||
fromDenomination: 'WEI',
|
||||
conversionRate,
|
||||
})
|
||||
const ETH = conversionUtil(txParams.value, {
|
||||
fromNumericBase: 'hex',
|
||||
toNumericBase: 'dec',
|
||||
fromCurrency: 'ETH',
|
||||
toCurrency: 'ETH',
|
||||
fromDenomination: 'WEI',
|
||||
conversionRate,
|
||||
numberOfDecimals: 6,
|
||||
})
|
||||
|
||||
return {
|
||||
fiat: Number(FIAT),
|
||||
token: Number(ETH),
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
getGasFee () {
|
||||
const { conversionRate, currentCurrency } = this.props
|
||||
const txMeta = this.gatherTxMeta()
|
||||
const txParams = txMeta.txParams || {}
|
||||
|
||||
// Gas
|
||||
const gas = txParams.gas
|
||||
const gasBn = hexToBn(gas)
|
||||
|
||||
// Gas Price
|
||||
const gasPrice = txParams.gasPrice || MIN_GAS_PRICE_HEX
|
||||
const gasPriceBn = hexToBn(gasPrice)
|
||||
|
||||
const txFeeBn = gasBn.mul(gasPriceBn)
|
||||
|
||||
const FIAT = conversionUtil(txFeeBn, {
|
||||
fromNumericBase: 'BN',
|
||||
toNumericBase: 'dec',
|
||||
fromDenomination: 'WEI',
|
||||
fromCurrency: 'ETH',
|
||||
toCurrency: currentCurrency,
|
||||
numberOfDecimals: 2,
|
||||
conversionRate,
|
||||
})
|
||||
const ETH = conversionUtil(txFeeBn, {
|
||||
fromNumericBase: 'BN',
|
||||
toNumericBase: 'dec',
|
||||
fromDenomination: 'WEI',
|
||||
fromCurrency: 'ETH',
|
||||
toCurrency: 'ETH',
|
||||
numberOfDecimals: 6,
|
||||
conversionRate,
|
||||
})
|
||||
|
||||
return {
|
||||
fiat: Number(FIAT),
|
||||
eth: Number(ETH),
|
||||
}
|
||||
}
|
||||
|
||||
renderGasFee () {
|
||||
const { currentCurrency } = this.props
|
||||
const { fiat: fiatGas, eth: ethGas } = this.getGasFee()
|
||||
|
||||
return (
|
||||
h('section.flex-row.flex-center.confirm-screen-row', [
|
||||
h('span.confirm-screen-label.confirm-screen-section-column', [ this.context.t('gasFee') ]),
|
||||
h('div.confirm-screen-section-column', [
|
||||
h('div.confirm-screen-row-info', `${fiatGas} ${currentCurrency.toUpperCase()}`),
|
||||
|
||||
h(
|
||||
'div.confirm-screen-row-detail',
|
||||
`${ethGas} ETH`
|
||||
),
|
||||
]),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
renderHeroAmount () {
|
||||
const { currentCurrency } = this.props
|
||||
const { fiat: fiatAmount } = this.getAmount()
|
||||
const txMeta = this.gatherTxMeta()
|
||||
const txParams = txMeta.txParams || {}
|
||||
const { memo = '' } = txParams
|
||||
|
||||
return (
|
||||
h('div.confirm-send-token__hero-amount-wrapper', [
|
||||
h('h3.flex-center.confirm-screen-send-amount', `${fiatAmount}`),
|
||||
h('h3.flex-center.confirm-screen-send-amount-currency', currentCurrency.toUpperCase()),
|
||||
h('div.flex-center.confirm-memo-wrapper', [
|
||||
h('h3.confirm-screen-send-memo', memo),
|
||||
]),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
renderTotalPlusGas () {
|
||||
const { currentCurrency } = this.props
|
||||
const { fiat: fiatAmount, token: tokenAmount } = this.getAmount()
|
||||
const { fiat: fiatGas, eth: ethGas } = this.getGasFee()
|
||||
|
||||
return (
|
||||
h('section.flex-row.flex-center.confirm-screen-row.confirm-screen-total-box ', [
|
||||
h('div.confirm-screen-section-column', [
|
||||
h('span.confirm-screen-label', [ this.context.t('total') + ' ' ]),
|
||||
h('div.confirm-screen-total-box__subtitle', [ this.context.t('amountPlusGas') ]),
|
||||
]),
|
||||
|
||||
h('div.confirm-screen-section-column', [
|
||||
h('div.confirm-screen-row-info', `${fiatAmount + fiatGas} ${currentCurrency.toUpperCase()}`),
|
||||
h('div.confirm-screen-row-detail', `${tokenAmount + ethGas} ETH`),
|
||||
]),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
render () {
|
||||
const { backToAccountDetail, selectedAddress } = this.props
|
||||
const txMeta = this.gatherTxMeta()
|
||||
|
||||
const {
|
||||
from: {
|
||||
address: fromAddress,
|
||||
name: fromName,
|
||||
},
|
||||
} = this.getData()
|
||||
|
||||
this.inputs = []
|
||||
|
||||
return (
|
||||
h('.page-container', [
|
||||
h('.page-container__header', [
|
||||
h('.page-container__header-row', [
|
||||
h('span.page-container__back-button', {
|
||||
onClick: () => backToAccountDetail(selectedAddress),
|
||||
}, this.context.t('back')),
|
||||
window.METAMASK_UI_TYPE === 'notification' && h(NetworkDisplay),
|
||||
]),
|
||||
h('.page-container__title', this.context.t('confirmContract')),
|
||||
h('.page-container__subtitle', this.context.t('pleaseReviewTransaction')),
|
||||
]),
|
||||
// Main Send token Card
|
||||
h('.page-container__content', [
|
||||
|
||||
h(SenderToRecipient, {
|
||||
senderName: fromName,
|
||||
senderAddress: fromAddress,
|
||||
}),
|
||||
|
||||
// h('h3.flex-center.confirm-screen-sending-to-message', {
|
||||
// style: {
|
||||
// textAlign: 'center',
|
||||
// fontSize: '16px',
|
||||
// },
|
||||
// }, [
|
||||
// `You're deploying a new contract.`,
|
||||
// ]),
|
||||
|
||||
this.renderHeroAmount(),
|
||||
|
||||
h('div.confirm-screen-rows', [
|
||||
h('section.flex-row.flex-center.confirm-screen-row', [
|
||||
h('span.confirm-screen-label.confirm-screen-section-column', [ this.context.t('from') ]),
|
||||
h('div.confirm-screen-section-column', [
|
||||
h('div.confirm-screen-row-info', fromName),
|
||||
h('div.confirm-screen-row-detail', `...${fromAddress.slice(fromAddress.length - 4)}`),
|
||||
]),
|
||||
]),
|
||||
|
||||
h('section.flex-row.flex-center.confirm-screen-row', [
|
||||
h('span.confirm-screen-label.confirm-screen-section-column', [ this.context.t('to') ]),
|
||||
h('div.confirm-screen-section-column', [
|
||||
h('div.confirm-screen-row-info', this.context.t('newContract')),
|
||||
]),
|
||||
]),
|
||||
|
||||
this.renderGasFee(),
|
||||
|
||||
this.renderTotalPlusGas(),
|
||||
|
||||
]),
|
||||
]),
|
||||
|
||||
h('form#pending-tx-form', {
|
||||
onSubmit: event => this.onSubmit(event),
|
||||
}, [
|
||||
h('.page-container__footer', [
|
||||
// Cancel Button
|
||||
h('button.btn-cancel.page-container__footer-button.allcaps', {
|
||||
onClick: event => this.cancel(event, txMeta),
|
||||
}, this.context.t('cancel')),
|
||||
|
||||
// Accept Button
|
||||
h('button.btn-confirm.page-container__footer-button.allcaps', {
|
||||
onClick: event => this.onSubmit(event),
|
||||
}, this.context.t('confirm')),
|
||||
]),
|
||||
]),
|
||||
])
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
ConfirmDeployContract.propTypes = {
|
||||
sendTransaction: PropTypes.func,
|
||||
cancelTransaction: PropTypes.func,
|
||||
backToAccountDetail: PropTypes.func,
|
||||
displayWarning: PropTypes.func,
|
||||
identities: PropTypes.object,
|
||||
conversionRate: PropTypes.number,
|
||||
currentCurrency: PropTypes.string,
|
||||
selectedAddress: PropTypes.string,
|
||||
t: PropTypes.func,
|
||||
}
|
||||
|
||||
const mapStateToProps = state => {
|
||||
const {
|
||||
conversionRate,
|
||||
identities,
|
||||
currentCurrency,
|
||||
} = state.metamask
|
||||
const accounts = state.metamask.accounts
|
||||
const selectedAddress = state.metamask.selectedAddress || Object.keys(accounts)[0]
|
||||
return {
|
||||
currentCurrency,
|
||||
conversionRate,
|
||||
identities,
|
||||
selectedAddress,
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
backToAccountDetail: address => dispatch(actions.backToAccountDetail(address)),
|
||||
cancelTransaction: ({ id }) => dispatch(actions.cancelTx({ id })),
|
||||
displayWarning: warning => actions.displayWarning(warning),
|
||||
}
|
||||
}
|
||||
|
||||
ConfirmDeployContract.contextTypes = {
|
||||
t: PropTypes.func,
|
||||
}
|
||||
|
||||
module.exports = connect(mapStateToProps, mapDispatchToProps)(ConfirmDeployContract)
|
@ -1,692 +0,0 @@
|
||||
const Component = require('react').Component
|
||||
const { withRouter } = require('react-router-dom')
|
||||
const { compose } = require('recompose')
|
||||
const PropTypes = require('prop-types')
|
||||
const connect = require('react-redux').connect
|
||||
const h = require('react-hyperscript')
|
||||
const inherits = require('util').inherits
|
||||
const actions = require('../../actions')
|
||||
const clone = require('clone')
|
||||
const ethUtil = require('ethereumjs-util')
|
||||
const BN = ethUtil.BN
|
||||
const hexToBn = require('../../../../app/scripts/lib/hex-to-bn')
|
||||
const classnames = require('classnames')
|
||||
const {
|
||||
conversionUtil,
|
||||
addCurrencies,
|
||||
multiplyCurrencies,
|
||||
} = require('../../conversion-util')
|
||||
const {
|
||||
calcGasTotal,
|
||||
isBalanceSufficient,
|
||||
} = require('../send_/send.utils')
|
||||
const GasFeeDisplay = require('../send_/send-content/send-gas-row/gas-fee-display/gas-fee-display.component').default
|
||||
const SenderToRecipient = require('../sender-to-recipient')
|
||||
const NetworkDisplay = require('../network-display')
|
||||
const currencyFormatter = require('currency-formatter')
|
||||
const currencies = require('currency-formatter/currencies')
|
||||
|
||||
const { MIN_GAS_PRICE_HEX } = require('../send_/send.constants')
|
||||
const { SEND_ROUTE, DEFAULT_ROUTE } = require('../../routes')
|
||||
const {
|
||||
ENVIRONMENT_TYPE_POPUP,
|
||||
ENVIRONMENT_TYPE_NOTIFICATION,
|
||||
} = require('../../../../app/scripts/lib/enums')
|
||||
|
||||
import {
|
||||
updateSendErrors,
|
||||
} from '../../ducks/send.duck'
|
||||
|
||||
ConfirmSendEther.contextTypes = {
|
||||
t: PropTypes.func,
|
||||
}
|
||||
|
||||
module.exports = compose(
|
||||
withRouter,
|
||||
connect(mapStateToProps, mapDispatchToProps)
|
||||
)(ConfirmSendEther)
|
||||
|
||||
|
||||
function mapStateToProps (state) {
|
||||
const {
|
||||
conversionRate,
|
||||
identities,
|
||||
currentCurrency,
|
||||
send,
|
||||
} = state.metamask
|
||||
const accounts = state.metamask.accounts
|
||||
const selectedAddress = state.metamask.selectedAddress || Object.keys(accounts)[0]
|
||||
const { balance } = accounts[selectedAddress]
|
||||
return {
|
||||
conversionRate,
|
||||
identities,
|
||||
selectedAddress,
|
||||
currentCurrency,
|
||||
send,
|
||||
balance,
|
||||
}
|
||||
}
|
||||
|
||||
function mapDispatchToProps (dispatch) {
|
||||
return {
|
||||
clearSend: () => dispatch(actions.clearSend()),
|
||||
editTransaction: txMeta => {
|
||||
const { id, txParams } = txMeta
|
||||
const {
|
||||
gas: gasLimit,
|
||||
gasPrice,
|
||||
to,
|
||||
value: amount,
|
||||
} = txParams
|
||||
|
||||
dispatch(actions.updateSend({
|
||||
gasLimit,
|
||||
gasPrice,
|
||||
gasTotal: null,
|
||||
to,
|
||||
amount,
|
||||
errors: { to: null, amount: null },
|
||||
editingTransactionId: id,
|
||||
}))
|
||||
},
|
||||
cancelTransaction: ({ id }) => dispatch(actions.cancelTx({ id })),
|
||||
showCustomizeGasModal: (txMeta, sendGasLimit, sendGasPrice, sendGasTotal) => {
|
||||
const { id, txParams, lastGasPrice } = txMeta
|
||||
const { gas: txGasLimit, gasPrice: txGasPrice } = txParams
|
||||
|
||||
let forceGasMin
|
||||
if (lastGasPrice) {
|
||||
forceGasMin = ethUtil.addHexPrefix(multiplyCurrencies(lastGasPrice, 1.1, {
|
||||
multiplicandBase: 16,
|
||||
multiplierBase: 10,
|
||||
toNumericBase: 'hex',
|
||||
fromDenomination: 'WEI',
|
||||
}))
|
||||
}
|
||||
|
||||
dispatch(actions.updateSend({
|
||||
gasLimit: sendGasLimit || txGasLimit,
|
||||
gasPrice: sendGasPrice || txGasPrice,
|
||||
editingTransactionId: id,
|
||||
gasTotal: sendGasTotal,
|
||||
forceGasMin,
|
||||
}))
|
||||
dispatch(actions.showModal({ name: 'CUSTOMIZE_GAS' }))
|
||||
},
|
||||
updateSendErrors: error => dispatch(updateSendErrors(error)),
|
||||
}
|
||||
}
|
||||
|
||||
inherits(ConfirmSendEther, Component)
|
||||
function ConfirmSendEther () {
|
||||
Component.call(this)
|
||||
this.state = {}
|
||||
this.onSubmit = this.onSubmit.bind(this)
|
||||
}
|
||||
|
||||
ConfirmSendEther.prototype.updateComponentSendErrors = function (prevProps) {
|
||||
const {
|
||||
balance: oldBalance,
|
||||
conversionRate: oldConversionRate,
|
||||
} = prevProps
|
||||
const {
|
||||
updateSendErrors,
|
||||
balance,
|
||||
conversionRate,
|
||||
send: {
|
||||
errors: {
|
||||
simulationFails,
|
||||
},
|
||||
},
|
||||
} = this.props
|
||||
const txMeta = this.gatherTxMeta()
|
||||
|
||||
const shouldUpdateBalanceSendErrors = balance && [
|
||||
balance !== oldBalance,
|
||||
conversionRate !== oldConversionRate,
|
||||
].some(x => Boolean(x))
|
||||
|
||||
if (shouldUpdateBalanceSendErrors) {
|
||||
const balanceIsSufficient = this.isBalanceSufficient(txMeta)
|
||||
updateSendErrors({
|
||||
insufficientFunds: balanceIsSufficient ? false : 'insufficientFunds',
|
||||
})
|
||||
}
|
||||
|
||||
const shouldUpdateSimulationSendError = Boolean(txMeta.simulationFails) !== Boolean(simulationFails)
|
||||
|
||||
if (shouldUpdateSimulationSendError) {
|
||||
updateSendErrors({
|
||||
simulationFails: !txMeta.simulationFails ? false : 'transactionError',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
ConfirmSendEther.prototype.componentWillMount = function () {
|
||||
this.updateComponentSendErrors({})
|
||||
}
|
||||
|
||||
ConfirmSendEther.prototype.componentDidUpdate = function (prevProps) {
|
||||
this.updateComponentSendErrors(prevProps)
|
||||
}
|
||||
|
||||
ConfirmSendEther.prototype.getAmount = function () {
|
||||
const { conversionRate, currentCurrency } = this.props
|
||||
const txMeta = this.gatherTxMeta()
|
||||
const txParams = txMeta.txParams || {}
|
||||
|
||||
const FIAT = conversionUtil(txParams.value, {
|
||||
fromNumericBase: 'hex',
|
||||
toNumericBase: 'dec',
|
||||
fromCurrency: 'ETH',
|
||||
toCurrency: currentCurrency,
|
||||
numberOfDecimals: 2,
|
||||
fromDenomination: 'WEI',
|
||||
conversionRate,
|
||||
})
|
||||
const ETH = conversionUtil(txParams.value, {
|
||||
fromNumericBase: 'hex',
|
||||
toNumericBase: 'dec',
|
||||
fromCurrency: 'ETH',
|
||||
toCurrency: 'ETH',
|
||||
fromDenomination: 'WEI',
|
||||
conversionRate,
|
||||
numberOfDecimals: 6,
|
||||
})
|
||||
|
||||
return {
|
||||
FIAT,
|
||||
ETH,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ConfirmSendEther.prototype.getGasFee = function () {
|
||||
const { conversionRate, currentCurrency } = this.props
|
||||
const txMeta = this.gatherTxMeta()
|
||||
const txParams = txMeta.txParams || {}
|
||||
|
||||
// Gas
|
||||
const gas = txParams.gas
|
||||
const gasBn = hexToBn(gas)
|
||||
|
||||
// From latest master
|
||||
// const gasLimit = new BN(parseInt(blockGasLimit))
|
||||
// const safeGasLimitBN = this.bnMultiplyByFraction(gasLimit, 19, 20)
|
||||
// const saferGasLimitBN = this.bnMultiplyByFraction(gasLimit, 18, 20)
|
||||
// const safeGasLimit = safeGasLimitBN.toString(10)
|
||||
|
||||
// Gas Price
|
||||
const gasPrice = txParams.gasPrice || MIN_GAS_PRICE_HEX
|
||||
const gasPriceBn = hexToBn(gasPrice)
|
||||
|
||||
const txFeeBn = gasBn.mul(gasPriceBn)
|
||||
|
||||
const FIAT = conversionUtil(txFeeBn, {
|
||||
fromNumericBase: 'BN',
|
||||
toNumericBase: 'dec',
|
||||
fromDenomination: 'WEI',
|
||||
fromCurrency: 'ETH',
|
||||
toCurrency: currentCurrency,
|
||||
numberOfDecimals: 2,
|
||||
conversionRate,
|
||||
})
|
||||
const ETH = conversionUtil(txFeeBn, {
|
||||
fromNumericBase: 'BN',
|
||||
toNumericBase: 'dec',
|
||||
fromDenomination: 'WEI',
|
||||
fromCurrency: 'ETH',
|
||||
toCurrency: 'ETH',
|
||||
numberOfDecimals: 6,
|
||||
conversionRate,
|
||||
})
|
||||
|
||||
return {
|
||||
FIAT,
|
||||
ETH,
|
||||
gasFeeInHex: txFeeBn.toString(16),
|
||||
}
|
||||
}
|
||||
|
||||
ConfirmSendEther.prototype.getData = function () {
|
||||
const { identities } = this.props
|
||||
const txMeta = this.gatherTxMeta()
|
||||
const txParams = txMeta.txParams || {}
|
||||
const account = identities ? identities[txParams.from] || {} : {}
|
||||
const { FIAT: gasFeeInFIAT, ETH: gasFeeInETH, gasFeeInHex } = this.getGasFee()
|
||||
const { FIAT: amountInFIAT, ETH: amountInETH } = this.getAmount()
|
||||
|
||||
const totalInFIAT = addCurrencies(gasFeeInFIAT, amountInFIAT, {
|
||||
toNumericBase: 'dec',
|
||||
numberOfDecimals: 2,
|
||||
})
|
||||
const totalInETH = addCurrencies(gasFeeInETH, amountInETH, {
|
||||
toNumericBase: 'dec',
|
||||
numberOfDecimals: 6,
|
||||
})
|
||||
|
||||
return {
|
||||
from: {
|
||||
address: txParams.from,
|
||||
name: account.name,
|
||||
},
|
||||
to: {
|
||||
address: txParams.to,
|
||||
name: identities[txParams.to] ? identities[txParams.to].name : this.context.t('newRecipient'),
|
||||
},
|
||||
memo: txParams.memo || '',
|
||||
gasFeeInFIAT,
|
||||
gasFeeInETH,
|
||||
amountInFIAT,
|
||||
amountInETH,
|
||||
totalInFIAT,
|
||||
totalInETH,
|
||||
gasFeeInHex,
|
||||
}
|
||||
}
|
||||
|
||||
ConfirmSendEther.prototype.convertToRenderableCurrency = function (value, currencyCode) {
|
||||
const upperCaseCurrencyCode = currencyCode.toUpperCase()
|
||||
|
||||
return currencies.find(currency => currency.code === upperCaseCurrencyCode)
|
||||
? currencyFormatter.format(Number(value), {
|
||||
code: upperCaseCurrencyCode,
|
||||
})
|
||||
: value
|
||||
}
|
||||
|
||||
ConfirmSendEther.prototype.editTransaction = function () {
|
||||
const { editTransaction, history } = this.props
|
||||
const txMeta = this.gatherTxMeta()
|
||||
editTransaction(txMeta)
|
||||
history.push(SEND_ROUTE)
|
||||
}
|
||||
|
||||
ConfirmSendEther.prototype.renderHeaderRow = function (isTxReprice) {
|
||||
const windowType = window.METAMASK_UI_TYPE
|
||||
const isFullScreen = windowType !== ENVIRONMENT_TYPE_NOTIFICATION &&
|
||||
windowType !== ENVIRONMENT_TYPE_POPUP
|
||||
|
||||
if (isTxReprice && isFullScreen) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
h('.page-container__header-row', [
|
||||
h('span.page-container__back-button', {
|
||||
onClick: () => this.editTransaction(),
|
||||
style: {
|
||||
visibility: isTxReprice ? 'hidden' : 'initial',
|
||||
},
|
||||
}, 'Edit'),
|
||||
!isFullScreen && h(NetworkDisplay),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
ConfirmSendEther.prototype.renderHeader = function (isTxReprice) {
|
||||
const title = isTxReprice ? this.context.t('speedUpTitle') : this.context.t('confirm')
|
||||
const subtitle = isTxReprice
|
||||
? this.context.t('speedUpSubtitle')
|
||||
: this.context.t('pleaseReviewTransaction')
|
||||
|
||||
return (
|
||||
h('.page-container__header', [
|
||||
this.renderHeaderRow(isTxReprice),
|
||||
h('.page-container__title', title),
|
||||
h('.page-container__subtitle', subtitle),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
ConfirmSendEther.prototype.render = function () {
|
||||
const {
|
||||
currentCurrency,
|
||||
clearSend,
|
||||
conversionRate,
|
||||
currentCurrency: convertedCurrency,
|
||||
showCustomizeGasModal,
|
||||
send: {
|
||||
gasTotal,
|
||||
gasLimit: sendGasLimit,
|
||||
gasPrice: sendGasPrice,
|
||||
errors,
|
||||
},
|
||||
} = this.props
|
||||
const txMeta = this.gatherTxMeta()
|
||||
const isTxReprice = Boolean(txMeta.lastGasPrice)
|
||||
const txParams = txMeta.txParams || {}
|
||||
|
||||
const {
|
||||
from: {
|
||||
address: fromAddress,
|
||||
name: fromName,
|
||||
},
|
||||
to: {
|
||||
address: toAddress,
|
||||
name: toName,
|
||||
},
|
||||
memo,
|
||||
gasFeeInHex,
|
||||
amountInFIAT,
|
||||
totalInFIAT,
|
||||
totalInETH,
|
||||
} = this.getData()
|
||||
|
||||
const convertedAmountInFiat = this.convertToRenderableCurrency(amountInFIAT, currentCurrency)
|
||||
const convertedTotalInFiat = this.convertToRenderableCurrency(totalInFIAT, currentCurrency)
|
||||
|
||||
// This is from the latest master
|
||||
// It handles some of the errors that we are not currently handling
|
||||
// Leaving as comments fo reference
|
||||
|
||||
// const balanceBn = hexToBn(balance)
|
||||
// const insufficientBalance = balanceBn.lt(maxCost)
|
||||
// const buyDisabled = insufficientBalance || !this.state.valid || !isValidAddress || this.state.submitting
|
||||
// const showRejectAll = props.unconfTxListLength > 1
|
||||
// const dangerousGasLimit = gasBn.gte(saferGasLimitBN)
|
||||
// const gasLimitSpecified = txMeta.gasLimitSpecified
|
||||
|
||||
this.inputs = []
|
||||
|
||||
return (
|
||||
// Main Send token Card
|
||||
h('.page-container', [
|
||||
this.renderHeader(isTxReprice),
|
||||
h('.page-container__content', [
|
||||
h(SenderToRecipient, {
|
||||
senderName: fromName,
|
||||
senderAddress: fromAddress,
|
||||
recipientName: toName,
|
||||
recipientAddress: txParams.to,
|
||||
}),
|
||||
|
||||
// h('h3.flex-center.confirm-screen-sending-to-message', {
|
||||
// style: {
|
||||
// textAlign: 'center',
|
||||
// fontSize: '16px',
|
||||
// },
|
||||
// }, [
|
||||
// `You're sending to Recipient ...${toAddress.slice(toAddress.length - 4)}`,
|
||||
// ]),
|
||||
|
||||
h('h3.flex-center.confirm-screen-send-amount', [`${convertedAmountInFiat}`]),
|
||||
h('h3.flex-center.confirm-screen-send-amount-currency', [ currentCurrency.toUpperCase() ]),
|
||||
h('div.flex-center.confirm-memo-wrapper', [
|
||||
h('h3.confirm-screen-send-memo', [ memo ? `"${memo}"` : '' ]),
|
||||
]),
|
||||
|
||||
h('div.confirm-screen-rows', [
|
||||
h('section.flex-row.flex-center.confirm-screen-row', [
|
||||
h('span.confirm-screen-label.confirm-screen-section-column', [ this.context.t('from') ]),
|
||||
h('div.confirm-screen-section-column', [
|
||||
h('div.confirm-screen-row-info', fromName),
|
||||
h('div.confirm-screen-row-detail', `...${fromAddress.slice(fromAddress.length - 4)}`),
|
||||
]),
|
||||
]),
|
||||
|
||||
h('section.flex-row.flex-center.confirm-screen-row', [
|
||||
h('span.confirm-screen-label.confirm-screen-section-column', [ this.context.t('to') ]),
|
||||
h('div.confirm-screen-section-column', [
|
||||
h('div.confirm-screen-row-info', toName),
|
||||
h('div.confirm-screen-row-detail', `...${toAddress.slice(toAddress.length - 4)}`),
|
||||
]),
|
||||
]),
|
||||
|
||||
h('section.flex-row.flex-center.confirm-screen-row', [
|
||||
h('span.confirm-screen-label.confirm-screen-section-column', [ this.context.t('gasFee') ]),
|
||||
h('div.confirm-screen-section-column', [
|
||||
h(GasFeeDisplay, {
|
||||
gasTotal: gasTotal || gasFeeInHex,
|
||||
conversionRate,
|
||||
convertedCurrency,
|
||||
onClick: () => showCustomizeGasModal(txMeta, sendGasLimit, sendGasPrice, gasTotal),
|
||||
}),
|
||||
]),
|
||||
]),
|
||||
|
||||
h('section.flex-row.flex-center.confirm-screen-row.confirm-screen-total-box ', [
|
||||
h('div', {
|
||||
className: classnames({
|
||||
'confirm-screen-section-column--with-error': errors['insufficientFunds'],
|
||||
'confirm-screen-section-column': !errors['insufficientFunds'],
|
||||
}),
|
||||
}, [
|
||||
h('span.confirm-screen-label', [ this.context.t('total') + ' ' ]),
|
||||
h('div.confirm-screen-total-box__subtitle', [ this.context.t('amountPlusGas') ]),
|
||||
]),
|
||||
|
||||
h('div.confirm-screen-section-column', [
|
||||
h('div.confirm-screen-row-info', `${convertedTotalInFiat} ${currentCurrency.toUpperCase()}`),
|
||||
h('div.confirm-screen-row-detail', `${totalInETH} ETH`),
|
||||
]),
|
||||
|
||||
this.renderErrorMessage('insufficientFunds'),
|
||||
]),
|
||||
]),
|
||||
|
||||
// These are latest errors handling from master
|
||||
// Leaving as comments as reference when we start implementing error handling
|
||||
// h('style', `
|
||||
// .conf-buttons button {
|
||||
// margin-left: 10px;
|
||||
// text-transform: uppercase;
|
||||
// }
|
||||
// `),
|
||||
|
||||
// txMeta.simulationFails ?
|
||||
// h('.error', {
|
||||
// style: {
|
||||
// marginLeft: 50,
|
||||
// fontSize: '0.9em',
|
||||
// },
|
||||
// }, 'Transaction Error. Exception thrown in contract code.')
|
||||
// : null,
|
||||
|
||||
// !isValidAddress ?
|
||||
// h('.error', {
|
||||
// style: {
|
||||
// marginLeft: 50,
|
||||
// fontSize: '0.9em',
|
||||
// },
|
||||
// }, 'Recipient address is invalid. Sending this transaction will result in a loss of ETH.')
|
||||
// : null,
|
||||
|
||||
// insufficientBalance ?
|
||||
// h('span.error', {
|
||||
// style: {
|
||||
// marginLeft: 50,
|
||||
// fontSize: '0.9em',
|
||||
// },
|
||||
// }, 'Insufficient balance for transaction')
|
||||
// : null,
|
||||
|
||||
// // send + cancel
|
||||
// h('.flex-row.flex-space-around.conf-buttons', {
|
||||
// style: {
|
||||
// display: 'flex',
|
||||
// justifyContent: 'flex-end',
|
||||
// margin: '14px 25px',
|
||||
// },
|
||||
// }, [
|
||||
// h('button', {
|
||||
// onClick: (event) => {
|
||||
// this.resetGasFields()
|
||||
// event.preventDefault()
|
||||
// },
|
||||
// }, 'Reset'),
|
||||
|
||||
// // Accept Button or Buy Button
|
||||
// insufficientBalance ? h('button.btn-green', { onClick: props.buyEth }, 'Buy Ether') :
|
||||
// h('input.confirm.btn-green', {
|
||||
// type: 'submit',
|
||||
// value: 'SUBMIT',
|
||||
// style: { marginLeft: '10px' },
|
||||
// disabled: buyDisabled,
|
||||
// }),
|
||||
|
||||
// h('button.cancel.btn-red', {
|
||||
// onClick: props.cancelTransaction,
|
||||
// }, 'Reject'),
|
||||
// ]),
|
||||
// showRejectAll ? h('.flex-row.flex-space-around.conf-buttons', {
|
||||
// style: {
|
||||
// display: 'flex',
|
||||
// justifyContent: 'flex-end',
|
||||
// margin: '14px 25px',
|
||||
// },
|
||||
// }, [
|
||||
// h('button.cancel.btn-red', {
|
||||
// onClick: props.cancelAllTransactions,
|
||||
// }, 'Reject All'),
|
||||
// ]) : null,
|
||||
// ]),
|
||||
// ])
|
||||
// )
|
||||
// }
|
||||
]),
|
||||
|
||||
h('form#pending-tx-form', {
|
||||
className: 'confirm-screen-form',
|
||||
onSubmit: this.onSubmit,
|
||||
}, [
|
||||
this.renderErrorMessage('simulationFails'),
|
||||
h('.page-container__footer', [
|
||||
// Cancel Button
|
||||
h('button.btn-cancel.page-container__footer-button.allcaps', {
|
||||
onClick: (event) => {
|
||||
clearSend()
|
||||
this.cancel(event, txMeta)
|
||||
},
|
||||
}, this.context.t('cancel')),
|
||||
|
||||
// Accept Button
|
||||
h('button.btn-confirm.page-container__footer-button.allcaps', {
|
||||
onClick: event => this.onSubmit(event),
|
||||
}, this.context.t('confirm')),
|
||||
]),
|
||||
]),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
ConfirmSendEther.prototype.renderErrorMessage = function (message) {
|
||||
const { send: { errors } } = this.props
|
||||
|
||||
return errors[message]
|
||||
? h('div.confirm-screen-error', [ errors[message] ])
|
||||
: null
|
||||
}
|
||||
|
||||
ConfirmSendEther.prototype.onSubmit = function (event) {
|
||||
event.preventDefault()
|
||||
const { updateSendErrors } = this.props
|
||||
const txMeta = this.gatherTxMeta()
|
||||
const valid = this.checkValidity()
|
||||
const balanceIsSufficient = this.isBalanceSufficient(txMeta)
|
||||
this.setState({ valid, submitting: true })
|
||||
|
||||
if (valid && this.verifyGasParams() && balanceIsSufficient) {
|
||||
this.props.sendTransaction(txMeta, event)
|
||||
} else if (!balanceIsSufficient) {
|
||||
updateSendErrors({ insufficientFunds: 'insufficientFunds' })
|
||||
} else {
|
||||
updateSendErrors({ invalidGasParams: 'invalidGasParams' })
|
||||
this.setState({ submitting: false })
|
||||
}
|
||||
}
|
||||
|
||||
ConfirmSendEther.prototype.cancel = function (event, txMeta) {
|
||||
event.preventDefault()
|
||||
const { cancelTransaction } = this.props
|
||||
|
||||
cancelTransaction(txMeta)
|
||||
.then(() => this.props.history.push(DEFAULT_ROUTE))
|
||||
}
|
||||
|
||||
ConfirmSendEther.prototype.isBalanceSufficient = function (txMeta) {
|
||||
const {
|
||||
balance,
|
||||
conversionRate,
|
||||
} = this.props
|
||||
const {
|
||||
txParams: {
|
||||
gas,
|
||||
gasPrice,
|
||||
value: amount,
|
||||
},
|
||||
} = txMeta
|
||||
const gasTotal = calcGasTotal(gas, gasPrice)
|
||||
|
||||
return isBalanceSufficient({
|
||||
amount,
|
||||
gasTotal,
|
||||
balance,
|
||||
conversionRate,
|
||||
})
|
||||
}
|
||||
|
||||
ConfirmSendEther.prototype.checkValidity = function () {
|
||||
const form = this.getFormEl()
|
||||
const valid = form.checkValidity()
|
||||
return valid
|
||||
}
|
||||
|
||||
ConfirmSendEther.prototype.getFormEl = function () {
|
||||
const form = document.querySelector('form#pending-tx-form')
|
||||
// Stub out form for unit tests:
|
||||
if (!form) {
|
||||
return { checkValidity () { return true } }
|
||||
}
|
||||
return form
|
||||
}
|
||||
|
||||
// After a customizable state value has been updated,
|
||||
ConfirmSendEther.prototype.gatherTxMeta = function () {
|
||||
const props = this.props
|
||||
const state = this.state
|
||||
const txData = clone(state.txData) || clone(props.txData)
|
||||
|
||||
const { gasPrice: sendGasPrice, gasLimit: sendGasLimit } = props.send
|
||||
const {
|
||||
lastGasPrice,
|
||||
txParams: {
|
||||
gasPrice: txGasPrice,
|
||||
gas: txGasLimit,
|
||||
},
|
||||
} = txData
|
||||
|
||||
let forceGasMin
|
||||
if (lastGasPrice) {
|
||||
forceGasMin = ethUtil.addHexPrefix(multiplyCurrencies(lastGasPrice, 1.1, {
|
||||
multiplicandBase: 16,
|
||||
multiplierBase: 10,
|
||||
toNumericBase: 'hex',
|
||||
}))
|
||||
}
|
||||
|
||||
txData.txParams.gasPrice = sendGasPrice || forceGasMin || txGasPrice
|
||||
txData.txParams.gas = sendGasLimit || txGasLimit
|
||||
|
||||
// log.debug(`UI has defaulted to tx meta ${JSON.stringify(txData)}`)
|
||||
return txData
|
||||
}
|
||||
|
||||
ConfirmSendEther.prototype.verifyGasParams = function () {
|
||||
// We call this in case the gas has not been modified at all
|
||||
if (!this.state) { return true }
|
||||
return (
|
||||
this._notZeroOrEmptyString(this.state.gas) &&
|
||||
this._notZeroOrEmptyString(this.state.gasPrice)
|
||||
)
|
||||
}
|
||||
|
||||
ConfirmSendEther.prototype._notZeroOrEmptyString = function (obj) {
|
||||
return obj !== '' && obj !== '0x0'
|
||||
}
|
||||
|
||||
ConfirmSendEther.prototype.bnMultiplyByFraction = function (targetBN, numerator, denominator) {
|
||||
const numBN = new BN(numerator)
|
||||
const denomBN = new BN(denominator)
|
||||
return targetBN.mul(numBN).div(denomBN)
|
||||
}
|
@ -1,696 +0,0 @@
|
||||
const Component = require('react').Component
|
||||
const { withRouter } = require('react-router-dom')
|
||||
const { compose } = require('recompose')
|
||||
const PropTypes = require('prop-types')
|
||||
const connect = require('react-redux').connect
|
||||
const h = require('react-hyperscript')
|
||||
const inherits = require('util').inherits
|
||||
const tokenAbi = require('human-standard-token-abi')
|
||||
const abiDecoder = require('abi-decoder')
|
||||
abiDecoder.addABI(tokenAbi)
|
||||
const actions = require('../../actions')
|
||||
const clone = require('clone')
|
||||
const Identicon = require('../identicon')
|
||||
const GasFeeDisplay = require('../send_/send-content/send-gas-row/gas-fee-display/gas-fee-display.component.js').default
|
||||
const NetworkDisplay = require('../network-display')
|
||||
const ethUtil = require('ethereumjs-util')
|
||||
const BN = ethUtil.BN
|
||||
const {
|
||||
conversionUtil,
|
||||
multiplyCurrencies,
|
||||
addCurrencies,
|
||||
} = require('../../conversion-util')
|
||||
const {
|
||||
calcGasTotal,
|
||||
isBalanceSufficient,
|
||||
} = require('../send_/send.utils')
|
||||
const {
|
||||
calcTokenAmount,
|
||||
} = require('../../token-util')
|
||||
const classnames = require('classnames')
|
||||
const currencyFormatter = require('currency-formatter')
|
||||
const currencies = require('currency-formatter/currencies')
|
||||
|
||||
const { MIN_GAS_PRICE_HEX } = require('../send_/send.constants')
|
||||
|
||||
const {
|
||||
getTokenExchangeRate,
|
||||
getSelectedAddress,
|
||||
getSelectedTokenContract,
|
||||
} = require('../../selectors')
|
||||
const { SEND_ROUTE, DEFAULT_ROUTE } = require('../../routes')
|
||||
|
||||
import {
|
||||
updateSendErrors,
|
||||
} from '../../ducks/send.duck'
|
||||
|
||||
const {
|
||||
ENVIRONMENT_TYPE_POPUP,
|
||||
ENVIRONMENT_TYPE_NOTIFICATION,
|
||||
} = require('../../../../app/scripts/lib/enums')
|
||||
|
||||
ConfirmSendToken.contextTypes = {
|
||||
t: PropTypes.func,
|
||||
}
|
||||
|
||||
module.exports = compose(
|
||||
withRouter,
|
||||
connect(mapStateToProps, mapDispatchToProps)
|
||||
)(ConfirmSendToken)
|
||||
|
||||
|
||||
function mapStateToProps (state, ownProps) {
|
||||
const { token: { address }, txData } = ownProps
|
||||
const { txParams } = txData || {}
|
||||
const tokenData = txParams.data && abiDecoder.decodeMethod(txParams.data)
|
||||
|
||||
const {
|
||||
conversionRate,
|
||||
identities,
|
||||
currentCurrency,
|
||||
} = state.metamask
|
||||
const accounts = state.metamask.accounts
|
||||
const selectedAddress = getSelectedAddress(state)
|
||||
const tokenExchangeRate = getTokenExchangeRate(state, address)
|
||||
const { balance } = accounts[selectedAddress]
|
||||
return {
|
||||
conversionRate,
|
||||
identities,
|
||||
selectedAddress,
|
||||
tokenExchangeRate,
|
||||
tokenData: tokenData || {},
|
||||
currentCurrency: currentCurrency.toUpperCase(),
|
||||
send: state.metamask.send,
|
||||
tokenContract: getSelectedTokenContract(state),
|
||||
balance,
|
||||
}
|
||||
}
|
||||
|
||||
function mapDispatchToProps (dispatch, ownProps) {
|
||||
return {
|
||||
backToAccountDetail: address => dispatch(actions.backToAccountDetail(address)),
|
||||
cancelTransaction: ({ id }) => dispatch(actions.cancelTx({ id })),
|
||||
editTransaction: txMeta => {
|
||||
const { token: { address } } = ownProps
|
||||
const { txParams = {}, id } = txMeta
|
||||
const tokenData = txParams.data && abiDecoder.decodeMethod(txParams.data) || {}
|
||||
const { params = [] } = tokenData
|
||||
const { value: to } = params[0] || {}
|
||||
const { value: tokenAmountInDec } = params[1] || {}
|
||||
const tokenAmountInHex = conversionUtil(tokenAmountInDec, {
|
||||
fromNumericBase: 'dec',
|
||||
toNumericBase: 'hex',
|
||||
})
|
||||
const {
|
||||
gas: gasLimit,
|
||||
gasPrice,
|
||||
} = txParams
|
||||
dispatch(actions.setSelectedToken(address))
|
||||
dispatch(actions.updateSend({
|
||||
gasLimit,
|
||||
gasPrice,
|
||||
gasTotal: null,
|
||||
to,
|
||||
amount: tokenAmountInHex,
|
||||
errors: { to: null, amount: null },
|
||||
editingTransactionId: id && id.toString(),
|
||||
token: ownProps.token,
|
||||
}))
|
||||
dispatch(actions.showSendTokenPage())
|
||||
},
|
||||
showCustomizeGasModal: (txMeta, sendGasLimit, sendGasPrice, sendGasTotal) => {
|
||||
const { id, txParams, lastGasPrice } = txMeta
|
||||
const { gas: txGasLimit, gasPrice: txGasPrice } = txParams
|
||||
const tokenData = txParams.data && abiDecoder.decodeMethod(txParams.data)
|
||||
const { params = [] } = tokenData
|
||||
const { value: to } = params[0] || {}
|
||||
const { value: tokenAmountInDec } = params[1] || {}
|
||||
const tokenAmountInHex = conversionUtil(tokenAmountInDec, {
|
||||
fromNumericBase: 'dec',
|
||||
toNumericBase: 'hex',
|
||||
})
|
||||
|
||||
let forceGasMin
|
||||
if (lastGasPrice) {
|
||||
forceGasMin = ethUtil.addHexPrefix(multiplyCurrencies(lastGasPrice, 1.1, {
|
||||
multiplicandBase: 16,
|
||||
multiplierBase: 10,
|
||||
toNumericBase: 'hex',
|
||||
fromDenomination: 'WEI',
|
||||
}))
|
||||
}
|
||||
|
||||
dispatch(actions.updateSend({
|
||||
gasLimit: sendGasLimit || txGasLimit,
|
||||
gasPrice: sendGasPrice || txGasPrice,
|
||||
editingTransactionId: id,
|
||||
gasTotal: sendGasTotal,
|
||||
to,
|
||||
amount: tokenAmountInHex,
|
||||
forceGasMin,
|
||||
}))
|
||||
dispatch(actions.showModal({ name: 'CUSTOMIZE_GAS' }))
|
||||
},
|
||||
updateSendErrors: error => dispatch(updateSendErrors(error)),
|
||||
}
|
||||
}
|
||||
|
||||
inherits(ConfirmSendToken, Component)
|
||||
function ConfirmSendToken () {
|
||||
Component.call(this)
|
||||
this.state = {}
|
||||
this.onSubmit = this.onSubmit.bind(this)
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype.editTransaction = function (txMeta) {
|
||||
const { editTransaction, history } = this.props
|
||||
editTransaction(txMeta)
|
||||
history.push(SEND_ROUTE)
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype.updateComponentSendErrors = function (prevProps) {
|
||||
const {
|
||||
balance: oldBalance,
|
||||
conversionRate: oldConversionRate,
|
||||
} = prevProps
|
||||
const {
|
||||
updateSendErrors,
|
||||
balance,
|
||||
conversionRate,
|
||||
send: {
|
||||
errors: {
|
||||
simulationFails,
|
||||
},
|
||||
},
|
||||
} = this.props
|
||||
const txMeta = this.gatherTxMeta()
|
||||
|
||||
const shouldUpdateBalanceSendErrors = balance && [
|
||||
balance !== oldBalance,
|
||||
conversionRate !== oldConversionRate,
|
||||
].some(x => Boolean(x))
|
||||
|
||||
if (shouldUpdateBalanceSendErrors) {
|
||||
const balanceIsSufficient = this.isBalanceSufficient(txMeta)
|
||||
updateSendErrors({
|
||||
insufficientFunds: balanceIsSufficient ? false : this.context.t('insufficientFunds'),
|
||||
})
|
||||
}
|
||||
|
||||
const shouldUpdateSimulationSendError = Boolean(txMeta.simulationFails) !== Boolean(simulationFails)
|
||||
|
||||
if (shouldUpdateSimulationSendError) {
|
||||
updateSendErrors({
|
||||
simulationFails: !txMeta.simulationFails ? false : this.context.t('transactionError'),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype.componentWillMount = function () {
|
||||
const { tokenContract, selectedAddress } = this.props
|
||||
tokenContract && tokenContract
|
||||
.balanceOf(selectedAddress)
|
||||
.then(usersToken => {
|
||||
})
|
||||
this.updateComponentSendErrors({})
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype.componentDidUpdate = function (prevProps) {
|
||||
this.updateComponentSendErrors(prevProps)
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype.getAmount = function () {
|
||||
const {
|
||||
conversionRate,
|
||||
tokenExchangeRate,
|
||||
token,
|
||||
tokenData,
|
||||
send: { amount, editingTransactionId },
|
||||
} = this.props
|
||||
const { params = [] } = tokenData
|
||||
let { value } = params[1] || {}
|
||||
const { decimals } = token
|
||||
|
||||
if (editingTransactionId) {
|
||||
value = conversionUtil(amount, {
|
||||
fromNumericBase: 'hex',
|
||||
toNumericBase: 'dec',
|
||||
})
|
||||
}
|
||||
|
||||
const sendTokenAmount = calcTokenAmount(value, decimals)
|
||||
|
||||
return {
|
||||
fiat: tokenExchangeRate
|
||||
? +(sendTokenAmount * tokenExchangeRate * conversionRate).toFixed(2)
|
||||
: null,
|
||||
token: typeof value === 'undefined'
|
||||
? this.context.t('unknown')
|
||||
: +sendTokenAmount.toFixed(decimals),
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype.getGasFee = function () {
|
||||
const { conversionRate, tokenExchangeRate, token, currentCurrency } = this.props
|
||||
const txMeta = this.gatherTxMeta()
|
||||
const txParams = txMeta.txParams || {}
|
||||
const { decimals } = token
|
||||
|
||||
const gas = txParams.gas
|
||||
const gasPrice = txParams.gasPrice || MIN_GAS_PRICE_HEX
|
||||
const gasTotal = multiplyCurrencies(gas, gasPrice, {
|
||||
multiplicandBase: 16,
|
||||
multiplierBase: 16,
|
||||
})
|
||||
|
||||
const FIAT = conversionUtil(gasTotal, {
|
||||
fromNumericBase: 'BN',
|
||||
toNumericBase: 'dec',
|
||||
fromDenomination: 'WEI',
|
||||
fromCurrency: 'ETH',
|
||||
toCurrency: currentCurrency,
|
||||
numberOfDecimals: 2,
|
||||
conversionRate,
|
||||
})
|
||||
const ETH = conversionUtil(gasTotal, {
|
||||
fromNumericBase: 'BN',
|
||||
toNumericBase: 'dec',
|
||||
fromDenomination: 'WEI',
|
||||
fromCurrency: 'ETH',
|
||||
toCurrency: 'ETH',
|
||||
numberOfDecimals: 6,
|
||||
conversionRate,
|
||||
})
|
||||
const tokenGas = multiplyCurrencies(gas, gasPrice, {
|
||||
toNumericBase: 'dec',
|
||||
multiplicandBase: 16,
|
||||
multiplierBase: 16,
|
||||
toCurrency: 'BAT',
|
||||
conversionRate: tokenExchangeRate,
|
||||
invertConversionRate: true,
|
||||
fromDenomination: 'WEI',
|
||||
numberOfDecimals: decimals || 4,
|
||||
})
|
||||
|
||||
return {
|
||||
fiat: +Number(FIAT).toFixed(2),
|
||||
eth: ETH,
|
||||
token: tokenExchangeRate
|
||||
? tokenGas
|
||||
: null,
|
||||
gasFeeInHex: gasTotal.toString(16),
|
||||
}
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype.getData = function () {
|
||||
const { identities, tokenData } = this.props
|
||||
const { params = [] } = tokenData
|
||||
const { value } = params[0] || {}
|
||||
const txMeta = this.gatherTxMeta()
|
||||
const txParams = txMeta.txParams || {}
|
||||
|
||||
return {
|
||||
from: {
|
||||
address: txParams.from,
|
||||
name: identities[txParams.from].name,
|
||||
},
|
||||
to: {
|
||||
address: value,
|
||||
name: identities[value] ? identities[value].name : this.context.t('newRecipient'),
|
||||
},
|
||||
memo: txParams.memo || '',
|
||||
}
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype.renderHeroAmount = function () {
|
||||
const { token: { symbol }, currentCurrency } = this.props
|
||||
const { fiat: fiatAmount, token: tokenAmount } = this.getAmount()
|
||||
const txMeta = this.gatherTxMeta()
|
||||
const txParams = txMeta.txParams || {}
|
||||
const { memo = '' } = txParams
|
||||
|
||||
const convertedAmountInFiat = this.convertToRenderableCurrency(fiatAmount, currentCurrency)
|
||||
|
||||
return fiatAmount
|
||||
? (
|
||||
h('div.confirm-send-token__hero-amount-wrapper', [
|
||||
h('h3.flex-center.confirm-screen-send-amount', `${convertedAmountInFiat}`),
|
||||
h('h3.flex-center.confirm-screen-send-amount-currency', currentCurrency),
|
||||
h('div.flex-center.confirm-memo-wrapper', [
|
||||
h('h3.confirm-screen-send-memo', [ memo ? `"${memo}"` : '' ]),
|
||||
]),
|
||||
])
|
||||
)
|
||||
: (
|
||||
h('div.confirm-send-token__hero-amount-wrapper', [
|
||||
h('h3.flex-center.confirm-screen-send-amount', tokenAmount),
|
||||
h('h3.flex-center.confirm-screen-send-amount-currency', symbol),
|
||||
h('div.flex-center.confirm-memo-wrapper', [
|
||||
h('h3.confirm-screen-send-memo', [ memo ? `"${memo}"` : '' ]),
|
||||
]),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype.renderGasFee = function () {
|
||||
const {
|
||||
currentCurrency: convertedCurrency,
|
||||
conversionRate,
|
||||
send: { gasTotal, gasLimit: sendGasLimit, gasPrice: sendGasPrice },
|
||||
showCustomizeGasModal,
|
||||
} = this.props
|
||||
const txMeta = this.gatherTxMeta()
|
||||
const { gasFeeInHex } = this.getGasFee()
|
||||
|
||||
return (
|
||||
h('section.flex-row.flex-center.confirm-screen-row', [
|
||||
h('span.confirm-screen-label.confirm-screen-section-column', [ this.context.t('gasFee') ]),
|
||||
h('div.confirm-screen-section-column', [
|
||||
h(GasFeeDisplay, {
|
||||
gasTotal: gasTotal || gasFeeInHex,
|
||||
conversionRate,
|
||||
convertedCurrency,
|
||||
onClick: () => showCustomizeGasModal(txMeta, sendGasLimit, sendGasPrice, gasTotal),
|
||||
}),
|
||||
]),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype.renderTotalPlusGas = function () {
|
||||
const { token: { symbol }, currentCurrency, send: { errors } } = this.props
|
||||
const { fiat: fiatAmount, token: tokenAmount } = this.getAmount()
|
||||
const { fiat: fiatGas, token: tokenGas } = this.getGasFee()
|
||||
|
||||
const totalInFIAT = fiatAmount && fiatGas && addCurrencies(fiatAmount, fiatGas)
|
||||
const convertedTotalInFiat = this.convertToRenderableCurrency(totalInFIAT, currentCurrency)
|
||||
|
||||
return fiatAmount && fiatGas
|
||||
? (
|
||||
h('section.flex-row.flex-center.confirm-screen-row.confirm-screen-total-box ', [
|
||||
h('div.confirm-screen-section-column', [
|
||||
h('span.confirm-screen-label', [ this.context.t('total') + ' ' ]),
|
||||
h('div.confirm-screen-total-box__subtitle', [ this.context.t('amountPlusGas') ]),
|
||||
]),
|
||||
|
||||
h('div.confirm-screen-section-column', [
|
||||
h('div.confirm-screen-row-info', `${convertedTotalInFiat} ${currentCurrency}`),
|
||||
h('div.confirm-screen-row-detail', `${addCurrencies(tokenAmount, tokenGas || '0')} ${symbol}`),
|
||||
]),
|
||||
])
|
||||
)
|
||||
: (
|
||||
h('section.flex-row.flex-center.confirm-screen-row.confirm-screen-total-box ', [
|
||||
h('div', {
|
||||
className: classnames({
|
||||
'confirm-screen-section-column--with-error': errors['insufficientFunds'],
|
||||
'confirm-screen-section-column': !errors['insufficientFunds'],
|
||||
}),
|
||||
}, [
|
||||
h('span.confirm-screen-label', [ this.context.t('total') + ' ' ]),
|
||||
h('div.confirm-screen-total-box__subtitle', [ this.context.t('amountPlusGas') ]),
|
||||
]),
|
||||
|
||||
h('div.confirm-screen-section-column', [
|
||||
h('div.confirm-screen-row-info', `${tokenAmount} ${symbol}`),
|
||||
h('div.confirm-screen-row-detail', `+ ${fiatGas} ${currentCurrency} ${this.context.t('gas')}`),
|
||||
]),
|
||||
|
||||
this.renderErrorMessage('insufficientFunds'),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype.renderErrorMessage = function (message) {
|
||||
const { send: { errors } } = this.props
|
||||
|
||||
return errors[message]
|
||||
? h('div.confirm-screen-error', [ errors[message] ])
|
||||
: null
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype.convertToRenderableCurrency = function (value, currencyCode) {
|
||||
const upperCaseCurrencyCode = currencyCode.toUpperCase()
|
||||
|
||||
return currencies.find(currency => currency.code === upperCaseCurrencyCode)
|
||||
? currencyFormatter.format(Number(value), {
|
||||
code: upperCaseCurrencyCode,
|
||||
})
|
||||
: value
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype.renderHeaderRow = function (isTxReprice) {
|
||||
const windowType = window.METAMASK_UI_TYPE
|
||||
const isFullScreen = windowType !== ENVIRONMENT_TYPE_NOTIFICATION &&
|
||||
windowType !== ENVIRONMENT_TYPE_POPUP
|
||||
|
||||
if (isTxReprice && isFullScreen) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
h('.page-container__header-row', [
|
||||
h('span.page-container__back-button', {
|
||||
onClick: () => this.editTransaction(),
|
||||
style: {
|
||||
visibility: isTxReprice ? 'hidden' : 'initial',
|
||||
},
|
||||
}, 'Edit'),
|
||||
!isFullScreen && h(NetworkDisplay),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype.renderHeader = function (isTxReprice) {
|
||||
const title = isTxReprice ? this.context.t('speedUpTitle') : this.context.t('confirm')
|
||||
const subtitle = isTxReprice
|
||||
? this.context.t('speedUpSubtitle')
|
||||
: this.context.t('pleaseReviewTransaction')
|
||||
|
||||
return (
|
||||
h('.page-container__header', [
|
||||
this.renderHeaderRow(isTxReprice),
|
||||
h('.page-container__title', title),
|
||||
h('.page-container__subtitle', subtitle),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype.render = function () {
|
||||
const txMeta = this.gatherTxMeta()
|
||||
const {
|
||||
from: {
|
||||
address: fromAddress,
|
||||
name: fromName,
|
||||
},
|
||||
to: {
|
||||
address: toAddress,
|
||||
name: toName,
|
||||
},
|
||||
} = this.getData()
|
||||
|
||||
const isTxReprice = Boolean(txMeta.lastGasPrice)
|
||||
|
||||
return (
|
||||
h('div.confirm-screen-container.confirm-send-token', [
|
||||
// Main Send token Card
|
||||
h('div.page-container', [
|
||||
this.renderHeader(isTxReprice),
|
||||
h('.page-container__content', [
|
||||
h('div.flex-row.flex-center.confirm-screen-identicons', [
|
||||
h('div.confirm-screen-account-wrapper', [
|
||||
h(
|
||||
Identicon,
|
||||
{
|
||||
address: fromAddress,
|
||||
diameter: 60,
|
||||
},
|
||||
),
|
||||
h('span.confirm-screen-account-name', fromName),
|
||||
// h('span.confirm-screen-account-number', fromAddress.slice(fromAddress.length - 4)),
|
||||
]),
|
||||
h('i.fa.fa-arrow-right.fa-lg'),
|
||||
h('div.confirm-screen-account-wrapper', [
|
||||
h(
|
||||
Identicon,
|
||||
{
|
||||
address: toAddress,
|
||||
diameter: 60,
|
||||
},
|
||||
),
|
||||
h('span.confirm-screen-account-name', toName),
|
||||
// h('span.confirm-screen-account-number', toAddress.slice(toAddress.length - 4)),
|
||||
]),
|
||||
]),
|
||||
|
||||
// h('h3.flex-center.confirm-screen-sending-to-message', {
|
||||
// style: {
|
||||
// textAlign: 'center',
|
||||
// fontSize: '16px',
|
||||
// },
|
||||
// }, [
|
||||
// `You're sending to Recipient ...${toAddress.slice(toAddress.length - 4)}`,
|
||||
// ]),
|
||||
|
||||
this.renderHeroAmount(),
|
||||
|
||||
h('div.confirm-screen-rows', [
|
||||
h('section.flex-row.flex-center.confirm-screen-row', [
|
||||
h('span.confirm-screen-label.confirm-screen-section-column', [ this.context.t('from') ]),
|
||||
h('div.confirm-screen-section-column', [
|
||||
h('div.confirm-screen-row-info', fromName),
|
||||
h('div.confirm-screen-row-detail', `...${fromAddress.slice(fromAddress.length - 4)}`),
|
||||
]),
|
||||
]),
|
||||
|
||||
toAddress && h('section.flex-row.flex-center.confirm-screen-row', [
|
||||
h('span.confirm-screen-label.confirm-screen-section-column', [ this.context.t('to') ]),
|
||||
h('div.confirm-screen-section-column', [
|
||||
h('div.confirm-screen-row-info', toName),
|
||||
h('div.confirm-screen-row-detail', `...${toAddress.slice(toAddress.length - 4)}`),
|
||||
]),
|
||||
]),
|
||||
|
||||
this.renderGasFee(),
|
||||
|
||||
this.renderTotalPlusGas(),
|
||||
|
||||
]),
|
||||
|
||||
]),
|
||||
|
||||
h('form#pending-tx-form', {
|
||||
className: 'confirm-screen-form',
|
||||
onSubmit: this.onSubmit,
|
||||
}, [
|
||||
this.renderErrorMessage('simulationFails'),
|
||||
h('.page-container__footer', [
|
||||
// Cancel Button
|
||||
h('button.btn-cancel.page-container__footer-button.allcaps', {
|
||||
onClick: (event) => this.cancel(event, txMeta),
|
||||
}, this.context.t('cancel')),
|
||||
|
||||
// Accept Button
|
||||
h('button.btn-confirm.page-container__footer-button.allcaps', {
|
||||
onClick: event => this.onSubmit(event),
|
||||
}, [this.context.t('confirm')]),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype.onSubmit = function (event) {
|
||||
event.preventDefault()
|
||||
const { updateSendErrors } = this.props
|
||||
const txMeta = this.gatherTxMeta()
|
||||
const valid = this.checkValidity()
|
||||
const balanceIsSufficient = this.isBalanceSufficient(txMeta)
|
||||
this.setState({ valid, submitting: true })
|
||||
|
||||
if (valid && this.verifyGasParams() && balanceIsSufficient) {
|
||||
this.props.sendTransaction(txMeta, event)
|
||||
} else if (!balanceIsSufficient) {
|
||||
updateSendErrors({ insufficientFunds: 'insufficientFunds' })
|
||||
} else {
|
||||
updateSendErrors({ invalidGasParams: 'invalidGasParams' })
|
||||
this.setState({ submitting: false })
|
||||
}
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype.isBalanceSufficient = function (txMeta) {
|
||||
const {
|
||||
balance,
|
||||
conversionRate,
|
||||
} = this.props
|
||||
const {
|
||||
txParams: {
|
||||
gas,
|
||||
gasPrice,
|
||||
},
|
||||
} = txMeta
|
||||
const gasTotal = calcGasTotal(gas, gasPrice)
|
||||
|
||||
return isBalanceSufficient({
|
||||
amount: '0',
|
||||
gasTotal,
|
||||
balance,
|
||||
conversionRate,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
ConfirmSendToken.prototype.cancel = function (event, txMeta) {
|
||||
event.preventDefault()
|
||||
const { cancelTransaction } = this.props
|
||||
|
||||
cancelTransaction(txMeta)
|
||||
.then(() => this.props.history.push(DEFAULT_ROUTE))
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype.checkValidity = function () {
|
||||
const form = this.getFormEl()
|
||||
const valid = form.checkValidity()
|
||||
return valid
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype.getFormEl = function () {
|
||||
const form = document.querySelector('form#pending-tx-form')
|
||||
// Stub out form for unit tests:
|
||||
if (!form) {
|
||||
return { checkValidity () { return true } }
|
||||
}
|
||||
return form
|
||||
}
|
||||
|
||||
// After a customizable state value has been updated,
|
||||
ConfirmSendToken.prototype.gatherTxMeta = function () {
|
||||
const props = this.props
|
||||
const state = this.state
|
||||
const txData = clone(state.txData) || clone(props.txData)
|
||||
|
||||
const { gasPrice: sendGasPrice, gasLimit: sendGasLimit } = props.send
|
||||
const {
|
||||
lastGasPrice,
|
||||
txParams: {
|
||||
gasPrice: txGasPrice,
|
||||
gas: txGasLimit,
|
||||
},
|
||||
} = txData
|
||||
|
||||
let forceGasMin
|
||||
if (lastGasPrice) {
|
||||
forceGasMin = ethUtil.addHexPrefix(multiplyCurrencies(lastGasPrice, 1.1, {
|
||||
multiplicandBase: 16,
|
||||
multiplierBase: 10,
|
||||
toNumericBase: 'hex',
|
||||
}))
|
||||
}
|
||||
|
||||
txData.txParams.gasPrice = sendGasPrice || forceGasMin || txGasPrice
|
||||
txData.txParams.gas = sendGasLimit || txGasLimit
|
||||
|
||||
// log.debug(`UI has defaulted to tx meta ${JSON.stringify(txData)}`)
|
||||
return txData
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype.verifyGasParams = function () {
|
||||
// We call this in case the gas has not been modified at all
|
||||
if (!this.state) { return true }
|
||||
return (
|
||||
this._notZeroOrEmptyString(this.state.gas) &&
|
||||
this._notZeroOrEmptyString(this.state.gasPrice)
|
||||
)
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype._notZeroOrEmptyString = function (obj) {
|
||||
return obj !== '' && obj !== '0x0'
|
||||
}
|
||||
|
||||
ConfirmSendToken.prototype.bnMultiplyByFraction = function (targetBN, numerator, denominator) {
|
||||
const numBN = new BN(numerator)
|
||||
const denomBN = new BN(denominator)
|
||||
return targetBN.mul(numBN).div(denomBN)
|
||||
}
|
@ -1,165 +0,0 @@
|
||||
const Component = require('react').Component
|
||||
const connect = require('react-redux').connect
|
||||
const h = require('react-hyperscript')
|
||||
const PropTypes = require('prop-types')
|
||||
const clone = require('clone')
|
||||
const abi = require('human-standard-token-abi')
|
||||
const abiDecoder = require('abi-decoder')
|
||||
abiDecoder.addABI(abi)
|
||||
const inherits = require('util').inherits
|
||||
const actions = require('../../actions')
|
||||
const { getSymbolAndDecimals } = require('../../token-util')
|
||||
const ConfirmSendEther = require('./confirm-send-ether')
|
||||
const ConfirmSendToken = require('./confirm-send-token')
|
||||
const ConfirmDeployContract = require('./confirm-deploy-contract')
|
||||
const Loading = require('../loading-screen')
|
||||
|
||||
const TX_TYPES = {
|
||||
DEPLOY_CONTRACT: 'deploy_contract',
|
||||
SEND_ETHER: 'send_ether',
|
||||
SEND_TOKEN: 'send_token',
|
||||
}
|
||||
|
||||
module.exports = connect(mapStateToProps, mapDispatchToProps)(PendingTx)
|
||||
|
||||
function mapStateToProps (state) {
|
||||
const {
|
||||
conversionRate,
|
||||
identities,
|
||||
tokens: existingTokens,
|
||||
} = state.metamask
|
||||
const accounts = state.metamask.accounts
|
||||
const selectedAddress = state.metamask.selectedAddress || Object.keys(accounts)[0]
|
||||
return {
|
||||
conversionRate,
|
||||
identities,
|
||||
selectedAddress,
|
||||
existingTokens,
|
||||
}
|
||||
}
|
||||
|
||||
function mapDispatchToProps (dispatch) {
|
||||
return {
|
||||
backToAccountDetail: address => dispatch(actions.backToAccountDetail(address)),
|
||||
cancelTransaction: ({ id }) => dispatch(actions.cancelTx({ id })),
|
||||
}
|
||||
}
|
||||
|
||||
inherits(PendingTx, Component)
|
||||
function PendingTx () {
|
||||
Component.call(this)
|
||||
this.state = {
|
||||
isFetching: true,
|
||||
transactionType: '',
|
||||
tokenAddress: '',
|
||||
tokenSymbol: '',
|
||||
tokenDecimals: '',
|
||||
}
|
||||
}
|
||||
|
||||
PendingTx.prototype.componentDidMount = function () {
|
||||
this.setTokenData()
|
||||
}
|
||||
|
||||
PendingTx.prototype.componentDidUpdate = function (prevProps, prevState) {
|
||||
if (prevState.isFetching) {
|
||||
this.setTokenData()
|
||||
}
|
||||
}
|
||||
|
||||
PendingTx.prototype.setTokenData = async function () {
|
||||
const { existingTokens } = this.props
|
||||
const txMeta = this.gatherTxMeta()
|
||||
const txParams = txMeta.txParams || {}
|
||||
|
||||
if (txMeta.loadingDefaults) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!txParams.to) {
|
||||
return this.setState({
|
||||
transactionType: TX_TYPES.DEPLOY_CONTRACT,
|
||||
isFetching: false,
|
||||
})
|
||||
}
|
||||
|
||||
// inspect tx data for supported special confirmation screens
|
||||
let isTokenTransaction = false
|
||||
if (txParams.data) {
|
||||
const tokenData = abiDecoder.decodeMethod(txParams.data)
|
||||
const { name: tokenMethodName } = tokenData || {}
|
||||
isTokenTransaction = (tokenMethodName === 'transfer')
|
||||
}
|
||||
|
||||
if (isTokenTransaction) {
|
||||
const { symbol, decimals } = await getSymbolAndDecimals(txParams.to, existingTokens)
|
||||
|
||||
this.setState({
|
||||
transactionType: TX_TYPES.SEND_TOKEN,
|
||||
tokenAddress: txParams.to,
|
||||
tokenSymbol: symbol,
|
||||
tokenDecimals: decimals,
|
||||
isFetching: false,
|
||||
})
|
||||
} else {
|
||||
this.setState({
|
||||
transactionType: TX_TYPES.SEND_ETHER,
|
||||
isFetching: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
PendingTx.prototype.gatherTxMeta = function () {
|
||||
const props = this.props
|
||||
const state = this.state
|
||||
const txData = clone(state.txData) || clone(props.txData)
|
||||
|
||||
return txData
|
||||
}
|
||||
|
||||
PendingTx.prototype.render = function () {
|
||||
const {
|
||||
isFetching,
|
||||
transactionType,
|
||||
tokenAddress,
|
||||
tokenSymbol,
|
||||
tokenDecimals,
|
||||
} = this.state
|
||||
|
||||
const { sendTransaction } = this.props
|
||||
|
||||
if (isFetching) {
|
||||
return h(Loading, {
|
||||
loadingMessage: this.context.t('generatingTransaction'),
|
||||
})
|
||||
}
|
||||
|
||||
switch (transactionType) {
|
||||
case TX_TYPES.SEND_ETHER:
|
||||
return h(ConfirmSendEther, {
|
||||
txData: this.gatherTxMeta(),
|
||||
sendTransaction,
|
||||
})
|
||||
case TX_TYPES.SEND_TOKEN:
|
||||
return h(ConfirmSendToken, {
|
||||
txData: this.gatherTxMeta(),
|
||||
sendTransaction,
|
||||
token: {
|
||||
address: tokenAddress,
|
||||
symbol: tokenSymbol,
|
||||
decimals: tokenDecimals,
|
||||
},
|
||||
})
|
||||
case TX_TYPES.DEPLOY_CONTRACT:
|
||||
return h(ConfirmDeployContract, {
|
||||
txData: this.gatherTxMeta(),
|
||||
sendTransaction,
|
||||
})
|
||||
default:
|
||||
return h(Loading)
|
||||
}
|
||||
}
|
||||
|
||||
PendingTx.contextTypes = {
|
||||
t: PropTypes.func,
|
||||
}
|
@ -1,17 +1,10 @@
|
||||
import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import copyToClipboard from 'copy-to-clipboard'
|
||||
import { addressSlicer } from '../../util'
|
||||
|
||||
const Tooltip = require('../tooltip-v2.js')
|
||||
|
||||
const addressStripper = (address = '') => {
|
||||
if (address.length < 4) {
|
||||
return address
|
||||
}
|
||||
|
||||
return `${address.slice(0, 4)}...${address.slice(-4)}`
|
||||
}
|
||||
|
||||
class SelectedAccount extends Component {
|
||||
state = {
|
||||
copied: false,
|
||||
@ -48,7 +41,7 @@ class SelectedAccount extends Component {
|
||||
{ selectedIdentity.name }
|
||||
</div>
|
||||
<div className="selected-account__address">
|
||||
{ addressStripper(selectedAddress) }
|
||||
{ addressSlicer(selectedAddress) }
|
||||
</div>
|
||||
</div>
|
||||
</Tooltip>
|
||||
|
@ -2,7 +2,7 @@ import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { checksumAddress } from '../../../util'
|
||||
import Identicon from '../../identicon'
|
||||
import CurrencyDisplay from '../../send/currency-display'
|
||||
import CurrencyDisplay from '../currency-display'
|
||||
|
||||
export default class AccountListItem extends Component {
|
||||
|
@ -4,7 +4,7 @@ import { shallow } from 'enzyme'
|
||||
import sinon from 'sinon'
|
||||
import proxyquire from 'proxyquire'
|
||||
import Identicon from '../../../identicon'
|
||||
import CurrencyDisplay from '../../../send/currency-display'
|
||||
import CurrencyDisplay from '../../currency-display'
|
||||
|
||||
const utilsMethodStubs = {
|
||||
checksumAddress: sinon.stub().returns('mockCheckSumAddress'),
|
@ -1,11 +1,16 @@
|
||||
const Component = require('react').Component
|
||||
const h = require('react-hyperscript')
|
||||
const inherits = require('util').inherits
|
||||
const { conversionUtil, multiplyCurrencies } = require('../../conversion-util')
|
||||
const { removeLeadingZeroes } = require('../send_/send.utils')
|
||||
const { conversionUtil, multiplyCurrencies } = require('../../../conversion-util')
|
||||
const { removeLeadingZeroes } = require('../send.utils')
|
||||
const currencyFormatter = require('currency-formatter')
|
||||
const currencies = require('currency-formatter/currencies')
|
||||
const ethUtil = require('ethereumjs-util')
|
||||
const PropTypes = require('prop-types')
|
||||
|
||||
CurrencyDisplay.contextTypes = {
|
||||
t: PropTypes.func,
|
||||
}
|
||||
|
||||
module.exports = CurrencyDisplay
|
||||
|
||||
@ -75,6 +80,12 @@ CurrencyDisplay.prototype.getValueToRender = function ({ selectedToken, conversi
|
||||
CurrencyDisplay.prototype.getConvertedValueToRender = function (nonFormattedValue) {
|
||||
const { primaryCurrency, convertedCurrency, conversionRate } = this.props
|
||||
|
||||
if (conversionRate === 0 || conversionRate === null || conversionRate === undefined) {
|
||||
if (nonFormattedValue !== 0) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
let convertedValue = conversionUtil(nonFormattedValue, {
|
||||
fromNumericBase: 'dec',
|
||||
fromCurrency: primaryCurrency,
|
||||
@ -82,16 +93,15 @@ CurrencyDisplay.prototype.getConvertedValueToRender = function (nonFormattedValu
|
||||
numberOfDecimals: 2,
|
||||
conversionRate,
|
||||
})
|
||||
|
||||
convertedValue = Number(convertedValue).toFixed(2)
|
||||
|
||||
const upperCaseCurrencyCode = convertedCurrency.toUpperCase()
|
||||
|
||||
return currencies.find(currency => currency.code === upperCaseCurrencyCode)
|
||||
? currencyFormatter.format(Number(convertedValue), {
|
||||
code: upperCaseCurrencyCode,
|
||||
})
|
||||
: convertedValue
|
||||
}
|
||||
: convertedValue
|
||||
}
|
||||
|
||||
CurrencyDisplay.prototype.handleChange = function (newVal) {
|
||||
this.setState({ valueToRender: removeLeadingZeroes(newVal) })
|
||||
@ -105,13 +115,24 @@ CurrencyDisplay.prototype.getInputWidth = function (valueToRender, readOnly) {
|
||||
return (valueLength + decimalPointDeficit + 0.75) + 'ch'
|
||||
}
|
||||
|
||||
CurrencyDisplay.prototype.onlyRenderConversions = function (convertedValueToRender) {
|
||||
const {
|
||||
convertedBalanceClassName = 'currency-display__converted-value',
|
||||
convertedCurrency,
|
||||
} = this.props
|
||||
return h('div', {
|
||||
className: convertedBalanceClassName,
|
||||
}, convertedValueToRender == null
|
||||
? this.context.t('noConversionRateAvailable')
|
||||
: `${convertedValueToRender} ${convertedCurrency.toUpperCase()}`
|
||||
)
|
||||
}
|
||||
|
||||
CurrencyDisplay.prototype.render = function () {
|
||||
const {
|
||||
className = 'currency-display',
|
||||
primaryBalanceClassName = 'currency-display__input',
|
||||
convertedBalanceClassName = 'currency-display__converted-value',
|
||||
primaryCurrency,
|
||||
convertedCurrency,
|
||||
readOnly = false,
|
||||
inError = false,
|
||||
onBlur,
|
||||
@ -157,11 +178,7 @@ CurrencyDisplay.prototype.render = function () {
|
||||
|
||||
]),
|
||||
|
||||
]),
|
||||
|
||||
h('div', {
|
||||
className: convertedBalanceClassName,
|
||||
}, `${convertedValueToRender} ${convertedCurrency.toUpperCase()}`),
|
||||
]), this.onlyRenderConversions(convertedValueToRender),
|
||||
|
||||
])
|
||||
|
1
ui/app/components/send/currency-display/index.js
Normal file
1
ui/app/components/send/currency-display/index.js
Normal file
@ -0,0 +1 @@
|
||||
export { default } from './currency-display.js'
|
@ -2,7 +2,7 @@ import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import SendRowWrapper from '../send-row-wrapper/'
|
||||
import AmountMaxButton from './amount-max-button/'
|
||||
import CurrencyDisplay from '../../../send/currency-display'
|
||||
import CurrencyDisplay from '../../currency-display'
|
||||
|
||||
export default class SendAmountRow extends Component {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user