2021-02-04 19:15:23 +01:00
|
|
|
import * as actionConstants from '../../store/actionConstants';
|
2021-04-28 21:53:59 +02:00
|
|
|
import { ALERT_TYPES } from '../../../shared/constants/alerts';
|
|
|
|
import { NETWORK_TYPE_RPC } from '../../../shared/constants/network';
|
2016-04-14 00:28:44 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export default function reduceMetamask(state = {}, action) {
|
2020-08-19 18:27:05 +02:00
|
|
|
const metamaskState = {
|
2016-04-14 00:28:44 +02:00
|
|
|
isInitialized: false,
|
|
|
|
isUnlocked: false,
|
2017-10-16 07:28:25 +02:00
|
|
|
isAccountMenuOpen: false,
|
2016-04-14 00:28:44 +02:00
|
|
|
identities: {},
|
2017-01-28 01:11:59 +01:00
|
|
|
unapprovedTxs: {},
|
2017-03-08 01:01:51 +01:00
|
|
|
frequentRpcList: [],
|
2017-03-09 22:58:42 +01:00
|
|
|
addressBook: [],
|
2018-04-16 05:37:42 +02:00
|
|
|
contractExchangeRates: {},
|
2017-10-03 19:25:52 +02:00
|
|
|
tokens: [],
|
2018-05-20 08:04:19 +02:00
|
|
|
pendingTokens: {},
|
2019-09-27 06:30:36 +02:00
|
|
|
customNonceValue: '',
|
2017-10-12 18:42:14 +02:00
|
|
|
send: {
|
|
|
|
gasLimit: null,
|
|
|
|
gasPrice: null,
|
2017-10-17 19:22:23 +02:00
|
|
|
gasTotal: null,
|
2018-11-20 01:06:34 +01:00
|
|
|
tokenBalance: '0x0',
|
2017-10-17 19:22:23 +02:00
|
|
|
from: '',
|
|
|
|
to: '',
|
2019-02-25 19:16:23 +01:00
|
|
|
amount: '0',
|
2017-10-17 19:22:23 +02:00
|
|
|
memo: '',
|
2017-10-17 22:13:20 +02:00
|
|
|
errors: {},
|
2017-11-16 19:14:25 +01:00
|
|
|
maxModeOn: false,
|
2017-11-08 17:44:48 +01:00
|
|
|
editingTransactionId: null,
|
2018-03-26 15:30:54 +02:00
|
|
|
toNickname: '',
|
2019-07-31 21:56:44 +02:00
|
|
|
ensResolution: null,
|
|
|
|
ensResolutionError: '',
|
2017-10-12 18:42:14 +02:00
|
|
|
},
|
2017-11-24 02:33:44 +01:00
|
|
|
useBlockie: false,
|
2017-11-14 17:04:55 +01:00
|
|
|
featureFlags: {},
|
2018-03-08 18:31:21 +01:00
|
|
|
welcomeScreenSeen: false,
|
2018-03-23 17:59:59 +01:00
|
|
|
currentLocale: '',
|
2018-10-17 01:03:29 +02:00
|
|
|
preferences: {
|
2020-05-13 16:53:00 +02:00
|
|
|
autoLockTimeLimit: undefined,
|
2019-02-26 19:30:41 +01:00
|
|
|
showFiatInTestnets: false,
|
2020-05-13 16:53:00 +02:00
|
|
|
useNativeCurrencyAsPrimaryCurrency: true,
|
2018-10-17 01:03:29 +02:00
|
|
|
},
|
2019-03-05 16:45:01 +01:00
|
|
|
firstTimeFlowType: null,
|
2019-01-23 16:25:34 +01:00
|
|
|
completedOnboarding: false,
|
2019-01-22 19:22:56 +01:00
|
|
|
knownMethodData: {},
|
2019-03-05 16:45:01 +01:00
|
|
|
participateInMetaMetrics: null,
|
|
|
|
metaMetricsSendCount: 0,
|
2019-09-27 06:30:36 +02:00
|
|
|
nextNonce: null,
|
2020-08-19 18:27:05 +02:00
|
|
|
...state,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2016-04-14 00:28:44 +02:00
|
|
|
|
|
|
|
switch (action.type) {
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.UPDATE_METAMASK_STATE:
|
2021-02-04 19:15:23 +01:00
|
|
|
return { ...metamaskState, ...action.value };
|
2016-06-21 22:18:32 +02:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.LOCK_METAMASK:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2016-06-21 22:18:32 +02:00
|
|
|
isUnlocked: false,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2016-06-21 22:18:32 +02:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.SET_RPC_TARGET:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2016-06-21 22:18:32 +02:00
|
|
|
provider: {
|
2021-01-20 17:49:05 +01:00
|
|
|
type: NETWORK_TYPE_RPC,
|
2020-10-06 19:57:02 +02:00
|
|
|
rpcUrl: action.value,
|
2016-06-21 22:18:32 +02:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2016-06-21 22:18:32 +02:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.SET_PROVIDER_TYPE:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2016-06-21 22:18:32 +02:00
|
|
|
provider: {
|
|
|
|
type: action.value,
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2016-06-21 22:18:32 +02:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.SHOW_ACCOUNT_DETAIL:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2016-06-21 22:18:32 +02:00
|
|
|
isUnlocked: true,
|
|
|
|
isInitialized: true,
|
2017-01-31 00:08:31 +01:00
|
|
|
selectedAddress: action.value,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2016-06-21 22:18:32 +02:00
|
|
|
|
2020-08-12 18:41:27 +02:00
|
|
|
case actionConstants.SET_ACCOUNT_LABEL: {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { account } = action.value;
|
|
|
|
const name = action.value.label;
|
|
|
|
const id = {};
|
|
|
|
id[account] = { ...metamaskState.identities[account], name };
|
|
|
|
const identities = { ...metamaskState.identities, ...id };
|
|
|
|
return Object.assign(metamaskState, { identities });
|
2020-08-12 18:41:27 +02:00
|
|
|
}
|
2016-06-21 22:18:32 +02:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.SET_CURRENT_FIAT:
|
2020-01-13 17:29:21 +01:00
|
|
|
return Object.assign(metamaskState, {
|
2017-03-15 01:06:16 +01:00
|
|
|
currentCurrency: action.value.currentCurrency,
|
2016-07-21 19:15:34 +02:00
|
|
|
conversionRate: action.value.conversionRate,
|
2016-07-21 23:08:26 +02:00
|
|
|
conversionDate: action.value.conversionDate,
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2016-07-21 19:15:34 +02:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.UPDATE_TOKENS:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2017-10-03 19:25:52 +02:00
|
|
|
tokens: action.newTokens,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2017-10-03 19:25:52 +02:00
|
|
|
|
2017-10-17 19:22:23 +02:00
|
|
|
// metamask.send
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.UPDATE_GAS_LIMIT:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2017-10-12 18:42:14 +02:00
|
|
|
send: {
|
|
|
|
...metamaskState.send,
|
|
|
|
gasLimit: action.value,
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.UPDATE_CUSTOM_NONCE:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2019-09-27 06:30:36 +02:00
|
|
|
customNonceValue: action.value,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.UPDATE_GAS_PRICE:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2017-10-12 18:42:14 +02:00
|
|
|
send: {
|
|
|
|
...metamaskState.send,
|
|
|
|
gasPrice: action.value,
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2017-10-12 18:42:14 +02:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.TOGGLE_ACCOUNT_MENU:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2017-10-16 07:28:25 +02:00
|
|
|
isAccountMenuOpen: !metamaskState.isAccountMenuOpen,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2017-10-16 07:28:25 +02:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.UPDATE_GAS_TOTAL:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2017-10-17 19:22:23 +02:00
|
|
|
send: {
|
|
|
|
...metamaskState.send,
|
|
|
|
gasTotal: action.value,
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2017-10-17 19:22:23 +02:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.UPDATE_SEND_TOKEN_BALANCE:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2017-10-30 18:48:50 +01:00
|
|
|
send: {
|
|
|
|
...metamaskState.send,
|
|
|
|
tokenBalance: action.value,
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2017-10-30 18:48:50 +01:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.UPDATE_SEND_HEX_DATA:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2018-07-17 00:31:36 +02:00
|
|
|
send: {
|
|
|
|
...metamaskState.send,
|
|
|
|
data: action.value,
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-07-17 00:31:36 +02:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.UPDATE_SEND_TO:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2017-10-17 19:22:23 +02:00
|
|
|
send: {
|
|
|
|
...metamaskState.send,
|
2018-03-26 15:30:54 +02:00
|
|
|
to: action.value.to,
|
|
|
|
toNickname: action.value.nickname,
|
2017-10-17 19:22:23 +02:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2017-10-17 19:22:23 +02:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.UPDATE_SEND_AMOUNT:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2017-10-17 19:22:23 +02:00
|
|
|
send: {
|
|
|
|
...metamaskState.send,
|
|
|
|
amount: action.value,
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2017-10-17 19:22:23 +02:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.UPDATE_MAX_MODE:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2017-11-16 19:14:25 +01:00
|
|
|
send: {
|
|
|
|
...metamaskState.send,
|
|
|
|
maxModeOn: action.value,
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2017-11-16 19:14:25 +01:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.UPDATE_SEND:
|
2020-01-13 17:29:21 +01:00
|
|
|
return Object.assign(metamaskState, {
|
2017-11-10 04:49:16 +01:00
|
|
|
send: {
|
|
|
|
...metamaskState.send,
|
|
|
|
...action.value,
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-07-31 21:56:44 +02:00
|
|
|
|
2020-08-12 18:41:27 +02:00
|
|
|
case actionConstants.UPDATE_SEND_TOKEN: {
|
2020-06-01 19:54:32 +02:00
|
|
|
const newSend = {
|
|
|
|
...metamaskState.send,
|
|
|
|
token: action.value,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-06-01 19:54:32 +02:00
|
|
|
// erase token-related state when switching back to native currency
|
|
|
|
if (newSend.editingTransactionId && !newSend.token) {
|
2020-11-03 00:41:28 +01:00
|
|
|
const unapprovedTx =
|
2021-02-04 19:15:23 +01:00
|
|
|
newSend?.unapprovedTxs?.[newSend.editingTransactionId] || {};
|
|
|
|
const txParams = unapprovedTx.txParams || {};
|
2020-06-01 19:54:32 +02:00
|
|
|
Object.assign(newSend, {
|
|
|
|
tokenBalance: null,
|
|
|
|
balance: '0',
|
|
|
|
from: unapprovedTx.from || '',
|
|
|
|
unapprovedTxs: {
|
|
|
|
...newSend.unapprovedTxs,
|
|
|
|
[newSend.editingTransactionId]: {
|
|
|
|
...unapprovedTx,
|
|
|
|
txParams: {
|
|
|
|
...txParams,
|
|
|
|
data: '',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-06-01 19:54:32 +02:00
|
|
|
}
|
|
|
|
return Object.assign(metamaskState, {
|
|
|
|
send: newSend,
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-08-12 18:41:27 +02:00
|
|
|
}
|
2020-06-01 19:54:32 +02:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.UPDATE_SEND_ENS_RESOLUTION:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2019-07-31 21:56:44 +02:00
|
|
|
send: {
|
|
|
|
...metamaskState.send,
|
|
|
|
ensResolution: action.payload,
|
|
|
|
ensResolutionError: '',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-07-31 21:56:44 +02:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.UPDATE_SEND_ENS_RESOLUTION_ERROR:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2019-07-31 21:56:44 +02:00
|
|
|
send: {
|
|
|
|
...metamaskState.send,
|
|
|
|
ensResolution: null,
|
|
|
|
ensResolutionError: action.payload,
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2017-11-10 04:49:16 +01:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.CLEAR_SEND:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2017-10-21 04:05:22 +02:00
|
|
|
send: {
|
|
|
|
gasLimit: null,
|
|
|
|
gasPrice: null,
|
|
|
|
gasTotal: null,
|
2017-11-10 04:49:16 +01:00
|
|
|
tokenBalance: null,
|
2017-10-21 04:05:22 +02:00
|
|
|
from: '',
|
|
|
|
to: '',
|
|
|
|
amount: '0x0',
|
|
|
|
memo: '',
|
|
|
|
errors: {},
|
2018-10-10 10:12:25 +02:00
|
|
|
maxModeOn: false,
|
2017-11-10 04:49:16 +01:00
|
|
|
editingTransactionId: null,
|
2018-10-10 10:12:25 +02:00
|
|
|
toNickname: '',
|
2017-10-21 04:05:22 +02:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2017-10-21 04:05:22 +02:00
|
|
|
|
2020-08-12 18:41:27 +02:00
|
|
|
case actionConstants.UPDATE_TRANSACTION_PARAMS: {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { id: txId, value } = action;
|
|
|
|
let { currentNetworkTxList } = metamaskState;
|
2020-03-06 22:34:56 +01:00
|
|
|
currentNetworkTxList = currentNetworkTxList.map((tx) => {
|
2017-11-08 20:18:27 +01:00
|
|
|
if (tx.id === txId) {
|
2021-02-04 19:15:23 +01:00
|
|
|
const newTx = { ...tx };
|
|
|
|
newTx.txParams = value;
|
|
|
|
return newTx;
|
2017-11-08 17:44:48 +01:00
|
|
|
}
|
2021-02-04 19:15:23 +01:00
|
|
|
return tx;
|
|
|
|
});
|
2017-11-08 17:44:48 +01:00
|
|
|
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2020-03-06 22:34:56 +01:00
|
|
|
currentNetworkTxList,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-08-12 18:41:27 +02:00
|
|
|
}
|
2017-11-08 17:44:48 +01:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.SET_PARTICIPATE_IN_METAMETRICS:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2019-03-05 16:45:01 +01:00
|
|
|
participateInMetaMetrics: action.value,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-03-05 16:45:01 +01:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.SET_METAMETRICS_SEND_COUNT:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2019-03-05 16:45:01 +01:00
|
|
|
metaMetricsSendCount: action.value,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-03-05 16:45:01 +01:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.SET_USE_BLOCKIE:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2018-10-10 10:12:25 +02:00
|
|
|
useBlockie: action.value,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2017-11-24 02:33:44 +01:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.UPDATE_FEATURE_FLAGS:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2017-11-14 17:04:55 +01:00
|
|
|
featureFlags: action.value,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2017-11-14 17:04:55 +01:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.CLOSE_WELCOME_SCREEN:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2018-03-08 18:31:21 +01:00
|
|
|
welcomeScreenSeen: true,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-03-08 18:31:21 +01:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.SET_CURRENT_LOCALE:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2019-09-06 15:47:07 +02:00
|
|
|
currentLocale: action.value.locale,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-03-16 01:29:45 +01:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.SET_PENDING_TOKENS:
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2018-05-20 08:04:19 +02:00
|
|
|
pendingTokens: { ...action.payload },
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-05-20 08:04:19 +02:00
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.CLEAR_PENDING_TOKENS: {
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2018-05-20 08:04:19 +02:00
|
|
|
pendingTokens: {},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-05-20 08:04:19 +02:00
|
|
|
}
|
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.UPDATE_PREFERENCES: {
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2019-02-26 19:30:41 +01:00
|
|
|
preferences: {
|
|
|
|
...metamaskState.preferences,
|
|
|
|
...action.payload,
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-10-17 01:03:29 +02:00
|
|
|
}
|
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.COMPLETE_ONBOARDING: {
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2019-01-23 16:25:34 +01:00
|
|
|
completedOnboarding: true,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-01-23 16:25:34 +01:00
|
|
|
}
|
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.SET_FIRST_TIME_FLOW_TYPE: {
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2019-03-05 16:45:01 +01:00
|
|
|
firstTimeFlowType: action.value,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-03-05 16:45:01 +01:00
|
|
|
}
|
|
|
|
|
2020-04-09 02:35:37 +02:00
|
|
|
case actionConstants.SET_NEXT_NONCE: {
|
2020-01-13 17:29:21 +01:00
|
|
|
return {
|
|
|
|
...metamaskState,
|
2019-09-27 06:30:36 +02:00
|
|
|
nextNonce: action.value,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-09-27 06:30:36 +02:00
|
|
|
}
|
|
|
|
|
2016-06-21 22:18:32 +02:00
|
|
|
default:
|
2021-02-04 19:15:23 +01:00
|
|
|
return metamaskState;
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
}
|
2020-03-23 18:07:05 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
export const getCurrentLocale = (state) => state.metamask.currentLocale;
|
2020-05-08 21:45:52 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
export const getAlertEnabledness = (state) => state.metamask.alertEnabledness;
|
2020-05-08 21:45:52 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export const getUnconnectedAccountAlertEnabledness = (state) =>
|
2021-02-04 19:15:23 +01:00
|
|
|
getAlertEnabledness(state)[ALERT_TYPES.unconnectedAccount];
|
2020-05-12 15:01:52 +02:00
|
|
|
|
2020-12-11 00:40:29 +01:00
|
|
|
export const getWeb3ShimUsageAlertEnabledness = (state) =>
|
2021-02-04 19:15:23 +01:00
|
|
|
getAlertEnabledness(state)[ALERT_TYPES.web3ShimUsage];
|
2020-12-11 00:40:29 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export const getUnconnectedAccountAlertShown = (state) =>
|
2021-02-04 19:15:23 +01:00
|
|
|
state.metamask.unconnectedAccountAlertShownOrigins;
|
2020-05-29 02:43:44 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
export const getTokens = (state) => state.metamask.tokens;
|