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