2020-01-09 04:34:58 +01:00
|
|
|
import EventEmitter from 'safe-event-emitter'
|
|
|
|
import ObservableStore from 'obs-store'
|
|
|
|
import ethUtil from 'ethereumjs-util'
|
|
|
|
import Transaction from 'ethereumjs-tx'
|
|
|
|
import EthQuery from 'ethjs-query'
|
|
|
|
import { ethErrors } from 'eth-json-rpc-errors'
|
|
|
|
import abi from 'human-standard-token-abi'
|
2020-08-22 04:29:19 +02:00
|
|
|
import { ethers } from 'ethers'
|
2020-08-18 21:18:25 +02:00
|
|
|
import NonceTracker from 'nonce-tracker'
|
|
|
|
import log from 'loglevel'
|
2020-10-08 04:24:04 +02:00
|
|
|
import BigNumber from 'bignumber.js'
|
2020-08-18 21:18:25 +02:00
|
|
|
import cleanErrorStack from '../../lib/cleanErrorStack'
|
2020-11-06 22:18:00 +01:00
|
|
|
import {
|
|
|
|
hexToBn,
|
|
|
|
bnToHex,
|
|
|
|
BnMultiplyByFraction,
|
|
|
|
addHexPrefix,
|
|
|
|
} from '../../lib/util'
|
2020-08-18 21:18:25 +02:00
|
|
|
import { TRANSACTION_NO_CONTRACT_ERROR_KEY } from '../../../../ui/app/helpers/constants/error-keys'
|
2020-10-06 20:28:38 +02:00
|
|
|
import { getSwapsTokensReceivedFromTxMeta } from '../../../../ui/app/pages/swaps/swaps.util'
|
2020-11-03 23:57:51 +01:00
|
|
|
import {
|
|
|
|
TRANSACTION_CATEGORIES,
|
|
|
|
TRANSACTION_STATUSES,
|
|
|
|
TRANSACTION_TYPES,
|
|
|
|
} from '../../../../shared/constants/transaction'
|
2020-01-09 04:34:58 +01:00
|
|
|
import TransactionStateManager from './tx-state-manager'
|
|
|
|
import TxGasUtil from './tx-gas-utils'
|
|
|
|
import PendingTransactionTracker from './pending-tx-tracker'
|
|
|
|
import * as txUtils from './lib/util'
|
2018-09-09 19:07:23 +02:00
|
|
|
|
2020-08-22 04:29:19 +02:00
|
|
|
const hstInterface = new ethers.utils.Interface(abi)
|
2020-05-01 00:50:12 +02:00
|
|
|
|
|
|
|
const SIMPLE_GAS_COST = '0x5208' // Hex for 21000, cost of a simple send.
|
2020-07-16 22:22:41 +02:00
|
|
|
const MAX_MEMSTORE_TX_LIST_SIZE = 100 // Number of transactions (by unique nonces) to keep in memory
|
2018-04-13 21:38:07 +02:00
|
|
|
|
|
|
|
/**
|
2017-09-06 06:50:36 +02:00
|
|
|
Transaction Controller is an aggregate of sub-controllers and trackers
|
|
|
|
composing them in a way to be exposed to the metamask controller
|
2018-04-13 21:38:07 +02:00
|
|
|
<br>- txStateManager
|
2017-09-06 06:50:36 +02:00
|
|
|
responsible for the state of a transaction and
|
|
|
|
storing the transaction
|
2018-04-13 21:38:07 +02:00
|
|
|
<br>- pendingTxTracker
|
2017-09-06 06:50:36 +02:00
|
|
|
watching blocks for transactions to be include
|
|
|
|
and emitting confirmed events
|
2018-04-13 21:38:07 +02:00
|
|
|
<br>- txGasUtil
|
2017-09-06 06:50:36 +02:00
|
|
|
gas calculations and safety buffering
|
2018-04-13 21:38:07 +02:00
|
|
|
<br>- nonceTracker
|
2017-09-06 06:50:36 +02:00
|
|
|
calculating nonces
|
2018-04-13 21:38:07 +02:00
|
|
|
|
2018-04-23 18:43:18 +02:00
|
|
|
@class
|
2020-11-10 18:30:41 +01:00
|
|
|
@param {Object} opts
|
|
|
|
@param {Object} opts.initState - initial transaction list default is an empty array
|
|
|
|
@param {Object} opts.networkStore - an observable store for network number
|
|
|
|
@param {Object} opts.blockTracker - An instance of eth-blocktracker
|
|
|
|
@param {Object} opts.provider - A network provider.
|
|
|
|
@param {Function} opts.signTransaction - function the signs an ethereumjs-tx
|
|
|
|
@param {Object} opts.getPermittedAccounts - get accounts that an origin has permissions for
|
|
|
|
@param {Function} opts.signTransaction - ethTx signer that returns a rawTx
|
|
|
|
@param {number} [opts.txHistoryLimit] - number *optional* for limiting how many transactions are in state
|
|
|
|
@param {Object} opts.preferencesStore
|
2017-09-06 06:50:36 +02:00
|
|
|
*/
|
2016-12-14 21:55:41 +01:00
|
|
|
|
2020-04-27 16:45:00 +02:00
|
|
|
export default class TransactionController extends EventEmitter {
|
2020-11-03 00:41:28 +01:00
|
|
|
constructor(opts) {
|
2016-12-14 21:55:41 +01:00
|
|
|
super()
|
2017-02-03 05:59:47 +01:00
|
|
|
this.networkStore = opts.networkStore || new ObservableStore({})
|
2020-10-06 22:18:24 +02:00
|
|
|
this._getCurrentChainId = opts.getCurrentChainId
|
2017-02-03 06:09:17 +01:00
|
|
|
this.preferencesStore = opts.preferencesStore || new ObservableStore({})
|
2017-05-23 07:56:10 +02:00
|
|
|
this.provider = opts.provider
|
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.getPermittedAccounts = opts.getPermittedAccounts
|
2017-05-23 07:56:10 +02:00
|
|
|
this.blockTracker = opts.blockTracker
|
2017-08-04 20:41:35 +02:00
|
|
|
this.signEthTx = opts.signTransaction
|
2019-07-19 05:37:51 +02:00
|
|
|
this.inProcessOfSigning = new Set()
|
2020-10-21 23:10:55 +02:00
|
|
|
this._trackMetaMetricsEvent = opts.trackMetaMetricsEvent
|
2020-10-08 18:41:23 +02:00
|
|
|
this._getParticipateInMetrics = opts.getParticipateInMetrics
|
2017-08-04 20:41:35 +02:00
|
|
|
|
2017-08-11 23:19:35 +02:00
|
|
|
this.memStore = new ObservableStore({})
|
|
|
|
this.query = new EthQuery(this.provider)
|
|
|
|
|
2020-10-06 20:28:38 +02:00
|
|
|
this.txGasUtil = new TxGasUtil(this.provider)
|
2018-04-19 20:29:26 +02:00
|
|
|
this._mapMethods()
|
2018-03-14 15:15:04 +01:00
|
|
|
this.txStateManager = new TransactionStateManager({
|
2017-09-12 18:59:59 +02:00
|
|
|
initState: opts.initState,
|
2017-08-11 23:19:35 +02:00
|
|
|
txHistoryLimit: opts.txHistoryLimit,
|
|
|
|
getNetwork: this.getNetwork.bind(this),
|
2017-08-18 21:23:35 +02:00
|
|
|
})
|
2018-04-12 21:24:16 +02:00
|
|
|
this._onBootCleanUp()
|
2018-01-18 01:49:38 +01:00
|
|
|
|
2017-09-27 01:52:08 +02:00
|
|
|
this.store = this.txStateManager.store
|
2017-06-15 08:44:02 +02:00
|
|
|
this.nonceTracker = new NonceTracker({
|
|
|
|
provider: this.provider,
|
2018-05-17 05:46:34 +02:00
|
|
|
blockTracker: this.blockTracker,
|
2020-11-03 00:41:28 +01:00
|
|
|
getPendingTransactions: this.txStateManager.getPendingTransactions.bind(
|
|
|
|
this.txStateManager,
|
|
|
|
),
|
|
|
|
getConfirmedTransactions: this.txStateManager.getConfirmedTransactions.bind(
|
|
|
|
this.txStateManager,
|
|
|
|
),
|
2017-06-15 08:44:02 +02:00
|
|
|
})
|
2017-08-04 20:41:35 +02:00
|
|
|
|
2017-08-09 00:30:49 +02:00
|
|
|
this.pendingTxTracker = new PendingTransactionTracker({
|
2017-08-04 20:41:35 +02:00
|
|
|
provider: this.provider,
|
|
|
|
nonceTracker: this.nonceTracker,
|
2017-09-12 21:19:26 +02:00
|
|
|
publishTransaction: (rawTx) => this.query.sendRawTransaction(rawTx),
|
2018-11-14 22:34:07 +01:00
|
|
|
getPendingTransactions: () => {
|
|
|
|
const pending = this.txStateManager.getPendingTransactions()
|
|
|
|
const approved = this.txStateManager.getApprovedTransactions()
|
|
|
|
return [...pending, ...approved]
|
|
|
|
},
|
|
|
|
approveTransaction: this.approveTransaction.bind(this),
|
2020-11-03 00:41:28 +01:00
|
|
|
getCompletedTransactions: this.txStateManager.getConfirmedTransactions.bind(
|
|
|
|
this.txStateManager,
|
|
|
|
),
|
2017-08-04 20:41:35 +02:00
|
|
|
})
|
|
|
|
|
2017-09-27 01:52:08 +02:00
|
|
|
this.txStateManager.store.subscribe(() => this.emit('update:badge'))
|
2018-05-28 23:29:31 +02:00
|
|
|
this._setupListeners()
|
2017-02-03 06:09:17 +01:00
|
|
|
// memstore is computed from a few different stores
|
2017-02-03 05:20:13 +01:00
|
|
|
this._updateMemstore()
|
2017-09-12 18:59:59 +02:00
|
|
|
this.txStateManager.store.subscribe(() => this._updateMemstore())
|
Fixed Vivek's bug (#5860)
* Fixed Vivek's bug
Fixes #5850
What was happening:
It seems that his MetaMask had crashed while some new transactions had
been loading defaults. He probably had a network connectivity issue to
Infura (which we are working with Infura to address).
As a result of this network cutout, his three unapproved transactions
were not marked failed, and were not marked as `loadingDefaults =
false`, as their gas prices had not yet been estimated.
Normally this behavior is supposed to clean itself up when the
transaction controller starts up, via the
`TransactionController._onBootCleanUp()` function, but in this case,
during unlock, that function was unable to do its job because when it
requested the transaction list, the current network was in the `loading`
state, making it proceed as if there were no pending transactions.
To fix this, I am doing two things:
- Setting transactions to loadingDefaults = false in more catch blocks.
- Calling `onBootCleanUp()` when the network store's status changes, so
that it will re-trigger when loading completes.
* Fixed reference
* Fixed infinite loop bug
Was refreshing the tx list on every tx state change instead of just
network changes, creating an infinite loop.
* Add notes to tx updates to clarify logs
2018-11-30 01:08:03 +01:00
|
|
|
this.networkStore.subscribe(() => {
|
|
|
|
this._onBootCleanUp()
|
|
|
|
this._updateMemstore()
|
|
|
|
})
|
2018-05-29 09:53:44 +02:00
|
|
|
|
|
|
|
// request state update to finalize initialization
|
|
|
|
this._updatePendingTxsAfterFirstBlock()
|
2016-12-16 19:33:36 +01:00
|
|
|
}
|
2018-05-29 09:53:44 +02:00
|
|
|
|
2020-07-08 23:05:09 +02:00
|
|
|
/**
|
|
|
|
* Gets the current chainId in the network store as a number, returning 0 if
|
|
|
|
* the chainId parses to NaN.
|
|
|
|
*
|
|
|
|
* @returns {number} The numerical chainId.
|
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
getChainId() {
|
2017-09-06 06:50:36 +02:00
|
|
|
const networkState = this.networkStore.getState()
|
2020-10-06 22:18:24 +02:00
|
|
|
const chainId = this._getCurrentChainId()
|
|
|
|
const integerChainId = parseInt(chainId, 16)
|
|
|
|
if (networkState === 'loading' || Number.isNaN(integerChainId)) {
|
2017-09-06 06:50:36 +02:00
|
|
|
return 0
|
|
|
|
}
|
2020-08-19 18:27:05 +02:00
|
|
|
return integerChainId
|
2017-07-26 20:56:52 +02:00
|
|
|
}
|
|
|
|
|
2019-07-31 22:17:11 +02:00
|
|
|
/**
|
2018-04-19 20:29:26 +02:00
|
|
|
Adds a tx to the txlist
|
|
|
|
@emits ${txMeta.id}:unapproved
|
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
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
addTx(txMeta) {
|
2017-08-11 23:19:35 +02:00
|
|
|
this.txStateManager.addTx(txMeta)
|
2016-12-16 19:33:36 +01:00
|
|
|
this.emit(`${txMeta.id}:unapproved`, txMeta)
|
2016-12-14 21:55:41 +01:00
|
|
|
}
|
|
|
|
|
2018-04-23 18:43:18 +02:00
|
|
|
/**
|
2018-04-25 20:13:51 +02:00
|
|
|
Wipes the transactions for a given account
|
2018-04-23 18:43:18 +02:00
|
|
|
@param {string} address - hex string of the from address for txs being removed
|
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
wipeTransactions(address) {
|
2018-04-12 21:24:16 +02:00
|
|
|
this.txStateManager.wipeTransactions(address)
|
|
|
|
}
|
|
|
|
|
2018-04-23 18:43:18 +02:00
|
|
|
/**
|
2020-11-03 00:41:28 +01:00
|
|
|
* Add a new unapproved transaction to the pipeline
|
|
|
|
*
|
2020-11-10 18:30:41 +01:00
|
|
|
* @returns {Promise<string>} the hash of the transaction after being submitted to the network
|
2020-11-03 00:41:28 +01:00
|
|
|
* @param {Object} txParams - txParams for the transaction
|
|
|
|
* @param {Object} opts - with the key origin to put the origin on the txMeta
|
|
|
|
*/
|
|
|
|
async newUnapprovedTransaction(txParams, opts = {}) {
|
|
|
|
log.debug(
|
|
|
|
`MetaMaskController newUnapprovedTransaction ${JSON.stringify(txParams)}`,
|
|
|
|
)
|
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
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const initialTxMeta = await this.addUnapprovedTransaction(
|
|
|
|
txParams,
|
|
|
|
opts.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
|
|
|
|
2017-08-03 00:58:05 +02:00
|
|
|
// listen for tx completion (success, fail)
|
|
|
|
return new Promise((resolve, reject) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
this.txStateManager.once(
|
|
|
|
`${initialTxMeta.id}:finished`,
|
|
|
|
(finishedTxMeta) => {
|
|
|
|
switch (finishedTxMeta.status) {
|
2020-11-07 08:38:12 +01:00
|
|
|
case TRANSACTION_STATUSES.SUBMITTED:
|
2020-11-03 00:41:28 +01:00
|
|
|
return resolve(finishedTxMeta.hash)
|
2020-11-07 08:38:12 +01:00
|
|
|
case TRANSACTION_STATUSES.REJECTED:
|
2020-11-03 00:41:28 +01:00
|
|
|
return reject(
|
|
|
|
cleanErrorStack(
|
|
|
|
ethErrors.provider.userRejectedRequest(
|
|
|
|
'MetaMask Tx Signature: User denied transaction signature.',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
2020-11-07 08:38:12 +01:00
|
|
|
case TRANSACTION_STATUSES.FAILED:
|
2020-11-03 00:41:28 +01:00
|
|
|
return reject(
|
|
|
|
cleanErrorStack(
|
|
|
|
ethErrors.rpc.internal(finishedTxMeta.err.message),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
default:
|
|
|
|
return reject(
|
|
|
|
cleanErrorStack(
|
|
|
|
ethErrors.rpc.internal(
|
|
|
|
`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(
|
|
|
|
finishedTxMeta.txParams,
|
|
|
|
)}`,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
)
|
2017-08-03 00:58:05 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-04-13 21:38:07 +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
|
|
|
* Validates and generates a txMeta with defaults and puts it in txStateManager
|
|
|
|
* store.
|
|
|
|
*
|
|
|
|
* @returns {txMeta}
|
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
async addUnapprovedTransaction(txParams, origin) {
|
2017-07-26 20:56:52 +02:00
|
|
|
// validate
|
2018-04-06 20:07:20 +02:00
|
|
|
const normalizedTxParams = txUtils.normalizeTxParams(txParams)
|
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
|
|
|
|
2018-04-06 20:07:20 +02:00
|
|
|
txUtils.validateTxParams(normalizedTxParams)
|
2020-08-19 18:27:05 +02:00
|
|
|
|
2019-11-27 13:58:03 +01:00
|
|
|
/**
|
|
|
|
`generateTxMeta` adds the default txMeta properties to the passed object.
|
|
|
|
These include the tx's `id`. As we use the id for determining order of
|
|
|
|
txes in the tx-state-manager, it is necessary to call the asynchronous
|
|
|
|
method `this._determineTransactionCategory` after `generateTxMeta`.
|
|
|
|
*/
|
2018-09-09 19:07:23 +02:00
|
|
|
let txMeta = this.txStateManager.generateTxMeta({
|
|
|
|
txParams: normalizedTxParams,
|
2020-11-03 23:57:51 +01:00
|
|
|
type: TRANSACTION_TYPES.STANDARD,
|
2018-09-09 19:07:23 +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 (origin === 'metamask') {
|
|
|
|
// Assert the from address is the selected address
|
|
|
|
if (normalizedTxParams.from !== this.getSelectedAddress()) {
|
|
|
|
throw ethErrors.rpc.internal({
|
|
|
|
message: `Internally initiated transaction is using invalid account.`,
|
|
|
|
data: {
|
|
|
|
origin,
|
|
|
|
fromAddress: normalizedTxParams.from,
|
|
|
|
selectedAddress: this.getSelectedAddress(),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Assert that the origin has permissions to initiate transactions from
|
|
|
|
// the specified address
|
|
|
|
const permittedAddresses = await this.getPermittedAccounts(origin)
|
|
|
|
if (!permittedAddresses.includes(normalizedTxParams.from)) {
|
2019-12-03 21:50:55 +01:00
|
|
|
throw ethErrors.provider.unauthorized({ data: { 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-19 18:27:05 +02:00
|
|
|
txMeta.origin = 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
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const {
|
|
|
|
transactionCategory,
|
|
|
|
getCodeResponse,
|
|
|
|
} = await this._determineTransactionCategory(txParams)
|
2019-11-27 13:58:03 +01:00
|
|
|
txMeta.transactionCategory = transactionCategory
|
2020-05-01 02:50:44 +02:00
|
|
|
|
|
|
|
// ensure value
|
|
|
|
txMeta.txParams.value = txMeta.txParams.value
|
2020-11-06 22:18:00 +01:00
|
|
|
? addHexPrefix(txMeta.txParams.value)
|
2020-05-01 02:50:44 +02:00
|
|
|
: '0x0'
|
|
|
|
|
2018-01-14 23:00:17 +01:00
|
|
|
this.addTx(txMeta)
|
|
|
|
this.emit('newUnapprovedTx', txMeta)
|
2018-05-30 15:53:18 +02:00
|
|
|
|
2018-01-18 00:42:01 +01:00
|
|
|
try {
|
2019-05-14 20:14:07 +02:00
|
|
|
txMeta = await this.addTxGasDefaults(txMeta, getCodeResponse)
|
2018-01-18 00:42:01 +01:00
|
|
|
} catch (error) {
|
2018-06-12 21:08:06 +02:00
|
|
|
log.warn(error)
|
2020-05-01 17:25:45 +02:00
|
|
|
txMeta = this.txStateManager.getTx(txMeta.id)
|
Fixed Vivek's bug (#5860)
* Fixed Vivek's bug
Fixes #5850
What was happening:
It seems that his MetaMask had crashed while some new transactions had
been loading defaults. He probably had a network connectivity issue to
Infura (which we are working with Infura to address).
As a result of this network cutout, his three unapproved transactions
were not marked failed, and were not marked as `loadingDefaults =
false`, as their gas prices had not yet been estimated.
Normally this behavior is supposed to clean itself up when the
transaction controller starts up, via the
`TransactionController._onBootCleanUp()` function, but in this case,
during unlock, that function was unable to do its job because when it
requested the transaction list, the current network was in the `loading`
state, making it proceed as if there were no pending transactions.
To fix this, I am doing two things:
- Setting transactions to loadingDefaults = false in more catch blocks.
- Calling `onBootCleanUp()` when the network store's status changes, so
that it will re-trigger when loading completes.
* Fixed reference
* Fixed infinite loop bug
Was refreshing the tx list on every tx state change instead of just
network changes, creating an infinite loop.
* Add notes to tx updates to clarify logs
2018-11-30 01:08:03 +01:00
|
|
|
txMeta.loadingDefaults = false
|
|
|
|
this.txStateManager.updateTx(txMeta, 'Failed to calculate gas defaults.')
|
2018-01-18 00:42:01 +01:00
|
|
|
throw error
|
|
|
|
}
|
Fixed Vivek's bug (#5860)
* Fixed Vivek's bug
Fixes #5850
What was happening:
It seems that his MetaMask had crashed while some new transactions had
been loading defaults. He probably had a network connectivity issue to
Infura (which we are working with Infura to address).
As a result of this network cutout, his three unapproved transactions
were not marked failed, and were not marked as `loadingDefaults =
false`, as their gas prices had not yet been estimated.
Normally this behavior is supposed to clean itself up when the
transaction controller starts up, via the
`TransactionController._onBootCleanUp()` function, but in this case,
during unlock, that function was unable to do its job because when it
requested the transaction list, the current network was in the `loading`
state, making it proceed as if there were no pending transactions.
To fix this, I am doing two things:
- Setting transactions to loadingDefaults = false in more catch blocks.
- Calling `onBootCleanUp()` when the network store's status changes, so
that it will re-trigger when loading completes.
* Fixed reference
* Fixed infinite loop bug
Was refreshing the tx list on every tx state change instead of just
network changes, creating an infinite loop.
* Add notes to tx updates to clarify logs
2018-11-30 01:08:03 +01:00
|
|
|
|
2018-01-14 23:00:17 +01:00
|
|
|
txMeta.loadingDefaults = false
|
2017-07-26 20:56:52 +02:00
|
|
|
// save txMeta
|
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.txStateManager.updateTx(txMeta, 'Added new unapproved transaction.')
|
2018-01-18 00:42:01 +01:00
|
|
|
|
2017-07-26 20:56:52 +02:00
|
|
|
return txMeta
|
2016-12-16 19:33:36 +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
|
|
|
|
2019-07-31 22:17:11 +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 the tx gas defaults: gas && gasPrice
|
2020-01-13 19:36:36 +01:00
|
|
|
* @param {Object} txMeta - the txMeta object
|
2020-11-10 18:30:41 +01:00
|
|
|
* @returns {Promise<object>} resolves with txMeta
|
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
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
async addTxGasDefaults(txMeta, getCodeResponse) {
|
2020-05-01 17:25:45 +02:00
|
|
|
const defaultGasPrice = await this._getDefaultGasPrice(txMeta)
|
2020-11-03 00:41:28 +01:00
|
|
|
const {
|
|
|
|
gasLimit: defaultGasLimit,
|
|
|
|
simulationFails,
|
|
|
|
} = await this._getDefaultGasLimit(txMeta, getCodeResponse)
|
2020-05-01 00:50:12 +02:00
|
|
|
|
2020-08-15 13:58:11 +02:00
|
|
|
// eslint-disable-next-line no-param-reassign
|
2020-05-01 17:25:45 +02:00
|
|
|
txMeta = this.txStateManager.getTx(txMeta.id)
|
|
|
|
if (simulationFails) {
|
|
|
|
txMeta.simulationFails = simulationFails
|
2018-01-08 22:19:18 +01:00
|
|
|
}
|
2020-05-01 17:25:45 +02:00
|
|
|
if (defaultGasPrice && !txMeta.txParams.gasPrice) {
|
|
|
|
txMeta.txParams.gasPrice = defaultGasPrice
|
|
|
|
}
|
|
|
|
if (defaultGasLimit && !txMeta.txParams.gas) {
|
|
|
|
txMeta.txParams.gas = defaultGasLimit
|
|
|
|
}
|
|
|
|
return txMeta
|
|
|
|
}
|
2020-05-01 00:50:12 +02:00
|
|
|
|
2020-05-01 17:25:45 +02:00
|
|
|
/**
|
|
|
|
* Gets default gas price, or returns `undefined` if gas price is already set
|
|
|
|
* @param {Object} txMeta - The txMeta object
|
2020-08-12 21:06:57 +02:00
|
|
|
* @returns {Promise<string|undefined>} The default gas price
|
2020-05-01 17:25:45 +02:00
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
async _getDefaultGasPrice(txMeta) {
|
2020-05-01 17:25:45 +02:00
|
|
|
if (txMeta.txParams.gasPrice) {
|
2020-08-12 21:06:57 +02:00
|
|
|
return undefined
|
2020-05-01 17:25:45 +02:00
|
|
|
}
|
2020-05-12 21:40:33 +02:00
|
|
|
const gasPrice = await this.query.gasPrice()
|
2020-05-01 00:50:12 +02:00
|
|
|
|
2020-11-06 22:18:00 +01:00
|
|
|
return addHexPrefix(gasPrice.toString(16))
|
2020-05-01 17:25:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets default gas limit, or debug information about why gas estimate failed.
|
|
|
|
* @param {Object} txMeta - The txMeta object
|
|
|
|
* @param {string} getCodeResponse - The transaction category code response, used for debugging purposes
|
|
|
|
* @returns {Promise<Object>} Object containing the default gas limit, or the simulation failure object
|
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
async _getDefaultGasLimit(txMeta, getCodeResponse) {
|
2020-05-01 17:25:45 +02:00
|
|
|
if (txMeta.txParams.gas) {
|
|
|
|
return {}
|
2020-05-01 01:53:35 +02:00
|
|
|
} else if (
|
2020-05-01 17:25:45 +02:00
|
|
|
txMeta.txParams.to &&
|
2020-11-03 23:57:51 +01:00
|
|
|
txMeta.transactionCategory === TRANSACTION_CATEGORIES.SENT_ETHER
|
2020-05-01 00:50:12 +02:00
|
|
|
) {
|
|
|
|
// if there's data in the params, but there's no contract code, it's not a valid transaction
|
2020-05-01 17:25:45 +02:00
|
|
|
if (txMeta.txParams.data) {
|
2020-11-03 00:41:28 +01:00
|
|
|
const err = new Error(
|
|
|
|
'TxGasUtil - Trying to call a function on a non-contract address',
|
|
|
|
)
|
2020-05-01 00:50:12 +02:00
|
|
|
// set error key so ui can display localized error message
|
|
|
|
err.errorKey = TRANSACTION_NO_CONTRACT_ERROR_KEY
|
|
|
|
|
|
|
|
// set the response on the error so that we can see in logs what the actual response was
|
|
|
|
err.getCodeResponse = getCodeResponse
|
|
|
|
throw err
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is a standard ether simple send, gas requirement is exactly 21k
|
2020-05-01 17:25:45 +02:00
|
|
|
return { gasLimit: SIMPLE_GAS_COST }
|
2020-05-01 00:50:12 +02:00
|
|
|
}
|
2020-05-01 02:44:51 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const {
|
|
|
|
blockGasLimit,
|
|
|
|
estimatedGasHex,
|
|
|
|
simulationFails,
|
|
|
|
} = await this.txGasUtil.analyzeGasUsage(txMeta)
|
2020-05-01 17:25:45 +02:00
|
|
|
|
|
|
|
// add additional gas buffer to our estimation for safety
|
2020-11-03 00:41:28 +01:00
|
|
|
const gasLimit = this.txGasUtil.addGasBuffer(
|
2020-11-06 22:18:00 +01:00
|
|
|
addHexPrefix(estimatedGasHex),
|
2020-11-03 00:41:28 +01:00
|
|
|
blockGasLimit,
|
|
|
|
)
|
2020-05-01 17:25:45 +02:00
|
|
|
return { gasLimit, simulationFails }
|
2017-01-10 20:52:25 +01:00
|
|
|
}
|
|
|
|
|
2018-09-09 19:07:23 +02:00
|
|
|
/**
|
|
|
|
* Creates a new approved transaction to attempt to cancel a previously submitted transaction. The
|
|
|
|
* new transaction contains the same nonce as the previous, is a basic ETH transfer of 0x value to
|
|
|
|
* the sender's address, and has a higher gasPrice than that of the previous 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
|
2018-09-09 19:07:23 +02:00
|
|
|
* @returns {txMeta}
|
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
async createCancelTransaction(originalTxId, customGasPrice) {
|
2018-09-09 19:07:23 +02:00
|
|
|
const originalTxMeta = this.txStateManager.getTx(originalTxId)
|
|
|
|
const { txParams } = originalTxMeta
|
|
|
|
const { gasPrice: lastGasPrice, from, nonce } = txParams
|
2018-09-17 19:34:29 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const newGasPrice =
|
|
|
|
customGasPrice ||
|
|
|
|
bnToHex(BnMultiplyByFraction(hexToBn(lastGasPrice), 11, 10))
|
2018-09-09 19:07:23 +02:00
|
|
|
const newTxMeta = this.txStateManager.generateTxMeta({
|
|
|
|
txParams: {
|
|
|
|
from,
|
|
|
|
to: from,
|
|
|
|
nonce,
|
|
|
|
gas: '0x5208',
|
|
|
|
value: '0x0',
|
|
|
|
gasPrice: newGasPrice,
|
|
|
|
},
|
|
|
|
lastGasPrice,
|
|
|
|
loadingDefaults: false,
|
2020-11-03 23:57:51 +01:00
|
|
|
status: TRANSACTION_STATUSES.APPROVED,
|
|
|
|
type: TRANSACTION_TYPES.CANCEL,
|
2018-09-09 19:07:23 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
this.addTx(newTxMeta)
|
|
|
|
await this.approveTransaction(newTxMeta.id)
|
|
|
|
return newTxMeta
|
|
|
|
}
|
|
|
|
|
2020-03-12 15:33:11 +01:00
|
|
|
/**
|
|
|
|
* Creates a new approved transaction to attempt to speed up a previously submitted transaction. The
|
|
|
|
* new transaction contains the same nonce as the previous. By default, the new transaction will use
|
|
|
|
* the same gas limit and a 10% higher gas price, though it is possible to set a custom value for
|
|
|
|
* each instead.
|
|
|
|
* @param {number} originalTxId - the id of the txMeta that you want to speed up
|
|
|
|
* @param {string} [customGasPrice] - The new custom gas price, in hex
|
|
|
|
* @param {string} [customGasLimit] - The new custom gas limt, in hex
|
|
|
|
* @returns {txMeta}
|
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
async createSpeedUpTransaction(originalTxId, customGasPrice, customGasLimit) {
|
2018-10-26 06:42:59 +02:00
|
|
|
const originalTxMeta = this.txStateManager.getTx(originalTxId)
|
|
|
|
const { txParams } = originalTxMeta
|
|
|
|
const { gasPrice: lastGasPrice } = txParams
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const newGasPrice =
|
|
|
|
customGasPrice ||
|
|
|
|
bnToHex(BnMultiplyByFraction(hexToBn(lastGasPrice), 11, 10))
|
2018-10-26 06:42:59 +02:00
|
|
|
|
|
|
|
const newTxMeta = this.txStateManager.generateTxMeta({
|
|
|
|
txParams: {
|
|
|
|
...txParams,
|
|
|
|
gasPrice: newGasPrice,
|
|
|
|
},
|
|
|
|
lastGasPrice,
|
|
|
|
loadingDefaults: false,
|
2020-11-03 23:57:51 +01:00
|
|
|
status: TRANSACTION_STATUSES.APPROVED,
|
|
|
|
type: TRANSACTION_TYPES.RETRY,
|
2018-10-26 06:42:59 +02:00
|
|
|
})
|
|
|
|
|
2020-03-12 15:33:11 +01:00
|
|
|
if (customGasLimit) {
|
|
|
|
newTxMeta.txParams.gas = customGasLimit
|
|
|
|
}
|
|
|
|
|
2018-10-26 06:42:59 +02:00
|
|
|
this.addTx(newTxMeta)
|
|
|
|
await this.approveTransaction(newTxMeta.id)
|
|
|
|
return newTxMeta
|
|
|
|
}
|
|
|
|
|
2018-04-13 21:38:07 +02:00
|
|
|
/**
|
|
|
|
updates the txMeta in the txStateManager
|
2020-01-13 19:36:36 +01:00
|
|
|
@param {Object} txMeta - the updated txMeta
|
2018-04-13 21:38:07 +02:00
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
async updateTransaction(txMeta) {
|
2017-12-20 18:17:16 +01:00
|
|
|
this.txStateManager.updateTx(txMeta, 'confTx: user updated transaction')
|
|
|
|
}
|
|
|
|
|
2018-04-13 21:38:07 +02:00
|
|
|
/**
|
|
|
|
updates and approves the transaction
|
2020-01-13 19:36:36 +01:00
|
|
|
@param {Object} txMeta
|
2018-04-13 21:38:07 +02:00
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
async updateAndApproveTransaction(txMeta) {
|
2017-10-02 22:41:29 +02:00
|
|
|
this.txStateManager.updateTx(txMeta, 'confTx: user approved transaction')
|
2017-07-26 20:56:52 +02:00
|
|
|
await this.approveTransaction(txMeta.id)
|
2016-12-14 21:55:41 +01:00
|
|
|
}
|
|
|
|
|
2018-04-13 21:38:07 +02:00
|
|
|
/**
|
|
|
|
sets the tx status to approved
|
|
|
|
auto fills the nonce
|
|
|
|
signs the transaction
|
|
|
|
publishes the transaction
|
|
|
|
if any of these steps fails the tx status will be set to failed
|
2020-01-13 19:36:36 +01:00
|
|
|
@param {number} txId - the tx's Id
|
2018-04-13 21:38:07 +02:00
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
async approveTransaction(txId) {
|
2019-07-19 05:37:51 +02:00
|
|
|
// TODO: Move this safety out of this function.
|
|
|
|
// Since this transaction is async,
|
|
|
|
// we need to keep track of what is currently being signed,
|
|
|
|
// So that we do not increment nonce + resubmit something
|
2020-07-23 22:31:13 +02:00
|
|
|
// that is already being incremented & signed.
|
2019-07-19 05:37:51 +02:00
|
|
|
if (this.inProcessOfSigning.has(txId)) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.inProcessOfSigning.add(txId)
|
2017-06-15 08:44:02 +02:00
|
|
|
let nonceLock
|
|
|
|
try {
|
|
|
|
// approve
|
2017-08-18 21:23:35 +02:00
|
|
|
this.txStateManager.setTxStatusApproved(txId)
|
2017-06-15 08:44:02 +02:00
|
|
|
// get next nonce
|
2017-08-18 21:23:35 +02:00
|
|
|
const txMeta = this.txStateManager.getTx(txId)
|
2017-06-15 08:44:02 +02:00
|
|
|
const fromAddress = txMeta.txParams.from
|
2017-07-26 19:40:08 +02:00
|
|
|
// wait for a nonce
|
2020-07-02 21:58:12 +02:00
|
|
|
let { customNonceValue } = txMeta
|
2019-09-27 06:30:36 +02:00
|
|
|
customNonceValue = Number(customNonceValue)
|
2017-06-15 08:44:02 +02:00
|
|
|
nonceLock = await this.nonceTracker.getNonceLock(fromAddress)
|
2017-07-26 19:40:08 +02:00
|
|
|
// add nonce to txParams
|
2018-03-28 08:55:18 +02:00
|
|
|
// if txMeta has lastGasPrice then it is a retry at same nonce with higher
|
2018-03-08 07:01:14 +01:00
|
|
|
// gas price transaction and their for the nonce should not be calculated
|
2020-11-03 00:41:28 +01:00
|
|
|
const nonce = txMeta.lastGasPrice
|
|
|
|
? txMeta.txParams.nonce
|
|
|
|
: nonceLock.nextNonce
|
|
|
|
const customOrNonce =
|
|
|
|
customNonceValue === 0 ? customNonceValue : customNonceValue || nonce
|
2019-09-27 06:30:36 +02:00
|
|
|
|
2020-11-06 22:18:00 +01:00
|
|
|
txMeta.txParams.nonce = addHexPrefix(customOrNonce.toString(16))
|
2017-07-26 19:40:08 +02:00
|
|
|
// add nonce debugging information to txMeta
|
|
|
|
txMeta.nonceDetails = nonceLock.nonceDetails
|
2019-09-27 06:30:36 +02:00
|
|
|
if (customNonceValue) {
|
|
|
|
txMeta.nonceDetails.customNonceValue = customNonceValue
|
|
|
|
}
|
2017-10-02 22:41:29 +02:00
|
|
|
this.txStateManager.updateTx(txMeta, 'transactions#approveTransaction')
|
2017-06-15 08:44:02 +02:00
|
|
|
// sign transaction
|
2017-07-13 21:25:43 +02:00
|
|
|
const rawTx = await this.signTransaction(txId)
|
2017-06-22 04:51:00 +02:00
|
|
|
await this.publishTransaction(txId, rawTx)
|
2017-06-15 08:44:02 +02:00
|
|
|
// must set transaction to submitted/failed before releasing lock
|
|
|
|
nonceLock.releaseLock()
|
|
|
|
} catch (err) {
|
2018-06-12 20:51:35 +02:00
|
|
|
// this is try-catch wrapped so that we can guarantee that the nonceLock is released
|
|
|
|
try {
|
|
|
|
this.txStateManager.setTxStatusFailed(txId, err)
|
2020-08-18 18:36:45 +02:00
|
|
|
} catch (err2) {
|
|
|
|
log.error(err2)
|
2018-06-12 20:51:35 +02:00
|
|
|
}
|
2017-06-15 08:44:02 +02:00
|
|
|
// must set transaction to submitted/failed before releasing lock
|
2019-11-20 01:03:20 +01:00
|
|
|
if (nonceLock) {
|
|
|
|
nonceLock.releaseLock()
|
|
|
|
}
|
2017-06-15 08:44:02 +02:00
|
|
|
// continue with error chain
|
2017-07-13 00:07:56 +02:00
|
|
|
throw err
|
2019-07-19 05:37:51 +02:00
|
|
|
} finally {
|
|
|
|
this.inProcessOfSigning.delete(txId)
|
2017-06-15 08:44:02 +02:00
|
|
|
}
|
2016-12-16 19:33:36 +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
|
|
|
|
2018-04-13 21:38:07 +02:00
|
|
|
/**
|
|
|
|
adds the chain id and signs the transaction and set the status to signed
|
2020-01-13 19:36:36 +01:00
|
|
|
@param {number} txId - the tx's Id
|
2020-11-10 18:30:41 +01:00
|
|
|
@returns {string} rawTx
|
2018-04-13 21:38:07 +02:00
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
async signTransaction(txId) {
|
2017-08-18 21:23:35 +02:00
|
|
|
const txMeta = this.txStateManager.getTx(txId)
|
2017-03-30 23:23:23 +02:00
|
|
|
// add network/chain id
|
2018-03-28 08:55:18 +02:00
|
|
|
const chainId = this.getChainId()
|
2020-08-19 18:27:05 +02:00
|
|
|
const txParams = { ...txMeta.txParams, chainId }
|
2018-03-28 08:55:18 +02:00
|
|
|
// sign tx
|
|
|
|
const fromAddress = txParams.from
|
2017-09-06 06:50:36 +02:00
|
|
|
const ethTx = new Transaction(txParams)
|
2017-08-03 00:58:05 +02:00
|
|
|
await this.signEthTx(ethTx, fromAddress)
|
2019-10-30 23:15:54 +01:00
|
|
|
|
|
|
|
// add r,s,v values for provider request purposes see createMetamaskMiddleware
|
|
|
|
// and JSON rpc standard for further explanation
|
|
|
|
txMeta.r = ethUtil.bufferToHex(ethTx.r)
|
|
|
|
txMeta.s = ethUtil.bufferToHex(ethTx.s)
|
|
|
|
txMeta.v = ethUtil.bufferToHex(ethTx.v)
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
this.txStateManager.updateTx(
|
|
|
|
txMeta,
|
|
|
|
'transactions#signTransaction: add r, s, v values',
|
|
|
|
)
|
2019-10-30 23:15:54 +01:00
|
|
|
|
2018-03-28 08:55:18 +02:00
|
|
|
// set state to signed
|
2017-08-18 21:23:35 +02:00
|
|
|
this.txStateManager.setTxStatusSigned(txMeta.id)
|
2017-08-03 00:58:05 +02:00
|
|
|
const rawTx = ethUtil.bufferToHex(ethTx.serialize())
|
2017-07-13 21:25:43 +02:00
|
|
|
return rawTx
|
2017-01-13 11:00:11 +01:00
|
|
|
}
|
|
|
|
|
2018-04-13 21:38:07 +02:00
|
|
|
/**
|
|
|
|
publishes the raw tx and sets the txMeta to submitted
|
2020-01-13 19:36:36 +01:00
|
|
|
@param {number} txId - the tx's Id
|
|
|
|
@param {string} rawTx - the hex string of the serialized signed transaction
|
2018-04-25 20:13:51 +02:00
|
|
|
@returns {Promise<void>}
|
2018-04-13 21:38:07 +02:00
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
async publishTransaction(txId, rawTx) {
|
2017-08-18 21:23:35 +02:00
|
|
|
const txMeta = this.txStateManager.getTx(txId)
|
2017-05-23 20:49:25 +02:00
|
|
|
txMeta.rawTx = rawTx
|
2020-11-03 23:57:51 +01:00
|
|
|
if (txMeta.transactionCategory === TRANSACTION_CATEGORIES.SWAP) {
|
2020-10-06 20:28:38 +02:00
|
|
|
const preTxBalance = await this.query.getBalance(txMeta.txParams.from)
|
|
|
|
txMeta.preTxBalance = preTxBalance.toString(16)
|
|
|
|
}
|
2017-10-02 22:41:29 +02:00
|
|
|
this.txStateManager.updateTx(txMeta, 'transactions#publishTransaction')
|
2019-10-30 22:40:33 +01:00
|
|
|
let txHash
|
|
|
|
try {
|
|
|
|
txHash = await this.query.sendRawTransaction(rawTx)
|
|
|
|
} catch (error) {
|
|
|
|
if (error.message.toLowerCase().includes('known transaction')) {
|
2020-11-06 22:18:00 +01:00
|
|
|
txHash = ethUtil.sha3(addHexPrefix(rawTx)).toString('hex')
|
|
|
|
txHash = addHexPrefix(txHash)
|
2019-10-30 22:40:33 +01:00
|
|
|
} else {
|
|
|
|
throw error
|
|
|
|
}
|
|
|
|
}
|
2017-08-03 00:58:05 +02:00
|
|
|
this.setTxHash(txId, txHash)
|
2019-10-30 22:40:33 +01:00
|
|
|
|
2017-08-18 21:23:35 +02:00
|
|
|
this.txStateManager.setTxStatusSubmitted(txId)
|
2017-01-13 11:00:11 +01:00
|
|
|
}
|
|
|
|
|
2018-10-16 00:00:47 +02:00
|
|
|
/**
|
|
|
|
* Sets the status of the transaction to confirmed and sets the status of nonce duplicates as
|
|
|
|
* dropped if the txParams have data it will fetch the txReceipt
|
|
|
|
* @param {number} txId - The tx's ID
|
|
|
|
* @returns {Promise<void>}
|
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
async confirmTransaction(txId, txReceipt) {
|
2018-10-16 00:00:47 +02:00
|
|
|
// get the txReceipt before marking the transaction confirmed
|
|
|
|
// to ensure the receipt is gotten before the ui revives the tx
|
2020-10-12 12:22:51 +02:00
|
|
|
const txMeta = this.txStateManager.getTx(txId)
|
2018-10-16 00:00:47 +02:00
|
|
|
|
2020-10-12 12:22:51 +02:00
|
|
|
if (!txMeta) {
|
2018-10-16 00:00:47 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
// It seems that sometimes the numerical values being returned from
|
|
|
|
// this.query.getTransactionReceipt are BN instances and not strings.
|
2020-11-03 00:41:28 +01:00
|
|
|
const gasUsed =
|
|
|
|
typeof txReceipt.gasUsed === 'string'
|
|
|
|
? txReceipt.gasUsed
|
|
|
|
: txReceipt.gasUsed.toString(16)
|
2018-10-16 00:00:47 +02:00
|
|
|
|
2020-10-12 12:22:51 +02:00
|
|
|
txMeta.txReceipt = {
|
2018-10-16 00:00:47 +02:00
|
|
|
...txReceipt,
|
|
|
|
gasUsed,
|
|
|
|
}
|
2020-10-08 20:31:35 +02:00
|
|
|
this.txStateManager.setTxStatusConfirmed(txId)
|
|
|
|
this._markNonceDuplicatesDropped(txId)
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
this.txStateManager.updateTx(
|
|
|
|
txMeta,
|
|
|
|
'transactions#confirmTransaction - add txReceipt',
|
|
|
|
)
|
2018-10-16 00:00:47 +02:00
|
|
|
|
2020-11-03 23:57:51 +01:00
|
|
|
if (txMeta.transactionCategory === TRANSACTION_CATEGORIES.SWAP) {
|
2020-10-06 20:28:38 +02:00
|
|
|
const postTxBalance = await this.query.getBalance(txMeta.txParams.from)
|
2020-10-12 12:22:51 +02:00
|
|
|
const latestTxMeta = this.txStateManager.getTx(txId)
|
|
|
|
|
2020-10-12 21:56:53 +02:00
|
|
|
const approvalTxMeta = latestTxMeta.approvalTxId
|
|
|
|
? this.txStateManager.getTx(latestTxMeta.approvalTxId)
|
|
|
|
: null
|
|
|
|
|
2020-10-12 12:22:51 +02:00
|
|
|
latestTxMeta.postTxBalance = postTxBalance.toString(16)
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
this.txStateManager.updateTx(
|
|
|
|
latestTxMeta,
|
|
|
|
'transactions#confirmTransaction - add postTxBalance',
|
|
|
|
)
|
2020-10-12 12:22:51 +02:00
|
|
|
|
2020-10-12 21:56:53 +02:00
|
|
|
this._trackSwapsMetrics(latestTxMeta, approvalTxMeta)
|
2020-10-06 20:28:38 +02:00
|
|
|
}
|
2018-10-16 00:00:47 +02:00
|
|
|
} catch (err) {
|
|
|
|
log.error(err)
|
|
|
|
}
|
2018-05-23 01:40:01 +02:00
|
|
|
}
|
|
|
|
|
2018-04-13 21:38:07 +02:00
|
|
|
/**
|
2018-04-25 20:13:51 +02:00
|
|
|
Convenience method for the ui thats sets the transaction to rejected
|
2020-01-13 19:36:36 +01:00
|
|
|
@param {number} txId - the tx's Id
|
2018-04-25 20:13:51 +02:00
|
|
|
@returns {Promise<void>}
|
2018-04-13 21:38:07 +02:00
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
async cancelTransaction(txId) {
|
2017-08-18 21:23:35 +02:00
|
|
|
this.txStateManager.setTxStatusRejected(txId)
|
2017-07-26 20:56:52 +02:00
|
|
|
}
|
|
|
|
|
2018-04-13 21:38:07 +02:00
|
|
|
/**
|
2018-04-25 20:13:51 +02:00
|
|
|
Sets the txHas on the txMeta
|
2020-01-13 19:36:36 +01:00
|
|
|
@param {number} txId - the tx's Id
|
|
|
|
@param {string} txHash - the hash for the txMeta
|
2018-04-13 21:38:07 +02:00
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
setTxHash(txId, txHash) {
|
2016-12-20 22:12:14 +01:00
|
|
|
// Add the tx hash to the persisted meta-tx object
|
2017-08-18 21:23:35 +02:00
|
|
|
const txMeta = this.txStateManager.getTx(txId)
|
2017-01-13 11:00:11 +01:00
|
|
|
txMeta.hash = txHash
|
2017-10-02 22:41:29 +02:00
|
|
|
this.txStateManager.updateTx(txMeta, 'transactions#setTxHash')
|
2016-12-14 21:55:41 +01:00
|
|
|
}
|
|
|
|
|
2019-07-31 22:17:11 +02:00
|
|
|
//
|
|
|
|
// PRIVATE METHODS
|
|
|
|
//
|
2018-04-13 21:38:07 +02:00
|
|
|
/** maps methods for convenience*/
|
2020-11-03 00:41:28 +01:00
|
|
|
_mapMethods() {
|
2020-11-10 18:30:41 +01:00
|
|
|
/** @returns {Object} the state in transaction controller */
|
2018-04-13 21:38:07 +02:00
|
|
|
this.getState = () => this.memStore.getState()
|
2020-08-19 18:27:05 +02:00
|
|
|
|
2020-11-10 18:30:41 +01:00
|
|
|
/** @returns {string|number} the network number stored in networkStore */
|
2018-04-13 21:38:07 +02:00
|
|
|
this.getNetwork = () => this.networkStore.getState()
|
2020-08-19 18:27:05 +02:00
|
|
|
|
2020-11-10 18:30:41 +01:00
|
|
|
/** @returns {string} the user selected address */
|
2020-11-03 00:41:28 +01:00
|
|
|
this.getSelectedAddress = () =>
|
|
|
|
this.preferencesStore.getState().selectedAddress
|
2020-08-19 18:27:05 +02:00
|
|
|
|
2020-11-10 18:30:41 +01:00
|
|
|
/** @returns {Array} transactions whos status is unapproved */
|
2020-11-03 00:41:28 +01:00
|
|
|
this.getUnapprovedTxCount = () =>
|
|
|
|
Object.keys(this.txStateManager.getUnapprovedTxList()).length
|
2020-08-19 18:27:05 +02:00
|
|
|
|
2018-04-25 20:13:51 +02:00
|
|
|
/**
|
2020-11-10 18:30:41 +01:00
|
|
|
@returns {number} number of transactions that have the status submitted
|
2020-01-13 19:36:36 +01:00
|
|
|
@param {string} account - hex prefixed account
|
2018-04-25 20:13:51 +02:00
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
this.getPendingTxCount = (account) =>
|
|
|
|
this.txStateManager.getPendingTransactions(account).length
|
2020-08-19 18:27:05 +02:00
|
|
|
|
2018-04-13 21:38:07 +02:00
|
|
|
/** see txStateManager */
|
2020-11-03 00:41:28 +01:00
|
|
|
this.getFilteredTxList = (opts) =>
|
|
|
|
this.txStateManager.getFilteredTxList(opts)
|
2018-04-13 21:38:07 +02:00
|
|
|
}
|
2017-02-03 05:20:13 +01:00
|
|
|
|
2018-05-29 09:53:44 +02:00
|
|
|
// called once on startup
|
2020-11-03 00:41:28 +01:00
|
|
|
async _updatePendingTxsAfterFirstBlock() {
|
2018-05-29 09:53:44 +02:00
|
|
|
// wait for first block so we know we're ready
|
|
|
|
await this.blockTracker.getLatestBlock()
|
|
|
|
// get status update for all pending transactions (for the current network)
|
|
|
|
await this.pendingTxTracker.updatePendingTxs()
|
|
|
|
}
|
|
|
|
|
2018-04-25 20:13:51 +02:00
|
|
|
/**
|
|
|
|
If transaction controller was rebooted with transactions that are uncompleted
|
|
|
|
in steps of the transaction signing or user confirmation process it will either
|
|
|
|
transition txMetas to a failed state or try to redo those tasks.
|
|
|
|
*/
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
_onBootCleanUp() {
|
|
|
|
this.txStateManager
|
|
|
|
.getFilteredTxList({
|
2020-11-07 08:38:12 +01:00
|
|
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
2020-11-03 00:41:28 +01:00
|
|
|
loadingDefaults: true,
|
|
|
|
})
|
|
|
|
.forEach((tx) => {
|
|
|
|
this.addTxGasDefaults(tx)
|
|
|
|
.then((txMeta) => {
|
|
|
|
txMeta.loadingDefaults = false
|
|
|
|
this.txStateManager.updateTx(
|
|
|
|
txMeta,
|
|
|
|
'transactions: gas estimation for tx on boot',
|
|
|
|
)
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
const txMeta = this.txStateManager.getTx(tx.id)
|
|
|
|
txMeta.loadingDefaults = false
|
|
|
|
this.txStateManager.updateTx(
|
|
|
|
txMeta,
|
|
|
|
'failed to estimate gas during boot cleanup.',
|
|
|
|
)
|
|
|
|
this.txStateManager.setTxStatusFailed(txMeta.id, error)
|
|
|
|
})
|
|
|
|
})
|
2018-04-12 21:24:16 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
this.txStateManager
|
|
|
|
.getFilteredTxList({
|
2020-11-03 23:57:51 +01:00
|
|
|
status: TRANSACTION_STATUSES.APPROVED,
|
2020-11-03 00:41:28 +01:00
|
|
|
})
|
|
|
|
.forEach((txMeta) => {
|
|
|
|
const txSignError = new Error(
|
|
|
|
'Transaction found as "approved" during boot - possibly stuck during signing',
|
|
|
|
)
|
|
|
|
this.txStateManager.setTxStatusFailed(txMeta.id, txSignError)
|
|
|
|
})
|
2018-04-12 21:24:16 +02:00
|
|
|
}
|
|
|
|
|
2018-04-13 22:18:45 +02:00
|
|
|
/**
|
|
|
|
is called in constructor applies the listeners for pendingTxTracker txStateManager
|
|
|
|
and blockTracker
|
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
_setupListeners() {
|
|
|
|
this.txStateManager.on(
|
|
|
|
'tx:status-update',
|
|
|
|
this.emit.bind(this, 'tx:status-update'),
|
|
|
|
)
|
2018-05-28 23:29:31 +02:00
|
|
|
this._setupBlockTrackerListener()
|
2018-04-12 21:24:16 +02:00
|
|
|
this.pendingTxTracker.on('tx:warning', (txMeta) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
this.txStateManager.updateTx(
|
|
|
|
txMeta,
|
|
|
|
'transactions/pending-tx-tracker#event: tx:warning',
|
|
|
|
)
|
2018-04-12 21:24:16 +02:00
|
|
|
})
|
2020-11-03 00:41:28 +01:00
|
|
|
this.pendingTxTracker.on(
|
|
|
|
'tx:failed',
|
|
|
|
this.txStateManager.setTxStatusFailed.bind(this.txStateManager),
|
|
|
|
)
|
|
|
|
this.pendingTxTracker.on('tx:confirmed', (txId, transactionReceipt) =>
|
|
|
|
this.confirmTransaction(txId, transactionReceipt),
|
|
|
|
)
|
|
|
|
this.pendingTxTracker.on(
|
|
|
|
'tx:dropped',
|
|
|
|
this.txStateManager.setTxStatusDropped.bind(this.txStateManager),
|
|
|
|
)
|
2018-04-12 21:24:16 +02:00
|
|
|
this.pendingTxTracker.on('tx:block-update', (txMeta, latestBlockNumber) => {
|
|
|
|
if (!txMeta.firstRetryBlockNumber) {
|
|
|
|
txMeta.firstRetryBlockNumber = latestBlockNumber
|
2020-11-03 00:41:28 +01:00
|
|
|
this.txStateManager.updateTx(
|
|
|
|
txMeta,
|
|
|
|
'transactions/pending-tx-tracker#event: tx:block-update',
|
|
|
|
)
|
2018-04-12 21:24:16 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
this.pendingTxTracker.on('tx:retry', (txMeta) => {
|
2019-11-20 01:03:20 +01:00
|
|
|
if (!('retryCount' in txMeta)) {
|
|
|
|
txMeta.retryCount = 0
|
|
|
|
}
|
2020-08-13 01:06:44 +02:00
|
|
|
txMeta.retryCount += 1
|
2020-11-03 00:41:28 +01:00
|
|
|
this.txStateManager.updateTx(
|
|
|
|
txMeta,
|
|
|
|
'transactions/pending-tx-tracker#event: tx:retry',
|
|
|
|
)
|
2018-04-12 21:24:16 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-05-08 21:18:33 +02:00
|
|
|
/**
|
|
|
|
Returns a "type" for a transaction out of the following list: simpleSend, tokenTransfer, tokenApprove,
|
|
|
|
contractDeployment, contractMethodCall
|
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
async _determineTransactionCategory(txParams) {
|
2019-05-08 21:18:33 +02:00
|
|
|
const { data, to } = txParams
|
2020-08-22 04:29:19 +02:00
|
|
|
let name
|
|
|
|
try {
|
|
|
|
name = data && hstInterface.parseTransaction({ data }).name
|
|
|
|
} catch (error) {
|
|
|
|
log.debug('Failed to parse transaction data.', error, data)
|
|
|
|
}
|
|
|
|
|
2019-05-08 21:18:33 +02:00
|
|
|
const tokenMethodName = [
|
2020-11-03 23:57:51 +01:00
|
|
|
TRANSACTION_CATEGORIES.TOKEN_METHOD_APPROVE,
|
|
|
|
TRANSACTION_CATEGORIES.TOKEN_METHOD_TRANSFER,
|
|
|
|
TRANSACTION_CATEGORIES.TOKEN_METHOD_TRANSFER_FROM,
|
2020-08-18 18:36:45 +02:00
|
|
|
].find((methodName) => methodName === name && name.toLowerCase())
|
2019-05-08 21:18:33 +02:00
|
|
|
|
|
|
|
let result
|
2020-12-04 03:15:59 +01:00
|
|
|
if (data && tokenMethodName) {
|
2019-05-08 21:18:33 +02:00
|
|
|
result = tokenMethodName
|
2020-12-04 03:15:59 +01:00
|
|
|
} else if (data && !to) {
|
2020-11-03 23:57:51 +01:00
|
|
|
result = TRANSACTION_CATEGORIES.DEPLOY_CONTRACT
|
2019-10-07 21:29:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
let code
|
|
|
|
if (!result) {
|
2019-05-08 21:18:33 +02:00
|
|
|
try {
|
|
|
|
code = await this.query.getCode(to)
|
|
|
|
} catch (e) {
|
2019-05-14 20:14:07 +02:00
|
|
|
code = null
|
2019-05-08 21:18:33 +02:00
|
|
|
log.warn(e)
|
|
|
|
}
|
2019-10-07 21:29:37 +02:00
|
|
|
|
2019-05-08 21:18:33 +02:00
|
|
|
const codeIsEmpty = !code || code === '0x' || code === '0x0'
|
|
|
|
|
2020-11-03 23:57:51 +01:00
|
|
|
result = codeIsEmpty
|
|
|
|
? TRANSACTION_CATEGORIES.SENT_ETHER
|
|
|
|
: TRANSACTION_CATEGORIES.CONTRACT_INTERACTION
|
2019-05-08 21:18:33 +02:00
|
|
|
}
|
|
|
|
|
2019-05-14 20:14:07 +02:00
|
|
|
return { transactionCategory: result, getCodeResponse: code }
|
2019-05-08 21:18:33 +02:00
|
|
|
}
|
|
|
|
|
2018-04-25 20:13:51 +02:00
|
|
|
/**
|
|
|
|
Sets other txMeta statuses to dropped if the txMeta that has been confirmed has other transactions
|
|
|
|
in the list have the same nonce
|
|
|
|
|
2020-01-13 19:36:36 +01:00
|
|
|
@param {number} txId - the txId of the transaction that has been confirmed in a block
|
2018-04-25 20:13:51 +02:00
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
_markNonceDuplicatesDropped(txId) {
|
2018-03-08 07:01:14 +01:00
|
|
|
// get the confirmed transactions nonce and from address
|
|
|
|
const txMeta = this.txStateManager.getTx(txId)
|
|
|
|
const { nonce, from } = txMeta.txParams
|
2019-12-03 21:50:55 +01:00
|
|
|
const sameNonceTxs = this.txStateManager.getFilteredTxList({ nonce, from })
|
2019-11-20 01:03:20 +01:00
|
|
|
if (!sameNonceTxs.length) {
|
|
|
|
return
|
|
|
|
}
|
2018-03-08 07:01:14 +01:00
|
|
|
// mark all same nonce transactions as dropped and give i a replacedBy hash
|
|
|
|
sameNonceTxs.forEach((otherTxMeta) => {
|
2019-11-20 01:03:20 +01:00
|
|
|
if (otherTxMeta.id === txId) {
|
|
|
|
return
|
|
|
|
}
|
2018-03-08 07:01:14 +01:00
|
|
|
otherTxMeta.replacedBy = txMeta.hash
|
2020-11-03 00:41:28 +01:00
|
|
|
this.txStateManager.updateTx(
|
|
|
|
txMeta,
|
|
|
|
'transactions/pending-tx-tracker#event: tx:confirmed reference to confirmed txHash with same nonce',
|
|
|
|
)
|
2018-03-08 07:01:14 +01:00
|
|
|
this.txStateManager.setTxStatusDropped(otherTxMeta.id)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
_setupBlockTrackerListener() {
|
2018-05-28 23:29:31 +02:00
|
|
|
let listenersAreActive = false
|
|
|
|
const latestBlockHandler = this._onLatestBlock.bind(this)
|
2020-08-18 22:06:58 +02:00
|
|
|
const { blockTracker, txStateManager } = this
|
2018-05-28 23:29:31 +02:00
|
|
|
|
|
|
|
txStateManager.on('tx:status-update', updateSubscription)
|
|
|
|
updateSubscription()
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function updateSubscription() {
|
2018-05-28 23:29:31 +02:00
|
|
|
const pendingTxs = txStateManager.getPendingTransactions()
|
|
|
|
if (!listenersAreActive && pendingTxs.length > 0) {
|
|
|
|
blockTracker.on('latest', latestBlockHandler)
|
|
|
|
listenersAreActive = true
|
|
|
|
} else if (listenersAreActive && !pendingTxs.length) {
|
|
|
|
blockTracker.removeListener('latest', latestBlockHandler)
|
|
|
|
listenersAreActive = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
async _onLatestBlock(blockNumber) {
|
2018-05-28 23:29:31 +02:00
|
|
|
try {
|
|
|
|
await this.pendingTxTracker.updatePendingTxs()
|
|
|
|
} catch (err) {
|
|
|
|
log.error(err)
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
await this.pendingTxTracker.resubmitPendingTxs(blockNumber)
|
|
|
|
} catch (err) {
|
|
|
|
log.error(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-25 20:13:51 +02:00
|
|
|
/**
|
|
|
|
Updates the memStore in transaction controller
|
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
_updateMemstore() {
|
2017-08-18 21:23:35 +02:00
|
|
|
const unapprovedTxs = this.txStateManager.getUnapprovedTxList()
|
2020-11-03 00:41:28 +01:00
|
|
|
const currentNetworkTxList = this.txStateManager.getTxList(
|
|
|
|
MAX_MEMSTORE_TX_LIST_SIZE,
|
|
|
|
)
|
2020-03-06 22:34:56 +01:00
|
|
|
this.memStore.updateState({ unapprovedTxs, currentNetworkTxList })
|
2016-12-20 22:12:14 +01:00
|
|
|
}
|
2020-07-17 03:37:56 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
_trackSwapsMetrics(txMeta, approvalTxMeta) {
|
2020-10-08 18:41:23 +02:00
|
|
|
if (this._getParticipateInMetrics() && txMeta.swapMetaData) {
|
|
|
|
if (txMeta.txReceipt.status === '0x0') {
|
2020-10-21 23:10:55 +02:00
|
|
|
this._trackMetaMetricsEvent({
|
2020-10-08 18:41:23 +02:00
|
|
|
event: 'Swap Failed',
|
2020-12-02 22:41:30 +01:00
|
|
|
sensitiveProperties: { ...txMeta.swapMetaData },
|
2020-10-08 18:41:23 +02:00
|
|
|
category: 'swaps',
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
const tokensReceived = getSwapsTokensReceivedFromTxMeta(
|
|
|
|
txMeta.destinationTokenSymbol,
|
|
|
|
txMeta,
|
|
|
|
txMeta.destinationTokenAddress,
|
|
|
|
txMeta.txParams.from,
|
|
|
|
txMeta.destinationTokenDecimals,
|
2020-10-12 21:56:53 +02:00
|
|
|
approvalTxMeta,
|
2020-10-08 18:41:23 +02:00
|
|
|
)
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const quoteVsExecutionRatio = `${new BigNumber(tokensReceived, 10)
|
|
|
|
.div(txMeta.swapMetaData.token_to_amount, 10)
|
|
|
|
.times(100)
|
|
|
|
.round(2)}%`
|
|
|
|
|
|
|
|
const estimatedVsUsedGasRatio = `${new BigNumber(
|
|
|
|
txMeta.txReceipt.gasUsed,
|
|
|
|
16,
|
|
|
|
)
|
|
|
|
.div(txMeta.swapMetaData.estimated_gas, 10)
|
|
|
|
.times(100)
|
|
|
|
.round(2)}%`
|
2020-10-13 20:41:26 +02:00
|
|
|
|
2020-10-21 23:10:55 +02:00
|
|
|
this._trackMetaMetricsEvent({
|
2020-10-08 18:41:23 +02:00
|
|
|
event: 'Swap Completed',
|
|
|
|
category: 'swaps',
|
2020-12-02 22:41:30 +01:00
|
|
|
sensitiveProperties: {
|
2020-10-08 18:41:23 +02:00
|
|
|
...txMeta.swapMetaData,
|
|
|
|
token_to_amount_received: tokensReceived,
|
|
|
|
quote_vs_executionRatio: quoteVsExecutionRatio,
|
2020-10-13 20:41:26 +02:00
|
|
|
estimated_vs_used_gasRatio: estimatedVsUsedGasRatio,
|
2020-10-08 18:41:23 +02:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-04-13 22:18:45 +02:00
|
|
|
}
|