2020-01-09 04:34:58 +01:00
|
|
|
import abi from 'human-standard-token-abi'
|
|
|
|
import pify from 'pify'
|
2020-08-18 21:18:25 +02:00
|
|
|
import log from 'loglevel'
|
2020-09-02 18:28:14 +02:00
|
|
|
import { capitalize } from 'lodash'
|
2020-01-09 04:34:58 +01:00
|
|
|
import getBuyEthUrl from '../../../app/scripts/lib/buy-eth-url'
|
2020-06-01 19:54:32 +02:00
|
|
|
import { checksumAddress } from '../helpers/utils/util'
|
2020-10-13 23:13:54 +02:00
|
|
|
import { calcTokenBalance, estimateGasForSend } from '../pages/send/send.utils'
|
2020-11-03 00:41:28 +01:00
|
|
|
import {
|
|
|
|
fetchLocale,
|
|
|
|
loadRelativeTimeFormatLocaleData,
|
|
|
|
} from '../helpers/utils/i18n-helper'
|
2020-01-09 04:34:58 +01:00
|
|
|
import { getMethodDataAsync } from '../helpers/utils/transactions.util'
|
|
|
|
import { fetchSymbolAndDecimals } from '../helpers/utils/token-util'
|
2019-09-03 19:47:54 +02:00
|
|
|
import switchDirection from '../helpers/utils/switch-direction'
|
2021-01-20 17:13:14 +01:00
|
|
|
import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../shared/constants/app'
|
2020-01-09 04:34:58 +01:00
|
|
|
import { hasUnconfirmedTransactions } from '../helpers/utils/confirm-tx.util'
|
|
|
|
import { setCustomGasLimit } from '../ducks/gas/gas.duck'
|
2020-02-06 17:38:14 +01:00
|
|
|
import txHelper from '../../lib/tx-helper'
|
2020-11-06 22:18:00 +01:00
|
|
|
import { getEnvironmentType, addHexPrefix } from '../../../app/scripts/lib/util'
|
2020-04-29 19:10:51 +02:00
|
|
|
import {
|
|
|
|
getPermittedAccountsForCurrentTab,
|
|
|
|
getSelectedAddress,
|
2020-05-02 21:41:17 +02:00
|
|
|
} from '../selectors'
|
2020-04-29 19:10:51 +02:00
|
|
|
import { switchedToUnconnectedAccount } from '../ducks/alerts/unconnected-account'
|
2020-05-08 21:45:52 +02:00
|
|
|
import { getUnconnectedAccountAlertEnabledness } from '../ducks/metamask/metamask'
|
2020-11-17 18:39:21 +01:00
|
|
|
import { LISTED_CONTRACT_ADDRESSES } from '../../../shared/constants/tokens'
|
2020-08-18 21:18:25 +02:00
|
|
|
import * as actionConstants from './actionConstants'
|
2016-04-14 00:28:44 +02:00
|
|
|
|
2019-12-03 15:52:01 +01:00
|
|
|
let background = null
|
2020-04-23 19:10:15 +02:00
|
|
|
let promisifiedBackground = null
|
2020-11-03 00:41:28 +01:00
|
|
|
export function _setBackgroundConnection(backgroundConnection) {
|
2016-10-20 18:58:33 +02:00
|
|
|
background = backgroundConnection
|
2020-04-23 19:10:15 +02:00
|
|
|
promisifiedBackground = pify(background)
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function goHome() {
|
2016-04-25 21:20:33 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.GO_HOME,
|
2016-04-25 21:20:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-14 00:28:44 +02:00
|
|
|
// async actions
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function tryUnlockMetamask(password) {
|
2020-02-15 21:34:12 +01:00
|
|
|
return (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
dispatch(unlockInProgress())
|
2017-02-23 23:23:45 +01:00
|
|
|
log.debug(`background.submitPassword`)
|
2018-03-03 22:08:10 +01:00
|
|
|
|
2018-03-08 16:29:29 +01:00
|
|
|
return new Promise((resolve, reject) => {
|
2020-02-15 21:34:12 +01:00
|
|
|
background.submitPassword(password, (error) => {
|
2018-03-08 16:29:29 +01:00
|
|
|
if (error) {
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(error)
|
|
|
|
return
|
2018-03-08 16:29:29 +01:00
|
|
|
}
|
2018-03-03 22:08:10 +01:00
|
|
|
|
2018-03-08 16:29:29 +01:00
|
|
|
resolve()
|
|
|
|
})
|
2016-04-14 00:28:44 +02:00
|
|
|
})
|
2018-03-08 16:29:29 +01:00
|
|
|
.then(() => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(unlockSucceeded())
|
2018-03-08 16:29:29 +01:00
|
|
|
return forceUpdateMetamaskState(dispatch)
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
return new Promise((resolve, reject) => {
|
2020-02-15 21:34:12 +01:00
|
|
|
background.verifySeedPhrase((err) => {
|
2018-03-08 16:29:29 +01:00
|
|
|
if (err) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(err.message))
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2018-03-08 16:29:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then(() => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(hideLoadingIndication())
|
2018-03-08 16:29:29 +01:00
|
|
|
})
|
2020-02-15 21:34:12 +01:00
|
|
|
.catch((err) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(unlockFailed(err.message))
|
|
|
|
dispatch(hideLoadingIndication())
|
2018-05-14 15:30:50 +02:00
|
|
|
return Promise.reject(err)
|
2018-03-08 16:29:29 +01:00
|
|
|
})
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function createNewVaultAndRestore(password, seed) {
|
2016-04-14 00:28:44 +02:00
|
|
|
return (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2017-02-23 23:23:45 +01:00
|
|
|
log.debug(`background.createNewVaultAndRestore`)
|
2019-09-16 19:11:01 +02:00
|
|
|
let vault
|
2017-10-21 07:31:59 +02:00
|
|
|
return new Promise((resolve, reject) => {
|
2019-09-16 19:11:01 +02:00
|
|
|
background.createNewVaultAndRestore(password, seed, (err, _vault) => {
|
2017-10-21 07:31:59 +02:00
|
|
|
if (err) {
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2017-10-21 07:31:59 +02:00
|
|
|
}
|
2019-09-16 19:11:01 +02:00
|
|
|
vault = _vault
|
2019-07-26 15:35:21 +02:00
|
|
|
resolve()
|
2017-10-21 07:31:59 +02:00
|
|
|
})
|
2016-11-01 19:25:38 +01:00
|
|
|
})
|
2020-01-09 04:34:58 +01:00
|
|
|
.then(() => dispatch(unMarkPasswordForgotten()))
|
2018-03-08 16:29:29 +01:00
|
|
|
.then(() => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showAccountsPage())
|
|
|
|
dispatch(hideLoadingIndication())
|
2019-09-16 19:11:01 +02:00
|
|
|
return vault
|
2018-03-08 16:29:29 +01:00
|
|
|
})
|
2020-02-15 21:34:12 +01:00
|
|
|
.catch((err) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
dispatch(hideLoadingIndication())
|
2019-01-23 16:25:34 +01:00
|
|
|
return Promise.reject(err)
|
2018-03-08 16:29:29 +01:00
|
|
|
})
|
2016-11-01 19:25:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function createNewVaultAndGetSeedPhrase(password) {
|
2020-02-15 21:34:12 +01:00
|
|
|
return async (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2019-01-23 16:25:34 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
await createNewVault(password)
|
|
|
|
const seedWords = await verifySeedPhrase()
|
|
|
|
return seedWords
|
|
|
|
} catch (error) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(error.message))
|
2019-01-23 16:25:34 +01:00
|
|
|
throw new Error(error.message)
|
2020-12-18 06:34:43 +01:00
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
2019-01-23 16:25:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function unlockAndGetSeedPhrase(password) {
|
2020-02-15 21:34:12 +01:00
|
|
|
return async (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2019-01-23 16:25:34 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
await submitPassword(password)
|
|
|
|
const seedWords = await verifySeedPhrase()
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
return seedWords
|
|
|
|
} catch (error) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(error.message))
|
2019-01-23 16:25:34 +01:00
|
|
|
throw new Error(error.message)
|
2020-12-18 06:34:43 +01:00
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
2019-01-23 16:25:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function submitPassword(password) {
|
2019-01-23 16:25:34 +01:00
|
|
|
return new Promise((resolve, reject) => {
|
2020-02-15 21:34:12 +01:00
|
|
|
background.submitPassword(password, (error) => {
|
2019-01-23 16:25:34 +01:00
|
|
|
if (error) {
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(error)
|
|
|
|
return
|
2019-01-23 16:25:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function createNewVault(password) {
|
2019-01-23 16:25:34 +01:00
|
|
|
return new Promise((resolve, reject) => {
|
2020-02-15 21:34:12 +01:00
|
|
|
background.createNewVaultAndKeychain(password, (error) => {
|
2019-01-23 16:25:34 +01:00
|
|
|
if (error) {
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(error)
|
|
|
|
return
|
2019-01-23 16:25:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
resolve(true)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function verifyPassword(password) {
|
2018-05-14 15:30:50 +02:00
|
|
|
return new Promise((resolve, reject) => {
|
2020-07-25 00:47:40 +02:00
|
|
|
background.verifyPassword(password, (error) => {
|
2018-05-14 15:30:50 +02:00
|
|
|
if (error) {
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(error)
|
|
|
|
return
|
2018-05-14 15:30:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
resolve(true)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function verifySeedPhrase() {
|
2018-05-14 15:30:50 +02:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.verifySeedPhrase((error, seedWords) => {
|
|
|
|
if (error) {
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(error)
|
|
|
|
return
|
2018-05-14 15:30:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
resolve(seedWords)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function requestRevealSeedWords(password) {
|
2020-02-15 21:34:12 +01:00
|
|
|
return async (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2020-07-25 00:47:40 +02:00
|
|
|
log.debug(`background.verifyPassword`)
|
2018-05-14 15:30:50 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
await verifyPassword(password)
|
|
|
|
const seedWords = await verifySeedPhrase()
|
|
|
|
return seedWords
|
|
|
|
} catch (error) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(error.message))
|
2018-05-14 15:30:50 +02:00
|
|
|
throw new Error(error.message)
|
2020-12-18 06:34:43 +01:00
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
2018-05-14 15:30:50 +02:00
|
|
|
}
|
2016-11-02 06:19:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function tryReverseResolveAddress(address) {
|
2019-11-01 18:54:00 +01:00
|
|
|
return () => {
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
background.tryReverseResolveAddress(address, (err) => {
|
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
|
|
|
}
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function fetchInfoToSync() {
|
2020-02-15 21:34:12 +01:00
|
|
|
return (dispatch) => {
|
2019-02-25 20:10:13 +01:00
|
|
|
log.debug(`background.fetchInfoToSync`)
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.fetchInfoToSync((err, result) => {
|
|
|
|
if (err) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(err.message))
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2019-02-25 20:10:13 +01:00
|
|
|
}
|
|
|
|
resolve(result)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function resetAccount() {
|
2020-02-15 21:34:12 +01:00
|
|
|
return (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2018-01-31 09:33:15 +01:00
|
|
|
|
2018-05-31 01:17:40 +02:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.resetAccount((err, account) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(hideLoadingIndication())
|
2018-05-31 01:17:40 +02:00
|
|
|
if (err) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(err.message))
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2018-05-31 01:17:40 +02:00
|
|
|
}
|
|
|
|
|
2020-08-19 18:27:05 +02:00
|
|
|
log.info(`Transaction history reset for ${account}`)
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showAccountsPage())
|
2018-05-31 01:17:40 +02:00
|
|
|
resolve(account)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
2018-01-31 09:33:15 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function removeAccount(address) {
|
2020-02-15 21:34:12 +01:00
|
|
|
return async (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2018-07-11 06:20:40 +02:00
|
|
|
|
2020-01-16 18:43:40 +01:00
|
|
|
try {
|
|
|
|
await new Promise((resolve, reject) => {
|
|
|
|
background.removeAccount(address, (error, account) => {
|
|
|
|
if (error) {
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(error)
|
|
|
|
return
|
2020-01-16 18:43:40 +01:00
|
|
|
}
|
2020-08-12 21:06:57 +02:00
|
|
|
resolve(account)
|
2020-01-16 18:43:40 +01:00
|
|
|
})
|
2018-07-11 06:20:40 +02:00
|
|
|
})
|
2020-01-16 18:43:40 +01:00
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
} catch (error) {
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
throw error
|
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
}
|
|
|
|
|
2020-08-19 18:27:05 +02:00
|
|
|
log.info(`Account removed: ${address}`)
|
2020-01-16 18:43:40 +01:00
|
|
|
dispatch(showAccountsPage())
|
2018-07-11 06:20:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function importNewAccount(strategy, args) {
|
2018-05-14 15:30:50 +02:00
|
|
|
return async (dispatch) => {
|
|
|
|
let newState
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication('This may take a while, please be patient.'))
|
2018-05-14 15:30:50 +02:00
|
|
|
try {
|
|
|
|
log.debug(`background.importAccountWithStrategy`)
|
2020-04-23 19:10:15 +02:00
|
|
|
await promisifiedBackground.importAccountWithStrategy(strategy, args)
|
2018-05-14 15:30:50 +02:00
|
|
|
log.debug(`background.getState`)
|
2020-04-23 19:10:15 +02:00
|
|
|
newState = await promisifiedBackground.getState()
|
2018-05-14 15:30:50 +02:00
|
|
|
} catch (err) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(err.message))
|
2018-05-14 15:30:50 +02:00
|
|
|
throw err
|
2020-12-18 06:34:43 +01:00
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
2018-05-14 15:30:50 +02:00
|
|
|
}
|
2020-12-18 06:34:43 +01:00
|
|
|
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(updateMetamaskState(newState))
|
2018-05-30 21:13:45 +02:00
|
|
|
if (newState.selectedAddress) {
|
|
|
|
dispatch({
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SHOW_ACCOUNT_DETAIL,
|
2018-05-30 21:13:45 +02:00
|
|
|
value: newState.selectedAddress,
|
|
|
|
})
|
|
|
|
}
|
2018-05-14 15:30:50 +02:00
|
|
|
return newState
|
2017-01-19 00:17:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function addNewAccount() {
|
2017-02-23 23:23:45 +01:00
|
|
|
log.debug(`background.addNewAccount`)
|
2020-04-27 21:03:25 +02:00
|
|
|
return async (dispatch, getState) => {
|
2017-09-22 23:00:00 +02:00
|
|
|
const oldIdentities = getState().metamask.identities
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2017-09-22 08:59:27 +02:00
|
|
|
|
2020-04-27 21:03:25 +02:00
|
|
|
let newIdentities
|
|
|
|
try {
|
|
|
|
const { identities } = await promisifiedBackground.addNewAccount()
|
|
|
|
newIdentities = identities
|
|
|
|
} catch (error) {
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
throw error
|
2020-12-18 06:34:43 +01:00
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
2020-04-27 21:03:25 +02:00
|
|
|
}
|
2020-12-18 06:34:43 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const newAccountAddress = Object.keys(newIdentities).find(
|
|
|
|
(address) => !oldIdentities[address],
|
|
|
|
)
|
2020-04-27 21:36:19 +02:00
|
|
|
await forceUpdateMetamaskState(dispatch)
|
2020-04-27 21:03:25 +02:00
|
|
|
return newAccountAddress
|
2017-09-22 08:59:27 +02:00
|
|
|
}
|
2016-10-28 21:10:35 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function checkHardwareStatus(deviceName, hdPath) {
|
2018-08-14 01:29:43 +02:00
|
|
|
log.debug(`background.checkHardwareStatus`, deviceName, hdPath)
|
2020-04-27 21:03:25 +02:00
|
|
|
return async (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2018-07-12 03:21:36 +02:00
|
|
|
|
2020-04-27 21:03:25 +02:00
|
|
|
let unlocked
|
|
|
|
try {
|
2020-11-03 00:41:28 +01:00
|
|
|
unlocked = await promisifiedBackground.checkHardwareStatus(
|
|
|
|
deviceName,
|
|
|
|
hdPath,
|
|
|
|
)
|
2020-04-27 21:03:25 +02:00
|
|
|
} catch (error) {
|
|
|
|
log.error(error)
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
throw error
|
2020-12-18 06:34:43 +01:00
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
2020-04-27 21:03:25 +02:00
|
|
|
}
|
2018-07-12 03:21:36 +02:00
|
|
|
|
2020-04-27 21:36:19 +02:00
|
|
|
await forceUpdateMetamaskState(dispatch)
|
2020-04-27 21:03:25 +02:00
|
|
|
return unlocked
|
2018-07-12 03:21:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function forgetDevice(deviceName) {
|
2018-07-12 03:21:36 +02:00
|
|
|
log.debug(`background.forgetDevice`, deviceName)
|
2020-04-27 21:03:25 +02:00
|
|
|
return async (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2020-04-27 21:03:25 +02:00
|
|
|
try {
|
|
|
|
await promisifiedBackground.forgetDevice(deviceName)
|
|
|
|
} catch (error) {
|
|
|
|
log.error(error)
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
throw error
|
2020-12-18 06:34:43 +01:00
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
2020-04-27 21:03:25 +02:00
|
|
|
}
|
2018-07-12 03:21:36 +02:00
|
|
|
|
2020-04-27 21:36:19 +02:00
|
|
|
await forceUpdateMetamaskState(dispatch)
|
2018-07-12 03:21:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function connectHardware(deviceName, page, hdPath) {
|
2018-08-14 01:29:43 +02:00
|
|
|
log.debug(`background.connectHardware`, deviceName, page, hdPath)
|
2020-04-27 21:03:25 +02:00
|
|
|
return async (dispatch) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
dispatch(
|
|
|
|
showLoadingIndication(`Looking for your ${capitalize(deviceName)}...`),
|
|
|
|
)
|
2018-06-10 09:52:32 +02:00
|
|
|
|
2020-04-27 21:03:25 +02:00
|
|
|
let accounts
|
|
|
|
try {
|
2020-11-03 00:41:28 +01:00
|
|
|
accounts = await promisifiedBackground.connectHardware(
|
|
|
|
deviceName,
|
|
|
|
page,
|
|
|
|
hdPath,
|
|
|
|
)
|
2020-04-27 21:03:25 +02:00
|
|
|
} catch (error) {
|
|
|
|
log.error(error)
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
throw error
|
2020-12-18 06:34:43 +01:00
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
2020-04-27 21:03:25 +02:00
|
|
|
}
|
2018-06-10 09:52:32 +02:00
|
|
|
|
2020-12-18 06:34:43 +01:00
|
|
|
await forceUpdateMetamaskState(dispatch)
|
2020-04-27 21:03:25 +02:00
|
|
|
return accounts
|
2018-06-10 09:52:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function unlockHardwareWalletAccount(index, deviceName, hdPath) {
|
2018-08-14 01:29:43 +02:00
|
|
|
log.debug(`background.unlockHardwareWalletAccount`, index, deviceName, hdPath)
|
2019-05-08 21:51:33 +02:00
|
|
|
return (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2018-06-10 09:52:32 +02:00
|
|
|
return new Promise((resolve, reject) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
background.unlockHardwareWalletAccount(
|
|
|
|
index,
|
|
|
|
deviceName,
|
|
|
|
hdPath,
|
|
|
|
(err) => {
|
2020-12-18 06:34:43 +01:00
|
|
|
dispatch(hideLoadingIndication())
|
2020-11-03 00:41:28 +01:00
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
reject(err)
|
|
|
|
return
|
|
|
|
}
|
2018-06-10 09:52:32 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
resolve()
|
|
|
|
},
|
|
|
|
)
|
2018-06-10 09:52:32 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function showQrScanner() {
|
2019-05-08 21:51:33 +02:00
|
|
|
return (dispatch) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
dispatch(
|
|
|
|
showModal({
|
|
|
|
name: 'QR_SCANNER',
|
|
|
|
}),
|
|
|
|
)
|
2018-08-01 00:30:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setCurrentCurrency(currencyCode) {
|
2020-04-27 21:30:27 +02:00
|
|
|
return async (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2017-03-15 01:06:16 +01:00
|
|
|
log.debug(`background.setCurrentCurrency`)
|
2020-04-27 21:30:27 +02:00
|
|
|
let data
|
|
|
|
try {
|
|
|
|
data = await promisifiedBackground.setCurrentCurrency(currencyCode)
|
|
|
|
} catch (error) {
|
|
|
|
log.error(error.stack)
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
return
|
2020-12-18 06:34:43 +01:00
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
2020-04-27 21:30:27 +02:00
|
|
|
}
|
2020-12-18 06:34:43 +01:00
|
|
|
|
2020-04-27 21:30:27 +02:00
|
|
|
dispatch({
|
|
|
|
type: actionConstants.SET_CURRENT_FIAT,
|
|
|
|
value: {
|
|
|
|
currentCurrency: data.currentCurrency,
|
|
|
|
conversionRate: data.conversionRate,
|
|
|
|
conversionDate: data.conversionDate,
|
|
|
|
},
|
2016-07-21 18:30:58 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function signMsg(msgData) {
|
2017-02-23 23:23:45 +01:00
|
|
|
log.debug('action - signMsg')
|
2020-04-28 14:49:10 +02:00
|
|
|
return async (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2020-04-28 14:49:10 +02:00
|
|
|
log.debug(`actions calling background.signMessage`)
|
|
|
|
let newState
|
|
|
|
try {
|
|
|
|
newState = await promisifiedBackground.signMessage(msgData)
|
|
|
|
} catch (error) {
|
|
|
|
log.error(error)
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
throw error
|
2020-12-18 06:34:43 +01:00
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
2020-04-28 14:49:10 +02:00
|
|
|
}
|
2020-12-18 06:34:43 +01:00
|
|
|
|
2020-04-28 14:49:10 +02:00
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(completedTx(msgData.metamaskId))
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
return msgData
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function signPersonalMsg(msgData) {
|
2017-02-23 23:23:45 +01:00
|
|
|
log.debug('action - signPersonalMsg')
|
2020-04-28 14:49:10 +02:00
|
|
|
return async (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2020-04-28 14:49:10 +02:00
|
|
|
log.debug(`actions calling background.signPersonalMessage`)
|
2017-02-23 01:23:13 +01:00
|
|
|
|
2020-04-28 14:49:10 +02:00
|
|
|
let newState
|
|
|
|
try {
|
|
|
|
newState = await promisifiedBackground.signPersonalMessage(msgData)
|
|
|
|
} catch (error) {
|
|
|
|
log.error(error)
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
throw error
|
2020-12-18 06:34:43 +01:00
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
2020-04-28 14:49:10 +02:00
|
|
|
}
|
2020-12-18 06:34:43 +01:00
|
|
|
|
2020-04-28 14:49:10 +02:00
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(completedTx(msgData.metamaskId))
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
return msgData
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function decryptMsgInline(decryptedMsgData) {
|
2020-02-19 19:24:16 +01:00
|
|
|
log.debug('action - decryptMsgInline')
|
2020-04-28 14:49:10 +02:00
|
|
|
return async (dispatch) => {
|
|
|
|
log.debug(`actions calling background.decryptMessageInline`)
|
2020-02-19 19:24:16 +01:00
|
|
|
|
2020-04-28 14:49:10 +02:00
|
|
|
let newState
|
|
|
|
try {
|
2020-11-03 00:41:28 +01:00
|
|
|
newState = await promisifiedBackground.decryptMessageInline(
|
|
|
|
decryptedMsgData,
|
|
|
|
)
|
2020-04-28 14:49:10 +02:00
|
|
|
} catch (error) {
|
|
|
|
log.error(error)
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
throw error
|
|
|
|
}
|
2020-02-19 19:24:16 +01:00
|
|
|
|
2020-04-28 14:49:10 +02:00
|
|
|
dispatch(updateMetamaskState(newState))
|
2020-08-15 13:58:11 +02:00
|
|
|
return newState.unapprovedDecryptMsgs[decryptedMsgData.metamaskId]
|
2020-02-19 19:24:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function decryptMsg(decryptedMsgData) {
|
2020-02-19 19:24:16 +01:00
|
|
|
log.debug('action - decryptMsg')
|
2020-04-28 14:49:10 +02:00
|
|
|
return async (dispatch) => {
|
2020-02-19 19:24:16 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2020-04-28 14:49:10 +02:00
|
|
|
log.debug(`actions calling background.decryptMessage`)
|
2020-02-19 19:24:16 +01:00
|
|
|
|
2020-04-28 14:49:10 +02:00
|
|
|
let newState
|
|
|
|
try {
|
|
|
|
newState = await promisifiedBackground.decryptMessage(decryptedMsgData)
|
|
|
|
} catch (error) {
|
|
|
|
log.error(error)
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
throw error
|
2020-12-18 06:34:43 +01:00
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
2020-04-28 14:49:10 +02:00
|
|
|
}
|
2020-12-18 06:34:43 +01:00
|
|
|
|
2020-04-28 14:49:10 +02:00
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(completedTx(decryptedMsgData.metamaskId))
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
return decryptedMsgData
|
2020-02-19 19:24:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function encryptionPublicKeyMsg(msgData) {
|
2020-02-19 19:24:16 +01:00
|
|
|
log.debug('action - encryptionPublicKeyMsg')
|
2020-04-28 14:49:10 +02:00
|
|
|
return async (dispatch) => {
|
2020-02-19 19:24:16 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2020-04-28 14:49:10 +02:00
|
|
|
log.debug(`actions calling background.encryptionPublicKey`)
|
2020-02-19 19:24:16 +01:00
|
|
|
|
2020-04-28 14:49:10 +02:00
|
|
|
let newState
|
|
|
|
try {
|
|
|
|
newState = await promisifiedBackground.encryptionPublicKey(msgData)
|
|
|
|
} catch (error) {
|
|
|
|
log.error(error)
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
throw error
|
2020-12-18 06:34:43 +01:00
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
2020-04-28 14:49:10 +02:00
|
|
|
}
|
2020-12-18 06:34:43 +01:00
|
|
|
|
2020-04-28 14:49:10 +02:00
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(completedTx(msgData.metamaskId))
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
return msgData
|
2020-02-19 19:24:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function signTypedMsg(msgData) {
|
2017-09-29 18:24:08 +02:00
|
|
|
log.debug('action - signTypedMsg')
|
2020-04-28 14:49:10 +02:00
|
|
|
return async (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2020-04-28 14:49:10 +02:00
|
|
|
log.debug(`actions calling background.signTypedMessage`)
|
2017-09-29 18:24:08 +02:00
|
|
|
|
2020-04-28 14:49:10 +02:00
|
|
|
let newState
|
|
|
|
try {
|
|
|
|
newState = await promisifiedBackground.signTypedMessage(msgData)
|
|
|
|
} catch (error) {
|
|
|
|
log.error(error)
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
throw error
|
2020-12-18 06:34:43 +01:00
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
2020-04-28 14:49:10 +02:00
|
|
|
}
|
2020-12-18 06:34:43 +01:00
|
|
|
|
2020-04-28 14:49:10 +02:00
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(completedTx(msgData.metamaskId))
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
return msgData
|
2017-09-29 18:24:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function signTx(txData) {
|
2016-05-06 23:46:04 +02:00
|
|
|
return (dispatch) => {
|
2019-05-08 21:51:33 +02:00
|
|
|
global.ethQuery.sendTransaction(txData, (err) => {
|
2018-06-23 08:52:45 +02:00
|
|
|
if (err) {
|
2020-08-12 21:06:57 +02:00
|
|
|
dispatch(displayWarning(err.message))
|
2018-06-23 08:52:45 +02:00
|
|
|
}
|
2016-05-06 23:46:04 +02:00
|
|
|
})
|
2020-02-06 17:38:14 +01:00
|
|
|
dispatch(showConfTxPage())
|
2016-05-06 23:46:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setGasLimit(gasLimit) {
|
2017-10-12 18:42:14 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.UPDATE_GAS_LIMIT,
|
2017-10-12 18:42:14 +02:00
|
|
|
value: gasLimit,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setGasPrice(gasPrice) {
|
2017-10-12 18:42:14 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.UPDATE_GAS_PRICE,
|
2017-10-12 18:42:14 +02:00
|
|
|
value: gasPrice,
|
|
|
|
}
|
|
|
|
}
|
2017-09-22 06:15:26 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setGasTotal(gasTotal) {
|
2017-10-17 19:22:23 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.UPDATE_GAS_TOTAL,
|
2017-10-17 19:22:23 +02:00
|
|
|
value: gasTotal,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateGasData({
|
2018-09-13 10:47:05 +02:00
|
|
|
gasPrice,
|
2018-05-22 17:16:53 +02:00
|
|
|
blockGasLimit,
|
|
|
|
selectedAddress,
|
2020-05-29 19:46:10 +02:00
|
|
|
sendToken,
|
2018-05-22 17:16:53 +02:00
|
|
|
to,
|
2018-05-23 18:43:25 +02:00
|
|
|
value,
|
2018-09-27 15:46:24 +02:00
|
|
|
data,
|
2018-05-22 17:16:53 +02:00
|
|
|
}) {
|
2018-04-27 21:03:00 +02:00
|
|
|
return (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(gasLoadingStarted())
|
2020-10-13 23:13:54 +02:00
|
|
|
return estimateGasForSend({
|
2020-04-23 20:01:38 +02:00
|
|
|
estimateGasMethod: promisifiedBackground.estimateGas,
|
2018-09-13 10:47:05 +02:00
|
|
|
blockGasLimit,
|
|
|
|
selectedAddress,
|
2020-05-29 19:46:10 +02:00
|
|
|
sendToken,
|
2018-09-13 10:47:05 +02:00
|
|
|
to,
|
|
|
|
value,
|
|
|
|
estimateGasPrice: gasPrice,
|
|
|
|
data,
|
2018-06-29 02:10:06 +02:00
|
|
|
})
|
2020-02-15 21:34:12 +01:00
|
|
|
.then((gas) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(setGasLimit(gas))
|
|
|
|
dispatch(setCustomGasLimit(gas))
|
2019-07-31 22:17:11 +02:00
|
|
|
dispatch(updateSendErrors({ gasLoadingError: null }))
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(gasLoadingFinished())
|
2019-07-31 22:17:11 +02:00
|
|
|
})
|
2020-02-15 21:34:12 +01:00
|
|
|
.catch((err) => {
|
2019-07-31 22:17:11 +02:00
|
|
|
log.error(err)
|
|
|
|
dispatch(updateSendErrors({ gasLoadingError: 'gasLoadingError' }))
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(gasLoadingFinished())
|
2019-07-31 22:17:11 +02:00
|
|
|
})
|
2018-04-27 21:03:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function gasLoadingStarted() {
|
2018-06-19 17:53:33 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.GAS_LOADING_STARTED,
|
2018-06-19 17:53:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function gasLoadingFinished() {
|
2018-06-19 17:53:33 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.GAS_LOADING_FINISHED,
|
2018-06-19 17:53:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateSendTokenBalance({ sendToken, tokenContract, address }) {
|
2018-04-27 21:03:00 +02:00
|
|
|
return (dispatch) => {
|
|
|
|
const tokenBalancePromise = tokenContract
|
|
|
|
? tokenContract.balanceOf(address)
|
|
|
|
: Promise.resolve()
|
|
|
|
return tokenBalancePromise
|
2020-02-15 21:34:12 +01:00
|
|
|
.then((usersToken) => {
|
2018-04-27 21:03:00 +02:00
|
|
|
if (usersToken) {
|
2020-05-29 19:46:10 +02:00
|
|
|
const newTokenBalance = calcTokenBalance({ sendToken, usersToken })
|
2018-11-20 01:06:34 +01:00
|
|
|
dispatch(setSendTokenBalance(newTokenBalance))
|
2018-04-27 21:03:00 +02:00
|
|
|
}
|
|
|
|
})
|
2020-02-15 21:34:12 +01:00
|
|
|
.catch((err) => {
|
2018-04-27 21:03:00 +02:00
|
|
|
log.error(err)
|
|
|
|
updateSendErrors({ tokenBalance: 'tokenBalanceError' })
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateSendErrors(errorObject) {
|
2018-04-27 21:03:00 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.UPDATE_SEND_ERRORS,
|
2018-04-27 21:03:00 +02:00
|
|
|
value: errorObject,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setSendTokenBalance(tokenBalance) {
|
2017-10-30 18:48:50 +01:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.UPDATE_SEND_TOKEN_BALANCE,
|
2017-10-30 18:48:50 +01:00
|
|
|
value: tokenBalance,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateSendHexData(value) {
|
2018-07-17 00:31:36 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.UPDATE_SEND_HEX_DATA,
|
2018-07-17 00:31:36 +02:00
|
|
|
value,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateSendTo(to, nickname = '') {
|
2017-10-17 19:22:23 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.UPDATE_SEND_TO,
|
2018-03-26 15:30:54 +02:00
|
|
|
value: { to, nickname },
|
2017-10-17 19:22:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateSendAmount(amount) {
|
2017-10-17 19:22:23 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.UPDATE_SEND_AMOUNT,
|
2017-10-17 19:22:23 +02:00
|
|
|
value: amount,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateCustomNonce(value) {
|
2019-09-27 06:30:36 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.UPDATE_CUSTOM_NONCE,
|
2020-08-19 18:27:05 +02:00
|
|
|
value,
|
2019-09-27 06:30:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setMaxModeTo(bool) {
|
2017-11-16 19:14:25 +01:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.UPDATE_MAX_MODE,
|
2017-11-16 19:14:25 +01:00
|
|
|
value: bool,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateSend(newSend) {
|
2017-11-10 04:49:16 +01:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.UPDATE_SEND,
|
2017-11-10 04:49:16 +01:00
|
|
|
value: newSend,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateSendToken(token) {
|
2020-06-01 19:54:32 +02:00
|
|
|
return {
|
|
|
|
type: actionConstants.UPDATE_SEND_TOKEN,
|
|
|
|
value: token,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function clearSend() {
|
2017-10-21 04:05:22 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.CLEAR_SEND,
|
2017-10-21 04:05:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateSendEnsResolution(ensResolution) {
|
2019-07-31 21:56:44 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.UPDATE_SEND_ENS_RESOLUTION,
|
2019-07-31 21:56:44 +02:00
|
|
|
payload: ensResolution,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateSendEnsResolutionError(errorMessage) {
|
2019-07-31 21:56:44 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.UPDATE_SEND_ENS_RESOLUTION_ERROR,
|
2019-07-31 21:56:44 +02:00
|
|
|
payload: errorMessage,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function signTokenTx(tokenAddress, toAddress, amount, txData) {
|
2020-12-18 06:34:43 +01:00
|
|
|
return async (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2020-12-18 06:34:43 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
const token = global.eth.contract(abi).at(tokenAddress)
|
|
|
|
const txPromise = token.transfer(toAddress, addHexPrefix(amount), txData)
|
|
|
|
dispatch(showConfTxPage())
|
2020-11-06 22:18:00 +01:00
|
|
|
dispatch(hideLoadingIndication())
|
2020-12-18 06:34:43 +01:00
|
|
|
await txPromise
|
|
|
|
} catch (error) {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
}
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-05 19:01:34 +02:00
|
|
|
const updateMetamaskStateFromBackground = () => {
|
|
|
|
log.debug(`background.getState`)
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.getState((error, newState) => {
|
|
|
|
if (error) {
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(error)
|
|
|
|
return
|
2019-07-05 19:01:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
resolve(newState)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateTransaction(txData, dontShowLoadingIndicator) {
|
2020-12-18 06:34:43 +01:00
|
|
|
return async (dispatch) => {
|
2020-10-06 20:28:38 +02:00
|
|
|
!dontShowLoadingIndicator && dispatch(showLoadingIndication())
|
2018-06-23 08:52:45 +02:00
|
|
|
|
2020-12-18 06:34:43 +01:00
|
|
|
try {
|
|
|
|
await promisifiedBackground.updateTransaction(txData)
|
|
|
|
} catch (error) {
|
|
|
|
dispatch(updateTransactionParams(txData.id, txData.txParams))
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch(txError(error))
|
|
|
|
dispatch(goHome())
|
|
|
|
log.error(error.message)
|
|
|
|
throw error
|
|
|
|
}
|
2018-06-23 08:52:45 +02:00
|
|
|
|
2020-12-18 06:34:43 +01:00
|
|
|
try {
|
|
|
|
dispatch(updateTransactionParams(txData.id, txData.txParams))
|
|
|
|
const newState = await updateMetamaskStateFromBackground()
|
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(showConfTxPage({ id: txData.id }))
|
|
|
|
return txData
|
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
}
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function addUnapprovedTransaction(txParams, origin) {
|
2020-10-06 20:28:38 +02:00
|
|
|
log.debug('background.addUnapprovedTransaction')
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.addUnapprovedTransaction(txParams, origin, (err, txMeta) => {
|
|
|
|
if (err) {
|
|
|
|
reject(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
resolve(txMeta)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateAndApproveTx(txData, dontShowLoadingIndicator) {
|
2019-07-16 10:55:52 +02:00
|
|
|
return (dispatch) => {
|
2020-10-06 20:28:38 +02:00
|
|
|
!dontShowLoadingIndicator && dispatch(showLoadingIndication())
|
2017-11-29 05:24:35 +01:00
|
|
|
return new Promise((resolve, reject) => {
|
2020-02-15 21:34:12 +01:00
|
|
|
background.updateAndApproveTransaction(txData, (err) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(updateTransactionParams(txData.id, txData.txParams))
|
|
|
|
dispatch(clearSend())
|
2017-11-29 05:24:35 +01:00
|
|
|
|
|
|
|
if (err) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(txError(err))
|
|
|
|
dispatch(goHome())
|
2017-11-29 05:24:35 +01:00
|
|
|
log.error(err.message)
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2017-11-29 05:24:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
resolve(txData)
|
|
|
|
})
|
2016-04-14 00:28:44 +02:00
|
|
|
})
|
2018-06-23 08:52:45 +02:00
|
|
|
.then(() => updateMetamaskStateFromBackground())
|
2020-02-15 21:34:12 +01:00
|
|
|
.then((newState) => dispatch(updateMetamaskState(newState)))
|
2018-06-23 08:52:45 +02:00
|
|
|
.then(() => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(clearSend())
|
|
|
|
dispatch(completedTx(txData.id))
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch(updateCustomNonce(''))
|
2019-07-16 10:55:52 +02:00
|
|
|
dispatch(closeCurrentNotificationWindow())
|
2018-07-24 05:25:04 +02:00
|
|
|
|
2018-06-23 08:52:45 +02:00
|
|
|
return txData
|
|
|
|
})
|
2018-08-28 21:18:57 +02:00
|
|
|
.catch((err) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(hideLoadingIndication())
|
2018-08-28 21:18:57 +02:00
|
|
|
return Promise.reject(err)
|
|
|
|
})
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function completedTx(id) {
|
2020-02-06 17:38:14 +01:00
|
|
|
return (dispatch, getState) => {
|
|
|
|
const state = getState()
|
|
|
|
const {
|
|
|
|
unapprovedTxs,
|
|
|
|
unapprovedMsgs,
|
|
|
|
unapprovedPersonalMsgs,
|
|
|
|
unapprovedTypedMessages,
|
|
|
|
network,
|
|
|
|
} = state.metamask
|
2020-11-03 00:41:28 +01:00
|
|
|
const unconfirmedActions = txHelper(
|
|
|
|
unapprovedTxs,
|
|
|
|
unapprovedMsgs,
|
|
|
|
unapprovedPersonalMsgs,
|
|
|
|
unapprovedTypedMessages,
|
|
|
|
network,
|
|
|
|
)
|
|
|
|
const otherUnconfirmedActions = unconfirmedActions.filter(
|
|
|
|
(tx) => tx.id !== id,
|
|
|
|
)
|
2020-02-06 17:38:14 +01:00
|
|
|
dispatch({
|
|
|
|
type: actionConstants.COMPLETED_TX,
|
|
|
|
value: {
|
|
|
|
id,
|
|
|
|
unconfirmedActionsCount: otherUnconfirmedActions.length,
|
|
|
|
},
|
|
|
|
})
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateTransactionParams(id, txParams) {
|
2017-11-08 17:44:48 +01:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.UPDATE_TRANSACTION_PARAMS,
|
2017-11-08 17:44:48 +01:00
|
|
|
id,
|
|
|
|
value: txParams,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function txError(err) {
|
2016-04-14 00:28:44 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.TRANSACTION_ERROR,
|
2016-04-14 00:28:44 +02:00
|
|
|
message: err.message,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function cancelMsg(msgData) {
|
2020-04-28 14:49:10 +02:00
|
|
|
return async (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2017-12-05 04:27:42 +01:00
|
|
|
|
2020-04-28 14:49:10 +02:00
|
|
|
let newState
|
|
|
|
try {
|
|
|
|
newState = await promisifiedBackground.cancelMessage(msgData.id)
|
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
}
|
2020-12-18 06:34:43 +01:00
|
|
|
|
2020-04-28 14:49:10 +02:00
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(completedTx(msgData.id))
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
return msgData
|
2017-12-05 04:27:42 +01:00
|
|
|
}
|
2016-05-03 23:32:22 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function cancelPersonalMsg(msgData) {
|
2020-04-28 14:49:10 +02:00
|
|
|
return async (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2018-07-24 05:25:04 +02:00
|
|
|
|
2020-04-28 14:49:10 +02:00
|
|
|
let newState
|
|
|
|
try {
|
|
|
|
newState = await promisifiedBackground.cancelPersonalMessage(msgData.id)
|
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
}
|
2020-12-18 06:34:43 +01:00
|
|
|
|
2020-04-28 14:49:10 +02:00
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(completedTx(msgData.id))
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
return msgData
|
2017-12-05 04:27:42 +01:00
|
|
|
}
|
2017-02-23 01:23:13 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function cancelDecryptMsg(msgData) {
|
2020-04-28 14:49:10 +02:00
|
|
|
return async (dispatch) => {
|
2020-02-19 19:24:16 +01:00
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
|
2020-04-28 14:49:10 +02:00
|
|
|
let newState
|
|
|
|
try {
|
|
|
|
newState = await promisifiedBackground.cancelDecryptMessage(msgData.id)
|
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
}
|
2020-12-18 06:34:43 +01:00
|
|
|
|
2020-04-28 14:49:10 +02:00
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(completedTx(msgData.id))
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
return msgData
|
2020-02-19 19:24:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function cancelEncryptionPublicKeyMsg(msgData) {
|
2020-04-28 14:49:10 +02:00
|
|
|
return async (dispatch) => {
|
2020-02-19 19:24:16 +01:00
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
|
2020-04-28 14:49:10 +02:00
|
|
|
let newState
|
|
|
|
try {
|
2020-11-03 00:41:28 +01:00
|
|
|
newState = await promisifiedBackground.cancelEncryptionPublicKey(
|
|
|
|
msgData.id,
|
|
|
|
)
|
2020-04-28 14:49:10 +02:00
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
}
|
2020-12-18 06:34:43 +01:00
|
|
|
|
2020-04-28 14:49:10 +02:00
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(completedTx(msgData.id))
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
return msgData
|
2020-02-19 19:24:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function cancelTypedMsg(msgData) {
|
2020-04-28 14:49:10 +02:00
|
|
|
return async (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2017-12-05 04:27:42 +01:00
|
|
|
|
2020-04-28 14:49:10 +02:00
|
|
|
let newState
|
|
|
|
try {
|
|
|
|
newState = await promisifiedBackground.cancelTypedMessage(msgData.id)
|
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
}
|
2020-12-18 06:34:43 +01:00
|
|
|
|
2020-04-28 14:49:10 +02:00
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(completedTx(msgData.id))
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
return msgData
|
2017-12-05 04:27:42 +01:00
|
|
|
}
|
2017-09-29 18:24:08 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function cancelTx(txData) {
|
2019-07-16 10:55:52 +02:00
|
|
|
return (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2017-11-29 05:24:35 +01:00
|
|
|
return new Promise((resolve, reject) => {
|
2020-12-18 06:34:43 +01:00
|
|
|
background.cancelTransaction(txData.id, (error) => {
|
|
|
|
if (error) {
|
|
|
|
reject(error)
|
2020-08-12 21:06:57 +02:00
|
|
|
return
|
2018-06-23 08:52:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then(() => updateMetamaskStateFromBackground())
|
2020-02-15 21:34:12 +01:00
|
|
|
.then((newState) => dispatch(updateMetamaskState(newState)))
|
2018-06-23 08:52:45 +02:00
|
|
|
.then(() => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(clearSend())
|
|
|
|
dispatch(completedTx(txData.id))
|
|
|
|
dispatch(hideLoadingIndication())
|
2019-07-16 10:55:52 +02:00
|
|
|
dispatch(closeCurrentNotificationWindow())
|
2018-07-24 05:25:04 +02:00
|
|
|
|
2018-06-23 08:52:45 +02:00
|
|
|
return txData
|
2017-11-29 05:24:35 +01:00
|
|
|
})
|
2020-12-18 06:34:43 +01:00
|
|
|
.catch((error) => {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
throw error
|
|
|
|
})
|
2017-08-04 03:20:01 +02:00
|
|
|
}
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
|
2018-09-20 02:48:28 +02:00
|
|
|
/**
|
|
|
|
* Cancels all of the given transactions
|
2020-01-13 19:36:36 +01:00
|
|
|
* @param {Array<object>} txDataList - a list of tx data objects
|
|
|
|
* @returns {function(*): Promise<void>}
|
2018-09-20 02:48:28 +02:00
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
export function cancelTxs(txDataList) {
|
2019-05-08 21:51:33 +02:00
|
|
|
return async (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2018-09-20 02:48:28 +02:00
|
|
|
|
2020-12-18 06:34:43 +01:00
|
|
|
try {
|
|
|
|
const txIds = txDataList.map(({ id }) => id)
|
|
|
|
const cancellations = txIds.map(
|
|
|
|
(id) =>
|
|
|
|
new Promise((resolve, reject) => {
|
|
|
|
background.cancelTransaction(id, (err) => {
|
|
|
|
if (err) {
|
|
|
|
reject(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
}),
|
|
|
|
)
|
2018-09-20 02:48:28 +02:00
|
|
|
|
2020-12-18 06:34:43 +01:00
|
|
|
await Promise.all(cancellations)
|
2018-09-20 02:48:28 +02:00
|
|
|
|
2020-12-18 06:34:43 +01:00
|
|
|
const newState = await updateMetamaskStateFromBackground()
|
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(clearSend())
|
2018-09-20 02:48:28 +02:00
|
|
|
|
2020-12-18 06:34:43 +01:00
|
|
|
txIds.forEach((id) => {
|
|
|
|
dispatch(completedTx(id))
|
|
|
|
})
|
|
|
|
} finally {
|
|
|
|
if (getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION) {
|
|
|
|
global.platform.closeCurrentWindow()
|
|
|
|
} else {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
}
|
2018-09-20 02:48:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function markPasswordForgotten() {
|
2020-04-22 21:15:22 +02:00
|
|
|
return async (dispatch) => {
|
|
|
|
try {
|
|
|
|
await new Promise((resolve, reject) => {
|
|
|
|
return background.markPasswordForgotten((error) => {
|
|
|
|
if (error) {
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(error)
|
|
|
|
return
|
2020-04-22 21:15:22 +02:00
|
|
|
}
|
2020-08-12 21:06:57 +02:00
|
|
|
resolve()
|
2020-04-22 21:15:22 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
} finally {
|
|
|
|
// TODO: handle errors
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch(forgotPassword())
|
2020-04-27 21:36:19 +02:00
|
|
|
await forceUpdateMetamaskState(dispatch)
|
2020-04-22 21:15:22 +02:00
|
|
|
}
|
2018-02-08 01:38:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function unMarkPasswordForgotten() {
|
2020-02-15 21:34:12 +01:00
|
|
|
return (dispatch) => {
|
|
|
|
return new Promise((resolve) => {
|
2018-03-08 16:29:29 +01:00
|
|
|
background.unMarkPasswordForgotten(() => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(forgotPassword(false))
|
2018-03-08 16:29:29 +01:00
|
|
|
resolve()
|
|
|
|
})
|
2020-11-03 00:41:28 +01:00
|
|
|
}).then(() => forceUpdateMetamaskState(dispatch))
|
2018-02-08 01:38:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function forgotPassword(forgotPasswordState = true) {
|
2016-12-20 00:46:09 +01:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.FORGOT_PASSWORD,
|
2018-03-03 03:14:05 +01:00
|
|
|
value: forgotPasswordState,
|
2016-12-20 00:46:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function closeWelcomeScreen() {
|
2018-03-08 18:31:21 +01:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.CLOSE_WELCOME_SCREEN,
|
2018-03-08 18:31:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-14 00:28:44 +02:00
|
|
|
//
|
|
|
|
// unlock screen
|
|
|
|
//
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function unlockInProgress() {
|
2016-04-14 00:28:44 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.UNLOCK_IN_PROGRESS,
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function unlockFailed(message) {
|
2016-04-14 00:28:44 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.UNLOCK_FAILED,
|
2016-11-02 01:00:17 +01:00
|
|
|
value: message,
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function unlockSucceeded(message) {
|
2018-01-30 03:44:43 +01:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.UNLOCK_SUCCEEDED,
|
2018-01-30 03:44:43 +01:00
|
|
|
value: message,
|
|
|
|
}
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateMetamaskState(newState) {
|
2020-04-28 15:40:28 +02:00
|
|
|
return (dispatch, getState) => {
|
|
|
|
const { metamask: currentState } = getState()
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const { currentLocale, selectedAddress } = currentState
|
2020-04-29 19:10:51 +02:00
|
|
|
const {
|
|
|
|
currentLocale: newLocale,
|
|
|
|
selectedAddress: newSelectedAddress,
|
|
|
|
} = newState
|
2020-04-28 15:40:28 +02:00
|
|
|
|
|
|
|
if (currentLocale && newLocale && currentLocale !== newLocale) {
|
|
|
|
dispatch(updateCurrentLocale(newLocale))
|
|
|
|
}
|
2020-04-29 19:10:51 +02:00
|
|
|
if (selectedAddress !== newSelectedAddress) {
|
|
|
|
dispatch({ type: actionConstants.SELECTED_ADDRESS_CHANGED })
|
|
|
|
}
|
2020-04-28 15:40:28 +02:00
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: actionConstants.UPDATE_METAMASK_STATE,
|
|
|
|
value: newState,
|
|
|
|
})
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-27 08:02:56 +02:00
|
|
|
const backgroundSetLocked = () => {
|
|
|
|
return new Promise((resolve, reject) => {
|
2020-02-15 21:34:12 +01:00
|
|
|
background.setLocked((error) => {
|
2017-10-27 08:02:56 +02:00
|
|
|
if (error) {
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(error)
|
|
|
|
return
|
2017-10-27 08:02:56 +02:00
|
|
|
}
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function lockMetamask() {
|
2017-02-23 23:23:45 +01:00
|
|
|
log.debug(`background.setLocked`)
|
2017-10-27 08:02:56 +02:00
|
|
|
|
2020-02-15 21:34:12 +01:00
|
|
|
return (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2017-10-27 08:02:56 +02:00
|
|
|
|
|
|
|
return backgroundSetLocked()
|
|
|
|
.then(() => updateMetamaskStateFromBackground())
|
2020-02-15 21:34:12 +01:00
|
|
|
.catch((error) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(error.message))
|
2017-10-27 08:02:56 +02:00
|
|
|
return Promise.reject(error)
|
|
|
|
})
|
2020-02-15 21:34:12 +01:00
|
|
|
.then((newState) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch({ type: actionConstants.LOCK_METAMASK })
|
2018-01-12 00:49:10 +01:00
|
|
|
})
|
|
|
|
.catch(() => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch({ type: actionConstants.LOCK_METAMASK })
|
2017-10-27 08:02:56 +02:00
|
|
|
})
|
|
|
|
}
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
async function _setSelectedAddress(dispatch, address) {
|
2020-05-01 18:56:46 +02:00
|
|
|
log.debug(`background.setSelectedAddress`)
|
|
|
|
const tokens = await promisifiedBackground.setSelectedAddress(address)
|
|
|
|
dispatch(updateTokens(tokens))
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setSelectedAddress(address) {
|
2020-04-27 23:56:17 +02:00
|
|
|
return async (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2017-10-12 19:29:03 +02:00
|
|
|
log.debug(`background.setSelectedAddress`)
|
2020-04-27 23:56:17 +02:00
|
|
|
try {
|
2020-05-01 18:56:46 +02:00
|
|
|
await _setSelectedAddress(dispatch, address)
|
2020-04-27 23:56:17 +02:00
|
|
|
} catch (error) {
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
return
|
2020-12-18 06:34:43 +01:00
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
2020-04-27 23:56:17 +02:00
|
|
|
}
|
2017-10-12 19:29:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function showAccountDetail(address) {
|
2020-04-29 19:10:51 +02:00
|
|
|
return async (dispatch, getState) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2017-02-23 23:23:45 +01:00
|
|
|
log.debug(`background.setSelectedAddress`)
|
2020-04-27 23:17:28 +02:00
|
|
|
|
2020-04-29 19:10:51 +02:00
|
|
|
const state = getState()
|
2020-11-03 00:41:28 +01:00
|
|
|
const unconnectedAccountAccountAlertIsEnabled = getUnconnectedAccountAlertEnabledness(
|
|
|
|
state,
|
|
|
|
)
|
2020-05-12 15:01:52 +02:00
|
|
|
const activeTabOrigin = state.activeTab.origin
|
2020-04-29 19:10:51 +02:00
|
|
|
const selectedAddress = getSelectedAddress(state)
|
2020-11-03 00:41:28 +01:00
|
|
|
const permittedAccountsForCurrentTab = getPermittedAccountsForCurrentTab(
|
|
|
|
state,
|
|
|
|
)
|
|
|
|
const currentTabIsConnectedToPreviousAddress =
|
|
|
|
Boolean(activeTabOrigin) &&
|
|
|
|
permittedAccountsForCurrentTab.includes(selectedAddress)
|
|
|
|
const currentTabIsConnectedToNextAddress =
|
|
|
|
Boolean(activeTabOrigin) &&
|
|
|
|
permittedAccountsForCurrentTab.includes(address)
|
|
|
|
const switchingToUnconnectedAddress =
|
|
|
|
currentTabIsConnectedToPreviousAddress &&
|
|
|
|
!currentTabIsConnectedToNextAddress
|
2020-04-29 19:10:51 +02:00
|
|
|
|
2020-04-27 23:17:28 +02:00
|
|
|
try {
|
2020-05-01 18:56:46 +02:00
|
|
|
await _setSelectedAddress(dispatch, address)
|
2020-04-27 23:17:28 +02:00
|
|
|
} catch (error) {
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
return
|
2020-12-18 06:34:43 +01:00
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
2020-04-27 23:17:28 +02:00
|
|
|
}
|
2020-12-18 06:34:43 +01:00
|
|
|
|
2020-04-27 23:17:28 +02:00
|
|
|
dispatch({
|
|
|
|
type: actionConstants.SHOW_ACCOUNT_DETAIL,
|
|
|
|
value: address,
|
2016-04-25 23:14:34 +02:00
|
|
|
})
|
2020-11-03 00:41:28 +01:00
|
|
|
if (
|
|
|
|
unconnectedAccountAccountAlertIsEnabled &&
|
|
|
|
switchingToUnconnectedAddress
|
|
|
|
) {
|
2020-04-29 19:10:51 +02:00
|
|
|
dispatch(switchedToUnconnectedAccount())
|
2020-06-15 21:08:53 +02:00
|
|
|
await setUnconnectedAccountAlertShown(activeTabOrigin)
|
2020-04-29 19:10:51 +02:00
|
|
|
}
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function addPermittedAccount(origin, address) {
|
2020-04-17 00:23:36 +02:00
|
|
|
return async (dispatch) => {
|
|
|
|
await new Promise((resolve, reject) => {
|
|
|
|
background.addPermittedAccount(origin, address, (error) => {
|
|
|
|
if (error) {
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(error)
|
|
|
|
return
|
2020-04-17 00:23:36 +02:00
|
|
|
}
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function removePermittedAccount(origin, address) {
|
2020-04-20 20:34:56 +02:00
|
|
|
return async (dispatch) => {
|
|
|
|
await new Promise((resolve, reject) => {
|
|
|
|
background.removePermittedAccount(origin, address, (error) => {
|
|
|
|
if (error) {
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(error)
|
|
|
|
return
|
2020-04-20 20:34:56 +02:00
|
|
|
}
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function showAccountsPage() {
|
2016-04-14 00:28:44 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SHOW_ACCOUNTS_PAGE,
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function showConfTxPage({ id } = {}) {
|
2016-04-14 00:28:44 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SHOW_CONF_TX_PAGE,
|
2017-08-30 05:16:30 +02:00
|
|
|
id,
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function addToken(
|
|
|
|
address,
|
|
|
|
symbol,
|
|
|
|
decimals,
|
|
|
|
image,
|
|
|
|
dontShowLoadingIndicator,
|
|
|
|
) {
|
2017-06-16 01:22:53 +02:00
|
|
|
return (dispatch) => {
|
2020-10-06 20:28:38 +02:00
|
|
|
!dontShowLoadingIndicator && dispatch(showLoadingIndication())
|
2017-09-22 03:44:52 +02:00
|
|
|
return new Promise((resolve, reject) => {
|
2018-08-23 20:54:40 +02:00
|
|
|
background.addToken(address, symbol, decimals, image, (err, tokens) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(hideLoadingIndication())
|
2017-09-22 03:44:52 +02:00
|
|
|
if (err) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(err.message))
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2017-09-22 03:44:52 +02:00
|
|
|
}
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(updateTokens(tokens))
|
2017-10-03 19:25:52 +02:00
|
|
|
resolve(tokens)
|
|
|
|
})
|
2017-06-16 01:22:53 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function removeToken(address) {
|
2017-10-03 19:25:52 +02:00
|
|
|
return (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2017-10-03 19:25:52 +02:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.removeToken(address, (err, tokens) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(hideLoadingIndication())
|
2017-10-03 19:25:52 +02:00
|
|
|
if (err) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(err.message))
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2017-10-03 19:25:52 +02:00
|
|
|
}
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(updateTokens(tokens))
|
2017-10-03 19:25:52 +02:00
|
|
|
resolve(tokens)
|
2017-09-22 03:44:52 +02:00
|
|
|
})
|
2017-06-16 01:22:53 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function addTokens(tokens) {
|
2020-02-15 21:34:12 +01:00
|
|
|
return (dispatch) => {
|
2017-09-22 03:44:52 +02:00
|
|
|
if (Array.isArray(tokens)) {
|
2020-11-03 00:41:28 +01:00
|
|
|
return Promise.all(
|
|
|
|
tokens.map(({ address, symbol, decimals }) =>
|
|
|
|
dispatch(addToken(address, symbol, decimals)),
|
|
|
|
),
|
|
|
|
)
|
2017-09-22 03:44:52 +02:00
|
|
|
}
|
2020-08-19 18:27:05 +02:00
|
|
|
return Promise.all(
|
2020-11-03 00:41:28 +01:00
|
|
|
Object.entries(tokens).map(([_, { address, symbol, decimals }]) =>
|
|
|
|
dispatch(addToken(address, symbol, decimals)),
|
|
|
|
),
|
2020-08-19 18:27:05 +02:00
|
|
|
)
|
2017-09-22 03:44:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function removeSuggestedTokens() {
|
2018-08-04 01:24:12 +02:00
|
|
|
return (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2019-05-08 21:51:33 +02:00
|
|
|
return new Promise((resolve) => {
|
2018-08-17 01:19:19 +02:00
|
|
|
background.removeSuggestedTokens((err, suggestedTokens) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(hideLoadingIndication())
|
2018-08-17 01:19:19 +02:00
|
|
|
if (err) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(err.message))
|
2018-08-17 01:19:19 +02:00
|
|
|
}
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(clearPendingTokens())
|
2020-04-02 00:28:10 +02:00
|
|
|
if (getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION) {
|
2020-08-12 21:06:57 +02:00
|
|
|
global.platform.closeCurrentWindow()
|
|
|
|
return
|
2018-08-17 01:19:19 +02:00
|
|
|
}
|
|
|
|
resolve(suggestedTokens)
|
|
|
|
})
|
2018-08-04 01:24:12 +02:00
|
|
|
})
|
2019-07-31 22:17:11 +02:00
|
|
|
.then(() => updateMetamaskStateFromBackground())
|
2020-11-03 00:41:28 +01:00
|
|
|
.then((suggestedTokens) =>
|
|
|
|
dispatch(updateMetamaskState({ ...suggestedTokens })),
|
|
|
|
)
|
2018-08-04 01:24:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function addKnownMethodData(fourBytePrefix, methodData) {
|
2019-05-08 21:51:33 +02:00
|
|
|
return () => {
|
2019-01-22 19:22:56 +01:00
|
|
|
background.addKnownMethodData(fourBytePrefix, methodData)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateTokens(newTokens) {
|
2018-08-04 01:24:12 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.UPDATE_TOKENS,
|
2018-08-08 01:12:16 +02:00
|
|
|
newTokens,
|
2018-08-04 01:24:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function clearPendingTokens() {
|
2017-10-03 19:25:52 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.CLEAR_PENDING_TOKENS,
|
2017-10-03 19:25:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function createCancelTransaction(txId, customGasPrice) {
|
2018-09-09 19:07:23 +02:00
|
|
|
log.debug('background.cancelTransaction')
|
|
|
|
let newTxId
|
|
|
|
|
2020-02-15 21:34:12 +01:00
|
|
|
return (dispatch) => {
|
2018-09-09 19:07:23 +02:00
|
|
|
return new Promise((resolve, reject) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
background.createCancelTransaction(
|
|
|
|
txId,
|
|
|
|
customGasPrice,
|
|
|
|
(err, newState) => {
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
reject(err)
|
|
|
|
return
|
|
|
|
}
|
2018-09-09 19:07:23 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const { currentNetworkTxList } = newState
|
|
|
|
const { id } = currentNetworkTxList[currentNetworkTxList.length - 1]
|
|
|
|
newTxId = id
|
|
|
|
resolve(newState)
|
|
|
|
},
|
|
|
|
)
|
2018-09-09 19:07:23 +02:00
|
|
|
})
|
2020-02-15 21:34:12 +01:00
|
|
|
.then((newState) => dispatch(updateMetamaskState(newState)))
|
2019-07-31 22:17:11 +02:00
|
|
|
.then(() => newTxId)
|
2018-09-09 19:07:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function createSpeedUpTransaction(txId, customGasPrice, customGasLimit) {
|
2018-10-26 07:50:36 +02:00
|
|
|
log.debug('background.createSpeedUpTransaction')
|
|
|
|
let newTx
|
|
|
|
|
2020-02-15 21:34:12 +01:00
|
|
|
return (dispatch) => {
|
2019-10-28 14:28:46 +01:00
|
|
|
return new Promise((resolve, reject) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
background.createSpeedUpTransaction(
|
|
|
|
txId,
|
|
|
|
customGasPrice,
|
|
|
|
customGasLimit,
|
|
|
|
(err, newState) => {
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
reject(err)
|
|
|
|
return
|
|
|
|
}
|
2019-10-28 14:28:46 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const { currentNetworkTxList } = newState
|
|
|
|
newTx = currentNetworkTxList[currentNetworkTxList.length - 1]
|
|
|
|
resolve(newState)
|
|
|
|
},
|
|
|
|
)
|
2019-10-28 14:28:46 +01:00
|
|
|
})
|
2020-02-15 21:34:12 +01:00
|
|
|
.then((newState) => dispatch(updateMetamaskState(newState)))
|
2019-10-28 14:28:46 +01:00
|
|
|
.then(() => newTx)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function createRetryTransaction(txId, customGasPrice, customGasLimit) {
|
2019-10-28 14:28:46 +01:00
|
|
|
log.debug('background.createRetryTransaction')
|
|
|
|
let newTx
|
|
|
|
|
2020-02-15 21:34:12 +01:00
|
|
|
return (dispatch) => {
|
2018-10-26 07:50:36 +02:00
|
|
|
return new Promise((resolve, reject) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
background.createSpeedUpTransaction(
|
|
|
|
txId,
|
|
|
|
customGasPrice,
|
|
|
|
customGasLimit,
|
|
|
|
(err, newState) => {
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
reject(err)
|
|
|
|
return
|
|
|
|
}
|
2018-10-26 07:50:36 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const { currentNetworkTxList } = newState
|
|
|
|
newTx = currentNetworkTxList[currentNetworkTxList.length - 1]
|
|
|
|
resolve(newState)
|
|
|
|
},
|
|
|
|
)
|
2018-10-26 07:50:36 +02:00
|
|
|
})
|
2020-02-15 21:34:12 +01:00
|
|
|
.then((newState) => dispatch(updateMetamaskState(newState)))
|
2019-07-31 22:17:11 +02:00
|
|
|
.then(() => newTx)
|
2018-10-26 07:50:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-14 00:28:44 +02:00
|
|
|
//
|
|
|
|
// config
|
|
|
|
//
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setProviderType(type) {
|
2021-01-07 00:31:11 +01:00
|
|
|
return async (dispatch) => {
|
2018-03-30 19:59:39 +02:00
|
|
|
log.debug(`background.setProviderType`, type)
|
2017-10-26 03:23:46 +02:00
|
|
|
|
2020-04-28 14:50:04 +02:00
|
|
|
try {
|
|
|
|
await promisifiedBackground.setProviderType(type)
|
|
|
|
} catch (error) {
|
|
|
|
log.error(error)
|
|
|
|
dispatch(displayWarning('Had a problem changing networks!'))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
dispatch(updateProviderType(type))
|
2017-10-05 01:12:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateProviderType(type) {
|
2017-10-05 01:12:07 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SET_PROVIDER_TYPE,
|
2017-10-05 01:12:07 +02:00
|
|
|
value: type,
|
2017-03-07 19:25:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateAndSetCustomRpc(
|
|
|
|
newRpc,
|
|
|
|
chainId,
|
|
|
|
ticker = 'ETH',
|
|
|
|
nickname,
|
|
|
|
rpcPrefs,
|
|
|
|
) {
|
2020-04-28 18:56:18 +02:00
|
|
|
return async (dispatch) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
log.debug(
|
|
|
|
`background.updateAndSetCustomRpc: ${newRpc} ${chainId} ${ticker} ${nickname}`,
|
|
|
|
)
|
2020-04-28 18:56:18 +02:00
|
|
|
|
|
|
|
try {
|
2020-11-03 00:41:28 +01:00
|
|
|
await promisifiedBackground.updateAndSetCustomRpc(
|
|
|
|
newRpc,
|
|
|
|
chainId,
|
|
|
|
ticker,
|
|
|
|
nickname || newRpc,
|
|
|
|
rpcPrefs,
|
|
|
|
)
|
2020-04-28 18:56:18 +02:00
|
|
|
} catch (error) {
|
|
|
|
log.error(error)
|
|
|
|
dispatch(displayWarning('Had a problem changing networks!'))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: actionConstants.SET_RPC_TARGET,
|
|
|
|
value: newRpc,
|
2019-01-29 19:13:51 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function editRpc(
|
|
|
|
oldRpc,
|
|
|
|
newRpc,
|
|
|
|
chainId,
|
|
|
|
ticker = 'ETH',
|
|
|
|
nickname,
|
|
|
|
rpcPrefs,
|
|
|
|
) {
|
2020-04-24 14:48:59 +02:00
|
|
|
return async (dispatch) => {
|
2019-05-09 19:27:14 +02:00
|
|
|
log.debug(`background.delRpcTarget: ${oldRpc}`)
|
2020-04-24 14:48:59 +02:00
|
|
|
try {
|
|
|
|
promisifiedBackground.delCustomRpc(oldRpc)
|
|
|
|
} catch (error) {
|
|
|
|
log.error(error)
|
|
|
|
dispatch(displayWarning('Had a problem removing network!'))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2020-11-03 00:41:28 +01:00
|
|
|
await promisifiedBackground.updateAndSetCustomRpc(
|
|
|
|
newRpc,
|
|
|
|
chainId,
|
|
|
|
ticker,
|
|
|
|
nickname || newRpc,
|
|
|
|
rpcPrefs,
|
|
|
|
)
|
2020-04-24 14:48:59 +02:00
|
|
|
} catch (error) {
|
|
|
|
log.error(error)
|
|
|
|
dispatch(displayWarning('Had a problem changing networks!'))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: actionConstants.SET_RPC_TARGET,
|
|
|
|
value: newRpc,
|
2019-05-09 19:27:14 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setRpcTarget(newRpc, chainId, ticker = 'ETH', nickname) {
|
2020-04-24 14:59:13 +02:00
|
|
|
return async (dispatch) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
log.debug(
|
|
|
|
`background.setRpcTarget: ${newRpc} ${chainId} ${ticker} ${nickname}`,
|
|
|
|
)
|
2020-04-24 14:59:13 +02:00
|
|
|
|
|
|
|
try {
|
2020-11-03 00:41:28 +01:00
|
|
|
await promisifiedBackground.setCustomRpc(
|
|
|
|
newRpc,
|
|
|
|
chainId,
|
|
|
|
ticker,
|
|
|
|
nickname || newRpc,
|
|
|
|
)
|
2020-04-24 14:59:13 +02:00
|
|
|
} catch (error) {
|
|
|
|
log.error(error)
|
|
|
|
dispatch(displayWarning('Had a problem changing networks!'))
|
|
|
|
}
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-07 00:31:11 +01:00
|
|
|
export function rollbackToPreviousProvider() {
|
|
|
|
return async (dispatch) => {
|
|
|
|
try {
|
|
|
|
await promisifiedBackground.rollbackToPreviousProvider()
|
|
|
|
} catch (error) {
|
|
|
|
log.error(error)
|
|
|
|
dispatch(displayWarning('Had a problem changing networks!'))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function delRpcTarget(oldRpc) {
|
2018-09-28 21:53:58 +02:00
|
|
|
return (dispatch) => {
|
|
|
|
log.debug(`background.delRpcTarget: ${oldRpc}`)
|
2019-07-02 14:13:02 +02:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.delCustomRpc(oldRpc, (err) => {
|
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning('Had a problem removing network!'))
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2019-07-02 14:13:02 +02:00
|
|
|
}
|
|
|
|
resolve()
|
|
|
|
})
|
2018-09-28 21:53:58 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-21 14:57:49 +01:00
|
|
|
// Calls the addressBookController to add a new address.
|
2020-11-03 00:41:28 +01:00
|
|
|
export function addToAddressBook(recipient, nickname = '', memo = '') {
|
2017-03-10 00:10:27 +01:00
|
|
|
log.debug(`background.addToAddressBook`)
|
2019-07-31 21:56:44 +02:00
|
|
|
|
2020-04-29 06:59:49 +02:00
|
|
|
return async (dispatch, getState) => {
|
2020-10-13 01:35:55 +02:00
|
|
|
const { chainId } = getState().metamask.provider
|
2019-08-14 01:13:05 +02:00
|
|
|
|
2020-04-29 06:59:49 +02:00
|
|
|
let set
|
|
|
|
try {
|
2020-11-03 00:41:28 +01:00
|
|
|
set = await promisifiedBackground.setAddressBook(
|
|
|
|
checksumAddress(recipient),
|
|
|
|
nickname,
|
|
|
|
chainId,
|
|
|
|
memo,
|
|
|
|
)
|
2020-04-29 06:59:49 +02:00
|
|
|
} catch (error) {
|
|
|
|
log.error(error)
|
|
|
|
dispatch(displayWarning('Address book failed to update'))
|
|
|
|
throw error
|
|
|
|
}
|
|
|
|
if (!set) {
|
2020-08-12 21:06:57 +02:00
|
|
|
dispatch(displayWarning('Address book failed to update'))
|
2020-04-29 06:59:49 +02:00
|
|
|
}
|
2019-07-31 21:56:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description Calls the addressBookController to remove an existing address.
|
2020-01-13 19:36:36 +01:00
|
|
|
* @param {string} addressToRemove - Address of the entry to remove from the address book
|
2019-07-31 21:56:44 +02:00
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
export function removeFromAddressBook(chainId, addressToRemove) {
|
2019-07-31 21:56:44 +02:00
|
|
|
log.debug(`background.removeFromAddressBook`)
|
|
|
|
|
2020-04-29 14:36:10 +02:00
|
|
|
return async () => {
|
2020-11-03 00:41:28 +01:00
|
|
|
await promisifiedBackground.removeFromAddressBook(
|
|
|
|
chainId,
|
|
|
|
checksumAddress(addressToRemove),
|
|
|
|
)
|
2017-03-10 00:10:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function showNetworkDropdown() {
|
2017-08-13 22:15:21 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.NETWORK_DROPDOWN_OPEN,
|
2017-08-13 22:15:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function hideNetworkDropdown() {
|
2017-08-13 22:15:21 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.NETWORK_DROPDOWN_CLOSE,
|
2017-08-13 22:15:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function showModal(payload) {
|
2017-08-08 22:37:16 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.MODAL_OPEN,
|
2017-08-21 03:32:58 +02:00
|
|
|
payload,
|
2017-08-08 22:37:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function hideModal(payload) {
|
2017-08-08 22:37:16 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.MODAL_CLOSE,
|
2017-08-21 03:32:58 +02:00
|
|
|
payload,
|
2017-08-08 22:37:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function closeCurrentNotificationWindow() {
|
2019-07-16 10:55:52 +02:00
|
|
|
return (dispatch, getState) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
if (
|
|
|
|
getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION &&
|
|
|
|
!hasUnconfirmedTransactions(getState())
|
|
|
|
) {
|
2019-07-16 10:55:52 +02:00
|
|
|
global.platform.closeCurrentWindow()
|
|
|
|
|
2020-04-23 14:16:05 +02:00
|
|
|
dispatch(closeNotificationWindow())
|
2019-07-16 10:55:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function closeNotificationWindow() {
|
2019-07-16 10:55:52 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.CLOSE_NOTIFICATION_WINDOW,
|
2019-07-16 10:55:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function showSidebar({ transitionName, type, props }) {
|
2017-08-02 22:32:02 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SIDEBAR_OPEN,
|
2018-08-23 04:27:35 +02:00
|
|
|
value: {
|
|
|
|
transitionName,
|
|
|
|
type,
|
2018-10-26 07:50:36 +02:00
|
|
|
props,
|
2018-08-23 04:27:35 +02:00
|
|
|
},
|
2017-08-02 22:32:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function hideSidebar() {
|
2017-08-02 22:32:02 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SIDEBAR_CLOSE,
|
2017-08-02 22:32:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function showAlert(msg) {
|
2018-07-19 08:31:02 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.ALERT_OPEN,
|
2018-07-19 08:31:02 +02:00
|
|
|
value: msg,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function hideAlert() {
|
2018-07-19 08:31:02 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.ALERT_CLOSE,
|
2018-07-19 08:31:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-08 21:42:25 +02:00
|
|
|
/**
|
|
|
|
* This action will receive two types of values via qrCodeData
|
|
|
|
* an object with the following structure {type, values}
|
|
|
|
* or null (used to clear the previous value)
|
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
export function qrCodeDetected(qrCodeData) {
|
2018-07-25 02:32:20 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.QR_CODE_DETECTED,
|
2018-07-25 02:32:20 +02:00
|
|
|
value: qrCodeData,
|
|
|
|
}
|
|
|
|
}
|
2017-08-02 22:32:02 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function showLoadingIndication(message) {
|
2016-04-14 00:28:44 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SHOW_LOADING,
|
2017-01-19 01:45:39 +01:00
|
|
|
value: message,
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setHardwareWalletDefaultHdPath({ device, path }) {
|
2019-07-31 22:17:11 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SET_HARDWARE_WALLET_DEFAULT_HD_PATH,
|
2019-12-03 21:50:55 +01:00
|
|
|
value: { device, path },
|
2019-07-31 22:17:11 +02:00
|
|
|
}
|
2018-08-14 01:29:43 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function hideLoadingIndication() {
|
2016-04-14 00:28:44 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.HIDE_LOADING,
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function displayWarning(text) {
|
2016-04-14 00:28:44 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.DISPLAY_WARNING,
|
2016-04-14 00:28:44 +02:00
|
|
|
value: text,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function hideWarning() {
|
2016-04-14 00:28:44 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.HIDE_WARNING,
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function exportAccount(password, address) {
|
2016-06-21 22:18:32 +02:00
|
|
|
return function (dispatch) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2016-04-14 00:28:44 +02:00
|
|
|
|
2020-08-27 01:19:41 +02:00
|
|
|
log.debug(`background.verifyPassword`)
|
2017-09-27 01:03:33 +02:00
|
|
|
return new Promise((resolve, reject) => {
|
2020-08-27 01:19:41 +02:00
|
|
|
background.verifyPassword(password, function (err) {
|
2017-03-21 16:53:34 +01:00
|
|
|
if (err) {
|
2020-08-27 01:19:41 +02:00
|
|
|
log.error('Error in verifying password.')
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch(displayWarning('Incorrect Password.'))
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2017-03-21 16:53:34 +01:00
|
|
|
}
|
2017-09-27 01:03:33 +02:00
|
|
|
log.debug(`background.exportAccount`)
|
2020-08-18 18:36:45 +02:00
|
|
|
background.exportAccount(address, function (err2, result) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(hideLoadingIndication())
|
2017-03-21 16:53:34 +01:00
|
|
|
|
2020-08-18 18:36:45 +02:00
|
|
|
if (err2) {
|
|
|
|
log.error(err2)
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning('Had a problem exporting the account.'))
|
2020-08-18 18:36:45 +02:00
|
|
|
reject(err2)
|
2020-08-12 21:06:57 +02:00
|
|
|
return
|
2017-09-27 01:03:33 +02:00
|
|
|
}
|
2017-03-21 16:53:34 +01:00
|
|
|
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showPrivateKey(result))
|
2020-08-12 21:06:57 +02:00
|
|
|
resolve(result)
|
2017-09-27 01:03:33 +02:00
|
|
|
})
|
2017-03-21 16:53:34 +01:00
|
|
|
})
|
2016-04-14 00:28:44 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function exportAccounts(password, addresses) {
|
2020-06-26 03:04:17 +02:00
|
|
|
return function (dispatch) {
|
|
|
|
log.debug(`background.submitPassword`)
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.submitPassword(password, function (err) {
|
|
|
|
if (err) {
|
|
|
|
log.error('Error in submitting password.')
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2020-06-26 03:04:17 +02:00
|
|
|
}
|
|
|
|
log.debug(`background.exportAccounts`)
|
2020-11-03 00:41:28 +01:00
|
|
|
const accountPromises = addresses.map(
|
|
|
|
(address) =>
|
|
|
|
new Promise((resolve2, reject2) =>
|
|
|
|
background.exportAccount(address, function (err2, result) {
|
|
|
|
if (err2) {
|
|
|
|
log.error(err2)
|
|
|
|
dispatch(
|
|
|
|
displayWarning('Had a problem exporting the account.'),
|
|
|
|
)
|
|
|
|
reject2(err2)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
resolve2(result)
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
)
|
2020-08-12 21:06:57 +02:00
|
|
|
resolve(Promise.all(accountPromises))
|
2020-06-26 03:04:17 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function showPrivateKey(key) {
|
2016-04-14 00:28:44 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SHOW_PRIVATE_KEY,
|
2016-04-14 00:28:44 +02:00
|
|
|
value: key,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setAccountLabel(account, label) {
|
2016-05-21 01:18:54 +02:00
|
|
|
return (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2018-04-19 05:33:51 +02:00
|
|
|
log.debug(`background.setAccountLabel`)
|
2017-10-26 03:23:46 +02:00
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
2018-04-19 05:33:51 +02:00
|
|
|
background.setAccountLabel(account, label, (err) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(hideLoadingIndication())
|
2017-10-26 03:23:46 +02:00
|
|
|
|
|
|
|
if (err) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(err.message))
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2017-10-26 03:23:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
dispatch({
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SET_ACCOUNT_LABEL,
|
2017-10-26 03:23:46 +02:00
|
|
|
value: { account, label },
|
|
|
|
})
|
|
|
|
resolve(account)
|
2016-05-21 01:18:54 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function clearAccountDetails() {
|
2020-08-15 01:08:26 +02:00
|
|
|
return {
|
|
|
|
type: actionConstants.CLEAR_ACCOUNT_DETAILS,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function showSendTokenPage() {
|
2017-09-07 13:24:03 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SHOW_SEND_TOKEN_PAGE,
|
2017-09-07 13:24:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function buyEth(opts) {
|
2016-08-10 22:43:01 +02:00
|
|
|
return (dispatch) => {
|
2017-04-05 03:23:46 +02:00
|
|
|
const url = getBuyEthUrl(opts)
|
2020-04-16 23:34:40 +02:00
|
|
|
global.platform.openTab({ url })
|
2016-08-10 22:43:01 +02:00
|
|
|
dispatch({
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.BUY_ETH,
|
2016-08-10 22:43:01 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setFeatureFlag(feature, activated, notificationType) {
|
2017-11-14 17:04:55 +01:00
|
|
|
return (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2017-11-14 17:04:55 +01:00
|
|
|
return new Promise((resolve, reject) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
background.setFeatureFlag(
|
|
|
|
feature,
|
|
|
|
activated,
|
|
|
|
(err, updatedFeatureFlags) => {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
reject(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
dispatch(updateFeatureFlags(updatedFeatureFlags))
|
|
|
|
notificationType && dispatch(showModal({ name: notificationType }))
|
|
|
|
resolve(updatedFeatureFlags)
|
|
|
|
},
|
|
|
|
)
|
2017-11-14 17:04:55 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateFeatureFlags(updatedFeatureFlags) {
|
2017-11-14 17:04:55 +01:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.UPDATE_FEATURE_FLAGS,
|
2017-11-14 17:04:55 +01:00
|
|
|
value: updatedFeatureFlags,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setPreference(preference, value) {
|
2020-02-15 21:34:12 +01:00
|
|
|
return (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2018-10-17 01:03:29 +02:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.setPreference(preference, value, (err, updatedPreferences) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(hideLoadingIndication())
|
2018-10-17 01:03:29 +02:00
|
|
|
|
|
|
|
if (err) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(err.message))
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2018-10-17 01:03:29 +02:00
|
|
|
}
|
|
|
|
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(updatePreferences(updatedPreferences))
|
2018-10-17 01:03:29 +02:00
|
|
|
resolve(updatedPreferences)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updatePreferences(value) {
|
2018-10-17 01:03:29 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.UPDATE_PREFERENCES,
|
2018-10-17 01:03:29 +02:00
|
|
|
value,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setDefaultHomeActiveTabName(value) {
|
2020-05-25 21:01:28 +02:00
|
|
|
return async () => {
|
|
|
|
await promisifiedBackground.setDefaultHomeActiveTabName(value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setUseNativeCurrencyAsPrimaryCurrencyPreference(value) {
|
2018-10-26 10:26:43 +02:00
|
|
|
return setPreference('useNativeCurrencyAsPrimaryCurrency', value)
|
2018-10-17 01:03:29 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setShowFiatConversionOnTestnetsPreference(value) {
|
2019-02-26 19:30:41 +01:00
|
|
|
return setPreference('showFiatInTestnets', value)
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setAutoLockTimeLimit(value) {
|
2020-01-21 23:09:53 +01:00
|
|
|
return setPreference('autoLockTimeLimit', value)
|
2019-05-08 20:57:21 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setCompletedOnboarding() {
|
2020-02-15 21:34:12 +01:00
|
|
|
return async (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2019-03-29 05:51:54 +01:00
|
|
|
|
2019-03-29 05:40:04 +01:00
|
|
|
try {
|
2020-04-23 19:10:15 +02:00
|
|
|
await promisifiedBackground.completeOnboarding()
|
2020-12-18 06:34:43 +01:00
|
|
|
dispatch(completeOnboarding())
|
2019-03-29 05:40:04 +01:00
|
|
|
} catch (err) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(err.message))
|
2019-03-29 05:40:04 +01:00
|
|
|
throw err
|
2020-12-18 06:34:43 +01:00
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
2019-03-29 05:40:04 +01:00
|
|
|
}
|
2019-01-23 16:25:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function completeOnboarding() {
|
2019-01-23 16:25:34 +01:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.COMPLETE_ONBOARDING,
|
2019-01-23 16:25:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setMouseUserState(isMouseUser) {
|
2018-02-12 18:45:53 +01:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SET_MOUSE_USER_STATE,
|
2018-02-12 18:45:53 +01:00
|
|
|
value: isMouseUser,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export async function forceUpdateMetamaskState(dispatch) {
|
2017-02-23 23:23:45 +01:00
|
|
|
log.debug(`background.getState`)
|
2018-03-08 16:29:29 +01:00
|
|
|
|
2020-04-27 23:21:17 +02:00
|
|
|
let newState
|
|
|
|
try {
|
|
|
|
newState = await promisifiedBackground.getState()
|
|
|
|
} catch (error) {
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
throw error
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
return newState
|
2017-02-04 05:45:20 +01:00
|
|
|
}
|
2017-10-16 07:28:25 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function toggleAccountMenu() {
|
2017-10-16 07:28:25 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.TOGGLE_ACCOUNT_MENU,
|
2017-10-16 07:28:25 +02:00
|
|
|
}
|
|
|
|
}
|
2017-11-24 02:33:44 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setParticipateInMetaMetrics(val) {
|
2019-03-05 16:45:01 +01:00
|
|
|
return (dispatch) => {
|
|
|
|
log.debug(`background.setParticipateInMetaMetrics`)
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.setParticipateInMetaMetrics(val, (err, metaMetricsId) => {
|
|
|
|
log.debug(err)
|
|
|
|
if (err) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(err.message))
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2019-03-05 16:45:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
dispatch({
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SET_PARTICIPATE_IN_METAMETRICS,
|
2019-03-05 16:45:01 +01:00
|
|
|
value: val,
|
|
|
|
})
|
|
|
|
resolve([val, metaMetricsId])
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setMetaMetricsSendCount(val) {
|
2019-03-05 16:45:01 +01:00
|
|
|
return (dispatch) => {
|
|
|
|
log.debug(`background.setMetaMetricsSendCount`)
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.setMetaMetricsSendCount(val, (err) => {
|
|
|
|
if (err) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(err.message))
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2019-03-05 16:45:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
dispatch({
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SET_METAMETRICS_SEND_COUNT,
|
2019-03-05 16:45:01 +01:00
|
|
|
value: val,
|
|
|
|
})
|
|
|
|
resolve(val)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setUseBlockie(val) {
|
2017-11-24 18:35:17 +01:00
|
|
|
return (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2017-11-24 18:35:17 +01:00
|
|
|
log.debug(`background.setUseBlockie`)
|
|
|
|
background.setUseBlockie(val, (err) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(hideLoadingIndication())
|
2017-11-24 18:35:17 +01:00
|
|
|
if (err) {
|
2020-08-12 21:06:57 +02:00
|
|
|
dispatch(displayWarning(err.message))
|
2017-11-24 18:35:17 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
dispatch({
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SET_USE_BLOCKIE,
|
2017-11-25 23:47:34 +01:00
|
|
|
value: val,
|
2017-11-24 18:35:17 +01:00
|
|
|
})
|
2017-11-24 02:33:44 +01:00
|
|
|
}
|
2017-11-25 23:47:34 +01:00
|
|
|
}
|
2017-12-22 19:43:02 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setUseNonceField(val) {
|
2019-09-27 06:30:36 +02:00
|
|
|
return (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2019-09-27 06:30:36 +02:00
|
|
|
log.debug(`background.setUseNonceField`)
|
|
|
|
background.setUseNonceField(val, (err) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(hideLoadingIndication())
|
2019-09-27 06:30:36 +02:00
|
|
|
if (err) {
|
2020-08-12 21:06:57 +02:00
|
|
|
dispatch(displayWarning(err.message))
|
2019-09-27 06:30:36 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
dispatch({
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SET_USE_NONCEFIELD,
|
2019-09-27 06:30:36 +02:00
|
|
|
value: val,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setUsePhishDetect(val) {
|
2020-02-27 07:29:41 +01:00
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
log.debug(`background.setUsePhishDetect`)
|
|
|
|
background.setUsePhishDetect(val, (err) => {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
if (err) {
|
2020-08-12 21:06:57 +02:00
|
|
|
dispatch(displayWarning(err.message))
|
2020-02-27 07:29:41 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setIpfsGateway(val) {
|
2019-12-12 20:28:07 +01:00
|
|
|
return (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2019-12-12 20:28:07 +01:00
|
|
|
log.debug(`background.setIpfsGateway`)
|
|
|
|
background.setIpfsGateway(val, (err) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(hideLoadingIndication())
|
2019-12-12 20:28:07 +01:00
|
|
|
if (err) {
|
2020-08-12 21:06:57 +02:00
|
|
|
dispatch(displayWarning(err.message))
|
2019-12-12 20:28:07 +01:00
|
|
|
} else {
|
|
|
|
dispatch({
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SET_IPFS_GATEWAY,
|
2019-12-12 20:28:07 +01:00
|
|
|
value: val,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateCurrentLocale(key) {
|
2020-07-03 02:34:48 +02:00
|
|
|
return async (dispatch) => {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(showLoadingIndication())
|
2020-12-18 06:34:43 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
await loadRelativeTimeFormatLocaleData(key)
|
|
|
|
const localeMessages = await fetchLocale(key)
|
|
|
|
const textDirection = await promisifiedBackground.setCurrentLocale(key)
|
|
|
|
await switchDirection(textDirection)
|
|
|
|
dispatch(setCurrentLocale(key, localeMessages))
|
|
|
|
} catch (error) {
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
return
|
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
}
|
2018-03-16 01:29:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setCurrentLocale(locale, messages) {
|
2018-03-16 01:29:45 +01:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SET_CURRENT_LOCALE,
|
2019-09-06 15:47:07 +02:00
|
|
|
value: {
|
|
|
|
locale,
|
|
|
|
messages,
|
|
|
|
},
|
2018-03-16 01:29:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setPendingTokens(pendingTokens) {
|
2018-05-20 08:04:19 +02:00
|
|
|
const { customToken = {}, selectedTokens = {} } = pendingTokens
|
|
|
|
const { address, symbol, decimals } = customToken
|
2020-11-03 00:41:28 +01:00
|
|
|
const tokens =
|
|
|
|
address && symbol && decimals
|
2020-11-17 18:39:21 +01:00
|
|
|
? {
|
|
|
|
...selectedTokens,
|
|
|
|
[address]: {
|
|
|
|
...customToken,
|
|
|
|
isCustom: true,
|
|
|
|
},
|
|
|
|
}
|
2020-11-03 00:41:28 +01:00
|
|
|
: selectedTokens
|
2018-05-20 08:04:19 +02:00
|
|
|
|
2020-11-17 18:39:21 +01:00
|
|
|
Object.keys(tokens).forEach((tokenAddress) => {
|
|
|
|
tokens[tokenAddress].unlisted = !LISTED_CONTRACT_ADDRESSES.includes(
|
|
|
|
tokenAddress.toLowerCase(),
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2018-05-20 08:04:19 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SET_PENDING_TOKENS,
|
2018-05-20 08:04:19 +02:00
|
|
|
payload: tokens,
|
2017-12-22 19:43:02 +01:00
|
|
|
}
|
|
|
|
}
|
2018-09-27 20:19:09 +02:00
|
|
|
|
2020-10-06 20:28:38 +02:00
|
|
|
// Swaps
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setSwapsLiveness(swapsFeatureIsLive) {
|
2020-10-06 20:28:38 +02:00
|
|
|
return async (dispatch) => {
|
|
|
|
await promisifiedBackground.setSwapsLiveness(swapsFeatureIsLive)
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function fetchAndSetQuotes(fetchParams, fetchParamsMetaData) {
|
2020-10-06 20:28:38 +02:00
|
|
|
return async (dispatch) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const [
|
|
|
|
quotes,
|
|
|
|
selectedAggId,
|
|
|
|
] = await promisifiedBackground.fetchAndSetQuotes(
|
|
|
|
fetchParams,
|
|
|
|
fetchParamsMetaData,
|
|
|
|
)
|
2020-10-06 20:28:38 +02:00
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
return [quotes, selectedAggId]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setSelectedQuoteAggId(aggId) {
|
2020-10-06 20:28:38 +02:00
|
|
|
return async (dispatch) => {
|
|
|
|
await promisifiedBackground.setSelectedQuoteAggId(aggId)
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setSwapsTokens(tokens) {
|
2020-10-06 20:28:38 +02:00
|
|
|
return async (dispatch) => {
|
|
|
|
await promisifiedBackground.setSwapsTokens(tokens)
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function resetBackgroundSwapsState() {
|
2020-10-06 20:28:38 +02:00
|
|
|
return async (dispatch) => {
|
|
|
|
const id = await promisifiedBackground.resetSwapsState()
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
return id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setCustomApproveTxData(data) {
|
2020-10-06 20:28:38 +02:00
|
|
|
return async (dispatch) => {
|
|
|
|
await promisifiedBackground.setCustomApproveTxData(data)
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setSwapsTxGasPrice(gasPrice) {
|
2020-10-06 20:28:38 +02:00
|
|
|
return async (dispatch) => {
|
|
|
|
await promisifiedBackground.setSwapsTxGasPrice(gasPrice)
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setSwapsTxGasLimit(gasLimit) {
|
2020-10-06 20:28:38 +02:00
|
|
|
return async (dispatch) => {
|
|
|
|
await promisifiedBackground.setSwapsTxGasLimit(gasLimit, true)
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:14:08 +01:00
|
|
|
export function customSwapsGasParamsUpdated(gasLimit, gasPrice) {
|
2020-10-06 20:28:38 +02:00
|
|
|
return async (dispatch) => {
|
|
|
|
await promisifiedBackground.setSwapsTxGasPrice(gasPrice)
|
|
|
|
await promisifiedBackground.setSwapsTxGasLimit(gasLimit, true)
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setTradeTxId(tradeTxId) {
|
2020-10-06 20:28:38 +02:00
|
|
|
return async (dispatch) => {
|
|
|
|
await promisifiedBackground.setTradeTxId(tradeTxId)
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setApproveTxId(approveTxId) {
|
2020-10-06 20:28:38 +02:00
|
|
|
return async (dispatch) => {
|
|
|
|
await promisifiedBackground.setApproveTxId(approveTxId)
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function safeRefetchQuotes() {
|
2020-10-06 20:28:38 +02:00
|
|
|
return async (dispatch) => {
|
|
|
|
await promisifiedBackground.safeRefetchQuotes()
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function stopPollingForQuotes() {
|
2020-10-06 20:28:38 +02:00
|
|
|
return async (dispatch) => {
|
|
|
|
await promisifiedBackground.stopPollingForQuotes()
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setBackgroundSwapRouteState(routeState) {
|
2020-10-06 20:28:38 +02:00
|
|
|
return async (dispatch) => {
|
|
|
|
await promisifiedBackground.setBackgroundSwapRouteState(routeState)
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function resetSwapsPostFetchState() {
|
2020-10-06 20:28:38 +02:00
|
|
|
return async (dispatch) => {
|
|
|
|
await promisifiedBackground.resetPostFetchState()
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setSwapsErrorKey(errorKey) {
|
2020-10-06 20:28:38 +02:00
|
|
|
return async (dispatch) => {
|
|
|
|
await promisifiedBackground.setSwapsErrorKey(errorKey)
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setInitialGasEstimate(initialAggId) {
|
2020-10-06 20:28:38 +02:00
|
|
|
return async (dispatch) => {
|
2020-10-07 21:00:17 +02:00
|
|
|
await promisifiedBackground.setInitialGasEstimate(initialAggId)
|
2020-10-06 20:28:38 +02:00
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
// Permissions
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function requestAccountsPermissionWithId(origin) {
|
2020-05-28 00:09:59 +02:00
|
|
|
return async (dispatch) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const id = await promisifiedBackground.requestAccountsPermissionWithId(
|
|
|
|
origin,
|
|
|
|
)
|
2020-05-28 00:09:59 +02:00
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
return id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-12-04 03:52:14 +01:00
|
|
|
* Approves the permissions request.
|
|
|
|
* @param {Object} request - The permissions request to approve
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
* @param {string[]} accounts - The accounts to expose, if any.
|
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
export function approvePermissionsRequest(request, accounts) {
|
2019-05-08 21:51:33 +02:00
|
|
|
return () => {
|
2019-12-04 03:52:14 +01:00
|
|
|
background.approvePermissionsRequest(request, accounts)
|
2018-09-27 20:19:09 +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
|
|
|
/**
|
2019-12-04 03:52:14 +01:00
|
|
|
* Rejects the permissions request with the given ID.
|
|
|
|
* @param {string} requestId - The id of the request to be rejected
|
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
|
|
|
export function rejectPermissionsRequest(requestId) {
|
2020-04-07 20:38:15 +02:00
|
|
|
return (dispatch) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.rejectPermissionsRequest(requestId, (err) => {
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2020-04-07 20:38:15 +02:00
|
|
|
}
|
2020-11-03 00:41:28 +01:00
|
|
|
forceUpdateMetamaskState(dispatch).then(resolve).catch(reject)
|
2020-04-07 20:38:15 +02:00
|
|
|
})
|
|
|
|
})
|
2018-09-27 20:19:09 +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
|
|
|
/**
|
|
|
|
* Clears the given permissions for the given origin.
|
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
export function removePermissionsFor(domains) {
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
return () => {
|
|
|
|
background.removePermissionsFor(domains)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clears all permissions for all domains.
|
|
|
|
*/
|
2020-11-03 00:41:28 +01:00
|
|
|
export function clearPermissions() {
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
return () => {
|
|
|
|
background.clearPermissions()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setFirstTimeFlowType(type) {
|
2019-03-05 16:45:01 +01:00
|
|
|
return (dispatch) => {
|
|
|
|
log.debug(`background.setFirstTimeFlowType`)
|
|
|
|
background.setFirstTimeFlowType(type, (err) => {
|
|
|
|
if (err) {
|
2020-08-12 21:06:57 +02:00
|
|
|
dispatch(displayWarning(err.message))
|
2019-03-05 16:45:01 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
dispatch({
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SET_FIRST_TIME_FLOW_TYPE,
|
2019-03-05 16:45:01 +01:00
|
|
|
value: type,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2019-05-09 19:27:14 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setSelectedSettingsRpcUrl(newRpcUrl) {
|
2019-05-09 19:27:14 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SET_SELECTED_SETTINGS_RPC_URL,
|
2019-05-09 19:27:14 +02:00
|
|
|
value: newRpcUrl,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setNetworksTabAddMode(isInAddMode) {
|
2019-05-09 19:27:14 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SET_NETWORKS_TAB_ADD_MODE,
|
2019-05-09 19:27:14 +02:00
|
|
|
value: isInAddMode,
|
|
|
|
}
|
|
|
|
}
|
2019-05-13 18:16:09 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setLastActiveTime() {
|
2019-05-13 18:16:09 +02:00
|
|
|
return (dispatch) => {
|
|
|
|
background.setLastActiveTime((err) => {
|
|
|
|
if (err) {
|
2020-08-12 21:06:57 +02:00
|
|
|
dispatch(displayWarning(err.message))
|
2019-05-13 18:16:09 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2019-06-18 14:17:14 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setConnectedStatusPopoverHasBeenShown() {
|
2020-04-22 19:11:36 +02:00
|
|
|
return () => {
|
|
|
|
background.setConnectedStatusPopoverHasBeenShown((err) => {
|
|
|
|
if (err) {
|
|
|
|
throw new Error(err.message)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setSwapsWelcomeMessageHasBeenShown() {
|
2020-10-06 20:28:38 +02:00
|
|
|
return () => {
|
|
|
|
background.setSwapsWelcomeMessageHasBeenShown((err) => {
|
|
|
|
if (err) {
|
|
|
|
throw new Error(err.message)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-11 00:40:29 +01:00
|
|
|
export async function setAlertEnabledness(alertId, enabledness) {
|
|
|
|
await promisifiedBackground.setAlertEnabledness(alertId, enabledness)
|
2020-05-08 21:45:52 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export async function setUnconnectedAccountAlertShown(origin) {
|
2020-06-15 21:08:53 +02:00
|
|
|
await promisifiedBackground.setUnconnectedAccountAlertShown(origin)
|
2020-05-12 15:01:52 +02:00
|
|
|
}
|
|
|
|
|
2020-12-11 00:40:29 +01:00
|
|
|
export async function setWeb3ShimUsageAlertDismissed(origin) {
|
|
|
|
await promisifiedBackground.setWeb3ShimUsageAlertDismissed(origin)
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function loadingMethodDataStarted() {
|
2019-06-18 14:17:14 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.LOADING_METHOD_DATA_STARTED,
|
2019-06-18 14:17:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function loadingMethodDataFinished() {
|
2019-06-18 14:17:14 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.LOADING_METHOD_DATA_FINISHED,
|
2019-06-18 14:17:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function getContractMethodData(data = '') {
|
2019-06-18 14:17:14 +02:00
|
|
|
return (dispatch, getState) => {
|
2020-11-06 22:18:00 +01:00
|
|
|
const prefixedData = addHexPrefix(data)
|
2019-06-18 14:17:14 +02:00
|
|
|
const fourBytePrefix = prefixedData.slice(0, 10)
|
|
|
|
const { knownMethodData } = getState().metamask
|
2020-07-22 20:05:23 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
if (
|
|
|
|
(knownMethodData &&
|
|
|
|
knownMethodData[fourBytePrefix] &&
|
|
|
|
Object.keys(knownMethodData[fourBytePrefix]).length !== 0) ||
|
|
|
|
fourBytePrefix === '0x'
|
|
|
|
) {
|
2019-06-18 14:17:14 +02:00
|
|
|
return Promise.resolve(knownMethodData[fourBytePrefix])
|
|
|
|
}
|
|
|
|
|
2020-04-23 14:16:05 +02:00
|
|
|
dispatch(loadingMethodDataStarted())
|
2019-06-18 14:17:14 +02:00
|
|
|
log.debug(`loadingMethodData`)
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
return getMethodDataAsync(fourBytePrefix).then(({ name, params }) => {
|
|
|
|
dispatch(loadingMethodDataFinished())
|
|
|
|
background.addKnownMethodData(fourBytePrefix, { name, params })
|
|
|
|
return { name, params }
|
|
|
|
})
|
2019-06-18 14:17:14 +02:00
|
|
|
}
|
|
|
|
}
|
2019-06-28 05:53:12 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function loadingTokenParamsStarted() {
|
2019-06-28 05:53:12 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.LOADING_TOKEN_PARAMS_STARTED,
|
2019-06-28 05:53:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function loadingTokenParamsFinished() {
|
2019-06-28 05:53:12 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.LOADING_TOKEN_PARAMS_FINISHED,
|
2019-06-28 05:53:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function getTokenParams(tokenAddress) {
|
2019-06-28 05:53:12 +02:00
|
|
|
return (dispatch, getState) => {
|
|
|
|
const existingTokens = getState().metamask.tokens
|
2020-11-03 00:41:28 +01:00
|
|
|
const existingToken = existingTokens.find(
|
|
|
|
({ address }) => tokenAddress === address,
|
|
|
|
)
|
2019-06-28 05:53:12 +02:00
|
|
|
|
|
|
|
if (existingToken) {
|
|
|
|
return Promise.resolve({
|
|
|
|
symbol: existingToken.symbol,
|
|
|
|
decimals: existingToken.decimals,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(loadingTokenParamsStarted())
|
2019-06-28 05:53:12 +02:00
|
|
|
log.debug(`loadingTokenParams`)
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
return fetchSymbolAndDecimals(tokenAddress, existingTokens).then(
|
|
|
|
({ symbol, decimals }) => {
|
2020-05-28 03:33:59 +02:00
|
|
|
dispatch(addToken(tokenAddress, symbol, Number(decimals)))
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(loadingTokenParamsFinished())
|
2020-11-03 00:41:28 +01:00
|
|
|
},
|
|
|
|
)
|
2019-06-28 05:53:12 +02:00
|
|
|
}
|
|
|
|
}
|
2019-08-01 15:24:33 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setSeedPhraseBackedUp(seedPhraseBackupState) {
|
2019-08-02 05:57:26 +02:00
|
|
|
return (dispatch) => {
|
|
|
|
log.debug(`background.setSeedPhraseBackedUp`)
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.setSeedPhraseBackedUp(seedPhraseBackupState, (err) => {
|
|
|
|
if (err) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(err.message))
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2019-08-02 05:57:26 +02:00
|
|
|
}
|
2020-11-03 00:41:28 +01:00
|
|
|
forceUpdateMetamaskState(dispatch).then(resolve).catch(reject)
|
2019-08-02 05:57:26 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2019-09-16 19:11:01 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function initializeThreeBox() {
|
2019-09-26 09:24:52 +02:00
|
|
|
return (dispatch) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.initializeThreeBox((err) => {
|
|
|
|
if (err) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(err.message))
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2019-09-26 09:24:52 +02:00
|
|
|
}
|
|
|
|
resolve()
|
2019-09-16 19:11:01 +02:00
|
|
|
})
|
2019-09-26 09:24:52 +02:00
|
|
|
})
|
2019-09-16 19:11:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setShowRestorePromptToFalse() {
|
2019-09-26 09:24:52 +02:00
|
|
|
return (dispatch) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.setShowRestorePromptToFalse((err) => {
|
|
|
|
if (err) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(err.message))
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2019-09-26 09:24:52 +02:00
|
|
|
}
|
|
|
|
resolve()
|
2019-09-16 19:11:01 +02:00
|
|
|
})
|
2019-09-26 09:24:52 +02:00
|
|
|
})
|
2019-09-16 19:11:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function turnThreeBoxSyncingOn() {
|
2019-09-26 09:24:52 +02:00
|
|
|
return (dispatch) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.turnThreeBoxSyncingOn((err) => {
|
|
|
|
if (err) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(err.message))
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2019-09-26 09:24:52 +02:00
|
|
|
}
|
|
|
|
resolve()
|
2019-09-16 19:11:01 +02:00
|
|
|
})
|
2019-09-26 09:24:52 +02:00
|
|
|
})
|
2019-09-16 19:11:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function restoreFromThreeBox(accountAddress) {
|
2019-09-26 09:24:52 +02:00
|
|
|
return (dispatch) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.restoreFromThreeBox(accountAddress, (err) => {
|
|
|
|
if (err) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(err.message))
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2019-09-26 09:24:52 +02:00
|
|
|
}
|
|
|
|
resolve()
|
2019-09-16 19:11:01 +02:00
|
|
|
})
|
2019-09-26 09:24:52 +02:00
|
|
|
})
|
2019-09-16 19:11:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function getThreeBoxLastUpdated() {
|
2019-09-26 09:24:52 +02:00
|
|
|
return (dispatch) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.getThreeBoxLastUpdated((err, lastUpdated) => {
|
|
|
|
if (err) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(err.message))
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2019-09-26 09:24:52 +02:00
|
|
|
}
|
|
|
|
resolve(lastUpdated)
|
2019-09-16 19:11:01 +02:00
|
|
|
})
|
2019-09-26 09:24:52 +02:00
|
|
|
})
|
2019-09-16 19:11:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setThreeBoxSyncingPermission(threeBoxSyncingAllowed) {
|
2019-09-26 09:24:52 +02:00
|
|
|
return (dispatch) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.setThreeBoxSyncingPermission(threeBoxSyncingAllowed, (err) => {
|
|
|
|
if (err) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(err.message))
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2019-09-26 09:24:52 +02:00
|
|
|
}
|
|
|
|
resolve()
|
2019-09-16 19:11:01 +02:00
|
|
|
})
|
2019-09-26 09:24:52 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function turnThreeBoxSyncingOnAndInitialize() {
|
2019-09-26 09:24:52 +02:00
|
|
|
return async (dispatch) => {
|
|
|
|
await dispatch(setThreeBoxSyncingPermission(true))
|
|
|
|
await dispatch(turnThreeBoxSyncingOn())
|
|
|
|
await dispatch(initializeThreeBox(true))
|
2019-09-16 19:11:01 +02:00
|
|
|
}
|
|
|
|
}
|
2019-09-27 06:30:36 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setNextNonce(nextNonce) {
|
2019-09-27 06:30:36 +02:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SET_NEXT_NONCE,
|
2019-09-27 06:30:36 +02:00
|
|
|
value: nextNonce,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function getNextNonce() {
|
2019-09-27 06:30:36 +02:00
|
|
|
return (dispatch, getState) => {
|
|
|
|
const address = getState().metamask.selectedAddress
|
|
|
|
return new Promise((resolve, reject) => {
|
2019-10-02 20:12:04 +02:00
|
|
|
background.getNextNonce(address, (err, nextNonce) => {
|
2019-09-27 06:30:36 +02:00
|
|
|
if (err) {
|
2020-01-09 04:34:58 +01:00
|
|
|
dispatch(displayWarning(err.message))
|
2020-08-12 21:06:57 +02:00
|
|
|
reject(err)
|
|
|
|
return
|
2019-09-27 06:30:36 +02:00
|
|
|
}
|
2019-10-02 20:12:04 +02:00
|
|
|
dispatch(setNextNonce(nextNonce))
|
|
|
|
resolve(nextNonce)
|
2019-09-27 06:30:36 +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
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setRequestAccountTabIds(requestAccountTabIds) {
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SET_REQUEST_ACCOUNT_TABS,
|
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
|
|
|
value: requestAccountTabIds,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function getRequestAccountTabIds() {
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
return async (dispatch) => {
|
2020-04-23 19:10:15 +02:00
|
|
|
const requestAccountTabIds = await promisifiedBackground.getRequestAccountTabIds()
|
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
|
|
|
dispatch(setRequestAccountTabIds(requestAccountTabIds))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setOpenMetamaskTabsIDs(openMetaMaskTabIDs) {
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SET_OPEN_METAMASK_TAB_IDS,
|
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
|
|
|
value: openMetaMaskTabIDs,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function getOpenMetamaskTabsIds() {
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
return async (dispatch) => {
|
2020-04-23 19:10:15 +02:00
|
|
|
const openMetaMaskTabIDs = await promisifiedBackground.getOpenMetamaskTabsIds()
|
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
|
|
|
dispatch(setOpenMetamaskTabsIDs(openMetaMaskTabIDs))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setCurrentWindowTab(currentWindowTab) {
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
return {
|
2020-01-09 04:34:58 +01:00
|
|
|
type: actionConstants.SET_CURRENT_WINDOW_TAB,
|
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
|
|
|
value: currentWindowTab,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function getCurrentWindowTab() {
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
return async (dispatch) => {
|
|
|
|
const currentWindowTab = await global.platform.currentTab()
|
|
|
|
dispatch(setCurrentWindowTab(currentWindowTab))
|
|
|
|
}
|
|
|
|
}
|
2020-12-02 22:41:30 +01:00
|
|
|
|
|
|
|
// MetaMetrics
|
|
|
|
/**
|
|
|
|
* @typedef {import('../../../shared/constants/metametrics').MetaMetricsEventPayload} MetaMetricsEventPayload
|
|
|
|
* @typedef {import('../../../shared/constants/metametrics').MetaMetricsEventOptions} MetaMetricsEventOptions
|
|
|
|
* @typedef {import('../../../shared/constants/metametrics').MetaMetricsPagePayload} MetaMetricsPagePayload
|
|
|
|
* @typedef {import('../../../shared/constants/metametrics').MetaMetricsPageOptions} MetaMetricsPageOptions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {MetaMetricsEventPayload} payload - details of the event to track
|
|
|
|
* @param {MetaMetricsEventOptions} options - options for routing/handling of event
|
|
|
|
* @returns {Promise<void>}
|
|
|
|
*/
|
|
|
|
export function trackMetaMetricsEvent(payload, options) {
|
|
|
|
return promisifiedBackground.trackMetaMetricsEvent(payload, options)
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {MetaMetricsPagePayload} payload - details of the page viewed
|
|
|
|
* @param {MetaMetricsPageOptions} options - options for handling the page view
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
export function trackMetaMetricsPage(payload, options) {
|
|
|
|
return promisifiedBackground.trackMetaMetricsPage(payload, options)
|
|
|
|
}
|