mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 01:47:00 +01:00
Dead and redundant code removal (#17512)
This commit is contained in:
parent
3fc26521d4
commit
02b2d7fa42
@ -25,9 +25,7 @@
|
|||||||
"name": "confTx",
|
"name": "confTx",
|
||||||
"context": 0
|
"context": 0
|
||||||
},
|
},
|
||||||
"accountDetail": {
|
"accountDetail": {},
|
||||||
"subview": "transactions"
|
|
||||||
},
|
|
||||||
"transForward": false,
|
"transForward": false,
|
||||||
"isLoading": false,
|
"isLoading": false,
|
||||||
"warning": null,
|
"warning": null,
|
||||||
|
@ -87,7 +87,7 @@ export default class AccountMenu extends Component {
|
|||||||
keyrings: PropTypes.array,
|
keyrings: PropTypes.array,
|
||||||
lockMetamask: PropTypes.func,
|
lockMetamask: PropTypes.func,
|
||||||
selectedAddress: PropTypes.string,
|
selectedAddress: PropTypes.string,
|
||||||
showAccountDetail: PropTypes.func,
|
setSelectedAccount: PropTypes.func,
|
||||||
toggleAccountMenu: PropTypes.func,
|
toggleAccountMenu: PropTypes.func,
|
||||||
addressConnectedSubjectMap: PropTypes.object,
|
addressConnectedSubjectMap: PropTypes.object,
|
||||||
originOfCurrentTab: PropTypes.string,
|
originOfCurrentTab: PropTypes.string,
|
||||||
@ -173,7 +173,7 @@ export default class AccountMenu extends Component {
|
|||||||
accounts,
|
accounts,
|
||||||
selectedAddress,
|
selectedAddress,
|
||||||
keyrings,
|
keyrings,
|
||||||
showAccountDetail,
|
setSelectedAccount,
|
||||||
addressConnectedSubjectMap,
|
addressConnectedSubjectMap,
|
||||||
originOfCurrentTab,
|
originOfCurrentTab,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
@ -219,7 +219,7 @@ export default class AccountMenu extends Component {
|
|||||||
location: 'Main Menu',
|
location: 'Main Menu',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
showAccountDetail(identity.address);
|
setSelectedAccount(identity.address);
|
||||||
}}
|
}}
|
||||||
key={identity.address}
|
key={identity.address}
|
||||||
data-testid="account-menu__account"
|
data-testid="account-menu__account"
|
||||||
|
@ -3,7 +3,7 @@ import { compose } from 'redux';
|
|||||||
import { withRouter } from 'react-router-dom';
|
import { withRouter } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
toggleAccountMenu,
|
toggleAccountMenu,
|
||||||
showAccountDetail,
|
setSelectedAccount,
|
||||||
lockMetamask,
|
lockMetamask,
|
||||||
hideWarning,
|
hideWarning,
|
||||||
} from '../../../store/actions';
|
} from '../../../store/actions';
|
||||||
@ -51,8 +51,8 @@ function mapStateToProps(state) {
|
|||||||
function mapDispatchToProps(dispatch) {
|
function mapDispatchToProps(dispatch) {
|
||||||
return {
|
return {
|
||||||
toggleAccountMenu: () => dispatch(toggleAccountMenu()),
|
toggleAccountMenu: () => dispatch(toggleAccountMenu()),
|
||||||
showAccountDetail: (address) => {
|
setSelectedAccount: (address) => {
|
||||||
dispatch(showAccountDetail(address));
|
dispatch(setSelectedAccount(address));
|
||||||
dispatch(toggleAccountMenu());
|
dispatch(toggleAccountMenu());
|
||||||
},
|
},
|
||||||
lockMetamask: () => {
|
lockMetamask: () => {
|
||||||
|
@ -47,7 +47,7 @@ describe('Account Menu', () => {
|
|||||||
],
|
],
|
||||||
prevIsAccountMenuOpen: false,
|
prevIsAccountMenuOpen: false,
|
||||||
lockMetamask: sinon.spy(),
|
lockMetamask: sinon.spy(),
|
||||||
showAccountDetail: sinon.spy(),
|
setSelectedAccount: sinon.spy(),
|
||||||
showRemoveAccountConfirmationModal: sinon.spy(),
|
showRemoveAccountConfirmationModal: sinon.spy(),
|
||||||
toggleAccountMenu: sinon.spy(),
|
toggleAccountMenu: sinon.spy(),
|
||||||
history: {
|
history: {
|
||||||
@ -80,8 +80,8 @@ describe('Account Menu', () => {
|
|||||||
const click = screen.getAllByTestId('account-menu__account');
|
const click = screen.getAllByTestId('account-menu__account');
|
||||||
fireEvent.click(click[0]);
|
fireEvent.click(click[0]);
|
||||||
|
|
||||||
expect(props.showAccountDetail.calledOnce).toStrictEqual(true);
|
expect(props.setSelectedAccount.calledOnce).toStrictEqual(true);
|
||||||
expect(props.showAccountDetail.getCall(0).args[0]).toStrictEqual('0x00');
|
expect(props.setSelectedAccount.getCall(0).args[0]).toStrictEqual('0x00');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('render imported account label', () => {
|
it('render imported account label', () => {
|
||||||
|
@ -24,7 +24,7 @@ export default function reduceApp(state = {}, action) {
|
|||||||
qrCodeData: null,
|
qrCodeData: null,
|
||||||
networkDropdownOpen: false,
|
networkDropdownOpen: false,
|
||||||
accountDetail: {
|
accountDetail: {
|
||||||
subview: 'transactions',
|
privateKey: '',
|
||||||
},
|
},
|
||||||
// Used to display loading indicator
|
// Used to display loading indicator
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
@ -38,7 +38,6 @@ export default function reduceApp(state = {}, action) {
|
|||||||
lattice: `m/44'/60'/0'/0`,
|
lattice: `m/44'/60'/0'/0`,
|
||||||
},
|
},
|
||||||
networksTabSelectedRpcUrl: '',
|
networksTabSelectedRpcUrl: '',
|
||||||
loadingMethodData: false,
|
|
||||||
requestAccountTabs: {},
|
requestAccountTabs: {},
|
||||||
openMetaMaskTabs: {},
|
openMetaMaskTabs: {},
|
||||||
currentWindowTab: {},
|
currentWindowTab: {},
|
||||||
@ -143,7 +142,9 @@ export default function reduceApp(state = {}, action) {
|
|||||||
case actionConstants.CLEAR_ACCOUNT_DETAILS:
|
case actionConstants.CLEAR_ACCOUNT_DETAILS:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
accountDetail: {},
|
accountDetail: {
|
||||||
|
privateKey: '',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
case actionConstants.SHOW_SEND_TOKEN_PAGE:
|
case actionConstants.SHOW_SEND_TOKEN_PAGE:
|
||||||
@ -164,23 +165,11 @@ export default function reduceApp(state = {}, action) {
|
|||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
accountDetail: {
|
accountDetail: {
|
||||||
subview: 'transactions',
|
|
||||||
accountExport: 'none',
|
|
||||||
privateKey: '',
|
privateKey: '',
|
||||||
},
|
},
|
||||||
warning: null,
|
warning: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
case actionConstants.SHOW_ACCOUNT_DETAIL:
|
|
||||||
return {
|
|
||||||
...appState,
|
|
||||||
accountDetail: {
|
|
||||||
subview: 'transactions',
|
|
||||||
accountExport: 'none',
|
|
||||||
privateKey: '',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
case actionConstants.SHOW_ACCOUNTS_PAGE:
|
case actionConstants.SHOW_ACCOUNTS_PAGE:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
@ -322,18 +311,6 @@ export default function reduceApp(state = {}, action) {
|
|||||||
portfolioTooltipWasShownInThisSession: true,
|
portfolioTooltipWasShownInThisSession: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
case actionConstants.LOADING_METHOD_DATA_STARTED:
|
|
||||||
return {
|
|
||||||
...appState,
|
|
||||||
loadingMethodData: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
case actionConstants.LOADING_METHOD_DATA_FINISHED:
|
|
||||||
return {
|
|
||||||
...appState,
|
|
||||||
loadingMethodData: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
case actionConstants.SET_REQUEST_ACCOUNT_TABS:
|
case actionConstants.SET_REQUEST_ACCOUNT_TABS:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
|
@ -121,27 +121,13 @@ describe('App State', () => {
|
|||||||
type: actions.GO_HOME,
|
type: actions.GO_HOME,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(state.accountDetail.subview).toStrictEqual('transactions');
|
|
||||||
expect(state.accountDetail.accountExport).toStrictEqual('none');
|
|
||||||
expect(state.accountDetail.privateKey).toStrictEqual('');
|
expect(state.accountDetail.privateKey).toStrictEqual('');
|
||||||
expect(state.warning).toBeNull();
|
expect(state.warning).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows account detail', () => {
|
|
||||||
const state = reduceApp(metamaskState, {
|
|
||||||
type: actions.SHOW_ACCOUNT_DETAIL,
|
|
||||||
value: 'context address',
|
|
||||||
});
|
|
||||||
expect(state.accountDetail.subview).toStrictEqual('transactions'); // default
|
|
||||||
expect(state.accountDetail.accountExport).toStrictEqual('none'); // default
|
|
||||||
expect(state.accountDetail.privateKey).toStrictEqual(''); // default
|
|
||||||
});
|
|
||||||
|
|
||||||
it('clears account details', () => {
|
it('clears account details', () => {
|
||||||
const exportPrivKeyModal = {
|
const exportPrivKeyModal = {
|
||||||
accountDetail: {
|
accountDetail: {
|
||||||
subview: 'export',
|
|
||||||
accountExport: 'completed',
|
|
||||||
privateKey: 'a-priv-key',
|
privateKey: 'a-priv-key',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -151,10 +137,10 @@ describe('App State', () => {
|
|||||||
type: actions.CLEAR_ACCOUNT_DETAILS,
|
type: actions.CLEAR_ACCOUNT_DETAILS,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(newState.accountDetail).toStrictEqual({});
|
expect(newState.accountDetail).toStrictEqual({ privateKey: '' });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shoes account page', () => {
|
it('shows account page', () => {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.SHOW_ACCOUNTS_PAGE,
|
type: actions.SHOW_ACCOUNTS_PAGE,
|
||||||
});
|
});
|
||||||
@ -220,7 +206,6 @@ describe('App State', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(state.warning).toBeNull();
|
expect(state.warning).toBeNull();
|
||||||
expect(state.accountDetail.subview).toStrictEqual('transactions');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets default warning when unlock fails', () => {
|
it('sets default warning when unlock fails', () => {
|
||||||
@ -314,8 +299,6 @@ describe('App State', () => {
|
|||||||
value: 'private key',
|
value: 'private key',
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(state.accountDetail.subview).toStrictEqual('export');
|
|
||||||
expect(state.accountDetail.accountExport).toStrictEqual('completed');
|
|
||||||
expect(state.accountDetail.privateKey).toStrictEqual('private key');
|
expect(state.accountDetail.privateKey).toStrictEqual('private key');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ import {
|
|||||||
GasEstimateTypes,
|
GasEstimateTypes,
|
||||||
NetworkCongestionThresholds,
|
NetworkCongestionThresholds,
|
||||||
} from '../../../shared/constants/gas';
|
} from '../../../shared/constants/gas';
|
||||||
import { NETWORK_TYPES } from '../../../shared/constants/network';
|
|
||||||
import {
|
import {
|
||||||
accountsWithSendEtherInfoSelector,
|
accountsWithSendEtherInfoSelector,
|
||||||
checkNetworkAndAccountSupports1559,
|
checkNetworkAndAccountSupports1559,
|
||||||
@ -82,31 +81,6 @@ export default function reduceMetamask(state = initialState, action) {
|
|||||||
isUnlocked: false,
|
isUnlocked: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
case actionConstants.SET_RPC_TARGET:
|
|
||||||
return {
|
|
||||||
...metamaskState,
|
|
||||||
provider: {
|
|
||||||
type: NETWORK_TYPES.RPC,
|
|
||||||
rpcUrl: action.value,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
case actionConstants.SET_PROVIDER_TYPE:
|
|
||||||
return {
|
|
||||||
...metamaskState,
|
|
||||||
provider: {
|
|
||||||
type: action.value,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
case actionConstants.SHOW_ACCOUNT_DETAIL:
|
|
||||||
return {
|
|
||||||
...metamaskState,
|
|
||||||
isUnlocked: true,
|
|
||||||
isInitialized: true,
|
|
||||||
selectedAddress: action.value,
|
|
||||||
};
|
|
||||||
|
|
||||||
case actionConstants.SET_ACCOUNT_LABEL: {
|
case actionConstants.SET_ACCOUNT_LABEL: {
|
||||||
const { account } = action.value;
|
const { account } = action.value;
|
||||||
const name = action.value.label;
|
const name = action.value.label;
|
||||||
@ -152,18 +126,6 @@ export default function reduceMetamask(state = initialState, action) {
|
|||||||
participateInMetaMetrics: action.value,
|
participateInMetaMetrics: action.value,
|
||||||
};
|
};
|
||||||
|
|
||||||
case actionConstants.SET_USE_BLOCKIE:
|
|
||||||
return {
|
|
||||||
...metamaskState,
|
|
||||||
useBlockie: action.value,
|
|
||||||
};
|
|
||||||
|
|
||||||
case actionConstants.UPDATE_FEATURE_FLAGS:
|
|
||||||
return {
|
|
||||||
...metamaskState,
|
|
||||||
featureFlags: action.value,
|
|
||||||
};
|
|
||||||
|
|
||||||
case actionConstants.CLOSE_WELCOME_SCREEN:
|
case actionConstants.CLOSE_WELCOME_SCREEN:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
@ -183,16 +145,6 @@ export default function reduceMetamask(state = initialState, action) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case actionConstants.UPDATE_PREFERENCES: {
|
|
||||||
return {
|
|
||||||
...metamaskState,
|
|
||||||
preferences: {
|
|
||||||
...metamaskState.preferences,
|
|
||||||
...action.payload,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
case actionConstants.COMPLETE_ONBOARDING: {
|
case actionConstants.COMPLETE_ONBOARDING: {
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
|
@ -128,42 +128,6 @@ describe('MetaMask Reducers', () => {
|
|||||||
expect(lockMetaMask.isUnlocked).toStrictEqual(false);
|
expect(lockMetaMask.isUnlocked).toStrictEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets rpc target', () => {
|
|
||||||
const state = reduceMetamask(
|
|
||||||
{},
|
|
||||||
{
|
|
||||||
type: actionConstants.SET_RPC_TARGET,
|
|
||||||
value: 'https://custom.rpc',
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(state.provider.rpcUrl).toStrictEqual('https://custom.rpc');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('sets provider type', () => {
|
|
||||||
const state = reduceMetamask(
|
|
||||||
{},
|
|
||||||
{
|
|
||||||
type: actionConstants.SET_PROVIDER_TYPE,
|
|
||||||
value: 'provider type',
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(state.provider.type).toStrictEqual('provider type');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('shows account detail', () => {
|
|
||||||
const state = reduceMetamask(
|
|
||||||
{},
|
|
||||||
{
|
|
||||||
type: actionConstants.SHOW_ACCOUNT_DETAIL,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(state.isUnlocked).toStrictEqual(true);
|
|
||||||
expect(state.isInitialized).toStrictEqual(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('sets account label', () => {
|
it('sets account label', () => {
|
||||||
const state = reduceMetamask(
|
const state = reduceMetamask(
|
||||||
{},
|
{},
|
||||||
@ -211,32 +175,6 @@ describe('MetaMask Reducers', () => {
|
|||||||
expect(state.currentNetworkTxList[0].txParams).toStrictEqual('bar');
|
expect(state.currentNetworkTxList[0].txParams).toStrictEqual('bar');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets blockies', () => {
|
|
||||||
const state = reduceMetamask(
|
|
||||||
{},
|
|
||||||
{
|
|
||||||
type: actionConstants.SET_USE_BLOCKIE,
|
|
||||||
value: true,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(state.useBlockie).toStrictEqual(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('updates an arbitrary feature flag', () => {
|
|
||||||
const state = reduceMetamask(
|
|
||||||
{},
|
|
||||||
{
|
|
||||||
type: actionConstants.UPDATE_FEATURE_FLAGS,
|
|
||||||
value: {
|
|
||||||
foo: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(state.featureFlags.foo).toStrictEqual(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('close welcome screen', () => {
|
it('close welcome screen', () => {
|
||||||
const state = reduceMetamask(
|
const state = reduceMetamask(
|
||||||
{},
|
{},
|
||||||
|
@ -1,36 +1,8 @@
|
|||||||
import freeze from 'deep-freeze-strict';
|
import freeze from 'deep-freeze-strict';
|
||||||
import reducers from '../ducks';
|
import reducers from '../ducks';
|
||||||
import { NETWORK_TYPES } from '../../shared/constants/network';
|
|
||||||
import * as actionConstants from './actionConstants';
|
import * as actionConstants from './actionConstants';
|
||||||
|
|
||||||
describe('Redux actionConstants', () => {
|
describe('Redux actionConstants', () => {
|
||||||
describe('SET_RPC_TARGET', () => {
|
|
||||||
const initialState = {
|
|
||||||
metamask: {
|
|
||||||
frequentRpcList: [],
|
|
||||||
provider: {
|
|
||||||
rpcUrl: 'bar',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
appState: {
|
|
||||||
currentView: {
|
|
||||||
name: 'accounts',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
freeze(initialState);
|
|
||||||
it('sets the state.metamask.rpcUrl property of the state to the action.value', () => {
|
|
||||||
const action = {
|
|
||||||
type: actionConstants.SET_RPC_TARGET,
|
|
||||||
value: 'foo',
|
|
||||||
};
|
|
||||||
|
|
||||||
const result = reducers(initialState, action);
|
|
||||||
expect(result.metamask.provider.type).toStrictEqual(NETWORK_TYPES.RPC);
|
|
||||||
expect(result.metamask.provider.rpcUrl).toStrictEqual('foo');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('SET_ACCOUNT_LABEL', () => {
|
describe('SET_ACCOUNT_LABEL', () => {
|
||||||
it('updates the state.metamask.identities[:i].name property of the state to the action.value.label', () => {
|
it('updates the state.metamask.identities[:i].name property of the state to the action.value.label', () => {
|
||||||
const initialState = {
|
const initialState = {
|
||||||
@ -59,23 +31,4 @@ describe('Redux actionConstants', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('SHOW_ACCOUNT_DETAIL', () => {
|
|
||||||
it('updates metamask state', () => {
|
|
||||||
const initialState = {
|
|
||||||
metamask: {},
|
|
||||||
};
|
|
||||||
freeze(initialState);
|
|
||||||
|
|
||||||
const action = {
|
|
||||||
type: actionConstants.SHOW_ACCOUNT_DETAIL,
|
|
||||||
value: 'bar',
|
|
||||||
};
|
|
||||||
freeze(action);
|
|
||||||
|
|
||||||
const resultingState = reducers(initialState, action);
|
|
||||||
expect(resultingState.metamask.isUnlocked).toStrictEqual(true);
|
|
||||||
expect(resultingState.metamask.isInitialized).toStrictEqual(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -28,7 +28,6 @@ export const DISPLAY_WARNING = 'DISPLAY_WARNING';
|
|||||||
export const HIDE_WARNING = 'HIDE_WARNING';
|
export const HIDE_WARNING = 'HIDE_WARNING';
|
||||||
export const CAPTURE_SINGLE_EXCEPTION = 'CAPTURE_SINGLE_EXCEPTION';
|
export const CAPTURE_SINGLE_EXCEPTION = 'CAPTURE_SINGLE_EXCEPTION';
|
||||||
// accounts screen
|
// accounts screen
|
||||||
export const SHOW_ACCOUNT_DETAIL = 'SHOW_ACCOUNT_DETAIL';
|
|
||||||
export const SHOW_ACCOUNTS_PAGE = 'SHOW_ACCOUNTS_PAGE';
|
export const SHOW_ACCOUNTS_PAGE = 'SHOW_ACCOUNTS_PAGE';
|
||||||
export const SHOW_CONF_TX_PAGE = 'SHOW_CONF_TX_PAGE';
|
export const SHOW_CONF_TX_PAGE = 'SHOW_CONF_TX_PAGE';
|
||||||
// account detail screen
|
// account detail screen
|
||||||
@ -42,8 +41,6 @@ export const TRANSACTION_ERROR = 'TRANSACTION_ERROR';
|
|||||||
export const UPDATE_TRANSACTION_PARAMS = 'UPDATE_TRANSACTION_PARAMS';
|
export const UPDATE_TRANSACTION_PARAMS = 'UPDATE_TRANSACTION_PARAMS';
|
||||||
export const SET_NEXT_NONCE = 'SET_NEXT_NONCE';
|
export const SET_NEXT_NONCE = 'SET_NEXT_NONCE';
|
||||||
// config screen
|
// config screen
|
||||||
export const SET_RPC_TARGET = 'SET_RPC_TARGET';
|
|
||||||
export const SET_PROVIDER_TYPE = 'SET_PROVIDER_TYPE';
|
|
||||||
export const SET_HARDWARE_WALLET_DEFAULT_HD_PATH =
|
export const SET_HARDWARE_WALLET_DEFAULT_HD_PATH =
|
||||||
'SET_HARDWARE_WALLET_DEFAULT_HD_PATH';
|
'SET_HARDWARE_WALLET_DEFAULT_HD_PATH';
|
||||||
// loading overlay
|
// loading overlay
|
||||||
@ -55,22 +52,13 @@ export const BUY = 'BUY';
|
|||||||
export const TOGGLE_ACCOUNT_MENU = 'TOGGLE_ACCOUNT_MENU';
|
export const TOGGLE_ACCOUNT_MENU = 'TOGGLE_ACCOUNT_MENU';
|
||||||
|
|
||||||
// preferences
|
// preferences
|
||||||
export const SET_USE_BLOCKIE = 'SET_USE_BLOCKIE';
|
|
||||||
export const SET_USE_NONCEFIELD = 'SET_USE_NONCEFIELD';
|
|
||||||
export const UPDATE_CUSTOM_NONCE = 'UPDATE_CUSTOM_NONCE';
|
export const UPDATE_CUSTOM_NONCE = 'UPDATE_CUSTOM_NONCE';
|
||||||
export const SET_IPFS_GATEWAY = 'SET_IPFS_GATEWAY';
|
|
||||||
|
|
||||||
export const SET_PARTICIPATE_IN_METAMETRICS = 'SET_PARTICIPATE_IN_METAMETRICS';
|
export const SET_PARTICIPATE_IN_METAMETRICS = 'SET_PARTICIPATE_IN_METAMETRICS';
|
||||||
|
|
||||||
// locale
|
// locale
|
||||||
export const SET_CURRENT_LOCALE = 'SET_CURRENT_LOCALE';
|
export const SET_CURRENT_LOCALE = 'SET_CURRENT_LOCALE';
|
||||||
|
|
||||||
// Feature Flags
|
|
||||||
export const UPDATE_FEATURE_FLAGS = 'UPDATE_FEATURE_FLAGS';
|
|
||||||
|
|
||||||
// Preferences
|
|
||||||
export const UPDATE_PREFERENCES = 'UPDATE_PREFERENCES';
|
|
||||||
|
|
||||||
// Onboarding
|
// Onboarding
|
||||||
export const COMPLETE_ONBOARDING = 'COMPLETE_ONBOARDING';
|
export const COMPLETE_ONBOARDING = 'COMPLETE_ONBOARDING';
|
||||||
export const ONBOARDED_IN_THIS_UI_SESSION = 'ONBOARDED_IN_THIS_UI_SESSION';
|
export const ONBOARDED_IN_THIS_UI_SESSION = 'ONBOARDED_IN_THIS_UI_SESSION';
|
||||||
@ -98,9 +86,6 @@ export const SET_NEW_CUSTOM_NETWORK_ADDED = 'SET_NEW_CUSTOM_NETWORK_ADDED';
|
|||||||
export const LOADING_METHOD_DATA_STARTED = 'LOADING_METHOD_DATA_STARTED';
|
export const LOADING_METHOD_DATA_STARTED = 'LOADING_METHOD_DATA_STARTED';
|
||||||
export const LOADING_METHOD_DATA_FINISHED = 'LOADING_METHOD_DATA_FINISHED';
|
export const LOADING_METHOD_DATA_FINISHED = 'LOADING_METHOD_DATA_FINISHED';
|
||||||
|
|
||||||
export const LOADING_TOKEN_PARAMS_STARTED = 'LOADING_TOKEN_PARAMS_STARTED';
|
|
||||||
export const LOADING_TOKEN_PARAMS_FINISHED = 'LOADING_TOKEN_PARAMS_FINISHED';
|
|
||||||
|
|
||||||
export const SET_REQUEST_ACCOUNT_TABS = 'SET_REQUEST_ACCOUNT_TABS';
|
export const SET_REQUEST_ACCOUNT_TABS = 'SET_REQUEST_ACCOUNT_TABS';
|
||||||
export const SET_CURRENT_WINDOW_TAB = 'SET_CURRENT_WINDOW_TAB';
|
export const SET_CURRENT_WINDOW_TAB = 'SET_CURRENT_WINDOW_TAB';
|
||||||
export const SET_OPEN_METAMASK_TAB_IDS = 'SET_OPEN_METAMASK_TAB_IDS';
|
export const SET_OPEN_METAMASK_TAB_IDS = 'SET_OPEN_METAMASK_TAB_IDS';
|
||||||
|
@ -335,12 +335,6 @@ export function importNewAccount(strategy, args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dispatch(updateMetamaskState(newState));
|
dispatch(updateMetamaskState(newState));
|
||||||
if (newState.selectedAddress) {
|
|
||||||
dispatch({
|
|
||||||
type: actionConstants.SHOW_ACCOUNT_DETAIL,
|
|
||||||
value: newState.selectedAddress,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return newState;
|
return newState;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -1574,7 +1568,7 @@ export function setSelectedAddress(address) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function showAccountDetail(address) {
|
export function setSelectedAccount(address) {
|
||||||
return async (dispatch, getState) => {
|
return async (dispatch, getState) => {
|
||||||
dispatch(showLoadingIndication());
|
dispatch(showLoadingIndication());
|
||||||
log.debug(`background.setSelectedAddress`);
|
log.debug(`background.setSelectedAddress`);
|
||||||
@ -1606,10 +1600,6 @@ export function showAccountDetail(address) {
|
|||||||
dispatch(hideLoadingIndication());
|
dispatch(hideLoadingIndication());
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch({
|
|
||||||
type: actionConstants.SHOW_ACCOUNT_DETAIL,
|
|
||||||
value: address,
|
|
||||||
});
|
|
||||||
if (
|
if (
|
||||||
unconnectedAccountAccountAlertIsEnabled &&
|
unconnectedAccountAccountAlertIsEnabled &&
|
||||||
switchingToUnconnectedAddress
|
switchingToUnconnectedAddress
|
||||||
@ -2076,16 +2066,7 @@ export function setProviderType(type) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(error);
|
log.error(error);
|
||||||
dispatch(displayWarning('Had a problem changing networks!'));
|
dispatch(displayWarning('Had a problem changing networks!'));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
dispatch(updateProviderType(type));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function updateProviderType(type) {
|
|
||||||
return {
|
|
||||||
type: actionConstants.SET_PROVIDER_TYPE,
|
|
||||||
value: type,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2112,13 +2093,7 @@ export function updateAndSetCustomRpc(
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(error);
|
log.error(error);
|
||||||
dispatch(displayWarning('Had a problem changing networks!'));
|
dispatch(displayWarning('Had a problem changing networks!'));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch({
|
|
||||||
type: actionConstants.SET_RPC_TARGET,
|
|
||||||
value: newRpc,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2151,13 +2126,7 @@ export function editRpc(
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(error);
|
log.error(error);
|
||||||
dispatch(displayWarning('Had a problem changing networks!'));
|
dispatch(displayWarning('Had a problem changing networks!'));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch({
|
|
||||||
type: actionConstants.SET_RPC_TARGET,
|
|
||||||
value: newRpc,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2516,7 +2485,6 @@ export function setFeatureFlag(feature, activated, notificationType) {
|
|||||||
reject(err);
|
reject(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dispatch(updateFeatureFlags(updatedFeatureFlags));
|
|
||||||
notificationType && dispatch(showModal({ name: notificationType }));
|
notificationType && dispatch(showModal({ name: notificationType }));
|
||||||
resolve(updatedFeatureFlags);
|
resolve(updatedFeatureFlags);
|
||||||
},
|
},
|
||||||
@ -2525,13 +2493,6 @@ export function setFeatureFlag(feature, activated, notificationType) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateFeatureFlags(updatedFeatureFlags) {
|
|
||||||
return {
|
|
||||||
type: actionConstants.UPDATE_FEATURE_FLAGS,
|
|
||||||
value: updatedFeatureFlags,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function setPreference(preference, value) {
|
export function setPreference(preference, value) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(showLoadingIndication());
|
dispatch(showLoadingIndication());
|
||||||
@ -2547,8 +2508,6 @@ export function setPreference(preference, value) {
|
|||||||
reject(err);
|
reject(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch(updatePreferences(updatedPreferences));
|
|
||||||
resolve(updatedPreferences);
|
resolve(updatedPreferences);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -2556,13 +2515,6 @@ export function setPreference(preference, value) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updatePreferences(value) {
|
|
||||||
return {
|
|
||||||
type: actionConstants.UPDATE_PREFERENCES,
|
|
||||||
value,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function setDefaultHomeActiveTabName(value) {
|
export function setDefaultHomeActiveTabName(value) {
|
||||||
return async (dispatch) => {
|
return async (dispatch) => {
|
||||||
await submitRequestToBackground('setDefaultHomeActiveTabName', [value]);
|
await submitRequestToBackground('setDefaultHomeActiveTabName', [value]);
|
||||||
@ -2676,10 +2628,6 @@ export function setUseBlockie(val) {
|
|||||||
dispatch(displayWarning(err.message));
|
dispatch(displayWarning(err.message));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dispatch({
|
|
||||||
type: actionConstants.SET_USE_BLOCKIE,
|
|
||||||
value: val,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2693,10 +2641,6 @@ export function setUseNonceField(val) {
|
|||||||
dispatch(displayWarning(error.message));
|
dispatch(displayWarning(error.message));
|
||||||
}
|
}
|
||||||
dispatch(hideLoadingIndication());
|
dispatch(hideLoadingIndication());
|
||||||
dispatch({
|
|
||||||
type: actionConstants.SET_USE_NONCEFIELD,
|
|
||||||
value: val,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2819,11 +2763,6 @@ export function setIpfsGateway(val) {
|
|||||||
callBackgroundMethod('setIpfsGateway', [val], (err) => {
|
callBackgroundMethod('setIpfsGateway', [val], (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
dispatch(displayWarning(err.message));
|
dispatch(displayWarning(err.message));
|
||||||
} else {
|
|
||||||
dispatch({
|
|
||||||
type: actionConstants.SET_IPFS_GATEWAY,
|
|
||||||
value: val,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -3282,18 +3221,6 @@ export function setOutdatedBrowserWarningLastShown(lastShown) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loadingMethodDataStarted() {
|
|
||||||
return {
|
|
||||||
type: actionConstants.LOADING_METHOD_DATA_STARTED,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function loadingMethodDataFinished() {
|
|
||||||
return {
|
|
||||||
type: actionConstants.LOADING_METHOD_DATA_FINISHED,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getContractMethodData(data = '') {
|
export function getContractMethodData(data = '') {
|
||||||
return async (dispatch, getState) => {
|
return async (dispatch, getState) => {
|
||||||
const prefixedData = addHexPrefix(data);
|
const prefixedData = addHexPrefix(data);
|
||||||
@ -3310,12 +3237,10 @@ export function getContractMethodData(data = '') {
|
|||||||
return knownMethodData[fourBytePrefix];
|
return knownMethodData[fourBytePrefix];
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch(loadingMethodDataStarted());
|
|
||||||
log.debug(`loadingMethodData`);
|
log.debug(`loadingMethodData`);
|
||||||
|
|
||||||
const { name, params } = await getMethodDataAsync(fourBytePrefix);
|
const { name, params } = await getMethodDataAsync(fourBytePrefix);
|
||||||
|
|
||||||
dispatch(loadingMethodDataFinished());
|
|
||||||
callBackgroundMethod(
|
callBackgroundMethod(
|
||||||
'addKnownMethodData',
|
'addKnownMethodData',
|
||||||
[fourBytePrefix, { name, params }],
|
[fourBytePrefix, { name, params }],
|
||||||
@ -3329,18 +3254,6 @@ export function getContractMethodData(data = '') {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loadingTokenParamsStarted() {
|
|
||||||
return {
|
|
||||||
type: actionConstants.LOADING_TOKEN_PARAMS_STARTED,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function loadingTokenParamsFinished() {
|
|
||||||
return {
|
|
||||||
type: actionConstants.LOADING_TOKEN_PARAMS_FINISHED,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function setSeedPhraseBackedUp(seedPhraseBackupState) {
|
export function setSeedPhraseBackedUp(seedPhraseBackupState) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
log.debug(`background.setSeedPhraseBackedUp`);
|
log.debug(`background.setSeedPhraseBackedUp`);
|
||||||
|
@ -986,12 +986,12 @@ describe('Actions', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#showAccountDetail', () => {
|
describe('#setSelectedAccount', () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
sinon.restore();
|
sinon.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('#showAccountDetail', async () => {
|
it('#setSelectedAccount', async () => {
|
||||||
const store = mockStore({
|
const store = mockStore({
|
||||||
activeTab: {},
|
activeTab: {},
|
||||||
metamask: { alertEnabledness: {}, selectedAddress: '0x123' },
|
metamask: { alertEnabledness: {}, selectedAddress: '0x123' },
|
||||||
@ -1005,7 +1005,7 @@ describe('Actions', () => {
|
|||||||
|
|
||||||
_setBackgroundConnection(background.getApi());
|
_setBackgroundConnection(background.getApi());
|
||||||
|
|
||||||
await store.dispatch(actions.showAccountDetail());
|
await store.dispatch(actions.setSelectedAccount());
|
||||||
expect(setSelectedAddressSpy.callCount).toStrictEqual(1);
|
expect(setSelectedAddressSpy.callCount).toStrictEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1031,7 +1031,7 @@ describe('Actions', () => {
|
|||||||
{ type: 'HIDE_LOADING_INDICATION' },
|
{ type: 'HIDE_LOADING_INDICATION' },
|
||||||
];
|
];
|
||||||
|
|
||||||
await store.dispatch(actions.showAccountDetail());
|
await store.dispatch(actions.setSelectedAccount());
|
||||||
expect(store.getActions()).toStrictEqual(expectedActions);
|
expect(store.getActions()).toStrictEqual(expectedActions);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1520,7 +1520,6 @@ describe('Actions', () => {
|
|||||||
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
|
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
|
||||||
{ type: 'HIDE_LOADING_INDICATION' },
|
{ type: 'HIDE_LOADING_INDICATION' },
|
||||||
{ type: 'DISPLAY_WARNING', value: 'error' },
|
{ type: 'DISPLAY_WARNING', value: 'error' },
|
||||||
{ type: 'SET_USE_BLOCKIE', value: undefined },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
await store.dispatch(actions.setUseBlockie());
|
await store.dispatch(actions.setUseBlockie());
|
||||||
|
Loading…
Reference in New Issue
Block a user