2020-01-09 04:34:58 +01:00
|
|
|
import EventEmitter from 'events'
|
|
|
|
|
|
|
|
import pump from 'pump'
|
|
|
|
import Dnode from 'dnode'
|
|
|
|
import extension from 'extensionizer'
|
|
|
|
import ObservableStore from 'obs-store'
|
|
|
|
import asStream from 'obs-store/lib/asStream'
|
|
|
|
import RpcEngine from 'json-rpc-engine'
|
2020-01-29 18:36:03 +01:00
|
|
|
import { debounce } from 'lodash'
|
2020-01-09 04:34:58 +01:00
|
|
|
import createEngineStream from 'json-rpc-middleware-stream/engineStream'
|
|
|
|
import createFilterMiddleware from 'eth-json-rpc-filters'
|
|
|
|
import createSubscriptionManager from 'eth-json-rpc-filters/subscriptionManager'
|
2020-08-18 21:18:25 +02:00
|
|
|
import providerAsMiddleware from 'eth-json-rpc-middleware/providerAsMiddleware'
|
|
|
|
import KeyringController from 'eth-keyring-controller'
|
|
|
|
import { Mutex } from 'await-semaphore'
|
|
|
|
import ethUtil from 'ethereumjs-util'
|
|
|
|
import log from 'loglevel'
|
|
|
|
import TrezorKeyring from 'eth-trezor-keyring'
|
|
|
|
import LedgerBridgeKeyring from '@metamask/eth-ledger-bridge-keyring'
|
|
|
|
import EthQuery from 'eth-query'
|
|
|
|
import nanoid from 'nanoid'
|
|
|
|
import contractMap from 'eth-contract-metadata'
|
|
|
|
import {
|
|
|
|
AddressBookController,
|
|
|
|
CurrencyRateController,
|
|
|
|
PhishingController,
|
|
|
|
} from '@metamask/controllers'
|
|
|
|
import ComposableObservableStore from './lib/ComposableObservableStore'
|
|
|
|
import AccountTracker from './lib/account-tracker'
|
2020-01-09 04:34:58 +01:00
|
|
|
import createLoggerMiddleware from './lib/createLoggerMiddleware'
|
2020-09-18 20:55:05 +02:00
|
|
|
import createMethodMiddleware from './lib/rpc-method-middleware'
|
2020-01-09 04:34:58 +01:00
|
|
|
import createOriginMiddleware from './lib/createOriginMiddleware'
|
2020-02-20 23:39:00 +01:00
|
|
|
import createTabIdMiddleware from './lib/createTabIdMiddleware'
|
2019-12-20 16:32:31 +01:00
|
|
|
import createOnboardingMiddleware from './lib/createOnboardingMiddleware'
|
2020-08-14 13:46:45 +02:00
|
|
|
import { setupMultiplex } from './lib/stream-utils'
|
2020-01-09 04:34:58 +01:00
|
|
|
import EnsController from './controllers/ens'
|
|
|
|
import NetworkController from './controllers/network'
|
|
|
|
import PreferencesController from './controllers/preferences'
|
|
|
|
import AppStateController from './controllers/app-state'
|
|
|
|
import CachedBalancesController from './controllers/cached-balances'
|
2020-05-08 21:45:52 +02:00
|
|
|
import AlertController from './controllers/alert'
|
2020-01-09 04:34:58 +01:00
|
|
|
import OnboardingController from './controllers/onboarding'
|
|
|
|
import ThreeBoxController from './controllers/threebox'
|
|
|
|
import IncomingTransactionsController from './controllers/incoming-transactions'
|
|
|
|
import MessageManager from './lib/message-manager'
|
2020-02-19 19:24:16 +01:00
|
|
|
import DecryptMessageManager from './lib/decrypt-message-manager'
|
|
|
|
import EncryptionPublicKeyManager from './lib/encryption-public-key-manager'
|
2020-01-09 04:34:58 +01:00
|
|
|
import PersonalMessageManager from './lib/personal-message-manager'
|
|
|
|
import TypedMessageManager from './lib/typed-message-manager'
|
|
|
|
import TransactionController from './controllers/transactions'
|
|
|
|
import TokenRatesController from './controllers/token-rates'
|
|
|
|
import DetectTokensController from './controllers/detect-tokens'
|
|
|
|
import { PermissionsController } from './controllers/permissions'
|
2020-03-16 18:13:22 +01:00
|
|
|
import getRestrictedMethods from './controllers/permissions/restrictedMethods'
|
2020-01-09 04:34:58 +01:00
|
|
|
import nodeify from './lib/nodeify'
|
|
|
|
import accountImporter from './account-import-strategies'
|
|
|
|
import selectChainId from './lib/select-chain-id'
|
|
|
|
import seedPhraseVerifier from './lib/seed-phrase-verifier'
|
|
|
|
|
2020-08-07 21:28:23 +02:00
|
|
|
import backgroundMetaMetricsEvent from './lib/background-metametrics'
|
2016-11-22 01:46:26 +01:00
|
|
|
|
2020-01-09 04:34:58 +01:00
|
|
|
export default class MetamaskController extends EventEmitter {
|
2016-06-24 22:05:21 +02:00
|
|
|
|
2018-03-15 23:27:10 +01:00
|
|
|
/**
|
|
|
|
* @constructor
|
2018-03-28 03:07:51 +02:00
|
|
|
* @param {Object} opts
|
2018-03-15 23:27:10 +01:00
|
|
|
*/
|
2019-07-31 22:17:11 +02:00
|
|
|
constructor (opts) {
|
2017-01-05 20:06:18 +01:00
|
|
|
super()
|
2017-06-16 03:00:24 +02:00
|
|
|
|
2018-01-25 21:28:11 +01:00
|
|
|
this.defaultMaxListeners = 20
|
|
|
|
|
2017-06-16 03:00:24 +02:00
|
|
|
this.sendUpdate = debounce(this.privateSendUpdate.bind(this), 200)
|
2016-06-25 02:00:35 +02:00
|
|
|
this.opts = opts
|
2020-08-18 18:36:45 +02:00
|
|
|
this.platform = opts.platform
|
2017-04-27 06:05:45 +02:00
|
|
|
const initState = opts.initState || {}
|
2017-11-28 20:14:57 +01:00
|
|
|
this.recordFirstTimeInfo(initState)
|
2017-01-12 04:04:19 +01:00
|
|
|
|
2018-08-22 01:30:11 +02:00
|
|
|
// this keeps track of how many "controllerStream" connections are open
|
|
|
|
// the only thing that uses controller connections are open metamask UI instances
|
|
|
|
this.activeControllerConnections = 0
|
|
|
|
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
this.getRequestAccountTabIds = opts.getRequestAccountTabIds
|
|
|
|
this.getOpenMetamaskTabsIds = opts.getOpenMetamaskTabsIds
|
|
|
|
|
2017-01-12 04:04:19 +01:00
|
|
|
// observable state store
|
2018-04-13 05:26:50 +02:00
|
|
|
this.store = new ComposableObservableStore(initState)
|
2017-01-28 01:11:59 +01:00
|
|
|
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
// external connections by origin
|
|
|
|
// Do not modify directly. Use the associated methods.
|
|
|
|
this.connections = {}
|
|
|
|
|
2017-11-20 22:47:35 +01:00
|
|
|
// lock to ensure only one vault created at once
|
|
|
|
this.createVaultMutex = new Mutex()
|
|
|
|
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
// next, we will initialize the controllers
|
2020-05-27 19:57:42 +02:00
|
|
|
// controller initialization order matters
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
|
2019-05-03 19:32:05 +02:00
|
|
|
this.networkController = new NetworkController(initState.NetworkController)
|
2020-09-10 18:16:00 +02:00
|
|
|
this.networkController.setInfuraProjectId(opts.infuraProjectId)
|
2017-06-22 21:32:08 +02:00
|
|
|
|
2017-01-30 22:01:07 +01:00
|
|
|
this.preferencesController = new PreferencesController({
|
|
|
|
initState: initState.PreferencesController,
|
2018-03-22 16:09:16 +01:00
|
|
|
initLangCode: opts.initLangCode,
|
2018-09-27 20:19:09 +02:00
|
|
|
openPopup: opts.openPopup,
|
2018-07-27 00:04:34 +02:00
|
|
|
network: this.networkController,
|
2017-01-30 21:42:24 +01:00
|
|
|
})
|
|
|
|
|
2019-05-13 18:16:09 +02:00
|
|
|
this.appStateController = new AppStateController({
|
2020-03-23 17:25:55 +01:00
|
|
|
addUnlockListener: this.on.bind(this, 'unlock'),
|
|
|
|
isUnlocked: this.isUnlocked.bind(this),
|
2019-11-26 22:24:53 +01:00
|
|
|
initState: initState.AppStateController,
|
2020-03-23 17:25:55 +01:00
|
|
|
onInactiveTimeout: () => this.setLocked(),
|
2020-05-05 16:03:21 +02:00
|
|
|
showUnlockRequest: opts.showUnlockRequest,
|
2020-03-23 17:25:55 +01:00
|
|
|
preferencesStore: this.preferencesController.store,
|
2019-05-13 18:16:09 +02:00
|
|
|
})
|
|
|
|
|
2019-06-01 00:14:22 +02:00
|
|
|
this.currencyRateController = new CurrencyRateController(undefined, initState.CurrencyController)
|
2017-02-03 08:32:24 +01:00
|
|
|
|
2019-05-06 18:12:52 +02:00
|
|
|
this.phishingController = new PhishingController()
|
2017-06-22 21:32:08 +02:00
|
|
|
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
// now we can initialize the RPC provider, which other controllers require
|
2018-08-17 18:56:07 +02:00
|
|
|
this.initializeProvider()
|
|
|
|
this.provider = this.networkController.getProviderAndBlockTracker().provider
|
|
|
|
this.blockTracker = this.networkController.getProviderAndBlockTracker().blockTracker
|
2017-01-27 00:09:31 +01:00
|
|
|
|
2018-04-16 17:21:06 +02:00
|
|
|
// token exchange rate tracker
|
|
|
|
this.tokenRatesController = new TokenRatesController({
|
2019-06-01 00:14:22 +02:00
|
|
|
currency: this.currencyRateController,
|
2018-04-16 17:21:06 +02:00
|
|
|
preferences: this.preferencesController.store,
|
|
|
|
})
|
|
|
|
|
2019-11-01 18:54:00 +01:00
|
|
|
this.ensController = new EnsController({
|
|
|
|
provider: this.provider,
|
|
|
|
networkStore: this.networkController.networkStore,
|
|
|
|
})
|
|
|
|
|
2019-08-16 20:54:10 +02:00
|
|
|
this.incomingTransactionsController = new IncomingTransactionsController({
|
|
|
|
blockTracker: this.blockTracker,
|
|
|
|
networkController: this.networkController,
|
|
|
|
preferencesController: this.preferencesController,
|
|
|
|
initState: initState.IncomingTransactionsController,
|
|
|
|
})
|
|
|
|
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
// account tracker watches balances, nonces, and any code at their address
|
2017-09-22 23:16:19 +02:00
|
|
|
this.accountTracker = new AccountTracker({
|
2017-02-03 07:05:06 +01:00
|
|
|
provider: this.provider,
|
2017-09-08 06:26:25 +02:00
|
|
|
blockTracker: this.blockTracker,
|
2019-02-20 20:12:12 +01:00
|
|
|
network: this.networkController,
|
2017-02-03 07:05:06 +01:00
|
|
|
})
|
2018-09-28 08:45:16 +02:00
|
|
|
|
2018-08-22 01:49:24 +02:00
|
|
|
// start and stop polling for balances based on activeControllerConnections
|
|
|
|
this.on('controllerConnectionChanged', (activeControllerConnections) => {
|
|
|
|
if (activeControllerConnections > 0) {
|
|
|
|
this.accountTracker.start()
|
2019-08-20 20:52:00 +02:00
|
|
|
this.incomingTransactionsController.start()
|
2020-06-05 20:36:55 +02:00
|
|
|
this.tokenRatesController.start()
|
2018-08-22 01:49:24 +02:00
|
|
|
} else {
|
|
|
|
this.accountTracker.stop()
|
2019-08-20 20:52:00 +02:00
|
|
|
this.incomingTransactionsController.stop()
|
2020-06-05 20:36:55 +02:00
|
|
|
this.tokenRatesController.stop()
|
2018-08-22 01:49:24 +02:00
|
|
|
}
|
|
|
|
})
|
2018-10-26 10:26:43 +02:00
|
|
|
|
2018-11-30 23:51:24 +01:00
|
|
|
this.cachedBalancesController = new CachedBalancesController({
|
|
|
|
accountTracker: this.accountTracker,
|
|
|
|
getNetwork: this.networkController.getNetworkState.bind(this.networkController),
|
|
|
|
initState: initState.CachedBalancesController,
|
|
|
|
})
|
|
|
|
|
2019-08-02 05:57:26 +02:00
|
|
|
this.onboardingController = new OnboardingController({
|
|
|
|
initState: initState.OnboardingController,
|
2019-11-22 18:03:51 +01:00
|
|
|
preferencesController: this.preferencesController,
|
2019-08-02 05:57:26 +02:00
|
|
|
})
|
|
|
|
|
2018-08-22 20:23:54 +02:00
|
|
|
// ensure accountTracker updates balances after network change
|
|
|
|
this.networkController.on('networkDidChange', () => {
|
|
|
|
this.accountTracker._updateAccounts()
|
|
|
|
})
|
2018-10-26 10:26:43 +02:00
|
|
|
|
2018-08-12 07:34:01 +02:00
|
|
|
const additionalKeyrings = [TrezorKeyring, LedgerBridgeKeyring]
|
2016-10-21 04:01:04 +02:00
|
|
|
this.keyringController = new KeyringController({
|
2018-06-10 09:52:32 +02:00
|
|
|
keyringTypes: additionalKeyrings,
|
2017-01-28 22:12:12 +01:00
|
|
|
initState: initState.KeyringController,
|
2017-05-18 23:54:02 +02:00
|
|
|
getNetwork: this.networkController.getNetworkState.bind(this.networkController),
|
2017-09-22 22:25:08 +02:00
|
|
|
encryptor: opts.encryptor || undefined,
|
2016-06-25 01:13:27 +02:00
|
|
|
})
|
2018-08-16 17:29:39 +02:00
|
|
|
this.keyringController.memStore.subscribe((s) => this._onKeyringControllerUpdate(s))
|
2020-03-23 17:25:55 +01:00
|
|
|
this.keyringController.on('unlock', () => this.emit('unlock'))
|
2017-01-27 00:09:31 +01:00
|
|
|
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
this.permissionsController = new PermissionsController({
|
2020-01-27 23:42:03 +01:00
|
|
|
getKeyringAccounts: this.keyringController.getAccounts.bind(this.keyringController),
|
2020-03-23 17:25:55 +01:00
|
|
|
getRestrictedMethods,
|
|
|
|
getUnlockPromise: this.appStateController.getUnlockPromise.bind(this.appStateController),
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
notifyDomain: this.notifyConnections.bind(this),
|
|
|
|
notifyAllDomains: this.notifyAllConnections.bind(this),
|
2020-04-16 18:16:53 +02:00
|
|
|
preferences: this.preferencesController.store,
|
2020-04-07 20:38:15 +02:00
|
|
|
showPermissionRequest: opts.showPermissionRequest,
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
}, initState.PermissionsController, initState.PermissionsMetadata)
|
|
|
|
|
2018-07-20 01:46:46 +02:00
|
|
|
this.detectTokensController = new DetectTokensController({
|
|
|
|
preferences: this.preferencesController,
|
|
|
|
network: this.networkController,
|
|
|
|
keyringMemStore: this.keyringController.memStore,
|
|
|
|
})
|
|
|
|
|
2019-03-12 05:40:41 +01:00
|
|
|
this.addressBookController = new AddressBookController(undefined, initState.AddressBookController)
|
2017-03-10 19:34:46 +01:00
|
|
|
|
2020-05-12 15:01:52 +02:00
|
|
|
this.alertController = new AlertController({
|
|
|
|
initState: initState.AlertController,
|
|
|
|
preferencesStore: this.preferencesController.store,
|
|
|
|
})
|
2020-05-08 21:45:52 +02:00
|
|
|
|
2020-08-18 18:36:45 +02:00
|
|
|
const version = this.platform.getVersion()
|
2019-09-16 19:11:01 +02:00
|
|
|
this.threeBoxController = new ThreeBoxController({
|
|
|
|
preferencesController: this.preferencesController,
|
|
|
|
addressBookController: this.addressBookController,
|
|
|
|
keyringController: this.keyringController,
|
|
|
|
initState: initState.ThreeBoxController,
|
|
|
|
getKeyringControllerState: this.keyringController.memStore.getState.bind(this.keyringController.memStore),
|
|
|
|
version,
|
|
|
|
})
|
|
|
|
|
2017-05-16 19:27:41 +02:00
|
|
|
this.txController = new TransactionController({
|
|
|
|
initState: initState.TransactionController || initState.TransactionManager,
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
getPermittedAccounts: this.permissionsController.getAccounts.bind(this.permissionsController),
|
2017-05-18 23:54:02 +02:00
|
|
|
networkStore: this.networkController.networkStore,
|
2017-02-03 06:09:17 +01:00
|
|
|
preferencesStore: this.preferencesController.store,
|
2016-12-16 19:33:36 +01:00
|
|
|
txHistoryLimit: 40,
|
2017-05-18 23:54:02 +02:00
|
|
|
getNetwork: this.networkController.getNetworkState.bind(this),
|
2017-01-13 11:00:11 +01:00
|
|
|
signTransaction: this.keyringController.signTransaction.bind(this.keyringController),
|
2016-12-16 19:33:36 +01:00
|
|
|
provider: this.provider,
|
2017-09-08 06:26:25 +02:00
|
|
|
blockTracker: this.blockTracker,
|
2016-12-16 19:33:36 +01:00
|
|
|
})
|
2018-09-10 02:33:09 +02:00
|
|
|
this.txController.on('newUnapprovedTx', () => opts.showUnapprovedTx())
|
2017-01-28 01:11:59 +01:00
|
|
|
|
2019-04-29 08:18:40 +02:00
|
|
|
this.txController.on(`tx:status-update`, async (txId, status) => {
|
2018-07-20 19:58:26 +02:00
|
|
|
if (status === 'confirmed' || status === 'failed') {
|
2018-07-20 13:20:40 +02:00
|
|
|
const txMeta = this.txController.txStateManager.getTx(txId)
|
|
|
|
this.platform.showTransactionNotification(txMeta)
|
2019-04-29 08:18:40 +02:00
|
|
|
|
|
|
|
const { txReceipt } = txMeta
|
2020-08-07 21:28:23 +02:00
|
|
|
if (txReceipt && txReceipt.status === '0x0') {
|
|
|
|
this.sendBackgroundMetaMetrics({
|
|
|
|
action: 'Transactions',
|
|
|
|
name: 'On Chain Failure',
|
|
|
|
customVariables: { errorMessage: txMeta.simulationFails?.reason },
|
2019-04-29 08:18:40 +02:00
|
|
|
})
|
|
|
|
}
|
2018-07-20 13:20:40 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2017-09-14 00:02:05 +02:00
|
|
|
this.networkController.on('networkDidChange', () => {
|
2020-07-08 23:44:38 +02:00
|
|
|
this.setCurrentCurrency(
|
|
|
|
this.currencyRateController.state.currentCurrency,
|
|
|
|
(error) => {
|
|
|
|
if (error) {
|
|
|
|
throw error
|
|
|
|
}
|
2020-07-14 17:20:41 +02:00
|
|
|
},
|
2020-07-08 23:44:38 +02:00
|
|
|
)
|
2017-09-14 00:02:05 +02:00
|
|
|
})
|
2017-09-13 00:06:19 +02:00
|
|
|
|
2017-05-18 23:54:02 +02:00
|
|
|
this.networkController.lookupNetwork()
|
2017-01-28 01:11:59 +01:00
|
|
|
this.messageManager = new MessageManager()
|
2017-02-21 23:25:47 +01:00
|
|
|
this.personalMessageManager = new PersonalMessageManager()
|
2020-02-19 19:24:16 +01:00
|
|
|
this.decryptMessageManager = new DecryptMessageManager()
|
|
|
|
this.encryptionPublicKeyManager = new EncryptionPublicKeyManager()
|
2018-09-10 23:11:57 +02:00
|
|
|
this.typedMessageManager = new TypedMessageManager({ networkController: this.networkController })
|
2019-05-03 19:32:05 +02:00
|
|
|
|
2018-04-13 05:26:50 +02:00
|
|
|
this.store.updateStructure({
|
2019-05-13 18:16:09 +02:00
|
|
|
AppStateController: this.appStateController.store,
|
2018-04-13 05:26:50 +02:00
|
|
|
TransactionController: this.txController.store,
|
|
|
|
KeyringController: this.keyringController.store,
|
|
|
|
PreferencesController: this.preferencesController.store,
|
2019-03-12 05:40:41 +01:00
|
|
|
AddressBookController: this.addressBookController,
|
2019-06-01 00:14:22 +02:00
|
|
|
CurrencyController: this.currencyRateController,
|
2018-04-13 05:26:50 +02:00
|
|
|
NetworkController: this.networkController.store,
|
2018-11-30 23:51:24 +01:00
|
|
|
CachedBalancesController: this.cachedBalancesController.store,
|
2020-05-08 21:45:52 +02:00
|
|
|
AlertController: this.alertController.store,
|
2019-08-02 05:57:26 +02:00
|
|
|
OnboardingController: this.onboardingController.store,
|
2019-08-16 20:54:10 +02:00
|
|
|
IncomingTransactionsController: this.incomingTransactionsController.store,
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
PermissionsController: this.permissionsController.permissions,
|
|
|
|
PermissionsMetadata: this.permissionsController.store,
|
|
|
|
ThreeBoxController: this.threeBoxController.store,
|
2017-05-18 23:54:02 +02:00
|
|
|
})
|
2018-01-31 19:49:58 +01:00
|
|
|
|
2018-04-13 05:26:50 +02:00
|
|
|
this.memStore = new ComposableObservableStore(null, {
|
2019-05-13 18:16:09 +02:00
|
|
|
AppStateController: this.appStateController.store,
|
2018-04-13 05:26:50 +02:00
|
|
|
NetworkController: this.networkController.store,
|
|
|
|
AccountTracker: this.accountTracker.store,
|
|
|
|
TxController: this.txController.memStore,
|
2018-11-30 23:51:24 +01:00
|
|
|
CachedBalancesController: this.cachedBalancesController.store,
|
2018-04-16 17:21:06 +02:00
|
|
|
TokenRatesController: this.tokenRatesController.store,
|
2018-04-13 05:26:50 +02:00
|
|
|
MessageManager: this.messageManager.memStore,
|
|
|
|
PersonalMessageManager: this.personalMessageManager.memStore,
|
2020-02-19 19:24:16 +01:00
|
|
|
DecryptMessageManager: this.decryptMessageManager.memStore,
|
|
|
|
EncryptionPublicKeyManager: this.encryptionPublicKeyManager.memStore,
|
2018-04-13 05:26:50 +02:00
|
|
|
TypesMessageManager: this.typedMessageManager.memStore,
|
|
|
|
KeyringController: this.keyringController.memStore,
|
|
|
|
PreferencesController: this.preferencesController.store,
|
2019-03-12 05:40:41 +01:00
|
|
|
AddressBookController: this.addressBookController,
|
2019-06-01 00:14:22 +02:00
|
|
|
CurrencyController: this.currencyRateController,
|
2020-05-08 21:45:52 +02:00
|
|
|
AlertController: this.alertController.store,
|
2019-08-02 05:57:26 +02:00
|
|
|
OnboardingController: this.onboardingController.store,
|
2019-08-16 20:54:10 +02:00
|
|
|
IncomingTransactionsController: this.incomingTransactionsController.store,
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
PermissionsController: this.permissionsController.permissions,
|
|
|
|
PermissionsMetadata: this.permissionsController.store,
|
2019-09-16 19:11:01 +02:00
|
|
|
ThreeBoxController: this.threeBoxController.store,
|
2019-11-01 18:54:00 +01:00
|
|
|
// ENS Controller
|
|
|
|
EnsController: this.ensController.store,
|
2017-06-22 21:32:08 +02:00
|
|
|
})
|
2018-04-13 05:26:50 +02:00
|
|
|
this.memStore.subscribe(this.sendUpdate.bind(this))
|
2020-05-15 21:40:06 +02:00
|
|
|
|
|
|
|
const password = process.env.CONF?.password
|
|
|
|
if (
|
|
|
|
password && !this.isUnlocked() &&
|
|
|
|
this.onboardingController.completedOnboarding
|
|
|
|
) {
|
|
|
|
this.submitPassword(password)
|
|
|
|
}
|
2016-06-24 22:05:21 +02:00
|
|
|
}
|
|
|
|
|
2018-03-15 23:27:10 +01:00
|
|
|
/**
|
|
|
|
* Constructor helper: initialize a provider.
|
|
|
|
*/
|
2017-10-19 00:09:32 +02:00
|
|
|
initializeProvider () {
|
2020-08-18 18:36:45 +02:00
|
|
|
const version = this.platform.getVersion()
|
2017-10-19 00:09:32 +02:00
|
|
|
const providerOpts = {
|
|
|
|
static: {
|
|
|
|
eth_syncing: false,
|
|
|
|
web3_clientVersion: `MetaMask/v${version}`,
|
|
|
|
},
|
2018-09-25 21:14:37 +02:00
|
|
|
version,
|
2017-10-19 00:09:32 +02:00
|
|
|
// account mgmt
|
2018-09-27 20:19:09 +02:00
|
|
|
getAccounts: async ({ origin }) => {
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
if (origin === 'metamask') {
|
|
|
|
const selectedAddress = this.preferencesController.getSelectedAddress()
|
|
|
|
return selectedAddress ? [selectedAddress] : []
|
2020-03-23 17:25:55 +01:00
|
|
|
} else if (this.isUnlocked()) {
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
return await this.permissionsController.getAccounts(origin)
|
2017-10-19 00:09:32 +02:00
|
|
|
}
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
return [] // changing this is a breaking change
|
2017-10-19 00:09:32 +02:00
|
|
|
},
|
|
|
|
// tx signing
|
2018-08-17 18:56:07 +02:00
|
|
|
processTransaction: this.newUnapprovedTransaction.bind(this),
|
|
|
|
// msg signing
|
|
|
|
processEthSignMessage: this.newUnsignedMessage.bind(this),
|
2018-10-25 05:03:55 +02:00
|
|
|
processTypedMessage: this.newUnsignedTypedMessage.bind(this),
|
|
|
|
processTypedMessageV3: this.newUnsignedTypedMessage.bind(this),
|
2019-08-20 21:52:59 +02:00
|
|
|
processTypedMessageV4: this.newUnsignedTypedMessage.bind(this),
|
2017-10-19 00:09:32 +02:00
|
|
|
processPersonalMessage: this.newUnsignedPersonalMessage.bind(this),
|
2020-02-19 19:24:16 +01:00
|
|
|
processDecryptMessage: this.newRequestDecryptMessage.bind(this),
|
|
|
|
processEncryptionPublicKey: this.newRequestEncryptionPublicKey.bind(this),
|
2018-09-21 19:34:21 +02:00
|
|
|
getPendingNonce: this.getPendingNonce.bind(this),
|
2019-10-30 23:15:54 +01:00
|
|
|
getPendingTransactionByHash: (hash) => this.txController.getFilteredTxList({ hash, status: 'submitted' })[0],
|
2017-10-19 00:09:32 +02:00
|
|
|
}
|
|
|
|
const providerProxy = this.networkController.initializeProvider(providerOpts)
|
|
|
|
return providerProxy
|
|
|
|
}
|
|
|
|
|
2018-03-15 23:27:10 +01:00
|
|
|
/**
|
2018-03-16 01:29:53 +01:00
|
|
|
* Constructor helper: initialize a public config store.
|
2018-04-19 02:54:50 +02:00
|
|
|
* This store is used to make some config info available to Dapps synchronously.
|
2018-03-15 23:27:10 +01:00
|
|
|
*/
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
createPublicConfigStore () {
|
2019-05-03 19:32:05 +02:00
|
|
|
// subset of state for metamask inpage provider
|
2017-05-05 02:56:30 +02:00
|
|
|
const publicConfigStore = new ObservableStore()
|
2017-05-05 02:50:59 +02:00
|
|
|
|
2019-05-03 19:32:05 +02:00
|
|
|
// setup memStore subscription hooks
|
|
|
|
this.on('update', updatePublicConfigStore)
|
|
|
|
updatePublicConfigStore(this.getState())
|
|
|
|
|
|
|
|
publicConfigStore.destroy = () => {
|
2019-05-15 10:53:09 +02:00
|
|
|
this.removeEventListener && this.removeEventListener('update', updatePublicConfigStore)
|
2019-05-03 19:32:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function updatePublicConfigStore (memState) {
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
publicConfigStore.putState(selectPublicState(memState))
|
2019-05-03 19:32:05 +02:00
|
|
|
}
|
2017-05-05 02:50:59 +02:00
|
|
|
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
function selectPublicState ({ isUnlocked, network, provider }) {
|
|
|
|
return {
|
2019-05-03 19:32:05 +02:00
|
|
|
isUnlocked,
|
|
|
|
networkVersion: network,
|
2019-09-10 02:31:34 +02:00
|
|
|
chainId: selectChainId({ network, provider }),
|
2017-05-05 02:50:59 +02:00
|
|
|
}
|
2017-01-27 06:19:09 +01:00
|
|
|
}
|
|
|
|
return publicConfigStore
|
|
|
|
}
|
|
|
|
|
2019-07-31 22:17:11 +02:00
|
|
|
//=============================================================================
|
|
|
|
// EXPOSED TO THE UI SUBSYSTEM
|
|
|
|
//=============================================================================
|
2017-01-27 06:19:09 +01:00
|
|
|
|
2018-03-15 23:27:10 +01:00
|
|
|
/**
|
2018-03-16 01:29:53 +01:00
|
|
|
* The metamask-state of the various controllers, made available to the UI
|
2018-03-28 03:07:51 +02:00
|
|
|
*
|
2020-01-13 19:36:36 +01:00
|
|
|
* @returns {Object} - status
|
2018-03-15 23:27:10 +01:00
|
|
|
*/
|
2016-06-25 00:52:56 +02:00
|
|
|
getState () {
|
2020-08-18 22:06:58 +02:00
|
|
|
const { vault } = this.keyringController.store.getState()
|
2020-08-19 18:27:05 +02:00
|
|
|
const isInitialized = Boolean(vault)
|
2017-09-13 23:20:19 +02:00
|
|
|
|
2018-04-13 05:26:50 +02:00
|
|
|
return {
|
|
|
|
...{ isInitialized },
|
|
|
|
...this.memStore.getFlatState(),
|
|
|
|
}
|
2016-06-24 22:05:21 +02:00
|
|
|
}
|
|
|
|
|
2018-03-15 23:27:10 +01:00
|
|
|
/**
|
2018-04-20 18:26:24 +02:00
|
|
|
* Returns an Object containing API Callback Functions.
|
|
|
|
* These functions are the interface for the UI.
|
|
|
|
* The API object can be transmitted over a stream with dnode.
|
2018-03-28 03:07:51 +02:00
|
|
|
*
|
2020-01-13 19:36:36 +01:00
|
|
|
* @returns {Object} - Object containing API functions.
|
2018-03-15 23:27:10 +01:00
|
|
|
*/
|
2016-06-25 00:52:56 +02:00
|
|
|
getApi () {
|
2020-08-18 22:06:58 +02:00
|
|
|
const {
|
|
|
|
keyringController,
|
|
|
|
networkController,
|
|
|
|
onboardingController,
|
|
|
|
alertController,
|
|
|
|
permissionsController,
|
|
|
|
preferencesController,
|
|
|
|
threeBoxController,
|
|
|
|
txController,
|
|
|
|
} = this
|
2016-06-24 22:05:21 +02:00
|
|
|
|
|
|
|
return {
|
2017-01-27 07:30:12 +01:00
|
|
|
// etc
|
2017-04-27 06:05:45 +02:00
|
|
|
getState: (cb) => cb(null, this.getState()),
|
|
|
|
setCurrentCurrency: this.setCurrentCurrency.bind(this),
|
2017-11-24 18:35:17 +01:00
|
|
|
setUseBlockie: this.setUseBlockie.bind(this),
|
2019-09-27 06:30:36 +02:00
|
|
|
setUseNonceField: this.setUseNonceField.bind(this),
|
2020-02-27 07:29:41 +01:00
|
|
|
setUsePhishDetect: this.setUsePhishDetect.bind(this),
|
2019-12-12 20:28:07 +01:00
|
|
|
setIpfsGateway: this.setIpfsGateway.bind(this),
|
2019-03-05 16:45:01 +01:00
|
|
|
setParticipateInMetaMetrics: this.setParticipateInMetaMetrics.bind(this),
|
|
|
|
setMetaMetricsSendCount: this.setMetaMetricsSendCount.bind(this),
|
|
|
|
setFirstTimeFlowType: this.setFirstTimeFlowType.bind(this),
|
2018-03-16 01:29:45 +01:00
|
|
|
setCurrentLocale: this.setCurrentLocale.bind(this),
|
2018-02-08 01:38:55 +01:00
|
|
|
markPasswordForgotten: this.markPasswordForgotten.bind(this),
|
|
|
|
unMarkPasswordForgotten: this.unMarkPasswordForgotten.bind(this),
|
2020-06-08 20:06:37 +02:00
|
|
|
safelistPhishingDomain: this.safelistPhishingDomain.bind(this),
|
|
|
|
getRequestAccountTabIds: (cb) => cb(null, this.getRequestAccountTabIds()),
|
|
|
|
getOpenMetamaskTabsIds: (cb) => cb(null, this.getOpenMetamaskTabsIds()),
|
2017-01-28 01:11:59 +01:00
|
|
|
|
2017-01-27 07:30:12 +01:00
|
|
|
// primary HD keyring management
|
2017-10-19 21:15:26 +02:00
|
|
|
addNewAccount: nodeify(this.addNewAccount, this),
|
2018-03-06 15:56:27 +01:00
|
|
|
verifySeedPhrase: nodeify(this.verifySeedPhrase, this),
|
2018-03-28 03:07:51 +02:00
|
|
|
resetAccount: nodeify(this.resetAccount, this),
|
2018-07-11 06:20:40 +02:00
|
|
|
removeAccount: nodeify(this.removeAccount, this),
|
2018-05-29 07:58:14 +02:00
|
|
|
importAccountWithStrategy: nodeify(this.importAccountWithStrategy, this),
|
2017-01-27 07:30:12 +01:00
|
|
|
|
2018-07-12 03:21:36 +02:00
|
|
|
// hardware wallets
|
2018-06-10 09:52:32 +02:00
|
|
|
connectHardware: nodeify(this.connectHardware, this),
|
2018-07-12 03:21:36 +02:00
|
|
|
forgetDevice: nodeify(this.forgetDevice, this),
|
|
|
|
checkHardwareStatus: nodeify(this.checkHardwareStatus, this),
|
2018-08-11 03:54:34 +02:00
|
|
|
unlockHardwareWalletAccount: nodeify(this.unlockHardwareWalletAccount, this),
|
2018-06-10 09:52:32 +02:00
|
|
|
|
2019-02-25 20:10:13 +01:00
|
|
|
// mobile
|
|
|
|
fetchInfoToSync: nodeify(this.fetchInfoToSync, this),
|
|
|
|
|
2017-01-27 07:30:12 +01:00
|
|
|
// vault management
|
2018-06-04 22:43:26 +02:00
|
|
|
submitPassword: nodeify(this.submitPassword, this),
|
2020-07-25 00:47:40 +02:00
|
|
|
verifyPassword: nodeify(this.verifyPassword, this),
|
2017-01-27 07:30:12 +01:00
|
|
|
|
2017-09-30 01:09:38 +02:00
|
|
|
// network management
|
|
|
|
setProviderType: nodeify(networkController.setProviderType, networkController),
|
|
|
|
setCustomRpc: nodeify(this.setCustomRpc, this),
|
2019-01-29 19:13:51 +01:00
|
|
|
updateAndSetCustomRpc: nodeify(this.updateAndSetCustomRpc, this),
|
2018-09-28 21:53:58 +02:00
|
|
|
delCustomRpc: nodeify(this.delCustomRpc, this),
|
2017-09-30 01:09:38 +02:00
|
|
|
|
2017-01-30 22:01:07 +01:00
|
|
|
// PreferencesController
|
2017-07-13 00:06:49 +02:00
|
|
|
setSelectedAddress: nodeify(preferencesController.setSelectedAddress, preferencesController),
|
|
|
|
addToken: nodeify(preferencesController.addToken, preferencesController),
|
2017-10-03 19:25:52 +02:00
|
|
|
removeToken: nodeify(preferencesController.removeToken, preferencesController),
|
2018-08-04 01:24:12 +02:00
|
|
|
removeSuggestedTokens: nodeify(preferencesController.removeSuggestedTokens, preferencesController),
|
2018-04-19 05:33:51 +02:00
|
|
|
setAccountLabel: nodeify(preferencesController.setAccountLabel, preferencesController),
|
2017-11-14 17:04:55 +01:00
|
|
|
setFeatureFlag: nodeify(preferencesController.setFeatureFlag, preferencesController),
|
2018-10-17 01:03:29 +02:00
|
|
|
setPreference: nodeify(preferencesController.setPreference, preferencesController),
|
2019-01-23 16:25:34 +01:00
|
|
|
completeOnboarding: nodeify(preferencesController.completeOnboarding, preferencesController),
|
2019-01-22 19:22:56 +01:00
|
|
|
addKnownMethodData: nodeify(preferencesController.addKnownMethodData, preferencesController),
|
2017-01-30 22:01:07 +01:00
|
|
|
|
2017-03-10 00:10:27 +01:00
|
|
|
// AddressController
|
2019-08-14 01:13:05 +02:00
|
|
|
setAddressBook: nodeify(this.addressBookController.set, this.addressBookController),
|
2020-09-11 14:28:51 +02:00
|
|
|
removeFromAddressBook: nodeify(this.addressBookController.delete, this.addressBookController),
|
2017-03-10 00:10:27 +01:00
|
|
|
|
2019-05-13 18:16:09 +02:00
|
|
|
// AppStateController
|
|
|
|
setLastActiveTime: nodeify(this.appStateController.setLastActiveTime, this.appStateController),
|
2020-05-25 21:01:28 +02:00
|
|
|
setDefaultHomeActiveTabName: nodeify(this.appStateController.setDefaultHomeActiveTabName, this.appStateController),
|
2020-04-22 19:11:36 +02:00
|
|
|
setConnectedStatusPopoverHasBeenShown: nodeify(this.appStateController.setConnectedStatusPopoverHasBeenShown, this.appStateController),
|
2019-05-13 18:16:09 +02:00
|
|
|
|
2019-11-01 18:54:00 +01:00
|
|
|
// EnsController
|
|
|
|
tryReverseResolveAddress: nodeify(this.ensController.reverseResolveAddress, this.ensController),
|
|
|
|
|
2017-01-27 07:30:12 +01:00
|
|
|
// KeyringController
|
2018-10-29 21:55:13 +01:00
|
|
|
setLocked: nodeify(this.setLocked, this),
|
2017-10-17 22:25:27 +02:00
|
|
|
createNewVaultAndKeychain: nodeify(this.createNewVaultAndKeychain, this),
|
|
|
|
createNewVaultAndRestore: nodeify(this.createNewVaultAndRestore, this),
|
2017-07-13 00:06:49 +02:00
|
|
|
exportAccount: nodeify(keyringController.exportAccount, keyringController),
|
2017-01-27 07:30:12 +01:00
|
|
|
|
2017-05-16 19:27:41 +02:00
|
|
|
// txController
|
2017-07-26 20:56:52 +02:00
|
|
|
cancelTransaction: nodeify(txController.cancelTransaction, txController),
|
2017-12-20 18:17:16 +01:00
|
|
|
updateTransaction: nodeify(txController.updateTransaction, txController),
|
2017-07-13 00:06:49 +02:00
|
|
|
updateAndApproveTransaction: nodeify(txController.updateAndApproveTransaction, txController),
|
2018-09-09 19:07:23 +02:00
|
|
|
createCancelTransaction: nodeify(this.createCancelTransaction, this),
|
2018-10-26 06:42:59 +02:00
|
|
|
createSpeedUpTransaction: nodeify(this.createSpeedUpTransaction, this),
|
2018-05-22 01:00:44 +02:00
|
|
|
getFilteredTxList: nodeify(txController.getFilteredTxList, txController),
|
2018-05-23 18:43:25 +02:00
|
|
|
isNonceTaken: nodeify(txController.isNonceTaken, txController),
|
|
|
|
estimateGas: nodeify(this.estimateGas, this),
|
2019-09-27 06:30:36 +02:00
|
|
|
getPendingNonce: nodeify(this.getPendingNonce, this),
|
2019-10-02 20:12:04 +02:00
|
|
|
getNextNonce: nodeify(this.getNextNonce, this),
|
2017-02-03 05:20:13 +01:00
|
|
|
|
|
|
|
// messageManager
|
2017-07-13 00:06:49 +02:00
|
|
|
signMessage: nodeify(this.signMessage, this),
|
2017-04-27 06:05:45 +02:00
|
|
|
cancelMessage: this.cancelMessage.bind(this),
|
2017-01-27 07:30:12 +01:00
|
|
|
|
2017-02-23 01:23:13 +01:00
|
|
|
// personalMessageManager
|
2017-07-13 00:06:49 +02:00
|
|
|
signPersonalMessage: nodeify(this.signPersonalMessage, this),
|
2017-04-27 06:05:45 +02:00
|
|
|
cancelPersonalMessage: this.cancelPersonalMessage.bind(this),
|
2017-01-27 07:30:12 +01:00
|
|
|
|
2020-03-16 23:06:22 +01:00
|
|
|
// typedMessageManager
|
2017-09-29 18:24:08 +02:00
|
|
|
signTypedMessage: nodeify(this.signTypedMessage, this),
|
|
|
|
cancelTypedMessage: this.cancelTypedMessage.bind(this),
|
|
|
|
|
2020-02-19 19:24:16 +01:00
|
|
|
// decryptMessageManager
|
|
|
|
decryptMessage: nodeify(this.decryptMessage, this),
|
|
|
|
decryptMessageInline: nodeify(this.decryptMessageInline, this),
|
|
|
|
cancelDecryptMessage: this.cancelDecryptMessage.bind(this),
|
|
|
|
|
|
|
|
// EncryptionPublicKeyManager
|
|
|
|
encryptionPublicKey: nodeify(this.encryptionPublicKey, this),
|
|
|
|
cancelEncryptionPublicKey: this.cancelEncryptionPublicKey.bind(this),
|
|
|
|
|
2019-08-02 05:57:26 +02:00
|
|
|
// onboarding controller
|
|
|
|
setSeedPhraseBackedUp: nodeify(onboardingController.setSeedPhraseBackedUp, onboardingController),
|
2019-09-16 19:11:01 +02:00
|
|
|
|
2020-05-08 21:45:52 +02:00
|
|
|
// alert controller
|
|
|
|
setAlertEnabledness: nodeify(alertController.setAlertEnabledness, alertController),
|
2020-06-15 21:08:53 +02:00
|
|
|
setUnconnectedAccountAlertShown: nodeify(this.alertController.setUnconnectedAccountAlertShown, this.alertController),
|
2020-05-08 21:45:52 +02:00
|
|
|
|
2019-09-16 19:11:01 +02:00
|
|
|
// 3Box
|
|
|
|
setThreeBoxSyncingPermission: nodeify(threeBoxController.setThreeBoxSyncingPermission, threeBoxController),
|
|
|
|
restoreFromThreeBox: nodeify(threeBoxController.restoreFromThreeBox, threeBoxController),
|
2019-09-26 09:24:52 +02:00
|
|
|
setShowRestorePromptToFalse: nodeify(threeBoxController.setShowRestorePromptToFalse, threeBoxController),
|
2019-09-16 19:11:01 +02:00
|
|
|
getThreeBoxLastUpdated: nodeify(threeBoxController.getLastUpdated, threeBoxController),
|
|
|
|
turnThreeBoxSyncingOn: nodeify(threeBoxController.turnThreeBoxSyncingOn, threeBoxController),
|
|
|
|
initializeThreeBox: nodeify(this.initializeThreeBox, this),
|
2019-09-24 23:08:38 +02:00
|
|
|
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
// permissions
|
|
|
|
approvePermissionsRequest: nodeify(permissionsController.approvePermissionsRequest, permissionsController),
|
|
|
|
clearPermissions: permissionsController.clearPermissions.bind(permissionsController),
|
2020-05-18 21:23:46 +02:00
|
|
|
getApprovedAccounts: nodeify(permissionsController.getAccounts, permissionsController),
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
rejectPermissionsRequest: nodeify(permissionsController.rejectPermissionsRequest, permissionsController),
|
|
|
|
removePermissionsFor: permissionsController.removePermissionsFor.bind(permissionsController),
|
2020-04-17 00:23:36 +02:00
|
|
|
addPermittedAccount: nodeify(permissionsController.addPermittedAccount, permissionsController),
|
2020-04-20 20:34:56 +02:00
|
|
|
removePermittedAccount: nodeify(permissionsController.removePermittedAccount, permissionsController),
|
2020-07-05 21:49:22 +02:00
|
|
|
requestAccountsPermissionWithId: nodeify(permissionsController.requestAccountsPermissionWithId, permissionsController),
|
2016-06-24 22:05:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-31 22:17:11 +02:00
|
|
|
//=============================================================================
|
|
|
|
// VAULT / KEYRING RELATED METHODS
|
|
|
|
//=============================================================================
|
2017-01-27 07:30:12 +01:00
|
|
|
|
2018-03-15 23:27:10 +01:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* Creates a new Vault and create a new keychain.
|
2018-03-28 03:07:51 +02:00
|
|
|
*
|
2018-04-19 02:54:50 +02:00
|
|
|
* A vault, or KeyringController, is a controller that contains
|
|
|
|
* many different account strategies, currently called Keyrings.
|
|
|
|
* Creating it new means wiping all previous keyrings.
|
2018-03-28 03:07:51 +02:00
|
|
|
*
|
2018-04-19 02:54:50 +02:00
|
|
|
* A keychain, or keyring, controls many accounts with a single backup and signing strategy.
|
|
|
|
* For example, a mnemonic phrase can generate many accounts, and is a keyring.
|
2018-03-28 03:07:51 +02:00
|
|
|
*
|
2018-04-19 02:54:50 +02:00
|
|
|
* @param {string} password
|
2018-03-28 03:07:51 +02:00
|
|
|
*
|
2020-01-13 19:36:36 +01:00
|
|
|
* @returns {Object} - vault
|
2018-03-15 23:27:10 +01:00
|
|
|
*/
|
2017-11-20 22:27:29 +01:00
|
|
|
async createNewVaultAndKeychain (password) {
|
2018-06-12 20:51:35 +02:00
|
|
|
const releaseLock = await this.createVaultMutex.acquire()
|
2017-11-20 22:47:35 +01:00
|
|
|
try {
|
2018-06-12 20:51:35 +02:00
|
|
|
let vault
|
2017-11-20 22:47:35 +01:00
|
|
|
const accounts = await this.keyringController.getAccounts()
|
|
|
|
if (accounts.length > 0) {
|
|
|
|
vault = await this.keyringController.fullUpdate()
|
|
|
|
} else {
|
2017-11-29 00:35:20 +01:00
|
|
|
vault = await this.keyringController.createNewVaultAndKeychain(password)
|
2020-08-18 18:36:45 +02:00
|
|
|
const addresses = await this.keyringController.getAccounts()
|
|
|
|
this.preferencesController.setAddresses(addresses)
|
2018-04-19 05:33:51 +02:00
|
|
|
this.selectFirstIdentity()
|
2017-11-20 22:47:35 +01:00
|
|
|
}
|
2018-06-12 20:51:35 +02:00
|
|
|
return vault
|
2020-03-23 17:25:55 +01:00
|
|
|
} finally {
|
|
|
|
releaseLock()
|
2017-11-20 22:27:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-15 23:27:10 +01:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* Create a new Vault and restore an existent keyring.
|
2018-03-15 23:27:10 +01:00
|
|
|
* @param {} password
|
|
|
|
* @param {} seed
|
|
|
|
*/
|
2017-11-20 22:27:29 +01:00
|
|
|
async createNewVaultAndRestore (password, seed) {
|
2018-06-12 20:51:35 +02:00
|
|
|
const releaseLock = await this.createVaultMutex.acquire()
|
2018-01-04 01:06:46 +01:00
|
|
|
try {
|
2018-07-27 05:40:11 +02:00
|
|
|
let accounts, lastBalance
|
|
|
|
|
2020-08-18 22:06:58 +02:00
|
|
|
const { keyringController } = this
|
2018-07-27 05:40:11 +02:00
|
|
|
|
2018-06-03 21:02:35 +02:00
|
|
|
// clear known identities
|
|
|
|
this.preferencesController.setAddresses([])
|
2020-06-14 03:42:39 +02:00
|
|
|
|
|
|
|
// clear permissions
|
|
|
|
this.permissionsController.clearPermissions()
|
|
|
|
|
2020-07-17 04:09:38 +02:00
|
|
|
// clear accounts in accountTracker
|
|
|
|
this.accountTracker.clearAccounts()
|
|
|
|
|
|
|
|
// clear cachedBalances
|
|
|
|
this.cachedBalancesController.clearCachedBalances()
|
|
|
|
|
2020-07-17 03:37:56 +02:00
|
|
|
// clear unapproved transactions
|
|
|
|
this.txController.txStateManager.clearUnapprovedTxs()
|
|
|
|
|
2018-06-03 21:02:35 +02:00
|
|
|
// create new vault
|
2018-07-27 05:40:11 +02:00
|
|
|
const vault = await keyringController.createNewVaultAndRestore(password, seed)
|
|
|
|
|
|
|
|
const ethQuery = new EthQuery(this.provider)
|
|
|
|
accounts = await keyringController.getAccounts()
|
|
|
|
lastBalance = await this.getBalance(accounts[accounts.length - 1], ethQuery)
|
|
|
|
|
|
|
|
const primaryKeyring = keyringController.getKeyringsByType('HD Key Tree')[0]
|
|
|
|
if (!primaryKeyring) {
|
|
|
|
throw new Error('MetamaskController - No HD Key Tree found')
|
|
|
|
}
|
|
|
|
|
|
|
|
// seek out the first zero balance
|
|
|
|
while (lastBalance !== '0x0') {
|
|
|
|
await keyringController.addNewAccount(primaryKeyring)
|
|
|
|
accounts = await keyringController.getAccounts()
|
|
|
|
lastBalance = await this.getBalance(accounts[accounts.length - 1], ethQuery)
|
|
|
|
}
|
|
|
|
|
2018-06-03 21:02:35 +02:00
|
|
|
// set new identities
|
2018-04-19 05:33:51 +02:00
|
|
|
this.preferencesController.setAddresses(accounts)
|
|
|
|
this.selectFirstIdentity()
|
2018-01-04 01:06:46 +01:00
|
|
|
return vault
|
2020-03-23 17:25:55 +01:00
|
|
|
} finally {
|
|
|
|
releaseLock()
|
2018-01-04 01:06:46 +01:00
|
|
|
}
|
2017-10-17 22:19:57 +02:00
|
|
|
}
|
|
|
|
|
2018-07-27 05:40:11 +02:00
|
|
|
/**
|
|
|
|
* Get an account balance from the AccountTracker or request it directly from the network.
|
|
|
|
* @param {string} address - The account address
|
|
|
|
* @param {EthQuery} ethQuery - The EthQuery instance to use when asking the network
|
|
|
|
*/
|
|
|
|
getBalance (address, ethQuery) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
const cached = this.accountTracker.store.getState().accounts[address]
|
|
|
|
|
|
|
|
if (cached && cached.balance) {
|
|
|
|
resolve(cached.balance)
|
|
|
|
} else {
|
|
|
|
ethQuery.getBalance(address, (error, balance) => {
|
|
|
|
if (error) {
|
|
|
|
reject(error)
|
|
|
|
log.error(error)
|
|
|
|
} else {
|
|
|
|
resolve(balance || '0x0')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-01-30 01:57:14 +01:00
|
|
|
getCurrentNetwork = () => {
|
|
|
|
return this.networkController.store.getState().network
|
|
|
|
}
|
|
|
|
|
2019-02-25 20:10:13 +01:00
|
|
|
/**
|
|
|
|
* Collects all the information that we want to share
|
|
|
|
* with the mobile client for syncing purposes
|
2020-01-13 19:36:36 +01:00
|
|
|
* @returns {Promise<Object>} - Parts of the state that we want to syncx
|
2019-02-25 20:10:13 +01:00
|
|
|
*/
|
2019-07-31 22:17:11 +02:00
|
|
|
async fetchInfoToSync () {
|
2019-02-25 20:10:13 +01:00
|
|
|
// Preferences
|
|
|
|
const {
|
|
|
|
accountTokens,
|
|
|
|
currentLocale,
|
|
|
|
frequentRpcList,
|
|
|
|
identities,
|
|
|
|
selectedAddress,
|
|
|
|
tokens,
|
|
|
|
} = this.preferencesController.store.getState()
|
|
|
|
|
2019-08-20 20:53:21 +02:00
|
|
|
// Filter ERC20 tokens
|
|
|
|
const filteredAccountTokens = {}
|
2020-02-15 21:34:12 +01:00
|
|
|
Object.keys(accountTokens).forEach((address) => {
|
2019-08-20 20:53:21 +02:00
|
|
|
const checksummedAddress = ethUtil.toChecksumAddress(address)
|
|
|
|
filteredAccountTokens[checksummedAddress] = {}
|
2020-08-14 13:47:43 +02:00
|
|
|
Object.keys(accountTokens[address]).forEach((networkType) => {
|
|
|
|
filteredAccountTokens[checksummedAddress][networkType] = networkType === 'mainnet'
|
|
|
|
? (
|
2020-08-18 18:36:45 +02:00
|
|
|
accountTokens[address][networkType].filter(({ address: tokenAddress }) => {
|
|
|
|
const checksumAddress = ethUtil.toChecksumAddress(tokenAddress)
|
|
|
|
return contractMap[checksumAddress] ? contractMap[checksumAddress].erc20 : true
|
2020-08-14 13:47:43 +02:00
|
|
|
})
|
|
|
|
)
|
|
|
|
: accountTokens[address][networkType]
|
|
|
|
})
|
2019-08-20 20:53:21 +02:00
|
|
|
})
|
|
|
|
|
2019-02-25 20:10:13 +01:00
|
|
|
const preferences = {
|
2019-08-20 20:53:21 +02:00
|
|
|
accountTokens: filteredAccountTokens,
|
2019-02-25 20:10:13 +01:00
|
|
|
currentLocale,
|
|
|
|
frequentRpcList,
|
|
|
|
identities,
|
|
|
|
selectedAddress,
|
|
|
|
tokens,
|
|
|
|
}
|
|
|
|
|
|
|
|
// Accounts
|
|
|
|
const hdKeyring = this.keyringController.getKeyringsByType('HD Key Tree')[0]
|
2020-06-26 03:04:17 +02:00
|
|
|
const simpleKeyPairKeyrings = this.keyringController.getKeyringsByType('Simple Key Pair')
|
2019-02-25 20:10:13 +01:00
|
|
|
const hdAccounts = await hdKeyring.getAccounts()
|
2020-06-26 03:04:17 +02:00
|
|
|
const simpleKeyPairKeyringAccounts = await Promise.all(
|
2020-07-14 17:20:41 +02:00
|
|
|
simpleKeyPairKeyrings.map((keyring) => keyring.getAccounts()),
|
2020-06-26 03:04:17 +02:00
|
|
|
)
|
|
|
|
const simpleKeyPairAccounts = simpleKeyPairKeyringAccounts.reduce((acc, accounts) => [...acc, ...accounts], [])
|
2019-02-25 20:10:13 +01:00
|
|
|
const accounts = {
|
2020-02-15 21:34:12 +01:00
|
|
|
hd: hdAccounts.filter((item, pos) => (hdAccounts.indexOf(item) === pos)).map((address) => ethUtil.toChecksumAddress(address)),
|
2020-06-26 03:04:17 +02:00
|
|
|
simpleKeyPair: simpleKeyPairAccounts.filter((item, pos) => (simpleKeyPairAccounts.indexOf(item) === pos)).map((address) => ethUtil.toChecksumAddress(address)),
|
2019-02-25 20:10:13 +01:00
|
|
|
ledger: [],
|
|
|
|
trezor: [],
|
|
|
|
}
|
|
|
|
|
|
|
|
// transactions
|
|
|
|
|
2020-08-18 22:06:58 +02:00
|
|
|
let { transactions } = this.txController.store.getState()
|
2019-02-25 20:10:13 +01:00
|
|
|
// delete tx for other accounts that we're not importing
|
2020-02-15 21:34:12 +01:00
|
|
|
transactions = transactions.filter((tx) => {
|
2019-02-25 20:10:13 +01:00
|
|
|
const checksummedTxFrom = ethUtil.toChecksumAddress(tx.txParams.from)
|
|
|
|
return (
|
|
|
|
accounts.hd.includes(checksummedTxFrom)
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
return {
|
|
|
|
accounts,
|
|
|
|
preferences,
|
|
|
|
transactions,
|
|
|
|
network: this.networkController.store.getState(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-04 22:43:26 +02:00
|
|
|
/*
|
|
|
|
* Submits the user's password and attempts to unlock the vault.
|
|
|
|
* Also synchronizes the preferencesController, to ensure its schema
|
|
|
|
* is up to date with known accounts once the vault is decrypted.
|
|
|
|
*
|
|
|
|
* @param {string} password - The user's password
|
|
|
|
* @returns {Promise<object>} - The keyringController update.
|
|
|
|
*/
|
|
|
|
async submitPassword (password) {
|
|
|
|
await this.keyringController.submitPassword(password)
|
|
|
|
|
2020-09-09 07:29:24 +02:00
|
|
|
try {
|
|
|
|
await this.blockTracker.checkForLatestBlock()
|
|
|
|
} catch (error) {
|
|
|
|
log.error('Error while unlocking extension.', error)
|
|
|
|
}
|
2019-09-16 19:11:01 +02:00
|
|
|
|
2019-10-01 15:01:57 +02:00
|
|
|
try {
|
|
|
|
const threeBoxSyncingAllowed = this.threeBoxController.getThreeBoxSyncingState()
|
|
|
|
if (threeBoxSyncingAllowed && !this.threeBoxController.box) {
|
2019-10-02 21:12:20 +02:00
|
|
|
// 'await' intentionally omitted to avoid waiting for initialization
|
|
|
|
this.threeBoxController.init()
|
2019-10-01 15:01:57 +02:00
|
|
|
this.threeBoxController.turnThreeBoxSyncingOn()
|
|
|
|
} else if (threeBoxSyncingAllowed && this.threeBoxController.box) {
|
|
|
|
this.threeBoxController.turnThreeBoxSyncingOn()
|
|
|
|
}
|
|
|
|
} catch (error) {
|
2020-09-09 07:29:24 +02:00
|
|
|
log.error('Error while unlocking extension.', error)
|
2019-09-16 19:11:01 +02:00
|
|
|
}
|
|
|
|
|
2018-06-04 22:43:26 +02:00
|
|
|
return this.keyringController.fullUpdate()
|
|
|
|
}
|
|
|
|
|
2020-07-25 00:47:40 +02:00
|
|
|
/**
|
|
|
|
* Submits a user's password to check its validity.
|
|
|
|
*
|
|
|
|
* @param {string} password The user's password
|
|
|
|
*/
|
|
|
|
async verifyPassword (password) {
|
|
|
|
await this.keyringController.verifyPassword(password)
|
|
|
|
}
|
|
|
|
|
2018-04-19 02:54:50 +02:00
|
|
|
/**
|
|
|
|
* @type Identity
|
|
|
|
* @property {string} name - The account nickname.
|
|
|
|
* @property {string} address - The account's ethereum address, in lower case.
|
|
|
|
* @property {boolean} mayBeFauceting - Whether this account is currently
|
|
|
|
* receiving funds from our automatic Ropsten faucet.
|
|
|
|
*/
|
|
|
|
|
2018-03-15 23:27:10 +01:00
|
|
|
/**
|
2018-04-19 05:33:51 +02:00
|
|
|
* Sets the first address in the state to the selected address
|
2018-03-15 23:27:10 +01:00
|
|
|
*/
|
2018-04-19 05:33:51 +02:00
|
|
|
selectFirstIdentity () {
|
|
|
|
const { identities } = this.preferencesController.store.getState()
|
2017-10-17 22:19:57 +02:00
|
|
|
const address = Object.keys(identities)[0]
|
|
|
|
this.preferencesController.setSelectedAddress(address)
|
|
|
|
}
|
|
|
|
|
2018-06-10 09:52:32 +02:00
|
|
|
//
|
|
|
|
// Hardware
|
|
|
|
//
|
|
|
|
|
2018-08-14 01:29:43 +02:00
|
|
|
async getKeyringForDevice (deviceName, hdPath = null) {
|
2018-08-11 03:54:34 +02:00
|
|
|
let keyringName = null
|
|
|
|
switch (deviceName) {
|
|
|
|
case 'trezor':
|
|
|
|
keyringName = TrezorKeyring.type
|
|
|
|
break
|
|
|
|
case 'ledger':
|
2018-08-12 07:34:01 +02:00
|
|
|
keyringName = LedgerBridgeKeyring.type
|
2018-08-11 03:54:34 +02:00
|
|
|
break
|
|
|
|
default:
|
2018-08-14 09:42:23 +02:00
|
|
|
throw new Error('MetamaskController:getKeyringForDevice - Unknown device')
|
2018-08-11 03:54:34 +02:00
|
|
|
}
|
|
|
|
let keyring = await this.keyringController.getKeyringsByType(keyringName)[0]
|
|
|
|
if (!keyring) {
|
|
|
|
keyring = await this.keyringController.addNewKeyring(keyringName)
|
|
|
|
}
|
2018-08-14 09:42:23 +02:00
|
|
|
if (hdPath && keyring.setHdPath) {
|
|
|
|
keyring.setHdPath(hdPath)
|
2018-08-14 01:29:43 +02:00
|
|
|
}
|
2018-08-11 03:54:34 +02:00
|
|
|
|
2018-08-14 07:26:18 +02:00
|
|
|
keyring.network = this.networkController.getProviderConfig().type
|
|
|
|
|
2018-08-11 03:54:34 +02:00
|
|
|
return keyring
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-06-10 09:52:32 +02:00
|
|
|
/**
|
|
|
|
* Fetch account list from a trezor device.
|
|
|
|
*
|
|
|
|
* @returns [] accounts
|
|
|
|
*/
|
2018-08-14 01:29:43 +02:00
|
|
|
async connectHardware (deviceName, page, hdPath) {
|
|
|
|
const keyring = await this.getKeyringForDevice(deviceName, hdPath)
|
2018-08-11 03:54:34 +02:00
|
|
|
let accounts = []
|
|
|
|
switch (page) {
|
2019-07-31 22:17:11 +02:00
|
|
|
case -1:
|
|
|
|
accounts = await keyring.getPreviousPage()
|
|
|
|
break
|
|
|
|
case 1:
|
|
|
|
accounts = await keyring.getNextPage()
|
|
|
|
break
|
|
|
|
default:
|
|
|
|
accounts = await keyring.getFirstPage()
|
2018-06-13 08:09:25 +02:00
|
|
|
}
|
2018-08-11 03:54:34 +02:00
|
|
|
|
|
|
|
// Merge with existing accounts
|
|
|
|
// and make sure addresses are not repeated
|
2018-08-11 08:35:20 +02:00
|
|
|
const oldAccounts = await this.keyringController.getAccounts()
|
2020-02-15 21:34:12 +01:00
|
|
|
const accountsToTrack = [...new Set(oldAccounts.concat(accounts.map((a) => a.address.toLowerCase())))]
|
2018-08-11 03:54:34 +02:00
|
|
|
this.accountTracker.syncWithAddresses(accountsToTrack)
|
|
|
|
return accounts
|
2018-06-10 09:52:32 +02:00
|
|
|
}
|
|
|
|
|
2018-07-17 01:36:08 +02:00
|
|
|
/**
|
|
|
|
* Check if the device is unlocked
|
|
|
|
*
|
|
|
|
* @returns {Promise<boolean>}
|
|
|
|
*/
|
2018-08-14 01:29:43 +02:00
|
|
|
async checkHardwareStatus (deviceName, hdPath) {
|
|
|
|
const keyring = await this.getKeyringForDevice(deviceName, hdPath)
|
2018-08-11 03:54:34 +02:00
|
|
|
return keyring.isUnlocked()
|
2018-07-12 03:21:36 +02:00
|
|
|
}
|
|
|
|
|
2018-07-17 01:36:08 +02:00
|
|
|
/**
|
|
|
|
* Clear
|
|
|
|
*
|
|
|
|
* @returns {Promise<boolean>}
|
|
|
|
*/
|
2018-07-12 03:21:36 +02:00
|
|
|
async forgetDevice (deviceName) {
|
|
|
|
|
2018-08-11 03:54:34 +02:00
|
|
|
const keyring = await this.getKeyringForDevice(deviceName)
|
|
|
|
keyring.forgetDevice()
|
|
|
|
return true
|
2018-07-12 03:21:36 +02:00
|
|
|
}
|
|
|
|
|
2018-06-10 09:52:32 +02:00
|
|
|
/**
|
|
|
|
* Imports an account from a trezor device.
|
|
|
|
*
|
|
|
|
* @returns {} keyState
|
|
|
|
*/
|
2018-08-14 01:29:43 +02:00
|
|
|
async unlockHardwareWalletAccount (index, deviceName, hdPath) {
|
|
|
|
const keyring = await this.getKeyringForDevice(deviceName, hdPath)
|
2018-06-10 09:52:32 +02:00
|
|
|
|
2018-06-11 01:02:54 +02:00
|
|
|
keyring.setAccountToUnlock(index)
|
2018-08-11 03:54:34 +02:00
|
|
|
const oldAccounts = await this.keyringController.getAccounts()
|
|
|
|
const keyState = await this.keyringController.addNewAccount(keyring)
|
|
|
|
const newAccounts = await this.keyringController.getAccounts()
|
2018-06-10 09:52:32 +02:00
|
|
|
this.preferencesController.setAddresses(newAccounts)
|
2020-02-15 21:34:12 +01:00
|
|
|
newAccounts.forEach((address) => {
|
2018-06-10 09:52:32 +02:00
|
|
|
if (!oldAccounts.includes(address)) {
|
2018-08-21 06:04:30 +02:00
|
|
|
// Set the account label to Trezor 1 / Ledger 1, etc
|
|
|
|
this.preferencesController.setAccountLabel(address, `${deviceName[0].toUpperCase()}${deviceName.slice(1)} ${parseInt(index, 10) + 1}`)
|
|
|
|
// Select the account
|
2018-06-10 09:52:32 +02:00
|
|
|
this.preferencesController.setSelectedAddress(address)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
const { identities } = this.preferencesController.store.getState()
|
|
|
|
return { ...keyState, identities }
|
2019-07-31 22:17:11 +02:00
|
|
|
}
|
2018-06-13 08:09:25 +02:00
|
|
|
|
2018-04-19 02:54:50 +02:00
|
|
|
//
|
|
|
|
// Account Management
|
2017-01-27 07:30:12 +01:00
|
|
|
//
|
|
|
|
|
2018-03-15 23:27:10 +01:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* Adds a new account to the default (first) HD seed phrase Keyring.
|
2018-03-28 03:07:51 +02:00
|
|
|
*
|
2018-03-15 23:27:10 +01:00
|
|
|
* @returns {} keyState
|
|
|
|
*/
|
2018-03-06 15:56:27 +01:00
|
|
|
async addNewAccount () {
|
2017-01-27 07:30:12 +01:00
|
|
|
const primaryKeyring = this.keyringController.getKeyringsByType('HD Key Tree')[0]
|
2018-03-06 15:56:27 +01:00
|
|
|
if (!primaryKeyring) {
|
|
|
|
throw new Error('MetamaskController - No HD Key Tree found')
|
|
|
|
}
|
2020-08-18 22:06:58 +02:00
|
|
|
const { keyringController } = this
|
2017-10-19 21:15:26 +02:00
|
|
|
const oldAccounts = await keyringController.getAccounts()
|
|
|
|
const keyState = await keyringController.addNewAccount(primaryKeyring)
|
|
|
|
const newAccounts = await keyringController.getAccounts()
|
|
|
|
|
2018-03-06 15:56:27 +01:00
|
|
|
await this.verifySeedPhrase()
|
|
|
|
|
2018-04-19 05:33:51 +02:00
|
|
|
this.preferencesController.setAddresses(newAccounts)
|
2017-10-19 21:15:26 +02:00
|
|
|
newAccounts.forEach((address) => {
|
|
|
|
if (!oldAccounts.includes(address)) {
|
|
|
|
this.preferencesController.setSelectedAddress(address)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2019-12-03 21:50:55 +01:00
|
|
|
const { identities } = this.preferencesController.store.getState()
|
|
|
|
return { ...keyState, identities }
|
2017-01-27 07:30:12 +01:00
|
|
|
}
|
|
|
|
|
2018-03-15 23:27:10 +01:00
|
|
|
/**
|
|
|
|
* Verifies the validity of the current vault's seed phrase.
|
2018-03-28 03:07:51 +02:00
|
|
|
*
|
2018-03-16 01:29:53 +01:00
|
|
|
* Validity: seed phrase restores the accounts belonging to the current vault.
|
2018-03-15 23:27:10 +01:00
|
|
|
*
|
|
|
|
* Called when the first account is created and on unlocking the vault.
|
2018-04-19 02:54:50 +02:00
|
|
|
*
|
2020-01-13 19:36:36 +01:00
|
|
|
* @returns {Promise<string>} - Seed phrase to be confirmed by the user.
|
2018-03-15 23:27:10 +01:00
|
|
|
*/
|
2018-03-06 15:56:27 +01:00
|
|
|
async verifySeedPhrase () {
|
2018-03-03 22:08:10 +01:00
|
|
|
|
2017-01-27 07:30:12 +01:00
|
|
|
const primaryKeyring = this.keyringController.getKeyringsByType('HD Key Tree')[0]
|
2018-03-06 15:56:27 +01:00
|
|
|
if (!primaryKeyring) {
|
|
|
|
throw new Error('MetamaskController - No HD Key Tree found')
|
|
|
|
}
|
|
|
|
|
|
|
|
const serialized = await primaryKeyring.serialize()
|
|
|
|
const seedWords = serialized.mnemonic
|
|
|
|
|
|
|
|
const accounts = await primaryKeyring.getAccounts()
|
|
|
|
if (accounts.length < 1) {
|
|
|
|
throw new Error('MetamaskController - No accounts found')
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
await seedPhraseVerifier.verifyAccounts(accounts, seedWords)
|
|
|
|
return seedWords
|
|
|
|
} catch (err) {
|
|
|
|
log.error(err.message)
|
|
|
|
throw err
|
|
|
|
}
|
2017-01-27 07:30:12 +01:00
|
|
|
}
|
|
|
|
|
2018-03-15 23:27:10 +01:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* Clears the transaction history, to allow users to force-reset their nonces.
|
|
|
|
* Mostly used in development environments, when networks are restarted with
|
|
|
|
* the same network ID.
|
|
|
|
*
|
2020-01-13 19:36:36 +01:00
|
|
|
* @returns {Promise<string>} - The current selected address.
|
2018-03-15 23:27:10 +01:00
|
|
|
*/
|
2018-04-19 02:54:50 +02:00
|
|
|
async resetAccount () {
|
2018-01-31 10:25:32 +01:00
|
|
|
const selectedAddress = this.preferencesController.getSelectedAddress()
|
|
|
|
this.txController.wipeTransactions(selectedAddress)
|
2018-06-07 01:46:39 +02:00
|
|
|
this.networkController.resetConnection()
|
2018-03-28 03:07:51 +02:00
|
|
|
|
|
|
|
return selectedAddress
|
2018-01-31 09:33:15 +01:00
|
|
|
}
|
|
|
|
|
2018-07-11 06:20:40 +02:00
|
|
|
/**
|
2018-07-12 02:01:44 +02:00
|
|
|
* Removes an account from state / storage.
|
2018-07-11 06:20:40 +02:00
|
|
|
*
|
2020-01-13 19:36:36 +01:00
|
|
|
* @param {string[]} address - A hex address
|
2018-07-11 06:20:40 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
async removeAccount (address) {
|
2020-06-15 15:27:27 +02:00
|
|
|
// Remove all associated permissions
|
|
|
|
await this.permissionsController.removeAllAccountPermissions(address)
|
2018-07-12 02:01:44 +02:00
|
|
|
// Remove account from the preferences controller
|
2018-07-11 06:20:40 +02:00
|
|
|
this.preferencesController.removeAddress(address)
|
2018-07-12 02:01:44 +02:00
|
|
|
// Remove account from the account tracker controller
|
2018-08-21 06:04:07 +02:00
|
|
|
this.accountTracker.removeAccount([address])
|
|
|
|
|
2018-07-12 02:01:44 +02:00
|
|
|
// Remove account from the keyring
|
|
|
|
await this.keyringController.removeAccount(address)
|
2018-07-11 06:20:40 +02:00
|
|
|
return address
|
|
|
|
}
|
|
|
|
|
2018-03-15 23:27:10 +01:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* Imports an account with the specified import strategy.
|
|
|
|
* These are defined in app/scripts/account-import-strategies
|
|
|
|
* Each strategy represents a different way of serializing an Ethereum key pair.
|
2018-03-28 03:07:51 +02:00
|
|
|
*
|
2018-04-20 18:26:24 +02:00
|
|
|
* @param {string} strategy - A unique identifier for an account import strategy.
|
2018-04-19 02:54:50 +02:00
|
|
|
* @param {any} args - The data required by that strategy to import an account.
|
|
|
|
* @param {Function} cb - A callback function called with a state update on success.
|
2018-03-15 23:27:10 +01:00
|
|
|
*/
|
2018-05-29 07:58:14 +02:00
|
|
|
async importAccountWithStrategy (strategy, args) {
|
|
|
|
const privateKey = await accountImporter.importAccount(strategy, args)
|
2020-08-19 18:27:05 +02:00
|
|
|
const keyring = await this.keyringController.addNewKeyring('Simple Key Pair', [privateKey])
|
2018-05-29 07:58:14 +02:00
|
|
|
const accounts = await keyring.getAccounts()
|
|
|
|
// update accounts in preferences controller
|
2018-05-29 08:14:38 +02:00
|
|
|
const allAccounts = await this.keyringController.getAccounts()
|
2018-05-29 07:58:14 +02:00
|
|
|
this.preferencesController.setAddresses(allAccounts)
|
|
|
|
// set new account as selected
|
|
|
|
await this.preferencesController.setSelectedAddress(accounts[0])
|
2017-01-27 07:30:12 +01:00
|
|
|
}
|
|
|
|
|
2018-03-16 01:29:53 +01:00
|
|
|
// ---------------------------------------------------------------------------
|
2018-04-19 02:54:50 +02:00
|
|
|
// Identity Management (signature operations)
|
|
|
|
|
2018-08-17 18:56:07 +02:00
|
|
|
/**
|
|
|
|
* Called when a Dapp suggests a new tx to be signed.
|
|
|
|
* this wrapper needs to exist so we can provide a reference to
|
|
|
|
* "newUnapprovedTransaction" before "txController" is instantiated
|
|
|
|
*
|
|
|
|
* @param {Object} msgParams - The params passed to eth_sign.
|
|
|
|
* @param {Object} req - (optional) the original request, containing the origin
|
|
|
|
*/
|
|
|
|
async newUnapprovedTransaction (txParams, req) {
|
|
|
|
return await this.txController.newUnapprovedTransaction(txParams, req)
|
|
|
|
}
|
|
|
|
|
2018-04-19 02:54:50 +02:00
|
|
|
// eth_sign methods:
|
2017-01-27 07:30:12 +01:00
|
|
|
|
2018-03-15 23:27:10 +01:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* Called when a Dapp uses the eth_sign method, to request user approval.
|
|
|
|
* eth_sign is a pure signature of arbitrary data. It is on a deprecation
|
|
|
|
* path, since this data can be a transaction, or can leak private key
|
|
|
|
* information.
|
|
|
|
*
|
|
|
|
* @param {Object} msgParams - The params passed to eth_sign.
|
|
|
|
* @param {Function} cb = The callback function called with the signature.
|
2018-03-15 23:27:10 +01:00
|
|
|
*/
|
2018-08-17 18:56:07 +02:00
|
|
|
newUnsignedMessage (msgParams, req) {
|
|
|
|
const promise = this.messageManager.addUnapprovedMessageAsync(msgParams, req)
|
2018-04-19 02:54:50 +02:00
|
|
|
this.sendUpdate()
|
|
|
|
this.opts.showUnconfirmedMessage()
|
2018-08-17 18:56:07 +02:00
|
|
|
return promise
|
2018-04-19 02:54:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Signifies user intent to complete an eth_sign method.
|
|
|
|
*
|
2020-01-13 19:36:36 +01:00
|
|
|
* @param {Object} msgParams - The params passed to eth_call.
|
|
|
|
* @returns {Promise<Object>} - Full state update.
|
2018-04-19 02:54:50 +02:00
|
|
|
*/
|
|
|
|
signMessage (msgParams) {
|
2017-02-23 23:23:45 +01:00
|
|
|
log.info('MetaMaskController - signMessage')
|
2017-01-28 01:11:59 +01:00
|
|
|
const msgId = msgParams.metamaskId
|
2017-02-23 23:23:45 +01:00
|
|
|
|
|
|
|
// sets the status op the message to 'approved'
|
|
|
|
// and removes the metamaskId for signing
|
|
|
|
return this.messageManager.approveMessage(msgParams)
|
2019-07-31 22:17:11 +02:00
|
|
|
.then((cleanMsgParams) => {
|
2017-02-23 23:23:45 +01:00
|
|
|
// signs the message
|
2019-07-31 22:17:11 +02:00
|
|
|
return this.keyringController.signMessage(cleanMsgParams)
|
|
|
|
})
|
|
|
|
.then((rawSig) => {
|
2017-02-23 23:23:45 +01:00
|
|
|
// tells the listener that the message has been signed
|
|
|
|
// and can be returned to the dapp
|
2019-07-31 22:17:11 +02:00
|
|
|
this.messageManager.setMsgStatusSigned(msgId, rawSig)
|
|
|
|
return this.getState()
|
|
|
|
})
|
2016-06-24 22:05:21 +02:00
|
|
|
}
|
|
|
|
|
2018-04-20 18:26:24 +02:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* Used to cancel a message submitted via eth_sign.
|
|
|
|
*
|
2018-04-20 18:26:24 +02:00
|
|
|
* @param {string} msgId - The id of the message to cancel.
|
2018-04-19 02:54:50 +02:00
|
|
|
*/
|
|
|
|
cancelMessage (msgId, cb) {
|
2020-08-18 22:06:58 +02:00
|
|
|
const { messageManager } = this
|
2018-04-19 02:54:50 +02:00
|
|
|
messageManager.rejectMsg(msgId)
|
2020-08-19 18:27:05 +02:00
|
|
|
if (!cb || typeof cb !== 'function') {
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2018-04-19 02:54:50 +02:00
|
|
|
}
|
2020-08-19 18:27:05 +02:00
|
|
|
cb(null, this.getState())
|
2018-04-19 02:54:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// personal_sign methods:
|
2018-03-28 03:07:51 +02:00
|
|
|
|
2018-04-20 18:26:24 +02:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* Called when a dapp uses the personal_sign method.
|
|
|
|
* This is identical to the Geth eth_sign method, and may eventually replace
|
|
|
|
* eth_sign.
|
|
|
|
*
|
|
|
|
* We currently define our eth_sign and personal_sign mostly for legacy Dapps.
|
2018-03-28 03:07:51 +02:00
|
|
|
*
|
2018-04-19 02:54:50 +02:00
|
|
|
* @param {Object} msgParams - The params of the message to sign & return to the Dapp.
|
|
|
|
* @param {Function} cb - The callback function called with the signature.
|
|
|
|
* Passed back to the requesting Dapp.
|
2018-03-15 23:27:10 +01:00
|
|
|
*/
|
2018-08-17 18:56:07 +02:00
|
|
|
async newUnsignedPersonalMessage (msgParams, req) {
|
|
|
|
const promise = this.personalMessageManager.addUnapprovedMessageAsync(msgParams, req)
|
2017-02-21 23:25:47 +01:00
|
|
|
this.sendUpdate()
|
|
|
|
this.opts.showUnconfirmedMessage()
|
2018-08-17 18:56:07 +02:00
|
|
|
return promise
|
2017-02-21 23:25:47 +01:00
|
|
|
}
|
2018-03-28 03:07:51 +02:00
|
|
|
|
2018-03-15 23:27:10 +01:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* Signifies a user's approval to sign a personal_sign message in queue.
|
|
|
|
* Triggers signing, and the callback function from newUnsignedPersonalMessage.
|
|
|
|
*
|
|
|
|
* @param {Object} msgParams - The params of the message to sign & return to the Dapp.
|
2018-04-23 23:47:11 +02:00
|
|
|
* @returns {Promise<Object>} - A full state update.
|
2018-03-15 23:27:10 +01:00
|
|
|
*/
|
2017-02-21 23:25:47 +01:00
|
|
|
signPersonalMessage (msgParams) {
|
2017-02-23 23:23:45 +01:00
|
|
|
log.info('MetaMaskController - signPersonalMessage')
|
2017-02-21 23:25:47 +01:00
|
|
|
const msgId = msgParams.metamaskId
|
|
|
|
// sets the status op the message to 'approved'
|
|
|
|
// and removes the metamaskId for signing
|
|
|
|
return this.personalMessageManager.approveMessage(msgParams)
|
2019-07-31 22:17:11 +02:00
|
|
|
.then((cleanMsgParams) => {
|
2017-02-21 23:25:47 +01:00
|
|
|
// signs the message
|
2019-07-31 22:17:11 +02:00
|
|
|
return this.keyringController.signPersonalMessage(cleanMsgParams)
|
|
|
|
})
|
|
|
|
.then((rawSig) => {
|
2017-02-21 23:25:47 +01:00
|
|
|
// tells the listener that the message has been signed
|
|
|
|
// and can be returned to the dapp
|
2019-07-31 22:17:11 +02:00
|
|
|
this.personalMessageManager.setMsgStatusSigned(msgId, rawSig)
|
|
|
|
return this.getState()
|
|
|
|
})
|
2017-02-21 23:25:47 +01:00
|
|
|
}
|
2018-03-28 03:07:51 +02:00
|
|
|
|
2018-04-20 18:26:24 +02:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* Used to cancel a personal_sign type message.
|
2018-04-20 18:26:24 +02:00
|
|
|
* @param {string} msgId - The ID of the message to cancel.
|
2018-04-19 02:54:50 +02:00
|
|
|
* @param {Function} cb - The callback function called with a full state update.
|
|
|
|
*/
|
|
|
|
cancelPersonalMessage (msgId, cb) {
|
|
|
|
const messageManager = this.personalMessageManager
|
|
|
|
messageManager.rejectMsg(msgId)
|
2020-08-19 18:27:05 +02:00
|
|
|
if (!cb || typeof cb !== 'function') {
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2018-04-19 02:54:50 +02:00
|
|
|
}
|
2020-08-19 18:27:05 +02:00
|
|
|
cb(null, this.getState())
|
2018-04-19 02:54:50 +02:00
|
|
|
}
|
|
|
|
|
2020-02-19 19:24:16 +01:00
|
|
|
// eth_decrypt methods
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a dapp uses the eth_decrypt method.
|
|
|
|
*
|
|
|
|
* @param {Object} msgParams - The params of the message to sign & return to the Dapp.
|
|
|
|
* @param {Object} req - (optional) the original request, containing the origin
|
|
|
|
* Passed back to the requesting Dapp.
|
|
|
|
*/
|
|
|
|
async newRequestDecryptMessage (msgParams, req) {
|
|
|
|
const promise = this.decryptMessageManager.addUnapprovedMessageAsync(msgParams, req)
|
|
|
|
this.sendUpdate()
|
|
|
|
this.opts.showUnconfirmedMessage()
|
|
|
|
return promise
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-07-20 19:02:49 +02:00
|
|
|
* Only decrypt message and don't touch transaction state
|
2020-02-19 19:24:16 +01:00
|
|
|
*
|
|
|
|
* @param {Object} msgParams - The params of the message to decrypt.
|
|
|
|
* @returns {Promise<Object>} - A full state update.
|
|
|
|
*/
|
|
|
|
async decryptMessageInline (msgParams) {
|
|
|
|
log.info('MetaMaskController - decryptMessageInline')
|
|
|
|
// decrypt the message inline
|
|
|
|
const msgId = msgParams.metamaskId
|
|
|
|
const msg = this.decryptMessageManager.getMsg(msgId)
|
|
|
|
try {
|
|
|
|
const stripped = ethUtil.stripHexPrefix(msgParams.data)
|
|
|
|
const buff = Buffer.from(stripped, 'hex')
|
|
|
|
msgParams.data = JSON.parse(buff.toString('utf8'))
|
|
|
|
|
|
|
|
msg.rawData = await this.keyringController.decryptMessage(msgParams)
|
|
|
|
} catch (e) {
|
|
|
|
msg.error = e.message
|
|
|
|
}
|
|
|
|
this.decryptMessageManager._updateMsg(msg)
|
|
|
|
|
|
|
|
return this.getState()
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Signifies a user's approval to decrypt a message in queue.
|
|
|
|
* Triggers decrypt, and the callback function from newUnsignedDecryptMessage.
|
|
|
|
*
|
|
|
|
* @param {Object} msgParams - The params of the message to decrypt & return to the Dapp.
|
|
|
|
* @returns {Promise<Object>} - A full state update.
|
|
|
|
*/
|
|
|
|
async decryptMessage (msgParams) {
|
|
|
|
log.info('MetaMaskController - decryptMessage')
|
|
|
|
const msgId = msgParams.metamaskId
|
|
|
|
// sets the status op the message to 'approved'
|
|
|
|
// and removes the metamaskId for decryption
|
|
|
|
try {
|
|
|
|
const cleanMsgParams = await this.decryptMessageManager.approveMessage(msgParams)
|
|
|
|
|
|
|
|
const stripped = ethUtil.stripHexPrefix(cleanMsgParams.data)
|
|
|
|
const buff = Buffer.from(stripped, 'hex')
|
|
|
|
cleanMsgParams.data = JSON.parse(buff.toString('utf8'))
|
|
|
|
|
|
|
|
// decrypt the message
|
|
|
|
const rawMess = await this.keyringController.decryptMessage(cleanMsgParams)
|
|
|
|
// tells the listener that the message has been decrypted and can be returned to the dapp
|
|
|
|
this.decryptMessageManager.setMsgStatusDecrypted(msgId, rawMess)
|
|
|
|
} catch (error) {
|
|
|
|
log.info('MetaMaskController - eth_decrypt failed.', error)
|
|
|
|
this.decryptMessageManager.errorMessage(msgId, error)
|
|
|
|
}
|
|
|
|
return this.getState()
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to cancel a eth_decrypt type message.
|
|
|
|
* @param {string} msgId - The ID of the message to cancel.
|
|
|
|
* @param {Function} cb - The callback function called with a full state update.
|
|
|
|
*/
|
|
|
|
cancelDecryptMessage (msgId, cb) {
|
|
|
|
const messageManager = this.decryptMessageManager
|
|
|
|
messageManager.rejectMsg(msgId)
|
2020-08-19 18:27:05 +02:00
|
|
|
if (!cb || typeof cb !== 'function') {
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2020-02-19 19:24:16 +01:00
|
|
|
}
|
2020-08-19 18:27:05 +02:00
|
|
|
cb(null, this.getState())
|
2020-02-19 19:24:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// eth_getEncryptionPublicKey methods
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a dapp uses the eth_getEncryptionPublicKey method.
|
|
|
|
*
|
|
|
|
* @param {Object} msgParams - The params of the message to sign & return to the Dapp.
|
|
|
|
* @param {Object} req - (optional) the original request, containing the origin
|
|
|
|
* Passed back to the requesting Dapp.
|
|
|
|
*/
|
|
|
|
async newRequestEncryptionPublicKey (msgParams, req) {
|
|
|
|
const promise = this.encryptionPublicKeyManager.addUnapprovedMessageAsync(msgParams, req)
|
|
|
|
this.sendUpdate()
|
|
|
|
this.opts.showUnconfirmedMessage()
|
|
|
|
return promise
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Signifies a user's approval to receiving encryption public key in queue.
|
|
|
|
* Triggers receiving, and the callback function from newUnsignedEncryptionPublicKey.
|
|
|
|
*
|
|
|
|
* @param {Object} msgParams - The params of the message to receive & return to the Dapp.
|
|
|
|
* @returns {Promise<Object>} - A full state update.
|
|
|
|
*/
|
|
|
|
async encryptionPublicKey (msgParams) {
|
|
|
|
log.info('MetaMaskController - encryptionPublicKey')
|
|
|
|
const msgId = msgParams.metamaskId
|
|
|
|
// sets the status op the message to 'approved'
|
|
|
|
// and removes the metamaskId for decryption
|
|
|
|
try {
|
|
|
|
const params = await this.encryptionPublicKeyManager.approveMessage(msgParams)
|
|
|
|
|
|
|
|
// EncryptionPublicKey message
|
|
|
|
const publicKey = await this.keyringController.getEncryptionPublicKey(params.data)
|
|
|
|
|
|
|
|
// tells the listener that the message has been processed
|
|
|
|
// and can be returned to the dapp
|
|
|
|
this.encryptionPublicKeyManager.setMsgStatusReceived(msgId, publicKey)
|
|
|
|
} catch (error) {
|
|
|
|
log.info('MetaMaskController - eth_getEncryptionPublicKey failed.', error)
|
|
|
|
this.encryptionPublicKeyManager.errorMessage(msgId, error)
|
|
|
|
}
|
|
|
|
return this.getState()
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to cancel a eth_getEncryptionPublicKey type message.
|
|
|
|
* @param {string} msgId - The ID of the message to cancel.
|
|
|
|
* @param {Function} cb - The callback function called with a full state update.
|
|
|
|
*/
|
|
|
|
cancelEncryptionPublicKey (msgId, cb) {
|
|
|
|
const messageManager = this.encryptionPublicKeyManager
|
|
|
|
messageManager.rejectMsg(msgId)
|
2020-08-19 18:27:05 +02:00
|
|
|
if (!cb || typeof cb !== 'function') {
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2020-02-19 19:24:16 +01:00
|
|
|
}
|
2020-08-19 18:27:05 +02:00
|
|
|
cb(null, this.getState())
|
2020-02-19 19:24:16 +01:00
|
|
|
}
|
|
|
|
|
2018-04-19 02:54:50 +02:00
|
|
|
// eth_signTypedData methods
|
|
|
|
|
2018-04-20 18:26:24 +02:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* Called when a dapp uses the eth_signTypedData method, per EIP 712.
|
|
|
|
*
|
|
|
|
* @param {Object} msgParams - The params passed to eth_signTypedData.
|
|
|
|
* @param {Function} cb - The callback function, called with the signature.
|
|
|
|
*/
|
2018-10-25 05:24:42 +02:00
|
|
|
newUnsignedTypedMessage (msgParams, req, version) {
|
|
|
|
const promise = this.typedMessageManager.addUnapprovedMessageAsync(msgParams, req, version)
|
2018-08-17 18:56:07 +02:00
|
|
|
this.sendUpdate()
|
|
|
|
this.opts.showUnconfirmedMessage()
|
|
|
|
return promise
|
2018-04-19 02:54:50 +02:00
|
|
|
}
|
|
|
|
|
2018-03-15 23:27:10 +01:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* The method for a user approving a call to eth_signTypedData, per EIP 712.
|
|
|
|
* Triggers the callback in newUnsignedTypedMessage.
|
|
|
|
*
|
|
|
|
* @param {Object} msgParams - The params passed to eth_signTypedData.
|
2020-08-12 21:06:57 +02:00
|
|
|
* @returns {Object|undefined} - Full state update.
|
2018-03-15 23:27:10 +01:00
|
|
|
*/
|
2018-09-10 23:11:57 +02:00
|
|
|
async signTypedMessage (msgParams) {
|
|
|
|
log.info('MetaMaskController - eth_signTypedData')
|
2017-09-29 18:24:08 +02:00
|
|
|
const msgId = msgParams.metamaskId
|
2020-08-18 22:06:58 +02:00
|
|
|
const { version } = msgParams
|
2018-09-10 23:11:57 +02:00
|
|
|
try {
|
|
|
|
const cleanMsgParams = await this.typedMessageManager.approveMessage(msgParams)
|
2019-10-22 20:33:49 +02:00
|
|
|
|
2019-10-22 23:53:25 +02:00
|
|
|
// For some reason every version after V1 used stringified params.
|
2019-10-22 20:33:49 +02:00
|
|
|
if (version !== 'V1') {
|
2019-10-22 23:53:25 +02:00
|
|
|
// But we don't have to require that. We can stop suggesting it now:
|
|
|
|
if (typeof cleanMsgParams.data === 'string') {
|
|
|
|
cleanMsgParams.data = JSON.parse(cleanMsgParams.data)
|
|
|
|
}
|
2018-09-10 23:11:57 +02:00
|
|
|
}
|
2019-10-22 20:33:49 +02:00
|
|
|
|
|
|
|
const signature = await this.keyringController.signTypedMessage(cleanMsgParams, { version })
|
2018-09-10 23:11:57 +02:00
|
|
|
this.typedMessageManager.setMsgStatusSigned(msgId, signature)
|
|
|
|
return this.getState()
|
|
|
|
} catch (error) {
|
|
|
|
log.info('MetaMaskController - eth_signTypedData failed.', error)
|
|
|
|
this.typedMessageManager.errorMessage(msgId, error)
|
2020-08-12 21:06:57 +02:00
|
|
|
return undefined
|
2018-09-10 23:11:57 +02:00
|
|
|
}
|
2017-09-29 18:24:08 +02:00
|
|
|
}
|
2018-03-28 03:07:51 +02:00
|
|
|
|
2018-04-20 18:26:24 +02:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* Used to cancel a eth_signTypedData type message.
|
2018-04-20 18:26:24 +02:00
|
|
|
* @param {string} msgId - The ID of the message to cancel.
|
2018-04-19 02:54:50 +02:00
|
|
|
* @param {Function} cb - The callback function called with a full state update.
|
|
|
|
*/
|
|
|
|
cancelTypedMessage (msgId, cb) {
|
|
|
|
const messageManager = this.typedMessageManager
|
|
|
|
messageManager.rejectMsg(msgId)
|
2020-08-19 18:27:05 +02:00
|
|
|
if (!cb || typeof cb !== 'function') {
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2018-04-19 02:54:50 +02:00
|
|
|
}
|
2020-08-19 18:27:05 +02:00
|
|
|
cb(null, this.getState())
|
2018-04-19 02:54:50 +02:00
|
|
|
}
|
|
|
|
|
2019-07-31 22:17:11 +02:00
|
|
|
//=============================================================================
|
|
|
|
// END (VAULT / KEYRING RELATED METHODS)
|
|
|
|
//=============================================================================
|
2018-03-16 01:29:53 +01:00
|
|
|
|
2018-09-09 19:07:23 +02:00
|
|
|
/**
|
|
|
|
* Allows a user to attempt to cancel a previously submitted transaction by creating a new
|
|
|
|
* transaction.
|
|
|
|
* @param {number} originalTxId - the id of the txMeta that you want to attempt to cancel
|
2020-01-13 19:36:36 +01:00
|
|
|
* @param {string} [customGasPrice] - the hex value to use for the cancel transaction
|
|
|
|
* @returns {Object} - MetaMask state
|
2018-09-09 19:07:23 +02:00
|
|
|
*/
|
2019-05-08 21:51:33 +02:00
|
|
|
async createCancelTransaction (originalTxId, customGasPrice) {
|
2020-08-12 21:07:15 +02:00
|
|
|
await this.txController.createCancelTransaction(originalTxId, customGasPrice)
|
|
|
|
const state = await this.getState()
|
|
|
|
return state
|
2017-12-07 05:20:15 +01:00
|
|
|
}
|
|
|
|
|
2020-03-12 15:33:11 +01:00
|
|
|
async createSpeedUpTransaction (originalTxId, customGasPrice, customGasLimit) {
|
|
|
|
await this.txController.createSpeedUpTransaction(originalTxId, customGasPrice, customGasLimit)
|
2018-10-26 06:42:59 +02:00
|
|
|
const state = await this.getState()
|
|
|
|
return state
|
|
|
|
}
|
|
|
|
|
2018-05-23 18:43:25 +02:00
|
|
|
estimateGas (estimateGasParams) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
return this.txController.txGasUtil.query.estimateGas(estimateGasParams, (err, res) => {
|
|
|
|
if (err) {
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return resolve(res)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-07-31 22:17:11 +02:00
|
|
|
//=============================================================================
|
|
|
|
// PASSWORD MANAGEMENT
|
|
|
|
//=============================================================================
|
2017-01-27 07:30:12 +01:00
|
|
|
|
2018-04-20 18:26:24 +02:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* Allows a user to begin the seed phrase recovery process.
|
|
|
|
* @param {Function} cb - A callback function called when complete.
|
|
|
|
*/
|
2018-07-03 00:49:33 +02:00
|
|
|
markPasswordForgotten (cb) {
|
2018-09-11 02:01:15 +02:00
|
|
|
this.preferencesController.setPasswordForgotten(true)
|
2018-02-08 01:38:55 +01:00
|
|
|
this.sendUpdate()
|
|
|
|
cb()
|
|
|
|
}
|
|
|
|
|
2018-04-20 18:26:24 +02:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* Allows a user to end the seed phrase recovery process.
|
|
|
|
* @param {Function} cb - A callback function called when complete.
|
|
|
|
*/
|
2018-07-03 00:49:33 +02:00
|
|
|
unMarkPasswordForgotten (cb) {
|
2018-09-11 02:01:15 +02:00
|
|
|
this.preferencesController.setPasswordForgotten(false)
|
2018-02-08 01:38:55 +01:00
|
|
|
this.sendUpdate()
|
|
|
|
cb()
|
|
|
|
}
|
|
|
|
|
2019-07-31 22:17:11 +02:00
|
|
|
//=============================================================================
|
|
|
|
// SETUP
|
|
|
|
//=============================================================================
|
2017-01-28 04:35:03 +01:00
|
|
|
|
2019-12-20 16:32:31 +01:00
|
|
|
/**
|
|
|
|
* A runtime.MessageSender object, as provided by the browser:
|
|
|
|
* @see https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/MessageSender
|
|
|
|
* @typedef {Object} MessageSender
|
|
|
|
*/
|
|
|
|
|
2018-04-20 18:26:24 +02:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* Used to create a multiplexed stream for connecting to an untrusted context
|
|
|
|
* like a Dapp or other extension.
|
|
|
|
* @param {*} connectionStream - The Duplex stream to connect to.
|
2019-12-20 16:32:31 +01:00
|
|
|
* @param {MessageSender} sender - The sender of the messages on this stream
|
2018-04-19 02:54:50 +02:00
|
|
|
*/
|
2019-12-20 16:32:31 +01:00
|
|
|
setupUntrustedCommunication (connectionStream, sender) {
|
2020-02-27 07:29:41 +01:00
|
|
|
const { usePhishDetect } = this.preferencesController.store.getState()
|
2020-08-18 22:06:58 +02:00
|
|
|
const { hostname } = new URL(sender.url)
|
2020-06-08 19:37:47 +02:00
|
|
|
// Check if new connection is blocked if phishing detection is on
|
2020-02-27 07:29:41 +01:00
|
|
|
if (usePhishDetect && this.phishingController.test(hostname)) {
|
2019-12-20 16:32:31 +01:00
|
|
|
log.debug('MetaMask - sending phishing warning for', hostname)
|
|
|
|
this.sendPhishingWarning(connectionStream, hostname)
|
2018-03-16 17:37:56 +01:00
|
|
|
return
|
2016-06-24 22:05:21 +02:00
|
|
|
}
|
2018-03-16 17:37:56 +01:00
|
|
|
|
|
|
|
// setup multiplexing
|
|
|
|
const mux = setupMultiplex(connectionStream)
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
|
|
|
|
// messages between inpage and background
|
2019-12-20 16:32:31 +01:00
|
|
|
this.setupProviderConnection(mux.createStream('provider'), sender)
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
this.setupPublicConfig(mux.createStream('publicConfig'))
|
2016-06-24 22:05:21 +02:00
|
|
|
}
|
|
|
|
|
2018-04-20 18:26:24 +02:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* Used to create a multiplexed stream for connecting to a trusted context,
|
|
|
|
* like our own user interfaces, which have the provider APIs, but also
|
|
|
|
* receive the exported API from this controller, which includes trusted
|
|
|
|
* functions, like the ability to approve transactions or sign messages.
|
|
|
|
*
|
|
|
|
* @param {*} connectionStream - The duplex stream to connect to.
|
2019-12-20 16:32:31 +01:00
|
|
|
* @param {MessageSender} sender - The sender of the messages on this stream
|
2018-04-19 02:54:50 +02:00
|
|
|
*/
|
2019-12-20 16:32:31 +01:00
|
|
|
setupTrustedCommunication (connectionStream, sender) {
|
2018-03-16 17:37:56 +01:00
|
|
|
// setup multiplexing
|
|
|
|
const mux = setupMultiplex(connectionStream)
|
|
|
|
// connect features
|
|
|
|
this.setupControllerConnection(mux.createStream('controller'))
|
2019-12-20 16:32:31 +01:00
|
|
|
this.setupProviderConnection(mux.createStream('provider'), sender, true)
|
2018-03-16 17:37:56 +01:00
|
|
|
}
|
|
|
|
|
2018-04-20 18:26:24 +02:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* Called when we detect a suspicious domain. Requests the browser redirects
|
|
|
|
* to our anti-phishing page.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @param {*} connectionStream - The duplex stream to the per-page script,
|
|
|
|
* for sending the reload attempt to.
|
2020-06-02 01:24:27 +02:00
|
|
|
* @param {string} hostname - The hostname that triggered the suspicion.
|
2018-04-19 02:54:50 +02:00
|
|
|
*/
|
2018-03-16 17:37:56 +01:00
|
|
|
sendPhishingWarning (connectionStream, hostname) {
|
|
|
|
const mux = setupMultiplex(connectionStream)
|
|
|
|
const phishingStream = mux.createStream('phishing')
|
|
|
|
phishingStream.write({ hostname })
|
|
|
|
}
|
|
|
|
|
2018-04-20 18:26:24 +02:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* A method for providing our API over a stream using Dnode.
|
|
|
|
* @param {*} outStream - The stream to provide our API over.
|
|
|
|
*/
|
2018-03-16 17:37:56 +01:00
|
|
|
setupControllerConnection (outStream) {
|
|
|
|
const api = this.getApi()
|
|
|
|
const dnode = Dnode(api)
|
2018-08-22 01:30:11 +02:00
|
|
|
// report new active controller connection
|
2020-08-13 01:06:44 +02:00
|
|
|
this.activeControllerConnections += 1
|
2018-08-22 01:30:11 +02:00
|
|
|
this.emit('controllerConnectionChanged', this.activeControllerConnections)
|
|
|
|
// connect dnode api to remote connection
|
2018-03-16 17:37:56 +01:00
|
|
|
pump(
|
|
|
|
outStream,
|
|
|
|
dnode,
|
|
|
|
outStream,
|
|
|
|
(err) => {
|
2018-08-22 01:30:11 +02:00
|
|
|
// report new active controller connection
|
2020-08-13 01:06:44 +02:00
|
|
|
this.activeControllerConnections -= 1
|
2018-08-22 01:30:11 +02:00
|
|
|
this.emit('controllerConnectionChanged', this.activeControllerConnections)
|
|
|
|
// report any error
|
2019-11-20 01:03:20 +01:00
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
|
|
|
}
|
2020-07-14 17:20:41 +02:00
|
|
|
},
|
2018-03-16 17:37:56 +01:00
|
|
|
)
|
|
|
|
dnode.on('remote', (remote) => {
|
|
|
|
// push updates to popup
|
2018-09-10 02:33:09 +02:00
|
|
|
const sendUpdate = (update) => remote.sendUpdate(update)
|
2018-03-16 17:37:56 +01:00
|
|
|
this.on('update', sendUpdate)
|
2018-09-10 02:33:09 +02:00
|
|
|
// remove update listener once the connection ends
|
|
|
|
dnode.on('end', () => this.removeListener('update', sendUpdate))
|
2017-01-28 04:35:03 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-04-20 18:26:24 +02:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* A method for serving our ethereum provider over a given stream.
|
|
|
|
* @param {*} outStream - The stream to provide over.
|
2019-12-20 16:32:31 +01:00
|
|
|
* @param {MessageSender} sender - The sender of the messages on this stream
|
|
|
|
* @param {boolean} isInternal - True if this is a connection with an internal process
|
2018-04-19 02:54:50 +02:00
|
|
|
*/
|
2019-12-20 16:32:31 +01:00
|
|
|
setupProviderConnection (outStream, sender, isInternal) {
|
|
|
|
const origin = isInternal
|
|
|
|
? 'metamask'
|
2020-06-02 01:24:27 +02:00
|
|
|
: (new URL(sender.url)).origin
|
2019-12-20 16:32:31 +01:00
|
|
|
let extensionId
|
|
|
|
if (sender.id !== extension.runtime.id) {
|
|
|
|
extensionId = sender.id
|
|
|
|
}
|
|
|
|
let tabId
|
|
|
|
if (sender.tab && sender.tab.id) {
|
|
|
|
tabId = sender.tab.id
|
|
|
|
}
|
|
|
|
|
2020-05-29 19:53:31 +02:00
|
|
|
const engine = this.setupProviderEngine({ origin, location: sender.url, extensionId, tabId, isInternal })
|
2019-07-16 01:28:04 +02:00
|
|
|
|
|
|
|
// setup connection
|
|
|
|
const providerStream = createEngineStream({ engine })
|
|
|
|
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
const connectionId = this.addConnection(origin, { engine })
|
|
|
|
|
2019-07-16 01:28:04 +02:00
|
|
|
pump(
|
|
|
|
outStream,
|
|
|
|
providerStream,
|
|
|
|
outStream,
|
|
|
|
(err) => {
|
2019-10-30 02:38:00 +01:00
|
|
|
// handle any middleware cleanup
|
2019-07-16 01:28:04 +02:00
|
|
|
engine._middleware.forEach((mid) => {
|
|
|
|
if (mid.destroy && typeof mid.destroy === 'function') {
|
|
|
|
mid.destroy()
|
|
|
|
}
|
|
|
|
})
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
connectionId && this.removeConnection(origin, connectionId)
|
2019-11-20 01:03:20 +01:00
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
|
|
|
}
|
2020-07-14 17:20:41 +02:00
|
|
|
},
|
2019-07-16 01:28:04 +02:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A method for creating a provider that is safely restricted for the requesting domain.
|
2019-12-20 16:32:31 +01:00
|
|
|
* @param {Object} options - Provider engine options
|
2020-06-02 01:24:27 +02:00
|
|
|
* @param {string} options.origin - The origin of the sender
|
2019-12-20 16:32:31 +01:00
|
|
|
* @param {string} options.location - The full URL of the sender
|
|
|
|
* @param {extensionId} [options.extensionId] - The extension ID of the sender, if the sender is an external extension
|
|
|
|
* @param {tabId} [options.tabId] - The tab ID of the sender - if the sender is within a tab
|
2020-05-29 19:53:31 +02:00
|
|
|
* @param {boolean} [options.isInternal] - True if called for a connection to an internal process
|
2019-07-16 01:28:04 +02:00
|
|
|
**/
|
2020-05-29 19:53:31 +02:00
|
|
|
setupProviderEngine ({ origin, location, extensionId, tabId, isInternal = false }) {
|
2018-03-16 17:37:56 +01:00
|
|
|
// setup json rpc engine stack
|
|
|
|
const engine = new RpcEngine()
|
2020-08-18 22:06:58 +02:00
|
|
|
const { provider, blockTracker } = this
|
2018-03-16 17:37:56 +01:00
|
|
|
|
|
|
|
// create filter polyfill middleware
|
2018-10-08 17:55:07 +02:00
|
|
|
const filterMiddleware = createFilterMiddleware({ provider, blockTracker })
|
2019-07-16 01:28:04 +02:00
|
|
|
|
2018-10-08 17:55:07 +02:00
|
|
|
// create subscription polyfill middleware
|
|
|
|
const subscriptionManager = createSubscriptionManager({ provider, blockTracker })
|
|
|
|
subscriptionManager.events.on('notification', (message) => engine.emit('notification', message))
|
2018-03-16 17:37:56 +01:00
|
|
|
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
// append origin to each request
|
2018-03-16 17:37:56 +01:00
|
|
|
engine.push(createOriginMiddleware({ origin }))
|
2020-02-20 23:39:00 +01:00
|
|
|
// append tabId to each request if it exists
|
|
|
|
if (tabId) {
|
|
|
|
engine.push(createTabIdMiddleware({ tabId }))
|
|
|
|
}
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
// logging
|
2018-03-16 17:37:56 +01:00
|
|
|
engine.push(createLoggerMiddleware({ origin }))
|
2019-12-20 16:32:31 +01:00
|
|
|
engine.push(createOnboardingMiddleware({
|
|
|
|
location,
|
|
|
|
registerOnboarding: this.onboardingController.registerOnboarding,
|
|
|
|
}))
|
2020-08-07 21:28:23 +02:00
|
|
|
engine.push(createMethodMiddleware({
|
|
|
|
origin,
|
|
|
|
sendMetrics: this.sendBackgroundMetaMetrics.bind(this),
|
|
|
|
}))
|
2018-10-08 17:55:07 +02:00
|
|
|
// filter and subscription polyfills
|
2018-03-16 17:37:56 +01:00
|
|
|
engine.push(filterMiddleware)
|
2018-10-08 17:55:07 +02:00
|
|
|
engine.push(subscriptionManager.middleware)
|
2020-05-29 19:53:31 +02:00
|
|
|
if (!isInternal) {
|
|
|
|
// permissions
|
|
|
|
engine.push(this.permissionsController.createMiddleware({ origin, extensionId }))
|
|
|
|
}
|
2018-10-08 17:55:07 +02:00
|
|
|
// watch asset
|
2018-08-21 03:32:14 +02:00
|
|
|
engine.push(this.preferencesController.requestWatchAsset.bind(this.preferencesController))
|
2018-10-08 17:55:07 +02:00
|
|
|
// forward to metamask primary provider
|
2019-04-04 16:11:28 +02:00
|
|
|
engine.push(providerAsMiddleware(provider))
|
2019-07-16 01:28:04 +02:00
|
|
|
return engine
|
2018-03-16 17:37:56 +01:00
|
|
|
}
|
|
|
|
|
2018-04-20 18:26:24 +02:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* A method for providing our public config info over a stream.
|
|
|
|
* This includes info we like to be synchronous if possible, like
|
|
|
|
* the current selected account, and network ID.
|
|
|
|
*
|
|
|
|
* Since synchronous methods have been deprecated in web3,
|
|
|
|
* this is a good candidate for deprecation.
|
|
|
|
*
|
|
|
|
* @param {*} outStream - The stream to provide public config over.
|
|
|
|
*/
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
setupPublicConfig (outStream) {
|
|
|
|
const configStore = this.createPublicConfigStore()
|
2019-05-03 19:32:05 +02:00
|
|
|
const configStream = asStream(configStore)
|
|
|
|
|
2018-03-16 17:37:56 +01:00
|
|
|
pump(
|
2018-09-10 02:33:09 +02:00
|
|
|
configStream,
|
2018-03-16 17:37:56 +01:00
|
|
|
outStream,
|
|
|
|
(err) => {
|
2019-05-03 19:32:05 +02:00
|
|
|
configStore.destroy()
|
2018-09-10 02:33:09 +02:00
|
|
|
configStream.destroy()
|
2019-11-20 01:03:20 +01:00
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
|
|
|
}
|
2020-07-14 17:20:41 +02:00
|
|
|
},
|
2018-03-16 17:37:56 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-05-03 19:32:05 +02:00
|
|
|
/**
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
* Adds a reference to a connection by origin. Ignores the 'metamask' origin.
|
|
|
|
* Caller must ensure that the returned id is stored such that the reference
|
|
|
|
* can be deleted later.
|
2019-05-03 19:32:05 +02:00
|
|
|
*
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
* @param {string} origin - The connection's origin string.
|
|
|
|
* @param {Object} options - Data associated with the connection
|
|
|
|
* @param {Object} options.engine - The connection's JSON Rpc Engine
|
|
|
|
* @returns {string} - The connection's id (so that it can be deleted later)
|
2019-05-03 19:32:05 +02:00
|
|
|
*/
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
addConnection (origin, { engine }) {
|
|
|
|
|
|
|
|
if (origin === 'metamask') {
|
|
|
|
return null
|
|
|
|
}
|
2019-05-03 19:32:05 +02:00
|
|
|
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
if (!this.connections[origin]) {
|
|
|
|
this.connections[origin] = {}
|
|
|
|
}
|
2019-05-03 19:32:05 +02:00
|
|
|
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
const id = nanoid()
|
|
|
|
this.connections[origin][id] = {
|
|
|
|
engine,
|
|
|
|
}
|
|
|
|
|
|
|
|
return id
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deletes a reference to a connection, by origin and id.
|
|
|
|
* Ignores unknown origins.
|
|
|
|
*
|
|
|
|
* @param {string} origin - The connection's origin string.
|
|
|
|
* @param {string} id - The connection's id, as returned from addConnection.
|
|
|
|
*/
|
|
|
|
removeConnection (origin, id) {
|
|
|
|
|
|
|
|
const connections = this.connections[origin]
|
|
|
|
if (!connections) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
delete connections[id]
|
|
|
|
|
2020-08-04 22:02:48 +02:00
|
|
|
if (Object.keys(connections).length === 0) {
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
delete this.connections[origin]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Causes the RPC engines associated with the connections to the given origin
|
|
|
|
* to emit a notification event with the given payload.
|
|
|
|
* Does nothing if the extension is locked or the origin is unknown.
|
|
|
|
*
|
|
|
|
* @param {string} origin - The connection's origin string.
|
|
|
|
* @param {any} payload - The event payload.
|
|
|
|
*/
|
|
|
|
notifyConnections (origin, payload) {
|
|
|
|
|
|
|
|
const connections = this.connections[origin]
|
2020-03-23 17:25:55 +01:00
|
|
|
if (!this.isUnlocked() || !connections) {
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
return
|
2019-05-03 19:32:05 +02:00
|
|
|
}
|
|
|
|
|
2020-02-15 21:34:12 +01:00
|
|
|
Object.values(connections).forEach((conn) => {
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
conn.engine && conn.engine.emit('notification', payload)
|
|
|
|
})
|
2019-05-03 19:32:05 +02:00
|
|
|
}
|
|
|
|
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
/**
|
|
|
|
* Causes the RPC engines associated with all connections to emit a
|
|
|
|
* notification event with the given payload.
|
|
|
|
* Does nothing if the extension is locked.
|
|
|
|
*
|
|
|
|
* @param {any} payload - The event payload.
|
|
|
|
*/
|
|
|
|
notifyAllConnections (payload) {
|
|
|
|
|
2020-03-23 17:25:55 +01:00
|
|
|
if (!this.isUnlocked()) {
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-02-15 21:34:12 +01:00
|
|
|
Object.values(this.connections).forEach((origin) => {
|
|
|
|
Object.values(origin).forEach((conn) => {
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
conn.engine && conn.engine.emit('notification', payload)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// handlers
|
|
|
|
|
2018-04-20 18:26:24 +02:00
|
|
|
/**
|
2018-08-16 17:29:39 +02:00
|
|
|
* Handle a KeyringController update
|
2020-01-13 19:36:36 +01:00
|
|
|
* @param {Object} state - the KC state
|
|
|
|
* @returns {Promise<void>}
|
2018-08-16 17:29:39 +02:00
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
async _onKeyringControllerUpdate (state) {
|
2020-03-20 20:37:27 +01:00
|
|
|
const { keyrings } = state
|
2019-12-03 21:50:55 +01:00
|
|
|
const addresses = keyrings.reduce((acc, { accounts }) => acc.concat(accounts), [])
|
2018-08-16 17:29:39 +02:00
|
|
|
|
|
|
|
if (!addresses.length) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ensure preferences + identities controller know about all addresses
|
2020-03-20 20:37:27 +01:00
|
|
|
this.preferencesController.syncAddresses(addresses)
|
2018-08-16 17:29:39 +02:00
|
|
|
this.accountTracker.syncWithAddresses(addresses)
|
|
|
|
}
|
|
|
|
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
// misc
|
|
|
|
|
2018-04-20 18:26:24 +02:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* A method for emitting the full MetaMask state to all registered listeners.
|
|
|
|
* @private
|
|
|
|
*/
|
2018-03-16 17:37:56 +01:00
|
|
|
privateSendUpdate () {
|
|
|
|
this.emit('update', this.getState())
|
|
|
|
}
|
|
|
|
|
2020-03-23 17:25:55 +01:00
|
|
|
/**
|
|
|
|
* @returns {boolean} Whether the extension is unlocked.
|
|
|
|
*/
|
|
|
|
isUnlocked () {
|
|
|
|
return this.keyringController.memStore.getState().isUnlocked
|
|
|
|
}
|
|
|
|
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
//=============================================================================
|
|
|
|
// MISCELLANEOUS
|
|
|
|
//=============================================================================
|
|
|
|
|
2018-09-21 19:34:21 +02:00
|
|
|
/**
|
|
|
|
* Returns the nonce that will be associated with a transaction once approved
|
2020-01-13 19:36:36 +01:00
|
|
|
* @param {string} address - The hex string address for the transaction
|
|
|
|
* @returns {Promise<number>}
|
2018-09-21 19:34:21 +02:00
|
|
|
*/
|
|
|
|
async getPendingNonce (address) {
|
2019-10-02 20:12:04 +02:00
|
|
|
const { nonceDetails, releaseLock } = await this.txController.nonceTracker.getNonceLock(address)
|
2018-09-21 19:34:21 +02:00
|
|
|
const pendingNonce = nonceDetails.params.highestSuggested
|
|
|
|
|
|
|
|
releaseLock()
|
|
|
|
return pendingNonce
|
|
|
|
}
|
|
|
|
|
2019-10-02 20:12:04 +02:00
|
|
|
/**
|
|
|
|
* Returns the next nonce according to the nonce-tracker
|
2020-01-13 19:36:36 +01:00
|
|
|
* @param {string} address - The hex string address for the transaction
|
|
|
|
* @returns {Promise<number>}
|
2019-10-02 20:12:04 +02:00
|
|
|
*/
|
|
|
|
async getNextNonce (address) {
|
|
|
|
let nonceLock
|
|
|
|
try {
|
|
|
|
nonceLock = await this.txController.nonceTracker.getNonceLock(address)
|
|
|
|
} finally {
|
|
|
|
nonceLock.releaseLock()
|
|
|
|
}
|
|
|
|
return nonceLock.nextNonce
|
|
|
|
}
|
|
|
|
|
2020-08-07 21:28:23 +02:00
|
|
|
async sendBackgroundMetaMetrics ({ action, name, customVariables } = {}) {
|
|
|
|
|
|
|
|
if (!action || !name) {
|
|
|
|
throw new Error('Must provide action and name.')
|
|
|
|
}
|
|
|
|
|
|
|
|
const metamaskState = await this.getState()
|
2020-08-10 17:10:30 +02:00
|
|
|
const version = this.platform.getVersion()
|
|
|
|
backgroundMetaMetricsEvent(
|
|
|
|
metamaskState,
|
|
|
|
version,
|
|
|
|
{
|
|
|
|
customVariables,
|
|
|
|
eventOpts: {
|
|
|
|
action,
|
2020-08-10 17:38:56 +02:00
|
|
|
category: 'Background',
|
2020-08-10 17:10:30 +02:00
|
|
|
name,
|
|
|
|
},
|
2020-08-07 21:28:23 +02:00
|
|
|
},
|
2020-08-10 17:10:30 +02:00
|
|
|
)
|
2020-08-07 21:28:23 +02:00
|
|
|
}
|
|
|
|
|
2019-07-31 22:17:11 +02:00
|
|
|
//=============================================================================
|
|
|
|
// CONFIG
|
|
|
|
//=============================================================================
|
2016-06-24 22:05:21 +02:00
|
|
|
|
2017-01-28 04:35:03 +01:00
|
|
|
// Log blocks
|
2016-10-06 12:24:28 +02:00
|
|
|
|
2018-04-20 18:26:24 +02:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* A method for setting the user's preferred display currency.
|
2018-04-20 18:26:24 +02:00
|
|
|
* @param {string} currencyCode - The code of the preferred currency.
|
2018-04-19 02:54:50 +02:00
|
|
|
* @param {Function} cb - A callback function returning currency info.
|
|
|
|
*/
|
2017-02-03 08:32:24 +01:00
|
|
|
setCurrentCurrency (currencyCode, cb) {
|
2018-10-26 10:26:43 +02:00
|
|
|
const { ticker } = this.networkController.getNetworkConfig()
|
2016-07-21 18:30:58 +02:00
|
|
|
try {
|
2019-06-01 00:14:22 +02:00
|
|
|
const currencyState = {
|
|
|
|
nativeCurrency: ticker,
|
|
|
|
currentCurrency: currencyCode,
|
2016-07-21 19:15:34 +02:00
|
|
|
}
|
2019-06-01 00:14:22 +02:00
|
|
|
this.currencyRateController.update(currencyState)
|
|
|
|
this.currencyRateController.configure(currencyState)
|
|
|
|
cb(null, this.currencyRateController.state)
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2016-12-16 21:44:47 +01:00
|
|
|
} catch (err) {
|
2017-02-03 08:32:24 +01:00
|
|
|
cb(err)
|
2020-08-19 18:27:05 +02:00
|
|
|
// eslint-disable-next-line no-useless-return
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2016-07-22 01:44:50 +02:00
|
|
|
}
|
2016-07-22 20:15:47 +02:00
|
|
|
}
|
|
|
|
|
2017-09-30 01:09:38 +02:00
|
|
|
// network
|
2019-01-29 19:13:51 +01:00
|
|
|
/**
|
|
|
|
* A method for selecting a custom URL for an ethereum RPC provider and updating it
|
|
|
|
* @param {string} rpcUrl - A URL for a valid Ethereum RPC API.
|
2020-07-08 23:05:09 +02:00
|
|
|
* @param {string} chainId - The chainId of the selected network.
|
2019-01-29 19:13:51 +01:00
|
|
|
* @param {string} ticker - The ticker symbol of the selected network.
|
|
|
|
* @param {string} nickname - Optional nickname of the selected network.
|
|
|
|
* @returns {Promise<String>} - The RPC Target URL confirmed.
|
|
|
|
*/
|
|
|
|
|
2019-05-09 19:27:14 +02:00
|
|
|
async updateAndSetCustomRpc (rpcUrl, chainId, ticker = 'ETH', nickname, rpcPrefs) {
|
|
|
|
await this.preferencesController.updateRpc({ rpcUrl, chainId, ticker, nickname, rpcPrefs })
|
|
|
|
this.networkController.setRpcTarget(rpcUrl, chainId, ticker, nickname, rpcPrefs)
|
2019-01-29 19:13:51 +01:00
|
|
|
return rpcUrl
|
|
|
|
}
|
|
|
|
|
2018-04-20 18:26:24 +02:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* A method for selecting a custom URL for an ethereum RPC provider.
|
2018-04-20 18:26:24 +02:00
|
|
|
* @param {string} rpcTarget - A URL for a valid Ethereum RPC API.
|
2020-07-08 23:05:09 +02:00
|
|
|
* @param {string} chainId - The chainId of the selected network.
|
2018-10-26 10:26:43 +02:00
|
|
|
* @param {string} ticker - The ticker symbol of the selected network.
|
|
|
|
* @param {string} nickname - Optional nickname of the selected network.
|
2018-04-19 02:54:50 +02:00
|
|
|
* @returns {Promise<String>} - The RPC Target URL confirmed.
|
|
|
|
*/
|
2019-05-09 19:27:14 +02:00
|
|
|
async setCustomRpc (rpcTarget, chainId, ticker = 'ETH', nickname = '', rpcPrefs = {}) {
|
2019-01-29 19:13:51 +01:00
|
|
|
const frequentRpcListDetail = this.preferencesController.getFrequentRpcListDetail()
|
|
|
|
const rpcSettings = frequentRpcListDetail.find((rpc) => rpcTarget === rpc.rpcUrl)
|
|
|
|
|
|
|
|
if (rpcSettings) {
|
2019-05-09 19:27:14 +02:00
|
|
|
this.networkController.setRpcTarget(rpcSettings.rpcUrl, rpcSettings.chainId, rpcSettings.ticker, rpcSettings.nickname, rpcPrefs)
|
2019-01-29 19:13:51 +01:00
|
|
|
} else {
|
2019-05-09 19:27:14 +02:00
|
|
|
this.networkController.setRpcTarget(rpcTarget, chainId, ticker, nickname, rpcPrefs)
|
|
|
|
await this.preferencesController.addToFrequentRpcList(rpcTarget, chainId, ticker, nickname, rpcPrefs)
|
2019-01-29 19:13:51 +01:00
|
|
|
}
|
2017-09-30 01:09:38 +02:00
|
|
|
return rpcTarget
|
2016-12-22 02:21:10 +01:00
|
|
|
}
|
2017-09-30 01:09:38 +02:00
|
|
|
|
2018-09-28 21:53:58 +02:00
|
|
|
/**
|
|
|
|
* A method for deleting a selected custom URL.
|
|
|
|
* @param {string} rpcTarget - A RPC URL to delete.
|
|
|
|
*/
|
|
|
|
async delCustomRpc (rpcTarget) {
|
2018-10-19 22:20:54 +02:00
|
|
|
await this.preferencesController.removeFromFrequentRpcList(rpcTarget)
|
2018-09-28 21:53:58 +02:00
|
|
|
}
|
|
|
|
|
2019-09-16 19:11:01 +02:00
|
|
|
async initializeThreeBox () {
|
2019-09-26 09:24:52 +02:00
|
|
|
await this.threeBoxController.init()
|
2019-09-16 19:11:01 +02:00
|
|
|
}
|
|
|
|
|
2018-04-20 18:26:24 +02:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* Sets whether or not to use the blockie identicon format.
|
2018-04-20 18:26:24 +02:00
|
|
|
* @param {boolean} val - True for bockie, false for jazzicon.
|
2018-04-19 02:54:50 +02:00
|
|
|
* @param {Function} cb - A callback function called when complete.
|
|
|
|
*/
|
2017-11-25 23:57:54 +01:00
|
|
|
setUseBlockie (val, cb) {
|
2017-11-24 18:35:17 +01:00
|
|
|
try {
|
|
|
|
this.preferencesController.setUseBlockie(val)
|
|
|
|
cb(null)
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2017-11-24 18:35:17 +01:00
|
|
|
} catch (err) {
|
|
|
|
cb(err)
|
2020-08-19 18:27:05 +02:00
|
|
|
// eslint-disable-next-line no-useless-return
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2019-09-27 06:30:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets whether or not to use the nonce field.
|
|
|
|
* @param {boolean} val - True for nonce field, false for not nonce field.
|
|
|
|
* @param {Function} cb - A callback function called when complete.
|
|
|
|
*/
|
|
|
|
setUseNonceField (val, cb) {
|
|
|
|
try {
|
|
|
|
this.preferencesController.setUseNonceField(val)
|
|
|
|
cb(null)
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2019-09-27 06:30:36 +02:00
|
|
|
} catch (err) {
|
|
|
|
cb(err)
|
2020-08-19 18:27:05 +02:00
|
|
|
// eslint-disable-next-line no-useless-return
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2019-12-12 20:28:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-27 07:29:41 +01:00
|
|
|
/**
|
|
|
|
* Sets whether or not to use phishing detection.
|
|
|
|
* @param {boolean} val
|
|
|
|
* @param {Function} cb
|
|
|
|
*/
|
|
|
|
setUsePhishDetect (val, cb) {
|
|
|
|
try {
|
|
|
|
this.preferencesController.setUsePhishDetect(val)
|
|
|
|
cb(null)
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2020-02-27 07:29:41 +01:00
|
|
|
} catch (err) {
|
|
|
|
cb(err)
|
2020-08-19 18:27:05 +02:00
|
|
|
// eslint-disable-next-line no-useless-return
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2020-02-27 07:29:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-12 20:28:07 +01:00
|
|
|
/**
|
|
|
|
* Sets the IPFS gateway to use for ENS content resolution.
|
|
|
|
* @param {string} val - the host of the gateway to set
|
|
|
|
* @param {Function} cb - A callback function called when complete.
|
|
|
|
*/
|
|
|
|
setIpfsGateway (val, cb) {
|
|
|
|
try {
|
|
|
|
this.preferencesController.setIpfsGateway(val)
|
|
|
|
cb(null)
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2019-12-12 20:28:07 +01:00
|
|
|
} catch (err) {
|
|
|
|
cb(err)
|
2020-08-19 18:27:05 +02:00
|
|
|
// eslint-disable-next-line no-useless-return
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2017-11-24 18:35:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-05 16:45:01 +01:00
|
|
|
/**
|
|
|
|
* Sets whether or not the user will have usage data tracked with MetaMetrics
|
|
|
|
* @param {boolean} bool - True for users that wish to opt-in, false for users that wish to remain out.
|
|
|
|
* @param {Function} cb - A callback function called when complete.
|
|
|
|
*/
|
|
|
|
setParticipateInMetaMetrics (bool, cb) {
|
|
|
|
try {
|
|
|
|
const metaMetricsId = this.preferencesController.setParticipateInMetaMetrics(bool)
|
|
|
|
cb(null, metaMetricsId)
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2019-03-05 16:45:01 +01:00
|
|
|
} catch (err) {
|
|
|
|
cb(err)
|
2020-08-19 18:27:05 +02:00
|
|
|
// eslint-disable-next-line no-useless-return
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2019-03-05 16:45:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setMetaMetricsSendCount (val, cb) {
|
|
|
|
try {
|
|
|
|
this.preferencesController.setMetaMetricsSendCount(val)
|
|
|
|
cb(null)
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2019-03-05 16:45:01 +01:00
|
|
|
} catch (err) {
|
|
|
|
cb(err)
|
2020-08-19 18:27:05 +02:00
|
|
|
// eslint-disable-next-line no-useless-return
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2019-03-05 16:45:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the type of first time flow the user wishes to follow: create or import
|
2020-01-13 19:36:36 +01:00
|
|
|
* @param {string} type - Indicates the type of first time flow the user wishes to follow
|
2019-03-05 16:45:01 +01:00
|
|
|
* @param {Function} cb - A callback function called when complete.
|
|
|
|
*/
|
|
|
|
setFirstTimeFlowType (type, cb) {
|
|
|
|
try {
|
|
|
|
this.preferencesController.setFirstTimeFlowType(type)
|
|
|
|
cb(null)
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2019-03-05 16:45:01 +01:00
|
|
|
} catch (err) {
|
|
|
|
cb(err)
|
2020-08-19 18:27:05 +02:00
|
|
|
// eslint-disable-next-line no-useless-return
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2019-03-05 16:45:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-20 18:26:24 +02:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* A method for setting a user's current locale, affecting the language rendered.
|
2018-04-20 18:26:24 +02:00
|
|
|
* @param {string} key - Locale identifier.
|
2018-04-19 02:54:50 +02:00
|
|
|
* @param {Function} cb - A callback function called when complete.
|
|
|
|
*/
|
2018-03-16 01:29:45 +01:00
|
|
|
setCurrentLocale (key, cb) {
|
|
|
|
try {
|
2019-09-03 19:47:54 +02:00
|
|
|
const direction = this.preferencesController.setCurrentLocale(key)
|
|
|
|
cb(null, direction)
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2018-03-16 01:29:45 +01:00
|
|
|
} catch (err) {
|
|
|
|
cb(err)
|
2020-08-19 18:27:05 +02:00
|
|
|
// eslint-disable-next-line no-useless-return
|
2020-07-18 00:49:52 +02:00
|
|
|
return
|
2018-03-16 01:29:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-20 18:26:24 +02:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* A method for initializing storage the first time.
|
|
|
|
* @param {Object} initState - The default state to initialize with.
|
|
|
|
* @private
|
|
|
|
*/
|
2017-11-28 20:14:57 +01:00
|
|
|
recordFirstTimeInfo (initState) {
|
|
|
|
if (!('firstTimeInfo' in initState)) {
|
2020-08-18 18:36:45 +02:00
|
|
|
const version = this.platform.getVersion()
|
2017-11-28 20:14:57 +01:00
|
|
|
initState.firstTimeInfo = {
|
|
|
|
version,
|
|
|
|
date: Date.now(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-22 21:05:41 +02:00
|
|
|
// TODO: Replace isClientOpen methods with `controllerConnectionChanged` events.
|
2018-04-20 18:26:24 +02:00
|
|
|
/**
|
2018-04-19 02:54:50 +02:00
|
|
|
* A method for recording whether the MetaMask user interface is open or not.
|
|
|
|
* @private
|
2018-04-20 18:26:24 +02:00
|
|
|
* @param {boolean} open
|
2018-04-19 02:54:50 +02:00
|
|
|
*/
|
2018-04-16 23:45:18 +02:00
|
|
|
set isClientOpen (open) {
|
|
|
|
this._isClientOpen = open
|
2018-07-21 01:58:03 +02:00
|
|
|
this.detectTokensController.isOpen = open
|
2018-04-16 23:45:18 +02:00
|
|
|
}
|
|
|
|
|
2019-07-31 22:17:11 +02:00
|
|
|
/**
|
2018-09-10 23:11:57 +02:00
|
|
|
* Creates RPC engine middleware for processing eth_signTypedData requests
|
|
|
|
*
|
|
|
|
* @param {Object} req - request object
|
|
|
|
* @param {Object} res - response object
|
|
|
|
* @param {Function} - next
|
|
|
|
* @param {Function} - end
|
|
|
|
*/
|
2018-10-02 01:35:57 +02:00
|
|
|
|
|
|
|
/**
|
2020-06-08 20:06:37 +02:00
|
|
|
* Adds a domain to the PhishingController safelist
|
|
|
|
* @param {string} hostname - the domain to safelist
|
2018-10-02 01:35:57 +02:00
|
|
|
*/
|
2020-06-08 20:06:37 +02:00
|
|
|
safelistPhishingDomain (hostname) {
|
2019-05-06 18:12:52 +02:00
|
|
|
return this.phishingController.bypass(hostname)
|
2018-10-02 01:35:57 +02:00
|
|
|
}
|
2018-10-29 21:55:13 +01:00
|
|
|
|
2018-10-29 22:28:59 +01:00
|
|
|
/**
|
|
|
|
* Locks MetaMask
|
|
|
|
*/
|
2018-11-17 01:54:55 +01:00
|
|
|
setLocked () {
|
2018-10-29 21:55:13 +01:00
|
|
|
return this.keyringController.setLocked()
|
|
|
|
}
|
2017-09-22 00:47:25 +02:00
|
|
|
}
|