|
|
|
import abi from 'human-standard-token-abi'
|
|
|
|
import pify from 'pify'
|
|
|
|
import getBuyEthUrl from '../../../app/scripts/lib/buy-eth-url'
|
|
|
|
import { getTokenAddressFromTokenObject, checksumAddress } from '../helpers/utils/util'
|
|
|
|
import { calcTokenBalance, estimateGas } from '../pages/send/send.utils'
|
|
|
|
import ethUtil from 'ethereumjs-util'
|
|
|
|
import { fetchLocale } from '../helpers/utils/i18n-helper'
|
|
|
|
import { getMethodDataAsync } from '../helpers/utils/transactions.util'
|
|
|
|
import { fetchSymbolAndDecimals } from '../helpers/utils/token-util'
|
|
|
|
import switchDirection from '../helpers/utils/switch-direction'
|
|
|
|
import log from 'loglevel'
|
|
|
|
import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../app/scripts/lib/enums'
|
|
|
|
import { hasUnconfirmedTransactions } from '../helpers/utils/confirm-tx.util'
|
|
|
|
import { setCustomGasLimit } from '../ducks/gas/gas.duck'
|
|
|
|
import txHelper from '../../lib/tx-helper'
|
|
|
|
import { getEnvironmentType } from '../../../app/scripts/lib/util'
|
|
|
|
import actionConstants from './actionConstants'
|
|
|
|
|
|
|
|
let background = null
|
|
|
|
let promisifiedBackground = null
|
|
|
|
export function _setBackgroundConnection (backgroundConnection) {
|
|
|
|
background = backgroundConnection
|
|
|
|
promisifiedBackground = pify(background)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function goHome () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.GO_HOME,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// async actions
|
|
|
|
|
|
|
|
export function tryUnlockMetamask (password) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
dispatch(unlockInProgress())
|
|
|
|
log.debug(`background.submitPassword`)
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.submitPassword(password, (error) => {
|
|
|
|
if (error) {
|
|
|
|
return reject(error)
|
|
|
|
}
|
|
|
|
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
dispatch(unlockSucceeded())
|
|
|
|
return forceUpdateMetamaskState(dispatch)
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.verifySeedPhrase((err) => {
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
dispatch(unlockFailed(err.message))
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
return Promise.reject(err)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function createNewVaultAndRestore (password, seed) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
log.debug(`background.createNewVaultAndRestore`)
|
|
|
|
let vault
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.createNewVaultAndRestore(password, seed, (err, _vault) => {
|
|
|
|
if (err) {
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
vault = _vault
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then(() => dispatch(unMarkPasswordForgotten()))
|
|
|
|
.then(() => {
|
|
|
|
dispatch(showAccountsPage())
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
return vault
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
return Promise.reject(err)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function createNewVaultAndGetSeedPhrase (password) {
|
|
|
|
return async (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
|
|
|
|
try {
|
|
|
|
await createNewVault(password)
|
|
|
|
const seedWords = await verifySeedPhrase()
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
return seedWords
|
|
|
|
} catch (error) {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
throw new Error(error.message)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function unlockAndGetSeedPhrase (password) {
|
|
|
|
return async (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
|
|
|
|
try {
|
|
|
|
await submitPassword(password)
|
|
|
|
const seedWords = await verifySeedPhrase()
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
return seedWords
|
|
|
|
} catch (error) {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
throw new Error(error.message)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function submitPassword (password) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.submitPassword(password, (error) => {
|
|
|
|
if (error) {
|
|
|
|
return reject(error)
|
|
|
|
}
|
|
|
|
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export function createNewVault (password) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.createNewVaultAndKeychain(password, (error) => {
|
|
|
|
if (error) {
|
|
|
|
return reject(error)
|
|
|
|
}
|
|
|
|
|
|
|
|
resolve(true)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export function verifyPassword (password) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.submitPassword(password, (error) => {
|
|
|
|
if (error) {
|
|
|
|
return reject(error)
|
|
|
|
}
|
|
|
|
|
|
|
|
resolve(true)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export function verifySeedPhrase () {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.verifySeedPhrase((error, seedWords) => {
|
|
|
|
if (error) {
|
|
|
|
return reject(error)
|
|
|
|
}
|
|
|
|
|
|
|
|
resolve(seedWords)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export function requestRevealSeedWords (password) {
|
|
|
|
return async (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
log.debug(`background.submitPassword`)
|
|
|
|
|
|
|
|
try {
|
|
|
|
await verifyPassword(password)
|
|
|
|
const seedWords = await verifySeedPhrase()
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
return seedWords
|
|
|
|
} catch (error) {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
throw new Error(error.message)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function tryReverseResolveAddress (address) {
|
|
|
|
return () => {
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
background.tryReverseResolveAddress(address, (err) => {
|
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
|
|
|
}
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function fetchInfoToSync () {
|
|
|
|
return (dispatch) => {
|
|
|
|
log.debug(`background.fetchInfoToSync`)
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.fetchInfoToSync((err, result) => {
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
resolve(result)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function resetAccount () {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.resetAccount((err, account) => {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
log.info('Transaction history reset for ' + account)
|
|
|
|
dispatch(showAccountsPage())
|
|
|
|
resolve(account)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function removeAccount (address) {
|
|
|
|
return async (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
|
|
|
|
try {
|
|
|
|
await new Promise((resolve, reject) => {
|
|
|
|
background.removeAccount(address, (error, account) => {
|
|
|
|
if (error) {
|
|
|
|
return reject(error)
|
|
|
|
}
|
|
|
|
return resolve(account)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
} catch (error) {
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
throw error
|
|
|
|
} finally {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
}
|
|
|
|
|
|
|
|
log.info('Account removed: ' + address)
|
|
|
|
dispatch(showAccountsPage())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function importNewAccount (strategy, args) {
|
|
|
|
return async (dispatch) => {
|
|
|
|
let newState
|
|
|
|
dispatch(showLoadingIndication('This may take a while, please be patient.'))
|
|
|
|
try {
|
|
|
|
log.debug(`background.importAccountWithStrategy`)
|
|
|
|
await promisifiedBackground.importAccountWithStrategy(strategy, args)
|
|
|
|
log.debug(`background.getState`)
|
|
|
|
newState = await promisifiedBackground.getState()
|
|
|
|
} catch (err) {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
throw err
|
|
|
|
}
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
if (newState.selectedAddress) {
|
|
|
|
dispatch({
|
|
|
|
type: actionConstants.SHOW_ACCOUNT_DETAIL,
|
|
|
|
value: newState.selectedAddress,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return newState
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function addNewAccount () {
|
|
|
|
log.debug(`background.addNewAccount`)
|
|
|
|
return async (dispatch, getState) => {
|
|
|
|
const oldIdentities = getState().metamask.identities
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
|
|
|
|
let newIdentities
|
|
|
|
try {
|
|
|
|
const { identities } = await promisifiedBackground.addNewAccount()
|
|
|
|
newIdentities = identities
|
|
|
|
} catch (error) {
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
throw error
|
|
|
|
}
|
|
|
|
const newAccountAddress = Object.keys(newIdentities).find((address) => !oldIdentities[address])
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
return newAccountAddress
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function checkHardwareStatus (deviceName, hdPath) {
|
|
|
|
log.debug(`background.checkHardwareStatus`, deviceName, hdPath)
|
|
|
|
return async (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
|
|
|
|
let unlocked
|
|
|
|
try {
|
|
|
|
unlocked = await promisifiedBackground.checkHardwareStatus(deviceName, hdPath)
|
|
|
|
} catch (error) {
|
|
|
|
log.error(error)
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
throw error
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
return unlocked
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function forgetDevice (deviceName) {
|
|
|
|
log.debug(`background.forgetDevice`, deviceName)
|
|
|
|
return async (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
try {
|
|
|
|
await promisifiedBackground.forgetDevice(deviceName)
|
|
|
|
} catch (error) {
|
|
|
|
log.error(error)
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
throw error
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function connectHardware (deviceName, page, hdPath) {
|
|
|
|
log.debug(`background.connectHardware`, deviceName, page, hdPath)
|
|
|
|
return async (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
|
|
|
|
let accounts
|
|
|
|
try {
|
|
|
|
accounts = await promisifiedBackground.connectHardware(deviceName, page, hdPath)
|
|
|
|
} catch (error) {
|
|
|
|
log.error(error)
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
throw error
|
|
|
|
}
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
|
|
|
|
return accounts
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function unlockHardwareWalletAccount (index, deviceName, hdPath) {
|
|
|
|
log.debug(`background.unlockHardwareWalletAccount`, index, deviceName, hdPath)
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.unlockHardwareWalletAccount(index, deviceName, hdPath, (err) => {
|
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
return resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function showQrScanner () {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showModal({
|
|
|
|
name: 'QR_SCANNER',
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setCurrentCurrency (currencyCode) {
|
|
|
|
return async (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
log.debug(`background.setCurrentCurrency`)
|
|
|
|
let data
|
|
|
|
try {
|
|
|
|
data = await promisifiedBackground.setCurrentCurrency(currencyCode)
|
|
|
|
} catch (error) {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
log.error(error.stack)
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch({
|
|
|
|
type: actionConstants.SET_CURRENT_FIAT,
|
|
|
|
value: {
|
|
|
|
currentCurrency: data.currentCurrency,
|
|
|
|
conversionRate: data.conversionRate,
|
|
|
|
conversionDate: data.conversionDate,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function signMsg (msgData) {
|
|
|
|
log.debug('action - signMsg')
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
log.debug(`actions calling background.signMessage`)
|
|
|
|
background.signMessage(msgData, (err, newState) => {
|
|
|
|
log.debug('signMessage called back')
|
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(completedTx(msgData.metamaskId))
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
|
|
|
|
return resolve(msgData)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function signPersonalMsg (msgData) {
|
|
|
|
log.debug('action - signPersonalMsg')
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
log.debug(`actions calling background.signPersonalMessage`)
|
|
|
|
background.signPersonalMessage(msgData, (err, newState) => {
|
|
|
|
log.debug('signPersonalMessage called back')
|
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(completedTx(msgData.metamaskId))
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
|
|
|
|
return resolve(msgData)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function decryptMsgInline (decryptedMsgData) {
|
|
|
|
log.debug('action - decryptMsgInline')
|
|
|
|
return (dispatch) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
log.debug(`actions calling background.decryptMessageInline`)
|
|
|
|
background.decryptMessageInline(decryptedMsgData, (err, newState) => {
|
|
|
|
log.debug('decryptMsgInline called back')
|
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
decryptedMsgData = newState.unapprovedDecryptMsgs[decryptedMsgData.metamaskId]
|
|
|
|
return resolve(decryptedMsgData)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function decryptMsg (decryptedMsgData) {
|
|
|
|
log.debug('action - decryptMsg')
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
log.debug(`actions calling background.decryptMessage`)
|
|
|
|
background.decryptMessage(decryptedMsgData, (err, newState) => {
|
|
|
|
log.debug('decryptMsg called back')
|
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(completedTx(decryptedMsgData.metamaskId))
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
console.log(decryptedMsgData)
|
|
|
|
return resolve(decryptedMsgData)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function encryptionPublicKeyMsg (msgData) {
|
|
|
|
log.debug('action - encryptionPublicKeyMsg')
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
log.debug(`actions calling background.encryptionPublicKey`)
|
|
|
|
background.encryptionPublicKey(msgData, (err, newState) => {
|
|
|
|
log.debug('encryptionPublicKeyMsg called back')
|
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(completedTx(msgData.metamaskId))
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
|
|
|
|
return resolve(msgData)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function signTypedMsg (msgData) {
|
|
|
|
log.debug('action - signTypedMsg')
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
log.debug(`actions calling background.signTypedMessage`)
|
|
|
|
background.signTypedMessage(msgData, (err, newState) => {
|
|
|
|
log.debug('signTypedMessage called back')
|
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(completedTx(msgData.metamaskId))
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
|
|
|
|
return resolve(msgData)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function signTx (txData) {
|
|
|
|
return (dispatch) => {
|
|
|
|
global.ethQuery.sendTransaction(txData, (err) => {
|
|
|
|
if (err) {
|
|
|
|
return dispatch(displayWarning(err.message))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
dispatch(showConfTxPage())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setGasLimit (gasLimit) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.UPDATE_GAS_LIMIT,
|
|
|
|
value: gasLimit,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setGasPrice (gasPrice) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.UPDATE_GAS_PRICE,
|
|
|
|
value: gasPrice,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setGasTotal (gasTotal) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.UPDATE_GAS_TOTAL,
|
|
|
|
value: gasTotal,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updateGasData ({
|
|
|
|
gasPrice,
|
|
|
|
blockGasLimit,
|
|
|
|
selectedAddress,
|
|
|
|
selectedToken,
|
|
|
|
to,
|
|
|
|
value,
|
|
|
|
data,
|
|
|
|
}) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(gasLoadingStarted())
|
|
|
|
return estimateGas({
|
|
|
|
estimateGasMethod: promisifiedBackground.estimateGas,
|
|
|
|
blockGasLimit,
|
|
|
|
selectedAddress,
|
|
|
|
selectedToken,
|
|
|
|
to,
|
|
|
|
value,
|
|
|
|
estimateGasPrice: gasPrice,
|
|
|
|
data,
|
|
|
|
})
|
|
|
|
.then((gas) => {
|
|
|
|
dispatch(setGasLimit(gas))
|
|
|
|
dispatch(setCustomGasLimit(gas))
|
|
|
|
dispatch(updateSendErrors({ gasLoadingError: null }))
|
|
|
|
dispatch(gasLoadingFinished())
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
log.error(err)
|
|
|
|
dispatch(updateSendErrors({ gasLoadingError: 'gasLoadingError' }))
|
|
|
|
dispatch(gasLoadingFinished())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function gasLoadingStarted () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.GAS_LOADING_STARTED,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function gasLoadingFinished () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.GAS_LOADING_FINISHED,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updateSendTokenBalance ({
|
|
|
|
selectedToken,
|
|
|
|
tokenContract,
|
|
|
|
address,
|
|
|
|
}) {
|
|
|
|
return (dispatch) => {
|
|
|
|
const tokenBalancePromise = tokenContract
|
|
|
|
? tokenContract.balanceOf(address)
|
|
|
|
: Promise.resolve()
|
|
|
|
return tokenBalancePromise
|
|
|
|
.then((usersToken) => {
|
|
|
|
if (usersToken) {
|
|
|
|
const newTokenBalance = calcTokenBalance({ selectedToken, usersToken })
|
|
|
|
dispatch(setSendTokenBalance(newTokenBalance))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
log.error(err)
|
|
|
|
updateSendErrors({ tokenBalance: 'tokenBalanceError' })
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updateSendErrors (errorObject) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.UPDATE_SEND_ERRORS,
|
|
|
|
value: errorObject,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setSendTokenBalance (tokenBalance) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.UPDATE_SEND_TOKEN_BALANCE,
|
|
|
|
value: tokenBalance,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updateSendHexData (value) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.UPDATE_SEND_HEX_DATA,
|
|
|
|
value,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updateSendTo (to, nickname = '') {
|
|
|
|
return {
|
|
|
|
type: actionConstants.UPDATE_SEND_TO,
|
|
|
|
value: { to, nickname },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updateSendAmount (amount) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.UPDATE_SEND_AMOUNT,
|
|
|
|
value: amount,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updateCustomNonce (value) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.UPDATE_CUSTOM_NONCE,
|
|
|
|
value: value,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setMaxModeTo (bool) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.UPDATE_MAX_MODE,
|
|
|
|
value: bool,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updateSend (newSend) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.UPDATE_SEND,
|
|
|
|
value: newSend,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function clearSend () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.CLEAR_SEND,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updateSendEnsResolution (ensResolution) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.UPDATE_SEND_ENS_RESOLUTION,
|
|
|
|
payload: ensResolution,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updateSendEnsResolutionError (errorMessage) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.UPDATE_SEND_ENS_RESOLUTION_ERROR,
|
|
|
|
payload: errorMessage,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function signTokenTx (tokenAddress, toAddress, amount, txData) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
const token = global.eth.contract(abi).at(tokenAddress)
|
|
|
|
token.transfer(toAddress, ethUtil.addHexPrefix(amount), txData)
|
|
|
|
.catch((err) => {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
})
|
|
|
|
dispatch(showConfTxPage())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const updateMetamaskStateFromBackground = () => {
|
|
|
|
log.debug(`background.getState`)
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.getState((error, newState) => {
|
|
|
|
if (error) {
|
|
|
|
return reject(error)
|
|
|
|
}
|
|
|
|
|
|
|
|
resolve(newState)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updateTransaction (txData) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.updateTransaction(txData, (err) => {
|
|
|
|
dispatch(updateTransactionParams(txData.id, txData.txParams))
|
|
|
|
if (err) {
|
|
|
|
dispatch(txError(err))
|
|
|
|
dispatch(goHome())
|
|
|
|
log.error(err.message)
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
resolve(txData)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then(() => updateMetamaskStateFromBackground())
|
|
|
|
.then((newState) => dispatch(updateMetamaskState(newState)))
|
|
|
|
.then(() => {
|
|
|
|
dispatch(showConfTxPage({ id: txData.id }))
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
return txData
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updateAndApproveTx (txData) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.updateAndApproveTransaction(txData, (err) => {
|
|
|
|
dispatch(updateTransactionParams(txData.id, txData.txParams))
|
|
|
|
dispatch(clearSend())
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
dispatch(txError(err))
|
|
|
|
dispatch(goHome())
|
|
|
|
log.error(err.message)
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
resolve(txData)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then(() => updateMetamaskStateFromBackground())
|
|
|
|
.then((newState) => dispatch(updateMetamaskState(newState)))
|
|
|
|
.then(() => {
|
|
|
|
dispatch(clearSend())
|
|
|
|
dispatch(completedTx(txData.id))
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch(updateCustomNonce(''))
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
|
|
|
|
return txData
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
return Promise.reject(err)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function completedTx (id) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
const state = getState()
|
|
|
|
const {
|
|
|
|
unapprovedTxs,
|
|
|
|
unapprovedMsgs,
|
|
|
|
unapprovedPersonalMsgs,
|
|
|
|
unapprovedTypedMessages,
|
|
|
|
network,
|
|
|
|
} = state.metamask
|
|
|
|
const unconfirmedActions = txHelper(unapprovedTxs, unapprovedMsgs, unapprovedPersonalMsgs, unapprovedTypedMessages, network)
|
|
|
|
const otherUnconfirmedActions = unconfirmedActions.filter((tx) => tx.id !== id)
|
|
|
|
dispatch({
|
|
|
|
type: actionConstants.COMPLETED_TX,
|
|
|
|
value: {
|
|
|
|
id,
|
|
|
|
unconfirmedActionsCount: otherUnconfirmedActions.length,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updateTransactionParams (id, txParams) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.UPDATE_TRANSACTION_PARAMS,
|
|
|
|
id,
|
|
|
|
value: txParams,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function txError (err) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.TRANSACTION_ERROR,
|
|
|
|
message: err.message,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function cancelMsg (msgData) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.cancelMessage(msgData.id, (err, newState) => {
|
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(completedTx(msgData.id))
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
|
|
|
|
return resolve(msgData)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function cancelPersonalMsg (msgData) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
const id = msgData.id
|
|
|
|
background.cancelPersonalMessage(id, (err, newState) => {
|
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(completedTx(id))
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
|
|
|
|
return resolve(msgData)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function cancelDecryptMsg (msgData) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
const id = msgData.id
|
|
|
|
background.cancelDecryptMessage(id, (err, newState) => {
|
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(completedTx(id))
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
|
|
|
|
return resolve(msgData)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function cancelEncryptionPublicKeyMsg (msgData) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
const id = msgData.id
|
|
|
|
background.cancelEncryptionPublicKey(id, (err, newState) => {
|
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(completedTx(id))
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
|
|
|
|
return resolve(msgData)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function cancelTypedMsg (msgData) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
const id = msgData.id
|
|
|
|
background.cancelTypedMessage(id, (err, newState) => {
|
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(completedTx(id))
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
|
|
|
|
return resolve(msgData)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function cancelTx (txData) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.cancelTransaction(txData.id, (err) => {
|
|
|
|
if (err) {
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then(() => updateMetamaskStateFromBackground())
|
|
|
|
.then((newState) => dispatch(updateMetamaskState(newState)))
|
|
|
|
.then(() => {
|
|
|
|
dispatch(clearSend())
|
|
|
|
dispatch(completedTx(txData.id))
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch(closeCurrentNotificationWindow())
|
|
|
|
|
|
|
|
return txData
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Cancels all of the given transactions
|
|
|
|
* @param {Array<object>} txDataList - a list of tx data objects
|
|
|
|
* @returns {function(*): Promise<void>}
|
|
|
|
*/
|
|
|
|
export function cancelTxs (txDataList) {
|
|
|
|
return async (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
const txIds = txDataList.map(({ id }) => id)
|
|
|
|
const cancellations = txIds.map((id) => new Promise((resolve, reject) => {
|
|
|
|
background.cancelTransaction(id, (err) => {
|
|
|
|
if (err) {
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
}))
|
|
|
|
|
|
|
|
await Promise.all(cancellations)
|
|
|
|
const newState = await updateMetamaskStateFromBackground()
|
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(clearSend())
|
|
|
|
|
|
|
|
txIds.forEach((id) => {
|
|
|
|
dispatch(completedTx(id))
|
|
|
|
})
|
|
|
|
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
|
|
|
|
if (getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION) {
|
|
|
|
return global.platform.closeCurrentWindow()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function markPasswordForgotten () {
|
|
|
|
return async (dispatch) => {
|
|
|
|
try {
|
|
|
|
await new Promise((resolve, reject) => {
|
|
|
|
return background.markPasswordForgotten((error) => {
|
|
|
|
if (error) {
|
|
|
|
return reject(error)
|
|
|
|
}
|
|
|
|
return resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} finally {
|
|
|
|
// TODO: handle errors
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch(forgotPassword())
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function unMarkPasswordForgotten () {
|
|
|
|
return (dispatch) => {
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
background.unMarkPasswordForgotten(() => {
|
|
|
|
dispatch(forgotPassword(false))
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then(() => forceUpdateMetamaskState(dispatch))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function forgotPassword (forgotPasswordState = true) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.FORGOT_PASSWORD,
|
|
|
|
value: forgotPasswordState,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function closeWelcomeScreen () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.CLOSE_WELCOME_SCREEN,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// unlock screen
|
|
|
|
//
|
|
|
|
|
|
|
|
export function unlockInProgress () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.UNLOCK_IN_PROGRESS,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function unlockFailed (message) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.UNLOCK_FAILED,
|
|
|
|
value: message,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function unlockSucceeded (message) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.UNLOCK_SUCCEEDED,
|
|
|
|
value: message,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updateMetamaskState (newState) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.UPDATE_METAMASK_STATE,
|
|
|
|
value: newState,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const backgroundSetLocked = () => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.setLocked((error) => {
|
|
|
|
if (error) {
|
|
|
|
return reject(error)
|
|
|
|
}
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export function lockMetamask () {
|
|
|
|
log.debug(`background.setLocked`)
|
|
|
|
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
|
|
|
|
return backgroundSetLocked()
|
|
|
|
.then(() => updateMetamaskStateFromBackground())
|
|
|
|
.catch((error) => {
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
return Promise.reject(error)
|
|
|
|
})
|
|
|
|
.then((newState) => {
|
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch({ type: actionConstants.LOCK_METAMASK })
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch({ type: actionConstants.LOCK_METAMASK })
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setSelectedToken (tokenAddress) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.SET_SELECTED_TOKEN,
|
|
|
|
value: tokenAddress || null,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setSelectedAddress (address) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
log.debug(`background.setSelectedAddress`)
|
|
|
|
background.setSelectedAddress(address, (err) => {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
if (err) {
|
|
|
|
return dispatch(displayWarning(err.message))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function showAccountDetail (address) {
|
|
|
|
return async (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
log.debug(`background.setSelectedAddress`)
|
|
|
|
|
|
|
|
let tokens
|
|
|
|
try {
|
|
|
|
tokens = await promisifiedBackground.setSelectedAddress(address)
|
|
|
|
} catch (error) {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch(updateTokens(tokens))
|
|
|
|
dispatch({
|
|
|
|
type: actionConstants.SHOW_ACCOUNT_DETAIL,
|
|
|
|
value: address,
|
|
|
|
})
|
|
|
|
dispatch(setSelectedToken())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function addPermittedAccount (origin, address) {
|
|
|
|
return async (dispatch) => {
|
|
|
|
await new Promise((resolve, reject) => {
|
|
|
|
background.addPermittedAccount(origin, address, (error) => {
|
|
|
|
if (error) {
|
|
|
|
return reject(error)
|
|
|
|
}
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function removePermittedAccount (origin, address) {
|
|
|
|
return async (dispatch) => {
|
|
|
|
await new Promise((resolve, reject) => {
|
|
|
|
background.removePermittedAccount(origin, address, (error) => {
|
|
|
|
if (error) {
|
|
|
|
return reject(error)
|
|
|
|
}
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
await forceUpdateMetamaskState(dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function showAccountsPage () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.SHOW_ACCOUNTS_PAGE,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function showConfTxPage ({ id } = {}) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.SHOW_CONF_TX_PAGE,
|
|
|
|
id,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function addToken (address, symbol, decimals, image) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.addToken(address, symbol, decimals, image, (err, tokens) => {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
dispatch(updateTokens(tokens))
|
|
|
|
resolve(tokens)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function removeToken (address) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.removeToken(address, (err, tokens) => {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
dispatch(updateTokens(tokens))
|
|
|
|
resolve(tokens)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function addTokens (tokens) {
|
|
|
|
return (dispatch) => {
|
|
|
|
if (Array.isArray(tokens)) {
|
|
|
|
dispatch(setSelectedToken(getTokenAddressFromTokenObject(tokens[0])))
|
|
|
|
return Promise.all(tokens.map(({ address, symbol, decimals }) => (
|
|
|
|
dispatch(addToken(address, symbol, decimals))
|
|
|
|
)))
|
|
|
|
} else {
|
|
|
|
dispatch(setSelectedToken(getTokenAddressFromTokenObject(tokens)))
|
|
|
|
return Promise.all(
|
|
|
|
Object
|
|
|
|
.entries(tokens)
|
|
|
|
.map(([_, { address, symbol, decimals }]) => (
|
|
|
|
dispatch(addToken(address, symbol, decimals))
|
|
|
|
))
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function removeSuggestedTokens () {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
background.removeSuggestedTokens((err, suggestedTokens) => {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
}
|
|
|
|
dispatch(clearPendingTokens())
|
|
|
|
if (getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION) {
|
|
|
|
return global.platform.closeCurrentWindow()
|
|
|
|
}
|
|
|
|
resolve(suggestedTokens)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then(() => updateMetamaskStateFromBackground())
|
|
|
|
.then((suggestedTokens) => dispatch(updateMetamaskState({ ...suggestedTokens })))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function addKnownMethodData (fourBytePrefix, methodData) {
|
|
|
|
return () => {
|
|
|
|
background.addKnownMethodData(fourBytePrefix, methodData)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updateTokens (newTokens) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.UPDATE_TOKENS,
|
|
|
|
newTokens,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function clearPendingTokens () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.CLEAR_PENDING_TOKENS,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function retryTransaction (txId, gasPrice) {
|
|
|
|
log.debug(`background.retryTransaction`)
|
|
|
|
let newTxId
|
|
|
|
|
|
|
|
return (dispatch) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.retryTransaction(txId, gasPrice, (err, newState) => {
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
const { currentNetworkTxList } = newState
|
|
|
|
const { id } = currentNetworkTxList[currentNetworkTxList.length - 1]
|
|
|
|
newTxId = id
|
|
|
|
resolve(newState)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then((newState) => dispatch(updateMetamaskState(newState)))
|
|
|
|
.then(() => newTxId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function createCancelTransaction (txId, customGasPrice) {
|
|
|
|
log.debug('background.cancelTransaction')
|
|
|
|
let newTxId
|
|
|
|
|
|
|
|
return (dispatch) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.createCancelTransaction(txId, customGasPrice, (err, newState) => {
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
const { currentNetworkTxList } = newState
|
|
|
|
const { id } = currentNetworkTxList[currentNetworkTxList.length - 1]
|
|
|
|
newTxId = id
|
|
|
|
resolve(newState)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then((newState) => dispatch(updateMetamaskState(newState)))
|
|
|
|
.then(() => newTxId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function createSpeedUpTransaction (txId, customGasPrice, customGasLimit) {
|
|
|
|
log.debug('background.createSpeedUpTransaction')
|
|
|
|
let newTx
|
|
|
|
|
|
|
|
return (dispatch) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.createSpeedUpTransaction(txId, customGasPrice, customGasLimit, (err, newState) => {
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
const { currentNetworkTxList } = newState
|
|
|
|
newTx = currentNetworkTxList[currentNetworkTxList.length - 1]
|
|
|
|
resolve(newState)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then((newState) => dispatch(updateMetamaskState(newState)))
|
|
|
|
.then(() => newTx)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function createRetryTransaction (txId, customGasPrice, customGasLimit) {
|
|
|
|
log.debug('background.createRetryTransaction')
|
|
|
|
let newTx
|
|
|
|
|
|
|
|
return (dispatch) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.createSpeedUpTransaction(txId, customGasPrice, customGasLimit, (err, newState) => {
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
const { currentNetworkTxList } = newState
|
|
|
|
newTx = currentNetworkTxList[currentNetworkTxList.length - 1]
|
|
|
|
resolve(newState)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then((newState) => dispatch(updateMetamaskState(newState)))
|
|
|
|
.then(() => newTx)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// config
|
|
|
|
//
|
|
|
|
|
|
|
|
export function setProviderType (type) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
const { type: currentProviderType } = getState().metamask.provider
|
|
|
|
log.debug(`background.setProviderType`, type)
|
|
|
|
background.setProviderType(type, (err) => {
|
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
|
|
|
return dispatch(displayWarning('Had a problem changing networks!'))
|
|
|
|
}
|
|
|
|
dispatch(setPreviousProvider(currentProviderType))
|
|
|
|
dispatch(updateProviderType(type))
|
|
|
|
dispatch(setSelectedToken())
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updateProviderType (type) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.SET_PROVIDER_TYPE,
|
|
|
|
value: type,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setPreviousProvider (type) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.SET_PREVIOUS_PROVIDER,
|
|
|
|
value: type,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updateAndSetCustomRpc (newRpc, chainId, ticker = 'ETH', nickname, rpcPrefs) {
|
|
|
|
return (dispatch) => {
|
|
|
|
log.debug(`background.updateAndSetCustomRpc: ${newRpc} ${chainId} ${ticker} ${nickname}`)
|
|
|
|
background.updateAndSetCustomRpc(newRpc, chainId, ticker, nickname || newRpc, rpcPrefs, (err) => {
|
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
|
|
|
return dispatch(displayWarning('Had a problem changing networks!'))
|
|
|
|
}
|
|
|
|
dispatch({
|
|
|
|
type: actionConstants.SET_RPC_TARGET,
|
|
|
|
value: newRpc,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function editRpc (oldRpc, newRpc, chainId, ticker = 'ETH', nickname, rpcPrefs) {
|
|
|
|
return (dispatch) => {
|
|
|
|
log.debug(`background.delRpcTarget: ${oldRpc}`)
|
|
|
|
background.delCustomRpc(oldRpc, (err) => {
|
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
|
|
|
return dispatch(displayWarning('Had a problem removing network!'))
|
|
|
|
}
|
|
|
|
dispatch(setSelectedToken())
|
|
|
|
background.updateAndSetCustomRpc(newRpc, chainId, ticker, nickname || newRpc, rpcPrefs, (err) => {
|
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
|
|
|
return dispatch(displayWarning('Had a problem changing networks!'))
|
|
|
|
}
|
|
|
|
dispatch({
|
|
|
|
type: actionConstants.SET_RPC_TARGET,
|
|
|
|
value: newRpc,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setRpcTarget (newRpc, chainId, ticker = 'ETH', nickname) {
|
|
|
|
return (dispatch) => {
|
|
|
|
log.debug(`background.setRpcTarget: ${newRpc} ${chainId} ${ticker} ${nickname}`)
|
|
|
|
background.setCustomRpc(newRpc, chainId, ticker, nickname || newRpc, (err) => {
|
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
|
|
|
return dispatch(displayWarning('Had a problem changing networks!'))
|
|
|
|
}
|
|
|
|
dispatch(setSelectedToken())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function delRpcTarget (oldRpc) {
|
|
|
|
return (dispatch) => {
|
|
|
|
log.debug(`background.delRpcTarget: ${oldRpc}`)
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.delCustomRpc(oldRpc, (err) => {
|
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
|
|
|
dispatch(displayWarning('Had a problem removing network!'))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
dispatch(setSelectedToken())
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calls the addressBookController to add a new address.
|
|
|
|
export function addToAddressBook (recipient, nickname = '', memo = '') {
|
|
|
|
log.debug(`background.addToAddressBook`)
|
|
|
|
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
const chainId = getState().metamask.network
|
|
|
|
background.setAddressBook(checksumAddress(recipient), nickname, chainId, memo, (err, set) => {
|
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
|
|
|
dispatch(displayWarning('Address book failed to update'))
|
|
|
|
throw err
|
|
|
|
}
|
|
|
|
if (!set) {
|
|
|
|
return dispatch(displayWarning('Address book failed to update'))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description Calls the addressBookController to remove an existing address.
|
|
|
|
* @param {string} addressToRemove - Address of the entry to remove from the address book
|
|
|
|
*/
|
|
|
|
export function removeFromAddressBook (chainId, addressToRemove) {
|
|
|
|
log.debug(`background.removeFromAddressBook`)
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
background.removeFromAddressBook(chainId, checksumAddress(addressToRemove))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function showNetworkDropdown () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.NETWORK_DROPDOWN_OPEN,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function hideNetworkDropdown () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.NETWORK_DROPDOWN_CLOSE,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function showModal (payload) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.MODAL_OPEN,
|
|
|
|
payload,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function hideModal (payload) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.MODAL_CLOSE,
|
|
|
|
payload,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function closeCurrentNotificationWindow () {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
if (getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION &&
|
|
|
|
!hasUnconfirmedTransactions(getState())) {
|
|
|
|
global.platform.closeCurrentWindow()
|
|
|
|
|
|
|
|
dispatch(closeNotificationWindow())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function closeNotificationWindow () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.CLOSE_NOTIFICATION_WINDOW,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function showSidebar ({ transitionName, type, props }) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.SIDEBAR_OPEN,
|
|
|
|
value: {
|
|
|
|
transitionName,
|
|
|
|
type,
|
|
|
|
props,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function hideSidebar () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.SIDEBAR_CLOSE,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function showAlert (msg) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.ALERT_OPEN,
|
|
|
|
value: msg,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function hideAlert () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.ALERT_CLOSE,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
*/
|
|
|
|
export function qrCodeDetected (qrCodeData) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.QR_CODE_DETECTED,
|
|
|
|
value: qrCodeData,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function showLoadingIndication (message) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.SHOW_LOADING,
|
|
|
|
value: message,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setHardwareWalletDefaultHdPath ({ device, path }) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.SET_HARDWARE_WALLET_DEFAULT_HD_PATH,
|
|
|
|
value: { device, path },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function hideLoadingIndication () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.HIDE_LOADING,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function displayWarning (text) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.DISPLAY_WARNING,
|
|
|
|
value: text,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function hideWarning () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.HIDE_WARNING,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function exportAccount (password, address) {
|
|
|
|
return function (dispatch) {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
|
|
|
|
log.debug(`background.submitPassword`)
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.submitPassword(password, function (err) {
|
|
|
|
if (err) {
|
|
|
|
log.error('Error in submitting password.')
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
dispatch(displayWarning('Incorrect Password.'))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
log.debug(`background.exportAccount`)
|
|
|
|
return background.exportAccount(address, function (err, result) {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
log.error(err)
|
|
|
|
dispatch(displayWarning('Had a problem exporting the account.'))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(showPrivateKey(result))
|
|
|
|
|
|
|
|
return resolve(result)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function showPrivateKey (key) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.SHOW_PRIVATE_KEY,
|
|
|
|
value: key,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setAccountLabel (account, label) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
log.debug(`background.setAccountLabel`)
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.setAccountLabel(account, label, (err) => {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: actionConstants.SET_ACCOUNT_LABEL,
|
|
|
|
value: { account, label },
|
|
|
|
})
|
|
|
|
|
|
|
|
resolve(account)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function showSendTokenPage () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.SHOW_SEND_TOKEN_PAGE,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function buyEth (opts) {
|
|
|
|
return (dispatch) => {
|
|
|
|
const url = getBuyEthUrl(opts)
|
|
|
|
global.platform.openTab({ url })
|
|
|
|
dispatch({
|
|
|
|
type: actionConstants.BUY_ETH,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setFeatureFlag (feature, activated, notificationType) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.setFeatureFlag(feature, activated, (err, updatedFeatureFlags) => {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
dispatch(updateFeatureFlags(updatedFeatureFlags))
|
|
|
|
notificationType && dispatch(showModal({ name: notificationType }))
|
|
|
|
resolve(updatedFeatureFlags)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updateFeatureFlags (updatedFeatureFlags) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.UPDATE_FEATURE_FLAGS,
|
|
|
|
value: updatedFeatureFlags,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setPreference (preference, value) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.setPreference(preference, value, (err, updatedPreferences) => {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(updatePreferences(updatedPreferences))
|
|
|
|
resolve(updatedPreferences)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updatePreferences (value) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.UPDATE_PREFERENCES,
|
|
|
|
value,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setUseNativeCurrencyAsPrimaryCurrencyPreference (value) {
|
|
|
|
return setPreference('useNativeCurrencyAsPrimaryCurrency', value)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setShowFiatConversionOnTestnetsPreference (value) {
|
|
|
|
return setPreference('showFiatInTestnets', value)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setAutoLockTimeLimit (value) {
|
|
|
|
return setPreference('autoLockTimeLimit', value)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setCompletedOnboarding () {
|
|
|
|
return async (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
|
|
|
|
try {
|
|
|
|
await promisifiedBackground.completeOnboarding()
|
|
|
|
} catch (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
throw err
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(completeOnboarding())
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function completeOnboarding () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.COMPLETE_ONBOARDING,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setMouseUserState (isMouseUser) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.SET_MOUSE_USER_STATE,
|
|
|
|
value: isMouseUser,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function forceUpdateMetamaskState (dispatch) {
|
|
|
|
log.debug(`background.getState`)
|
|
|
|
|
|
|
|
let newState
|
|
|
|
try {
|
|
|
|
newState = await promisifiedBackground.getState()
|
|
|
|
} catch (error) {
|
|
|
|
dispatch(displayWarning(error.message))
|
|
|
|
throw error
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(updateMetamaskState(newState))
|
|
|
|
return newState
|
|
|
|
}
|
|
|
|
|
|
|
|
export function toggleAccountMenu () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.TOGGLE_ACCOUNT_MENU,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setParticipateInMetaMetrics (val) {
|
|
|
|
return (dispatch) => {
|
|
|
|
log.debug(`background.setParticipateInMetaMetrics`)
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.setParticipateInMetaMetrics(val, (err, metaMetricsId) => {
|
|
|
|
log.debug(err)
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: actionConstants.SET_PARTICIPATE_IN_METAMETRICS,
|
|
|
|
value: val,
|
|
|
|
})
|
|
|
|
|
|
|
|
resolve([val, metaMetricsId])
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setMetaMetricsSendCount (val) {
|
|
|
|
return (dispatch) => {
|
|
|
|
log.debug(`background.setMetaMetricsSendCount`)
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.setMetaMetricsSendCount(val, (err) => {
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: actionConstants.SET_METAMETRICS_SEND_COUNT,
|
|
|
|
value: val,
|
|
|
|
})
|
|
|
|
|
|
|
|
resolve(val)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setUseBlockie (val) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
log.debug(`background.setUseBlockie`)
|
|
|
|
background.setUseBlockie(val, (err) => {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
if (err) {
|
|
|
|
return dispatch(displayWarning(err.message))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
dispatch({
|
|
|
|
type: actionConstants.SET_USE_BLOCKIE,
|
|
|
|
value: val,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setUseNonceField (val) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
log.debug(`background.setUseNonceField`)
|
|
|
|
background.setUseNonceField(val, (err) => {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
if (err) {
|
|
|
|
return dispatch(displayWarning(err.message))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
dispatch({
|
|
|
|
type: actionConstants.SET_USE_NONCEFIELD,
|
|
|
|
value: val,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setUsePhishDetect (val) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
log.debug(`background.setUsePhishDetect`)
|
|
|
|
background.setUsePhishDetect(val, (err) => {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
if (err) {
|
|
|
|
return dispatch(displayWarning(err.message))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setIpfsGateway (val) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
log.debug(`background.setIpfsGateway`)
|
|
|
|
background.setIpfsGateway(val, (err) => {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
if (err) {
|
|
|
|
return dispatch(displayWarning(err.message))
|
|
|
|
} else {
|
|
|
|
dispatch({
|
|
|
|
type: actionConstants.SET_IPFS_GATEWAY,
|
|
|
|
value: val,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updateCurrentLocale (key) {
|
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(showLoadingIndication())
|
|
|
|
return fetchLocale(key)
|
|
|
|
.then((localeMessages) => {
|
|
|
|
log.debug(`background.setCurrentLocale`)
|
|
|
|
background.setCurrentLocale(key, (err, textDirection) => {
|
|
|
|
if (err) {
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
return dispatch(displayWarning(err.message))
|
|
|
|
}
|
|
|
|
switchDirection(textDirection)
|
|
|
|
dispatch(setCurrentLocale(key, localeMessages))
|
|
|
|
dispatch(hideLoadingIndication())
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setCurrentLocale (locale, messages) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.SET_CURRENT_LOCALE,
|
|
|
|
value: {
|
|
|
|
locale,
|
|
|
|
messages,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setPendingTokens (pendingTokens) {
|
|
|
|
const { customToken = {}, selectedTokens = {} } = pendingTokens
|
|
|
|
const { address, symbol, decimals } = customToken
|
|
|
|
const tokens = address && symbol && decimals
|
|
|
|
? { ...selectedTokens, [address]: { ...customToken, isCustom: true } }
|
|
|
|
: selectedTokens
|
|
|
|
|
|
|
|
return {
|
|
|
|
type: actionConstants.SET_PENDING_TOKENS,
|
|
|
|
payload: tokens,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
5 years ago
|
|
|
// Permissions
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
5 years ago
|
|
|
* @param {string[]} accounts - The accounts to expose, if any.
|
|
|
|
*/
|
|
|
|
export function approvePermissionsRequest (request, accounts) {
|
|
|
|
return () => {
|
|
|
|
background.approvePermissionsRequest(request, accounts)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
5 years ago
|
|
|
/**
|
|
|
|
* 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
5 years ago
|
|
|
*/
|
|
|
|
export function rejectPermissionsRequest (requestId) {
|
|
|
|
return (dispatch) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.rejectPermissionsRequest(requestId, (err) => {
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
reject()
|
|
|
|
}
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
5 years ago
|
|
|
/**
|
|
|
|
* Exposes the given account(s) to the given origin.
|
|
|
|
* Call ONLY as a result of direct user action.
|
|
|
|
*/
|
|
|
|
export function legacyExposeAccounts (origin, accounts) {
|
|
|
|
return () => {
|
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
5 years ago
|
|
|
return background.legacyExposeAccounts(origin, accounts)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
5 years ago
|
|
|
/**
|
|
|
|
* Clears the given permissions for the given origin.
|
|
|
|
*/
|
|
|
|
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
5 years ago
|
|
|
return () => {
|
|
|
|
background.removePermissionsFor(domains)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clears all permissions for all domains.
|
|
|
|
*/
|
|
|
|
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
5 years ago
|
|
|
return () => {
|
|
|
|
background.clearPermissions()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setFirstTimeFlowType (type) {
|
|
|
|
return (dispatch) => {
|
|
|
|
log.debug(`background.setFirstTimeFlowType`)
|
|
|
|
background.setFirstTimeFlowType(type, (err) => {
|
|
|
|
if (err) {
|
|
|
|
return dispatch(displayWarning(err.message))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
dispatch({
|
|
|
|
type: actionConstants.SET_FIRST_TIME_FLOW_TYPE,
|
|
|
|
value: type,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setSelectedSettingsRpcUrl (newRpcUrl) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.SET_SELECTED_SETTINGS_RPC_URL,
|
|
|
|
value: newRpcUrl,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setNetworksTabAddMode (isInAddMode) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.SET_NETWORKS_TAB_ADD_MODE,
|
|
|
|
value: isInAddMode,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setLastActiveTime () {
|
|
|
|
return (dispatch) => {
|
|
|
|
background.setLastActiveTime((err) => {
|
|
|
|
if (err) {
|
|
|
|
return dispatch(displayWarning(err.message))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setConnectedStatusPopoverHasBeenShown () {
|
|
|
|
return () => {
|
|
|
|
background.setConnectedStatusPopoverHasBeenShown((err) => {
|
|
|
|
if (err) {
|
|
|
|
throw new Error(err.message)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function loadingMethodDataStarted () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.LOADING_METHOD_DATA_STARTED,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function loadingMethodDataFinished () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.LOADING_METHOD_DATA_FINISHED,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getContractMethodData (data = '') {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
const prefixedData = ethUtil.addHexPrefix(data)
|
|
|
|
const fourBytePrefix = prefixedData.slice(0, 10)
|
|
|
|
const { knownMethodData } = getState().metamask
|
|
|
|
if (knownMethodData && knownMethodData[fourBytePrefix]) {
|
|
|
|
return Promise.resolve(knownMethodData[fourBytePrefix])
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(loadingMethodDataStarted())
|
|
|
|
log.debug(`loadingMethodData`)
|
|
|
|
|
|
|
|
return getMethodDataAsync(fourBytePrefix)
|
|
|
|
.then(({ name, params }) => {
|
|
|
|
dispatch(loadingMethodDataFinished())
|
|
|
|
|
|
|
|
background.addKnownMethodData(fourBytePrefix, { name, params })
|
|
|
|
|
|
|
|
return { name, params }
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function loadingTokenParamsStarted () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.LOADING_TOKEN_PARAMS_STARTED,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function loadingTokenParamsFinished () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.LOADING_TOKEN_PARAMS_FINISHED,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getTokenParams (tokenAddress) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
const existingTokens = getState().metamask.tokens
|
|
|
|
const existingToken = existingTokens.find(({ address }) => tokenAddress === address)
|
|
|
|
|
|
|
|
if (existingToken) {
|
|
|
|
return Promise.resolve({
|
|
|
|
symbol: existingToken.symbol,
|
|
|
|
decimals: existingToken.decimals,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(loadingTokenParamsStarted())
|
|
|
|
log.debug(`loadingTokenParams`)
|
|
|
|
|
|
|
|
|
|
|
|
return fetchSymbolAndDecimals(tokenAddress, existingTokens)
|
|
|
|
.then(({ symbol, decimals }) => {
|
|
|
|
dispatch(addToken(tokenAddress, symbol, decimals))
|
|
|
|
dispatch(loadingTokenParamsFinished())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setSeedPhraseBackedUp (seedPhraseBackupState) {
|
|
|
|
return (dispatch) => {
|
|
|
|
log.debug(`background.setSeedPhraseBackedUp`)
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.setSeedPhraseBackedUp(seedPhraseBackupState, (err) => {
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
return forceUpdateMetamaskState(dispatch)
|
|
|
|
.then(resolve)
|
|
|
|
.catch(reject)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function hideSeedPhraseBackupAfterOnboarding () {
|
|
|
|
return {
|
|
|
|
type: actionConstants.HIDE_SEED_PHRASE_BACKUP_AFTER_ONBOARDING,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function initializeThreeBox () {
|
|
|
|
return (dispatch) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.initializeThreeBox((err) => {
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setShowRestorePromptToFalse () {
|
|
|
|
return (dispatch) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.setShowRestorePromptToFalse((err) => {
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function turnThreeBoxSyncingOn () {
|
|
|
|
return (dispatch) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.turnThreeBoxSyncingOn((err) => {
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function restoreFromThreeBox (accountAddress) {
|
|
|
|
return (dispatch) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.restoreFromThreeBox(accountAddress, (err) => {
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getThreeBoxLastUpdated () {
|
|
|
|
return (dispatch) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.getThreeBoxLastUpdated((err, lastUpdated) => {
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
resolve(lastUpdated)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setThreeBoxSyncingPermission (threeBoxSyncingAllowed) {
|
|
|
|
return (dispatch) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.setThreeBoxSyncingPermission(threeBoxSyncingAllowed, (err) => {
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function turnThreeBoxSyncingOnAndInitialize () {
|
|
|
|
return async (dispatch) => {
|
|
|
|
await dispatch(setThreeBoxSyncingPermission(true))
|
|
|
|
await dispatch(turnThreeBoxSyncingOn())
|
|
|
|
await dispatch(initializeThreeBox(true))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setNextNonce (nextNonce) {
|
|
|
|
return {
|
|
|
|
type: actionConstants.SET_NEXT_NONCE,
|
|
|
|
value: nextNonce,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getNextNonce () {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
const address = getState().metamask.selectedAddress
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
background.getNextNonce(address, (err, nextNonce) => {
|
|
|
|
if (err) {
|
|
|
|
dispatch(displayWarning(err.message))
|
|
|
|
return reject(err)
|
|
|
|
}
|
|
|
|
dispatch(setNextNonce(nextNonce))
|
|
|
|
resolve(nextNonce)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
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
5 years ago
|
|
|
|
|
|
|
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
5 years ago
|
|
|
return {
|
|
|
|
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
5 years ago
|
|
|
value: requestAccountTabIds,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
5 years ago
|
|
|
return async (dispatch) => {
|
|
|
|
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
5 years ago
|
|
|
dispatch(setRequestAccountTabIds(requestAccountTabIds))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
5 years ago
|
|
|
return {
|
|
|
|
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
5 years ago
|
|
|
value: openMetaMaskTabIDs,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
5 years ago
|
|
|
return async (dispatch) => {
|
|
|
|
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
5 years ago
|
|
|
dispatch(setOpenMetamaskTabsIDs(openMetaMaskTabIDs))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
5 years ago
|
|
|
return {
|
|
|
|
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
5 years ago
|
|
|
value: currentWindowTab,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
5 years ago
|
|
|
return async (dispatch) => {
|
|
|
|
const currentWindowTab = await global.platform.currentTab()
|
|
|
|
dispatch(setCurrentWindowTab(currentWindowTab))
|
|
|
|
}
|
|
|
|
}
|