diff --git a/ui/pages/swaps/slippage-buttons/index.scss b/ui/pages/swaps/slippage-buttons/index.scss
index f9e2df7bc..fcfab7eb9 100644
--- a/ui/pages/swaps/slippage-buttons/index.scss
+++ b/ui/pages/swaps/slippage-buttons/index.scss
@@ -10,7 +10,6 @@
margin-bottom: 0;
margin-left: auto;
margin-right: auto;
- cursor: pointer;
background: unset;
margin-bottom: 8px;
}
diff --git a/ui/pages/swaps/swaps-gas-customization-modal/swaps-gas-customization-modal.container.js b/ui/pages/swaps/swaps-gas-customization-modal/swaps-gas-customization-modal.container.js
index 15efd88d6..9bcd95717 100644
--- a/ui/pages/swaps/swaps-gas-customization-modal/swaps-gas-customization-modal.container.js
+++ b/ui/pages/swaps/swaps-gas-customization-modal/swaps-gas-customization-modal.container.js
@@ -8,9 +8,9 @@ import {
getDefaultActiveButtonIndex,
getRenderableGasButtonData,
getUSDConversionRate,
- getNativeCurrency,
getSwapsDefaultToken,
} from '../../../selectors';
+import { getNativeCurrency } from '../../../ducks/metamask/metamask';
import {
getSwapsCustomizationModalPrice,
diff --git a/ui/pages/swaps/swaps.util.js b/ui/pages/swaps/swaps.util.js
index e72483f35..58ef33f63 100644
--- a/ui/pages/swaps/swaps.util.js
+++ b/ui/pages/swaps/swaps.util.js
@@ -16,6 +16,7 @@ import {
WETH_SYMBOL,
MAINNET_CHAIN_ID,
} from '../../../shared/constants/network';
+import { SECOND } from '../../../shared/constants/time';
import {
calcTokenValue,
calcTokenAmount,
@@ -47,6 +48,8 @@ const getBaseApi = function (type, chainId = MAINNET_CHAIN_ID) {
return `${METASWAP_CHAINID_API_HOST_MAP[chainId]}/trades?`;
case 'tokens':
return `${METASWAP_CHAINID_API_HOST_MAP[chainId]}/tokens`;
+ case 'token':
+ return `${METASWAP_CHAINID_API_HOST_MAP[chainId]}/token`;
case 'topAssets':
return `${METASWAP_CHAINID_API_HOST_MAP[chainId]}/topAssets`;
case 'featureFlag':
@@ -237,7 +240,7 @@ export async function fetchTradesInfo(
sourceToken,
sourceAmount: calcTokenValue(value, sourceDecimals).toString(10),
slippage,
- timeout: 10000,
+ timeout: SECOND * 10,
walletAddress: fromAddress,
};
@@ -250,7 +253,7 @@ export async function fetchTradesInfo(
const tradesResponse = await fetchWithCache(
tradeURL,
{ method: 'GET' },
- { cacheRefreshTime: 0, timeout: 15000 },
+ { cacheRefreshTime: 0, timeout: SECOND * 15 },
);
const newQuotes = tradesResponse.reduce((aggIdTradeMap, quote) => {
if (
@@ -290,10 +293,20 @@ export async function fetchTradesInfo(
return newQuotes;
}
+export async function fetchToken(contractAddress, chainId) {
+ const tokenUrl = getBaseApi('token', chainId);
+ const token = await fetchWithCache(
+ `${tokenUrl}?address=${contractAddress}`,
+ { method: 'GET' },
+ { cacheRefreshTime: CACHE_REFRESH_FIVE_MINUTES },
+ );
+ return token;
+}
+
export async function fetchTokens(chainId) {
- const tokenUrl = getBaseApi('tokens', chainId);
+ const tokensUrl = getBaseApi('tokens', chainId);
const tokens = await fetchWithCache(
- tokenUrl,
+ tokensUrl,
{ method: 'GET' },
{ cacheRefreshTime: CACHE_REFRESH_FIVE_MINUTES },
);
@@ -301,7 +314,7 @@ export async function fetchTokens(chainId) {
SWAPS_CHAINID_DEFAULT_TOKEN_MAP[chainId],
...tokens.filter((token) => {
return (
- validateData(TOKEN_VALIDATORS, token, tokenUrl) &&
+ validateData(TOKEN_VALIDATORS, token, tokensUrl) &&
!(
isSwapsDefaultTokenSymbol(token.symbol, chainId) ||
isSwapsDefaultTokenAddress(token.address, chainId)
diff --git a/ui/pages/swaps/view-quote/index.scss b/ui/pages/swaps/view-quote/index.scss
index 64d3d59d7..3e2e421bc 100644
--- a/ui/pages/swaps/view-quote/index.scss
+++ b/ui/pages/swaps/view-quote/index.scss
@@ -95,46 +95,53 @@
&-wrapper {
width: 100%;
- &.medium .actionable-message,
- &.fiat-error .actionable-message {
- border-color: $Yellow-500;
- background: $Yellow-100;
+ &.low,
+ &.medium,
+ &.high {
+ .actionable-message {
+ .actionable-message__message {
+ color: inherit;
+ }
- .actionable-message__message {
- color: inherit;
+ button {
+ font-size: $font-size-h8;
+ padding: 4px 12px;
+ border-radius: 42px;
+ }
}
+ }
- button {
- background: $Yellow-500;
- border-radius: 42px;
+ &.low {
+ .actionable-message {
+ button {
+ background: $Blue-500;
+ color: #fff;
+ }
}
}
- &.high {
+ &.medium {
.actionable-message {
- border-color: $Red-500;
- background: $Red-100;
+ border-color: $Yellow-500;
+ background: $Yellow-100;
- .actionable-message__message {
- color: $Red-500;
+ button {
+ background: $Yellow-500;
}
}
+ }
- button {
- background: $Red-500;
- color: #fff;
- border-radius: 42px;
+ &.high {
+ .actionable-message {
+ border-color: $Red-300;
+ background: $Red-000;
- /* Offsets the width of ActionableMessage icon */
- margin-right: -22px;
+ button {
+ background: $Red-500;
+ color: #fff;
+ }
}
}
-
- /* Hides info tooltip if there's a fiat error message */
- &.fiat-error div[data-tooltipped] {
- /* !important overrides style being applied directly to tooltip by component */
- display: none !important;
- }
}
&-contents {
@@ -160,10 +167,9 @@
width: 100%;
align-items: center;
justify-content: center;
- width: intrinsic; /* Safari/WebKit uses a non-standard name */
- width: max-content;
max-width: 340px;
margin-top: 8px;
+ margin-bottom: 28px;
@media screen and (min-width: 576px) {
&--thin {
diff --git a/ui/pages/swaps/view-quote/view-quote-price-difference.js b/ui/pages/swaps/view-quote/view-quote-price-difference.js
index 61d1ad52b..327aaaf49 100644
--- a/ui/pages/swaps/view-quote/view-quote-price-difference.js
+++ b/ui/pages/swaps/view-quote/view-quote-price-difference.js
@@ -6,6 +6,11 @@ import { I18nContext } from '../../../contexts/i18n';
import ActionableMessage from '../actionable-message';
import Tooltip from '../../../components/ui/tooltip';
+import Box from '../../../components/ui/box';
+import {
+ JUSTIFY_CONTENT,
+ DISPLAY,
+} from '../../../helpers/constants/design-system';
export default function ViewQuotePriceDifference(props) {
const {
@@ -28,9 +33,10 @@ export default function ViewQuotePriceDifference(props) {
let priceDifferenceAcknowledgementText = '';
if (priceSlippageUnknownFiatValue) {
// A calculation error signals we cannot determine dollar value
- priceDifferenceMessage = t('swapPriceDifferenceUnavailable');
- priceDifferenceClass = 'fiat-error';
- priceDifferenceAcknowledgementText = t('continue');
+ priceDifferenceTitle = t('swapPriceUnavailableTitle');
+ priceDifferenceMessage = t('swapPriceUnavailableDescription');
+ priceDifferenceClass = 'high';
+ priceDifferenceAcknowledgementText = t('tooltipApproveButton');
} else {
priceDifferenceTitle = t('swapPriceDifferenceTitle', [
priceDifferencePercentage,
@@ -44,9 +50,7 @@ export default function ViewQuotePriceDifference(props) {
priceSlippageFromDestination, // Destination tokens total value
]);
priceDifferenceClass = usedQuote.priceSlippage.bucket;
- priceDifferenceAcknowledgementText = t(
- 'swapPriceDifferenceAcknowledgement',
- );
+ priceDifferenceAcknowledgementText = t('tooltipApproveButton');
}
return (
@@ -60,11 +64,22 @@ export default function ViewQuotePriceDifference(props) {
message={
- {priceDifferenceTitle && (
+
{priceDifferenceTitle}
- )}
+
+
+
+
{priceDifferenceMessage}
{!acknowledged && (
@@ -78,13 +93,6 @@ export default function ViewQuotePriceDifference(props) {
)}
-
-
-
}
/>
diff --git a/ui/pages/swaps/view-quote/view-quote-price-difference.test.js b/ui/pages/swaps/view-quote/view-quote-price-difference.test.js
index f18950464..cd94ab4a0 100644
--- a/ui/pages/swaps/view-quote/view-quote-price-difference.test.js
+++ b/ui/pages/swaps/view-quote/view-quote-price-difference.test.js
@@ -144,6 +144,6 @@ describe('View Price Quote Difference', () => {
'Could not determine price.';
renderComponent(props);
- expect(component.html()).toContain('fiat-error');
+ expect(component.html()).toContain('high');
});
});
diff --git a/ui/pages/swaps/view-quote/view-quote.js b/ui/pages/swaps/view-quote/view-quote.js
index c472f1f40..217de73de 100644
--- a/ui/pages/swaps/view-quote/view-quote.js
+++ b/ui/pages/swaps/view-quote/view-quote.js
@@ -38,12 +38,13 @@ import {
getTokenExchangeRates,
getSwapsDefaultToken,
getCurrentChainId,
- getNativeCurrency,
isHardwareWallet,
getHardwareWalletType,
} from '../../../selectors';
+import { getNativeCurrency, getTokens } from '../../../ducks/metamask/metamask';
+
import { toPrecisionWithoutTrailingZeros } from '../../../helpers/utils/util';
-import { getTokens } from '../../../ducks/metamask/metamask';
+
import {
safeRefetchQuotes,
setCustomApproveTxData,
diff --git a/ui/selectors/confirm-transaction.js b/ui/selectors/confirm-transaction.js
index ba837e8ab..70982d1b1 100644
--- a/ui/selectors/confirm-transaction.js
+++ b/ui/selectors/confirm-transaction.js
@@ -11,8 +11,8 @@ import {
} from '../helpers/utils/confirm-tx.util';
import { sumHexes } from '../helpers/utils/transactions.util';
import { transactionMatchesNetwork } from '../../shared/modules/transaction.utils';
+import { getNativeCurrency } from '../ducks/metamask/metamask';
import { getCurrentChainId, deprecatedGetCurrentNetworkId } from './selectors';
-import { getNativeCurrency } from '.';
const unapprovedTxsSelector = (state) => state.metamask.unapprovedTxs;
const unapprovedMsgsSelector = (state) => state.metamask.unapprovedMsgs;
diff --git a/ui/selectors/custom-gas.js b/ui/selectors/custom-gas.js
index ea64bcbe6..4f905a7fe 100644
--- a/ui/selectors/custom-gas.js
+++ b/ui/selectors/custom-gas.js
@@ -9,6 +9,8 @@ import { formatETHFee } from '../helpers/utils/formatters';
import { calcGasTotal } from '../pages/send/send.utils';
import { GAS_ESTIMATE_TYPES } from '../helpers/constants/common';
+import { BASIC_ESTIMATE_STATES, GAS_SOURCE } from '../ducks/gas/gas.duck';
+import { GAS_LIMITS } from '../../shared/constants/gas';
import {
getCurrentCurrency,
getIsMainnet,
@@ -98,6 +100,28 @@ export function isCustomPriceSafe(state) {
return customPriceSafe;
}
+export function isCustomPriceSafeForCustomNetwork(state) {
+ const estimatedPrice = state.gas.basicEstimates.average;
+
+ const customGasPrice = getCustomGasPrice(state);
+
+ if (!customGasPrice) {
+ return true;
+ }
+
+ const customPriceSafe = conversionGreaterThan(
+ {
+ value: customGasPrice,
+ fromNumericBase: 'hex',
+ fromDenomination: 'WEI',
+ toDenomination: 'GWEI',
+ },
+ { value: estimatedPrice, fromNumericBase: 'dec' },
+ );
+
+ return customPriceSafe;
+}
+
export function isCustomPriceExcessive(state, checkSend = false) {
const customPrice = checkSend ? getGasPrice(state) : getCustomGasPrice(state);
const fastPrice = getFastPriceEstimate(state);
@@ -294,7 +318,7 @@ export function getRenderableEstimateDataForSmallButtonsFromGWEI(state) {
const isMainnet = getIsMainnet(state);
const showFiat = isMainnet || Boolean(showFiatInTestnets);
const gasLimit =
- state.metamask.send.gasLimit || getCustomGasLimit(state) || '0x5208';
+ state.send.gasLimit || getCustomGasLimit(state) || GAS_LIMITS.SIMPLE;
const { conversionRate } = state.metamask;
const currentCurrency = getCurrentCurrency(state);
const {
@@ -361,13 +385,21 @@ export function getRenderableEstimateDataForSmallButtonsFromGWEI(state) {
export function getIsEthGasPriceFetched(state) {
const gasState = state.gas;
return Boolean(
- gasState.estimateSource === 'eth_gasprice' &&
- gasState.basicEstimateStatus === 'READY' &&
+ gasState.estimateSource === GAS_SOURCE.ETHGASPRICE &&
+ gasState.basicEstimateStatus === BASIC_ESTIMATE_STATES.READY &&
getIsMainnet(state),
);
}
export function getNoGasPriceFetched(state) {
const gasState = state.gas;
- return Boolean(gasState.basicEstimateStatus === 'FAILED');
+ return Boolean(gasState.basicEstimateStatus === BASIC_ESTIMATE_STATES.FAILED);
+}
+
+export function getIsGasEstimatesFetched(state) {
+ const gasState = state.gas;
+ return Boolean(
+ gasState.estimateSource === GAS_SOURCE.METASWAPS &&
+ gasState.basicEstimateStatus === BASIC_ESTIMATE_STATES.READY,
+ );
}
diff --git a/ui/selectors/custom-gas.test.js b/ui/selectors/custom-gas.test.js
index 8838641fe..91344b96b 100644
--- a/ui/selectors/custom-gas.test.js
+++ b/ui/selectors/custom-gas.test.js
@@ -1,3 +1,4 @@
+import { GAS_LIMITS } from '../../shared/constants/gas';
import {
getCustomGasLimit,
getCustomGasPrice,
@@ -110,10 +111,8 @@ describe('custom-gas selectors', () => {
});
it('should return false gas.basicEstimates.price 0x28bed01600 (175) (checkSend=true)', () => {
const mockState = {
- metamask: {
- send: {
- gasPrice: '0x28bed0160',
- },
+ send: {
+ gasPrice: '0x28bed0160',
},
gas: {
customData: { price: null },
@@ -124,10 +123,8 @@ describe('custom-gas selectors', () => {
});
it('should return true gas.basicEstimates.price 0x30e4f9b400 (210) (checkSend=true)', () => {
const mockState = {
- metamask: {
- send: {
- gasPrice: '0x30e4f9b400',
- },
+ send: {
+ gasPrice: '0x30e4f9b400',
},
gas: {
customData: { price: null },
@@ -220,9 +217,6 @@ describe('custom-gas selectors', () => {
metamask: {
conversionRate: 2557.1,
currentCurrency: 'usd',
- send: {
- gasLimit: '0x5208',
- },
preferences: {
showFiatInTestnets: false,
},
@@ -231,6 +225,9 @@ describe('custom-gas selectors', () => {
chainId: '0x1',
},
},
+ send: {
+ gasLimit: GAS_LIMITS.SIMPLE,
+ },
gas: {
basicEstimates: {
blockTime: 14.16326530612245,
@@ -271,9 +268,6 @@ describe('custom-gas selectors', () => {
metamask: {
conversionRate: 2557.1,
currentCurrency: 'usd',
- send: {
- gasLimit: '0x5208',
- },
preferences: {
showFiatInTestnets: false,
},
@@ -282,6 +276,9 @@ describe('custom-gas selectors', () => {
chainId: '0x4',
},
},
+ send: {
+ gasLimit: GAS_LIMITS.SIMPLE,
+ },
gas: {
basicEstimates: {
blockTime: 14.16326530612245,
@@ -322,9 +319,6 @@ describe('custom-gas selectors', () => {
metamask: {
conversionRate: 2557.1,
currentCurrency: 'usd',
- send: {
- gasLimit: '0x5208',
- },
preferences: {
showFiatInTestnets: true,
},
@@ -333,6 +327,9 @@ describe('custom-gas selectors', () => {
chainId: '0x4',
},
},
+ send: {
+ gasLimit: GAS_LIMITS.SIMPLE,
+ },
gas: {
basicEstimates: {
safeLow: 5,
@@ -367,9 +364,6 @@ describe('custom-gas selectors', () => {
metamask: {
conversionRate: 2557.1,
currentCurrency: 'usd',
- send: {
- gasLimit: '0x5208',
- },
preferences: {
showFiatInTestnets: true,
},
@@ -378,6 +372,9 @@ describe('custom-gas selectors', () => {
chainId: '0x1',
},
},
+ send: {
+ gasLimit: GAS_LIMITS.SIMPLE,
+ },
gas: {
basicEstimates: {
safeLow: 5,
@@ -393,7 +390,7 @@ describe('custom-gas selectors', () => {
expect(
getRenderableBasicEstimateData(
test.mockState,
- '0x5208',
+ GAS_LIMITS.SIMPLE,
test.useFastestButtons,
),
).toStrictEqual(test.expectedResult);
@@ -428,9 +425,6 @@ describe('custom-gas selectors', () => {
metamask: {
conversionRate: 255.71,
currentCurrency: 'usd',
- send: {
- gasLimit: '0x5208',
- },
preferences: {
showFiatInTestnets: false,
},
@@ -439,6 +433,9 @@ describe('custom-gas selectors', () => {
chainId: '0x1',
},
},
+ send: {
+ gasLimit: GAS_LIMITS.SIMPLE,
+ },
gas: {
basicEstimates: {
safeLow: 25,
@@ -473,9 +470,6 @@ describe('custom-gas selectors', () => {
metamask: {
conversionRate: 2557.1,
currentCurrency: 'usd',
- send: {
- gasLimit: '0x5208',
- },
preferences: {
showFiatInTestnets: false,
},
@@ -484,6 +478,9 @@ describe('custom-gas selectors', () => {
chainId: '0x1',
},
},
+ send: {
+ gasLimit: GAS_LIMITS.SIMPLE,
+ },
gas: {
basicEstimates: {
blockTime: 14.16326530612245,
@@ -524,9 +521,6 @@ describe('custom-gas selectors', () => {
metamask: {
conversionRate: 2557.1,
currentCurrency: 'usd',
- send: {
- gasLimit: '0x5208',
- },
preferences: {
showFiatInTestnets: false,
},
@@ -535,6 +529,9 @@ describe('custom-gas selectors', () => {
chainId: '0x4',
},
},
+ send: {
+ gasLimit: GAS_LIMITS.SIMPLE,
+ },
gas: {
basicEstimates: {
blockTime: 14.16326530612245,
@@ -575,9 +572,6 @@ describe('custom-gas selectors', () => {
metamask: {
conversionRate: 2557.1,
currentCurrency: 'usd',
- send: {
- gasLimit: '0x5208',
- },
preferences: {
showFiatInTestnets: true,
},
@@ -586,6 +580,9 @@ describe('custom-gas selectors', () => {
chainId: '0x4',
},
},
+ send: {
+ gasLimit: GAS_LIMITS.SIMPLE,
+ },
gas: {
basicEstimates: {
safeLow: 50,
@@ -620,9 +617,6 @@ describe('custom-gas selectors', () => {
metamask: {
conversionRate: 2557.1,
currentCurrency: 'usd',
- send: {
- gasLimit: '0x5208',
- },
preferences: {
showFiatInTestnets: true,
},
@@ -631,6 +625,9 @@ describe('custom-gas selectors', () => {
chainId: '0x1',
},
},
+ send: {
+ gasLimit: GAS_LIMITS.SIMPLE,
+ },
gas: {
basicEstimates: {
safeLow: 50,
diff --git a/ui/selectors/selectors.js b/ui/selectors/selectors.js
index 70c249ed1..a41005a7e 100644
--- a/ui/selectors/selectors.js
+++ b/ui/selectors/selectors.js
@@ -23,7 +23,8 @@ import {
import { TEMPLATED_CONFIRMATION_MESSAGE_TYPES } from '../pages/confirmation/templates';
import { toChecksumHexAddress } from '../../shared/modules/hexstring-utils';
-import { getNativeCurrency } from './send';
+import { DAY } from '../../shared/constants/time';
+import { getNativeCurrency } from '../ducks/metamask/metamask';
/**
* One of the only remaining valid uses of selecting the network subkey of the
@@ -563,3 +564,15 @@ export function getSortedNotificationsToShow(state) {
);
return notificationsSortedByDate;
}
+
+export function getShowRecoveryPhraseReminder(state) {
+ const {
+ recoveryPhraseReminderLastShown,
+ recoveryPhraseReminderHasBeenShown,
+ } = state.metamask;
+
+ const currentTime = new Date().getTime();
+ const frequency = recoveryPhraseReminderHasBeenShown ? DAY * 90 : DAY * 2;
+
+ return currentTime - recoveryPhraseReminderLastShown >= frequency;
+}
diff --git a/ui/selectors/send-selectors-test-data.js b/ui/selectors/send-selectors-test-data.js
index e6c0d230c..b2663aadb 100644
--- a/ui/selectors/send-selectors-test-data.js
+++ b/ui/selectors/send-selectors-test-data.js
@@ -150,21 +150,6 @@ const state = {
},
],
selectedAddress: '0xd85a4b6a394794842887b8284293d69163007bbb',
- send: {
- gasLimit: '0xFFFF',
- gasPrice: '0xaa',
- gasTotal: '0xb451dc41b578',
- tokenBalance: 3434,
- from: '0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb',
- to: '0x987fedabc',
- amount: '0x080',
- memo: '',
- errors: {
- someError: null,
- },
- maxModeOn: false,
- editingTransactionId: 97531,
- },
unapprovedTxs: {
4768706228115573: {
id: 4768706228115573,
@@ -210,8 +195,19 @@ const state = {
identities: {},
send: {
fromDropdownOpen: false,
- toDropdownOpen: false,
- errors: { someError: null },
+ gasLimit: '0xFFFF',
+ gasPrice: '0xaa',
+ gasTotal: '0xb451dc41b578',
+ tokenBalance: 3434,
+ from: '0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb',
+ to: '0x987fedabc',
+ amount: '0x080',
+ memo: '',
+ errors: {
+ someError: null,
+ },
+ maxModeOn: false,
+ editingTransactionId: 97531,
},
};
diff --git a/ui/selectors/send.js b/ui/selectors/send.js
index d6f291c9f..3d0b11d83 100644
--- a/ui/selectors/send.js
+++ b/ui/selectors/send.js
@@ -1,31 +1,17 @@
import abi from 'human-standard-token-abi';
import { calcGasTotal } from '../pages/send/send.utils';
import {
- accountsWithSendEtherInfoSelector,
- getAddressBook,
getSelectedAccount,
getTargetAccount,
getAveragePriceEstimateInHexWEI,
} from '.';
-export function getBlockGasLimit(state) {
- return state.metamask.currentBlockGasLimit;
-}
-
-export function getConversionRate(state) {
- return state.metamask.conversionRate;
-}
-
-export function getNativeCurrency(state) {
- return state.metamask.nativeCurrency;
-}
-
export function getGasLimit(state) {
- return state.metamask.send.gasLimit || '0';
+ return state.send.gasLimit || '0';
}
export function getGasPrice(state) {
- return state.metamask.send.gasPrice || getAveragePriceEstimateInHexWEI(state);
+ return state.send.gasPrice || getAveragePriceEstimateInHexWEI(state);
}
export function getGasTotal(state) {
@@ -38,7 +24,7 @@ export function getPrimaryCurrency(state) {
}
export function getSendToken(state) {
- return state.metamask.send.token;
+ return state.send.token;
}
export function getSendTokenAddress(state) {
@@ -53,19 +39,15 @@ export function getSendTokenContract(state) {
}
export function getSendAmount(state) {
- return state.metamask.send.amount;
+ return state.send.amount;
}
export function getSendHexData(state) {
- return state.metamask.send.data;
-}
-
-export function getSendHexDataFeatureFlagState(state) {
- return state.metamask.featureFlags.sendHexData;
+ return state.send.data;
}
export function getSendEditingTransactionId(state) {
- return state.metamask.send.editingTransactionId;
+ return state.send.editingTransactionId;
}
export function getSendErrors(state) {
@@ -77,7 +59,7 @@ export function sendAmountIsInError(state) {
}
export function getSendFrom(state) {
- return state.metamask.send.from;
+ return state.send.from;
}
export function getSendFromBalance(state) {
@@ -93,36 +75,27 @@ export function getSendFromObject(state) {
}
export function getSendMaxModeState(state) {
- return state.metamask.send.maxModeOn;
+ return state.send.maxModeOn;
}
export function getSendTo(state) {
- return state.metamask.send.to;
+ return state.send.to;
}
export function getSendToNickname(state) {
- return state.metamask.send.toNickname;
+ return state.send.toNickname;
}
-export function getSendToAccounts(state) {
- const fromAccounts = accountsWithSendEtherInfoSelector(state);
- const addressBookAccounts = getAddressBook(state);
- return [...fromAccounts, ...addressBookAccounts];
-}
export function getTokenBalance(state) {
- return state.metamask.send.tokenBalance;
+ return state.send.tokenBalance;
}
export function getSendEnsResolution(state) {
- return state.metamask.send.ensResolution;
+ return state.send.ensResolution;
}
export function getSendEnsResolutionError(state) {
- return state.metamask.send.ensResolutionError;
-}
-
-export function getUnapprovedTxs(state) {
- return state.metamask.unapprovedTxs;
+ return state.send.ensResolutionError;
}
export function getQrCodeData(state) {
diff --git a/ui/selectors/send.test.js b/ui/selectors/send.test.js
index bab7b63fe..aadbc28e5 100644
--- a/ui/selectors/send.test.js
+++ b/ui/selectors/send.test.js
@@ -1,9 +1,5 @@
import sinon from 'sinon';
-import { TRANSACTION_STATUSES } from '../../shared/constants/transaction';
import {
- getBlockGasLimit,
- getConversionRate,
- getNativeCurrency,
getGasLimit,
getGasPrice,
getGasTotal,
@@ -17,12 +13,9 @@ import {
getSendFrom,
getSendFromBalance,
getSendFromObject,
- getSendHexDataFeatureFlagState,
getSendMaxModeState,
getSendTo,
- getSendToAccounts,
getTokenBalance,
- getUnapprovedTxs,
gasFeeIsInError,
getGasLoadingError,
getGasButtonGroupShown,
@@ -84,18 +77,6 @@ describe('send selectors', () => {
});
});
- describe('getBlockGasLimit', () => {
- it('should return the current block gas limit', () => {
- expect(getBlockGasLimit(mockState)).toStrictEqual('0x4c1878');
- });
- });
-
- describe('getConversionRate()', () => {
- it('should return the eth conversion rate', () => {
- expect(getConversionRate(mockState)).toStrictEqual(1200.88200327);
- });
- });
-
describe('getCurrentAccountWithSendEtherInfo()', () => {
it('should return the currently selected account with identity info', () => {
expect(getCurrentAccountWithSendEtherInfo(mockState)).toStrictEqual({
@@ -108,12 +89,6 @@ describe('send selectors', () => {
});
});
- describe('getNativeCurrency()', () => {
- it('should return the ticker symbol of the selected network', () => {
- expect(getNativeCurrency(mockState)).toStrictEqual('ETH');
- });
- });
-
describe('getGasLimit()', () => {
it('should return the send.gasLimit', () => {
expect(getGasLimit(mockState)).toStrictEqual('0xFFFF');
@@ -136,7 +111,7 @@ describe('send selectors', () => {
it('should return the symbol of the send token', () => {
expect(
getPrimaryCurrency({
- metamask: { send: { token: { symbol: 'DEF' } } },
+ send: { token: { symbol: 'DEF' } },
}),
).toStrictEqual('DEF');
});
@@ -146,13 +121,11 @@ describe('send selectors', () => {
it('should return the current send token if set', () => {
expect(
getSendToken({
- metamask: {
- send: {
- token: {
- address: '0x8d6b81208414189a58339873ab429b6c47ab92d3',
- decimals: 4,
- symbol: 'DEF',
- },
+ send: {
+ token: {
+ address: '0x8d6b81208414189a58339873ab429b6c47ab92d3',
+ decimals: 4,
+ symbol: 'DEF',
},
},
}),
@@ -168,13 +141,11 @@ describe('send selectors', () => {
it('should return the contract at the send token address', () => {
expect(
getSendTokenContract({
- metamask: {
- send: {
- token: {
- address: '0x8d6b81208414189a58339873ab429b6c47ab92d3',
- decimals: 4,
- symbol: 'DEF',
- },
+ send: {
+ token: {
+ address: '0x8d6b81208414189a58339873ab429b6c47ab92d3',
+ decimals: 4,
+ symbol: 'DEF',
},
},
}),
@@ -182,10 +153,7 @@ describe('send selectors', () => {
});
it('should return null if send token is not set', () => {
- const modifiedMetamaskState = { ...mockState.metamask, send: {} };
- expect(
- getSendTokenContract({ ...mockState, metamask: modifiedMetamaskState }),
- ).toBeNull();
+ expect(getSendTokenContract({ ...mockState, send: {} })).toBeNull();
});
});
@@ -207,12 +175,6 @@ describe('send selectors', () => {
});
});
- describe('getSendHexDataFeatureFlagState()', () => {
- it('should return the sendHexData feature flag state', () => {
- expect(getSendHexDataFeatureFlagState(mockState)).toStrictEqual(true);
- });
- });
-
describe('getSendFrom()', () => {
it('should return the send.from', () => {
expect(getSendFrom(mockState)).toStrictEqual(
@@ -228,11 +190,10 @@ describe('send selectors', () => {
it('should get the selected account balance if the send.from does not exist', () => {
const editedMockState = {
- metamask: {
- ...mockState.metamask,
- send: {
- from: null,
- },
+ ...mockState,
+ send: {
+ ...mockState.send,
+ from: null,
},
};
expect(getSendFromBalance(editedMockState)).toStrictEqual('0x0');
@@ -251,11 +212,9 @@ describe('send selectors', () => {
it('should return the current account if send.from does not exist', () => {
const editedMockState = {
- metamask: {
- ...mockState.metamask,
- send: {
- from: null,
- },
+ ...mockState,
+ send: {
+ from: null,
},
};
expect(getSendFromObject(editedMockState)).toStrictEqual({
@@ -279,78 +238,12 @@ describe('send selectors', () => {
});
});
- describe('getSendToAccounts()', () => {
- it('should return an array including all the users accounts and the address book', () => {
- expect(getSendToAccounts(mockState)).toStrictEqual([
- {
- code: '0x',
- balance: '0x47c9d71831c76efe',
- nonce: '0x1b',
- address: '0xfdea65c8e26263f6d9a1b5de9555d2931a33b825',
- name: 'Send Account 1',
- },
- {
- code: '0x',
- balance: '0x37452b1315889f80',
- nonce: '0xa',
- address: '0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb',
- name: 'Send Account 2',
- },
- {
- code: '0x',
- balance: '0x30c9d71831c76efe',
- nonce: '0x1c',
- address: '0x2f8d4a878cfa04a6e60d46362f5644deab66572d',
- name: 'Send Account 3',
- },
- {
- code: '0x',
- balance: '0x0',
- nonce: '0x0',
- address: '0xd85a4b6a394794842887b8284293d69163007bbb',
- name: 'Send Account 4',
- },
- {
- address: '0x06195827297c7a80a443b6894d3bdb8824b43896',
- name: 'Address Book Account 1',
- chainId: '0x3',
- },
- ]);
- });
- });
-
describe('getTokenBalance()', () => {
it('should', () => {
expect(getTokenBalance(mockState)).toStrictEqual(3434);
});
});
- describe('getUnapprovedTxs()', () => {
- it('should return the unapproved txs', () => {
- expect(getUnapprovedTxs(mockState)).toStrictEqual({
- 4768706228115573: {
- id: 4768706228115573,
- time: 1487363153561,
- status: TRANSACTION_STATUSES.UNAPPROVED,
- gasMultiplier: 1,
- metamaskNetworkId: '3',
- txParams: {
- from: '0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb',
- to: '0x18a3462427bcc9133bb46e88bcbe39cd7ef0e761',
- value: '0xde0b6b3a7640000',
- metamaskId: 4768706228115573,
- metamaskNetworkId: '3',
- gas: '0x5209',
- },
- txFee: '17e0186e60800',
- txValue: 'de0b6b3a7640000',
- maxCost: 'de234b52e4a0800',
- gasPrice: '4a817c800',
- },
- });
- });
- });
-
describe('send-amount-row selectors', () => {
describe('sendAmountIsInError()', () => {
it('should return true if send.errors.amount is truthy', () => {
@@ -436,9 +329,7 @@ describe('send selectors', () => {
describe('send-header selectors', () => {
const getMetamaskSendMockState = (send) => {
return {
- metamask: {
- send: { ...send },
- },
+ send: { ...send },
};
};
diff --git a/ui/store/actionConstants.js b/ui/store/actionConstants.js
index 8a9f5cd84..d16caa61f 100644
--- a/ui/store/actionConstants.js
+++ b/ui/store/actionConstants.js
@@ -39,24 +39,6 @@ export const COMPLETED_TX = 'COMPLETED_TX';
export const TRANSACTION_ERROR = 'TRANSACTION_ERROR';
export const UPDATE_TRANSACTION_PARAMS = 'UPDATE_TRANSACTION_PARAMS';
export const SET_NEXT_NONCE = 'SET_NEXT_NONCE';
-// send screen
-export const UPDATE_GAS_LIMIT = 'UPDATE_GAS_LIMIT';
-export const UPDATE_GAS_PRICE = 'UPDATE_GAS_PRICE';
-export const UPDATE_GAS_TOTAL = 'UPDATE_GAS_TOTAL';
-export const UPDATE_SEND_HEX_DATA = 'UPDATE_SEND_HEX_DATA';
-export const UPDATE_SEND_TOKEN_BALANCE = 'UPDATE_SEND_TOKEN_BALANCE';
-export const UPDATE_SEND_TO = 'UPDATE_SEND_TO';
-export const UPDATE_SEND_AMOUNT = 'UPDATE_SEND_AMOUNT';
-export const UPDATE_SEND_ERRORS = 'UPDATE_SEND_ERRORS';
-export const UPDATE_MAX_MODE = 'UPDATE_MAX_MODE';
-export const UPDATE_SEND = 'UPDATE_SEND';
-export const UPDATE_SEND_TOKEN = 'UPDATE_SEND_TOKEN';
-export const CLEAR_SEND = 'CLEAR_SEND';
-export const GAS_LOADING_STARTED = 'GAS_LOADING_STARTED';
-export const GAS_LOADING_FINISHED = 'GAS_LOADING_FINISHED';
-export const UPDATE_SEND_ENS_RESOLUTION = 'UPDATE_SEND_ENS_RESOLUTION';
-export const UPDATE_SEND_ENS_RESOLUTION_ERROR =
- 'UPDATE_SEND_ENS_RESOLUTION_ERROR';
// config screen
export const SET_RPC_TARGET = 'SET_RPC_TARGET';
export const SET_PROVIDER_TYPE = 'SET_PROVIDER_TYPE';
diff --git a/ui/store/actions.js b/ui/store/actions.js
index f5c28ee24..f2269cdad 100644
--- a/ui/store/actions.js
+++ b/ui/store/actions.js
@@ -3,7 +3,6 @@ import pify from 'pify';
import log from 'loglevel';
import { capitalize } from 'lodash';
import getBuyEthUrl from '../../app/scripts/lib/buy-eth-url';
-import { calcTokenBalance, estimateGasForSend } from '../pages/send/send.utils';
import {
fetchLocale,
loadRelativeTimeFormatLocaleData,
@@ -13,7 +12,6 @@ import { getSymbolAndDecimals } 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 '../helpers/utils/tx-helper';
import { getEnvironmentType, addHexPrefix } from '../../app/scripts/lib/util';
import {
@@ -22,8 +20,9 @@ import {
} from '../selectors';
import { switchedToUnconnectedAccount } from '../ducks/alerts/unconnected-account';
import { getUnconnectedAccountAlertEnabledness } from '../ducks/metamask/metamask';
-import { toChecksumHexAddress } from '../../shared/modules/hexstring-utils';
import { LISTED_CONTRACT_ADDRESSES } from '../../shared/constants/tokens';
+import { toChecksumHexAddress } from '../../shared/modules/hexstring-utils';
+import { clearSend } from '../ducks/send/send.duck';
import * as actionConstants from './actionConstants';
let background = null;
@@ -38,7 +37,6 @@ export function goHome() {
type: actionConstants.GO_HOME,
};
}
-
// async actions
export function tryUnlockMetamask(password) {
@@ -624,138 +622,18 @@ export function signTypedMsg(msgData) {
}
export function signTx(txData) {
- return (dispatch) => {
+ return async (dispatch) => {
+ dispatch(showLoadingIndication());
global.ethQuery.sendTransaction(txData, (err) => {
if (err) {
dispatch(displayWarning(err.message));
}
});
+ dispatch(hideLoadingIndication());
dispatch(showConfTxPage());
};
}
-export function setGasLimit(gasLimit) {
- return {
- type: actionConstants.UPDATE_GAS_LIMIT,
- value: gasLimit,
- };
-}
-
-export function setGasPrice(gasPrice) {
- return {
- type: actionConstants.UPDATE_GAS_PRICE,
- value: gasPrice,
- };
-}
-
-export function setGasTotal(gasTotal) {
- return {
- type: actionConstants.UPDATE_GAS_TOTAL,
- value: gasTotal,
- };
-}
-
-export function updateGasData({
- gasPrice,
- blockGasLimit,
- selectedAddress,
- sendToken,
- to,
- value,
- data,
-}) {
- return (dispatch) => {
- dispatch(gasLoadingStarted());
- return estimateGasForSend({
- estimateGasMethod: promisifiedBackground.estimateGas,
- blockGasLimit,
- selectedAddress,
- sendToken,
- to,
- value,
- estimateGasPrice: gasPrice,
- data,
- })
- .then((gas) => {
- dispatch(setGasLimit(gas));
- dispatch(setCustomGasLimit(gas));
- dispatch(updateSendErrors({ gasLoadingError: null }));
- dispatch(gasLoadingFinished());
- })
- .catch((err) => {
- log.error(err);
- dispatch(updateSendErrors({ gasLoadingError: 'gasLoadingError' }));
- dispatch(gasLoadingFinished());
- });
- };
-}
-
-export function gasLoadingStarted() {
- return {
- type: actionConstants.GAS_LOADING_STARTED,
- };
-}
-
-export function gasLoadingFinished() {
- return {
- type: actionConstants.GAS_LOADING_FINISHED,
- };
-}
-
-export function updateSendTokenBalance({ sendToken, tokenContract, address }) {
- return (dispatch) => {
- const tokenBalancePromise = tokenContract
- ? tokenContract.balanceOf(address)
- : Promise.resolve();
- return tokenBalancePromise
- .then((usersToken) => {
- if (usersToken) {
- const newTokenBalance = calcTokenBalance({ sendToken, usersToken });
- dispatch(setSendTokenBalance(newTokenBalance));
- }
- })
- .catch((err) => {
- log.error(err);
- updateSendErrors({ tokenBalance: 'tokenBalanceError' });
- });
- };
-}
-
-export function updateSendErrors(errorObject) {
- return {
- type: actionConstants.UPDATE_SEND_ERRORS,
- value: errorObject,
- };
-}
-
-export function setSendTokenBalance(tokenBalance) {
- return {
- type: actionConstants.UPDATE_SEND_TOKEN_BALANCE,
- value: tokenBalance,
- };
-}
-
-export function updateSendHexData(value) {
- return {
- type: actionConstants.UPDATE_SEND_HEX_DATA,
- value,
- };
-}
-
-export function updateSendTo(to, nickname = '') {
- return {
- type: actionConstants.UPDATE_SEND_TO,
- value: { to, nickname },
- };
-}
-
-export function updateSendAmount(amount) {
- return {
- type: actionConstants.UPDATE_SEND_AMOUNT,
- value: amount,
- };
-}
-
export function updateCustomNonce(value) {
return {
type: actionConstants.UPDATE_CUSTOM_NONCE,
@@ -763,57 +641,15 @@ export function updateCustomNonce(value) {
};
}
-export function setMaxModeTo(bool) {
- return {
- type: actionConstants.UPDATE_MAX_MODE,
- value: bool,
- };
-}
-
-export function updateSend(newSend) {
- return {
- type: actionConstants.UPDATE_SEND,
- value: newSend,
- };
-}
-
-export function updateSendToken(token) {
- return {
- type: actionConstants.UPDATE_SEND_TOKEN,
- value: token,
- };
-}
-
-export function clearSend() {
- return {
- type: actionConstants.CLEAR_SEND,
- };
-}
-
-export function updateSendEnsResolution(ensResolution) {
- return {
- type: actionConstants.UPDATE_SEND_ENS_RESOLUTION,
- payload: ensResolution,
- };
-}
-
-export function updateSendEnsResolutionError(errorMessage) {
- return {
- type: actionConstants.UPDATE_SEND_ENS_RESOLUTION_ERROR,
- payload: errorMessage,
- };
-}
-
export function signTokenTx(tokenAddress, toAddress, amount, txData) {
return async (dispatch) => {
dispatch(showLoadingIndication());
try {
const token = global.eth.contract(abi).at(tokenAddress);
- const txPromise = token.transfer(toAddress, addHexPrefix(amount), txData);
+ token.transfer(toAddress, addHexPrefix(amount), txData);
dispatch(showConfTxPage());
dispatch(hideLoadingIndication());
- await txPromise;
} catch (error) {
dispatch(hideLoadingIndication());
dispatch(displayWarning(error.message));
@@ -2570,16 +2406,24 @@ export function setConnectedStatusPopoverHasBeenShown() {
};
}
-export async function setAlertEnabledness(alertId, enabledness) {
- await promisifiedBackground.setAlertEnabledness(alertId, enabledness);
-}
-
-export async function setUnconnectedAccountAlertShown(origin) {
- await promisifiedBackground.setUnconnectedAccountAlertShown(origin);
+export function setRecoveryPhraseReminderHasBeenShown() {
+ return () => {
+ background.setRecoveryPhraseReminderHasBeenShown((err) => {
+ if (err) {
+ throw new Error(err.message);
+ }
+ });
+ };
}
-export async function setWeb3ShimUsageAlertDismissed(origin) {
- await promisifiedBackground.setWeb3ShimUsageAlertDismissed(origin);
+export function setRecoveryPhraseReminderLastShown(lastShown) {
+ return () => {
+ background.setRecoveryPhraseReminderLastShown(lastShown, (err) => {
+ if (err) {
+ throw new Error(err.message);
+ }
+ });
+ };
}
export function loadingMethodDataStarted() {
@@ -2848,6 +2692,18 @@ export function setLedgerLivePreference(value) {
};
}
+// Wrappers around promisifedBackground
+/**
+ * The "actions" below are not actions nor action creators. They cannot use
+ * dispatch nor should they be dispatched when used. Instead they can be
+ * called directly. These wrappers will be moved into their location at some
+ * point in the future.
+ */
+
+export function estimateGas(params) {
+ return promisifiedBackground.estimateGas(params);
+}
+
// MetaMetrics
/**
* @typedef {import('../../shared/constants/metametrics').MetaMetricsEventPayload} MetaMetricsEventPayload
@@ -2879,3 +2735,15 @@ export function updateViewedNotifications(notificationIdViewedStatusMap) {
notificationIdViewedStatusMap,
);
}
+
+export async function setAlertEnabledness(alertId, enabledness) {
+ await promisifiedBackground.setAlertEnabledness(alertId, enabledness);
+}
+
+export async function setUnconnectedAccountAlertShown(origin) {
+ await promisifiedBackground.setUnconnectedAccountAlertShown(origin);
+}
+
+export async function setWeb3ShimUsageAlertDismissed(origin) {
+ await promisifiedBackground.setWeb3ShimUsageAlertDismissed(origin);
+}
diff --git a/ui/store/actions.test.js b/ui/store/actions.test.js
index 409f03853..d28defb8c 100644
--- a/ui/store/actions.test.js
+++ b/ui/store/actions.test.js
@@ -5,6 +5,7 @@ import EthQuery from 'eth-query';
import enLocale from '../../app/_locales/en/messages.json';
import MetaMaskController from '../../app/scripts/metamask-controller';
import { TRANSACTION_STATUSES } from '../../shared/constants/transaction';
+import { GAS_LIMITS } from '../../shared/constants/gas';
import * as actions from './actions';
const middleware = [thunk];
@@ -618,7 +619,7 @@ describe('Actions', () => {
it('calls setCurrentCurrency', async () => {
const store = mockStore();
- background.setCurrentCurrency.callsFake((_, cb) => cb());
+ background.setCurrentCurrency = sinon.stub().callsFake((_, cb) => cb());
actions._setBackgroundConnection(background);
await store.dispatch(actions.setCurrentCurrency('jpy'));
@@ -627,9 +628,9 @@ describe('Actions', () => {
it('throws if setCurrentCurrency throws', async () => {
const store = mockStore();
- background.setCurrentCurrency.callsFake((_, cb) =>
- cb(new Error('error')),
- );
+ background.setCurrentCurrency = sinon
+ .stub()
+ .callsFake((_, cb) => cb(new Error('error')));
actions._setBackgroundConnection(background);
const expectedActions = [
@@ -837,7 +838,9 @@ describe('Actions', () => {
it('errors in when sendTransaction throws', async () => {
const store = mockStore();
const expectedActions = [
+ { type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'DISPLAY_WARNING', value: 'error' },
+ { type: 'HIDE_LOADING_INDICATION' },
{ type: 'SHOW_CONF_TX_PAGE', id: undefined },
];
@@ -852,67 +855,6 @@ describe('Actions', () => {
});
});
- describe('#updatedGasData', () => {
- it('errors when get code does not return', async () => {
- const store = mockStore();
-
- background.estimateGas = sinon.stub().rejects();
-
- actions._setBackgroundConnection(background);
-
- global.eth = {
- getCode: sinon.stub().rejects(),
- };
-
- const expectedActions = [
- { type: 'GAS_LOADING_STARTED' },
- {
- type: 'UPDATE_SEND_ERRORS',
- value: { gasLoadingError: 'gasLoadingError' },
- },
- { type: 'GAS_LOADING_FINISHED' },
- ];
-
- const mockData = {
- gasPrice: '0x3b9aca00', //
- blockGasLimit: '0x6ad79a', // 7002010
- selectedAddress: '0x0DCD5D886577d5081B0c52e242Ef29E70Be3E7bc',
- to: '0xEC1Adf982415D2Ef5ec55899b9Bfb8BC0f29251B',
- value: '0xde0b6b3a7640000', // 1000000000000000000
- };
-
- await store.dispatch(actions.updateGasData(mockData));
-
- expect(store.getActions()).toStrictEqual(expectedActions);
- });
-
- it('returns default gas limit for basic eth transaction', async () => {
- const mockData = {
- gasPrice: '0x3b9aca00',
- blockGasLimit: '0x6ad79a', // 7002010
- selectedAddress: '0x0DCD5D886577d5081B0c52e242Ef29E70Be3E7bc',
- to: '0xEC1Adf982415D2Ef5ec55899b9Bfb8BC0f29251B',
- value: '0xde0b6b3a7640000', // 1000000000000000000
- };
-
- global.eth = {
- getCode: sinon.stub().returns('0x'),
- };
- const store = mockStore();
-
- const expectedActions = [
- { type: 'GAS_LOADING_STARTED' },
- { type: 'UPDATE_GAS_LIMIT', value: '0x5208' },
- { type: 'metamask/gas/SET_CUSTOM_GAS_LIMIT', value: '0x5208' },
- { type: 'UPDATE_SEND_ERRORS', value: { gasLoadingError: null } },
- { type: 'GAS_LOADING_FINISHED' },
- ];
-
- await store.dispatch(actions.updateGasData(mockData));
- expect(store.getActions()).toStrictEqual(expectedActions);
- });
- });
-
describe('#signTokenTx', () => {
it('calls eth.contract', async () => {
global.eth = {
@@ -929,7 +871,7 @@ describe('Actions', () => {
describe('#updateTransaction', () => {
const txParams = {
from: '0x1',
- gas: '0x5208',
+ gas: GAS_LIMITS.SIMPLE,
gasPrice: '0x3b9aca00',
to: '0x2',
value: '0x0',
@@ -998,7 +940,7 @@ describe('Actions', () => {
id: '1',
value: {
from: '0x1',
- gas: '0x5208',
+ gas: GAS_LIMITS.SIMPLE,
gasPrice: '0x3b9aca00',
to: '0x2',
value: '0x0',
diff --git a/yarn.lock b/yarn.lock
index cfd31b2f5..c5537275a 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2620,21 +2620,26 @@
prop-types "^15.7.2"
react-is "^16.8.0"
-"@metamask/auto-changelog@^1.0.0":
- version "1.0.0"
- resolved "https://registry.yarnpkg.com/@metamask/auto-changelog/-/auto-changelog-1.0.0.tgz#ca6a71d1b983cf08b715bdcd8e240d746974d0c7"
- integrity sha512-3Bcm+JsEmNllPi7kRtzS6EAjYTzz+Isa4QFq2DQ4DFwIsv2HUxdR+KNU2GJ1BdX4lbPcQTrpTdaPgBZ9G4NhLA==
+"@metamask/auto-changelog@^2.1.0":
+ version "2.3.0"
+ resolved "https://registry.yarnpkg.com/@metamask/auto-changelog/-/auto-changelog-2.3.0.tgz#e8edf9210753b495d799b64af07de24ed0839004"
+ integrity sha512-l5Tk9Dx1+wF3L1ZvN+HObS7R077BDErRmElq5LckJTtAbAhEhg/MMD/6u2yZBmVIlPrint29BVt3tsqRp1GjIA==
dependencies:
cross-spawn "^7.0.3"
diff "^5.0.0"
semver "^7.3.5"
yargs "^17.0.1"
-"@metamask/contract-metadata@^1.19.0", "@metamask/contract-metadata@^1.22.0", "@metamask/contract-metadata@^1.24.0":
+"@metamask/contract-metadata@^1.19.0", "@metamask/contract-metadata@^1.25.0":
version "1.25.0"
resolved "https://registry.yarnpkg.com/@metamask/contract-metadata/-/contract-metadata-1.25.0.tgz#442ace91fb40165310764b68d8096d0017bb0492"
integrity sha512-yhmYB9CQPv0dckNcPoWDcgtrdUp0OgK0uvkRE5QIBv4b3qENI1/03BztvK2ijbTuMlORUpjPq7/1MQDUPoRPVw==
+"@metamask/contract-metadata@^1.26.0":
+ version "1.26.0"
+ resolved "https://registry.yarnpkg.com/@metamask/contract-metadata/-/contract-metadata-1.26.0.tgz#06be4f4dc645da69f6364f75cb2bd47afa642fe6"
+ integrity sha512-58A8csapIPoc854n6AI+3jwJcQfh75BzVrl6SAySgJ9fWTa1XItm9Tx/ORaqYrwaR/9JqH4SnkbXtqyFwuUL6w==
+
"@metamask/controllers@^5.0.0":
version "5.1.0"
resolved "https://registry.yarnpkg.com/@metamask/controllers/-/controllers-5.1.0.tgz#02c1957295bcb6db1655a716d165665d170e7f34"
@@ -2663,20 +2668,20 @@
web3 "^0.20.7"
web3-provider-engine "^16.0.1"
-"@metamask/controllers@^8.0.0":
- version "8.0.0"
- resolved "https://registry.yarnpkg.com/@metamask/controllers/-/controllers-8.0.0.tgz#42ac5aaef67a03d3fe599a67a36597e01902ca8d"
- integrity sha512-TrteMifsCxV1g3WHcSD1X98fF4hKep3sXZNGfrvkPqa8mrF03hJke21WBSTRtvJ3vkNLRWgi+5I6lVXFTzbYuQ==
+"@metamask/controllers@^9.0.0":
+ version "9.1.0"
+ resolved "https://registry.yarnpkg.com/@metamask/controllers/-/controllers-9.1.0.tgz#4434f22eba2522889224b35aa08bc7b67d7248b7"
+ integrity sha512-jn/F0BNbaPsgEevHaPqk0lGAONKom4re1a4yBC67h7Vu6yu26CRi30SJl4xIh3IW4+ySbPhVLaiXFiXr3fESRQ==
dependencies:
- "@metamask/contract-metadata" "^1.24.0"
+ "@metamask/contract-metadata" "^1.25.0"
"@types/uuid" "^8.3.0"
async-mutex "^0.2.6"
babel-runtime "^6.26.0"
eth-ens-namehash "^2.0.8"
eth-json-rpc-infura "^5.1.0"
- eth-keyring-controller "^6.1.0"
+ eth-keyring-controller "^6.2.1"
eth-method-registry "1.1.0"
- eth-phishing-detect "^1.1.13"
+ eth-phishing-detect "^1.1.14"
eth-query "^2.1.2"
eth-rpc-errors "^4.0.0"
eth-sig-util "^3.0.0"
@@ -2690,6 +2695,7 @@
isomorphic-fetch "^3.0.0"
jsonschema "^1.2.4"
nanoid "^3.1.12"
+ punycode "^2.1.1"
single-call-balance-checker-abi "^1.0.0"
uuid "^8.3.2"
web3 "^0.20.7"
@@ -10509,20 +10515,6 @@ eth-ens-namehash@^1.0.2:
idna-uts46 "^1.0.1"
js-sha3 "^0.5.7"
-eth-hd-keyring@^3.5.0:
- version "3.5.0"
- resolved "https://registry.yarnpkg.com/eth-hd-keyring/-/eth-hd-keyring-3.5.0.tgz#3976d83a27b24305481c389178f290d9264e839d"
- integrity sha512-Ix1LcWYxHMxCCSIMz+TLXLtt50zF6ZDd/TRVXthdw91IwOk1ajuf7QHg3bCDcfeUpdf9oEpwIPbL3xjDqEEjYw==
- dependencies:
- bip39 "^2.2.0"
- eth-sig-util "^2.4.4"
- eth-simple-keyring "^3.5.0"
- ethereumjs-abi "^0.6.5"
- ethereumjs-util "^5.1.1"
- ethereumjs-wallet "^0.6.0"
- events "^1.1.1"
- xtend "^4.0.1"
-
eth-hd-keyring@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/eth-hd-keyring/-/eth-hd-keyring-3.6.0.tgz#6835d30aa411b8d3ef098e82f6427b5325082abb"
@@ -10603,25 +10595,10 @@ eth-json-rpc-middleware@^6.0.0:
pify "^3.0.0"
safe-event-emitter "^1.0.1"
-eth-keyring-controller@^6.1.0:
- version "6.1.0"
- resolved "https://registry.yarnpkg.com/eth-keyring-controller/-/eth-keyring-controller-6.1.0.tgz#dc9313d0b793e085dc1badf84dd4f5e3004e127e"
- integrity sha512-wPxH++98VDBcDv9YkPzxhZC0gF1ixuRbyKR2u/NOT/roBpNQDe4reqyllBRC7jhPehiKnRxzf7r6HEyirRnPxQ==
- dependencies:
- bip39 "^2.4.0"
- bluebird "^3.5.0"
- browser-passworder "^2.0.3"
- eth-hd-keyring "^3.5.0"
- eth-sig-util "^1.4.0"
- eth-simple-keyring "^3.5.0"
- ethereumjs-util "^5.1.2"
- loglevel "^1.5.0"
- obs-store "^4.0.3"
-
-eth-keyring-controller@^6.2.0:
- version "6.2.0"
- resolved "https://registry.yarnpkg.com/eth-keyring-controller/-/eth-keyring-controller-6.2.0.tgz#c649e7ced9bc9a11c2a6ab48234fae212569d390"
- integrity sha512-UYYs+hTgrJNqy7xkI56QpekfsPuZw4kLxrFEUkHefCkBv9poSg/Abx4rvBsRwcj7yxXcxfgTNtoltJfR2we4uw==
+eth-keyring-controller@^6.1.0, eth-keyring-controller@^6.2.0, eth-keyring-controller@^6.2.1:
+ version "6.2.1"
+ resolved "https://registry.yarnpkg.com/eth-keyring-controller/-/eth-keyring-controller-6.2.1.tgz#61901071fc74059ed37cb5ae93870fdcae6e3781"
+ integrity sha512-x2gTM1iHp2Kbvdtd9Eslysw0qzVZiqOzpVB3AU/ni2Xiit+rlcv2H80zYKjrEwlfWFDj4YILD3bOqlnEMmRJOA==
dependencies:
bip39 "^2.4.0"
bluebird "^3.5.0"
@@ -10698,7 +10675,7 @@ eth-rpc-errors@^4.0.0, eth-rpc-errors@^4.0.2:
dependencies:
fast-safe-stringify "^2.0.6"
-eth-sig-util@^1.4.0, eth-sig-util@^1.4.2:
+eth-sig-util@^1.4.2:
version "1.4.2"
resolved "https://registry.yarnpkg.com/eth-sig-util/-/eth-sig-util-1.4.2.tgz#8d958202c7edbaae839707fba6f09ff327606210"
integrity sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=
@@ -10706,7 +10683,7 @@ eth-sig-util@^1.4.0, eth-sig-util@^1.4.2:
ethereumjs-abi "git+https://github.com/ethereumjs/ethereumjs-abi.git"
ethereumjs-util "^5.1.1"
-eth-sig-util@^2.0.0, eth-sig-util@^2.4.4, eth-sig-util@^2.5.0:
+eth-sig-util@^2.0.0:
version "2.5.4"
resolved "https://registry.yarnpkg.com/eth-sig-util/-/eth-sig-util-2.5.4.tgz#577b01fe491b6bf59b0464be09633e20c1677bc5"
integrity sha512-aCMBwp8q/4wrW4QLsF/HYBOSA7TpLKmkVwP3pYQNkEEseW2Rr8Z5Uxc9/h6HX+OG3tuHo+2bINVSihIeBfym6A==
@@ -10726,18 +10703,6 @@ eth-sig-util@^3.0.0, eth-sig-util@^3.0.1:
tweetnacl "^1.0.3"
tweetnacl-util "^0.15.0"
-eth-simple-keyring@^3.5.0:
- version "3.5.0"
- resolved "https://registry.yarnpkg.com/eth-simple-keyring/-/eth-simple-keyring-3.5.0.tgz#c7fa285ca58d31ef44bc7db678b689f9ffd7b453"
- integrity sha512-z9IPt9aoMWAw5Zc3Jk/HKbWPJNc7ivZ5ECNtl3ZoQUGRnwoWO71W5+liVPJtXFNacGOOGsBfqTqrXL9C4EnYYQ==
- dependencies:
- eth-sig-util "^2.5.0"
- ethereumjs-abi "^0.6.5"
- ethereumjs-util "^5.1.1"
- ethereumjs-wallet "^0.6.0"
- events "^1.1.1"
- xtend "^4.0.1"
-
eth-simple-keyring@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/eth-simple-keyring/-/eth-simple-keyring-4.2.0.tgz#c197a4bd4cce7d701b5f3607d0b843112ddb17e3"
@@ -10828,7 +10793,7 @@ ethereum-ens-network-map@^1.0.0, ethereum-ens-network-map@^1.0.2:
resolved "https://registry.yarnpkg.com/ethereum-ens-network-map/-/ethereum-ens-network-map-1.0.2.tgz#4e27bad18dae7bd95d84edbcac2c9e739fc959b9"
integrity sha512-5qwJ5n3YhjSpE6O/WEBXCAb2nagUgyagJ6C0lGUBWC4LjKp/rRzD+pwtDJ6KCiITFEAoX4eIrWOjRy0Sylq5Hg==
-ethereumjs-abi@0.6.8, ethereumjs-abi@^0.6.4, ethereumjs-abi@^0.6.5, ethereumjs-abi@^0.6.8:
+ethereumjs-abi@0.6.8, ethereumjs-abi@^0.6.4, ethereumjs-abi@^0.6.8:
version "0.6.8"
resolved "https://registry.yarnpkg.com/ethereumjs-abi/-/ethereumjs-abi-0.6.8.tgz#71bc152db099f70e62f108b7cdfca1b362c6fcae"
integrity sha512-Tx0r/iXI6r+lRsdvkFDlut0N08jWMnKRZ6Gkq+Nmw75lZe4e6o3EkSnkaBP5NF6+m5PTGAr9JP43N3LyeoglsA==
@@ -10951,19 +10916,19 @@ ethereumjs-util@^5.0.0, ethereumjs-util@^5.0.1, ethereumjs-util@^5.1.1, ethereum
safe-buffer "^5.1.1"
secp256k1 "^3.0.1"
-ethereumjs-util@^7.0.2:
- version "7.0.8"
- resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-7.0.8.tgz#5258762b7b17e3d828e41834948363ff0a703ffd"
- integrity sha512-JJt7tDpCAmDPw/sGoFYeq0guOVqT3pTE9xlEbBmc/nlCij3JRCoS2c96SQ6kXVHOT3xWUNLDm5QCJLQaUnVAtQ==
+ethereumjs-util@^7.0.10:
+ version "7.0.10"
+ resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-7.0.10.tgz#5fb7b69fa1fda0acc59634cf39d6b0291180fc1f"
+ integrity sha512-c/xThw6A+EAnej5Xk5kOzFzyoSnw0WX0tSlZ6pAsfGVvQj3TItaDg9b1+Fz1RJXA+y2YksKwQnuzgt1eY6LKzw==
dependencies:
- "@types/bn.js" "^4.11.3"
+ "@types/bn.js" "^5.1.0"
bn.js "^5.1.2"
create-hash "^1.1.2"
ethereum-cryptography "^0.1.3"
ethjs-util "0.1.6"
rlp "^2.2.4"
-ethereumjs-util@^7.0.9:
+ethereumjs-util@^7.0.2, ethereumjs-util@^7.0.9:
version "7.0.9"
resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-7.0.9.tgz#2038baeb30f370a3e576ec175bd70bbbb6807d42"
integrity sha512-cRqvYYKJoitq6vMKMf8pXeVwvTrX+dRD0JwHaYqm8jvogK14tqIoCWH/KUHcRwnVxVXEYF/o6pup5jRG4V0xzg==
@@ -11026,7 +10991,7 @@ ethereumjs-vm@^2.1.0, ethereumjs-vm@^2.3.4, ethereumjs-vm@^2.6.0:
rustbn.js "~0.2.0"
safe-buffer "^5.1.1"
-ethereumjs-wallet@0.6.5, ethereumjs-wallet@^0.6.0, ethereumjs-wallet@^0.6.4:
+ethereumjs-wallet@0.6.5, ethereumjs-wallet@^0.6.4:
version "0.6.5"
resolved "https://registry.yarnpkg.com/ethereumjs-wallet/-/ethereumjs-wallet-0.6.5.tgz#685e9091645cee230ad125c007658833991ed474"
integrity sha512-MDwjwB9VQVnpp/Dc1XzA6J1a3wgHQ4hSvA1uWNatdpOrtCbPVuQSKSyRnjLvS0a+KKMw2pvQ9Ybqpb3+eW8oNA==
@@ -13533,6 +13498,13 @@ history@^4.9.0:
tiny-warning "^1.0.0"
value-equal "^1.0.1"
+history@^5.0.0:
+ version "5.0.0"
+ resolved "https://registry.yarnpkg.com/history/-/history-5.0.0.tgz#0cabbb6c4bbf835addb874f8259f6d25101efd08"
+ integrity sha512-3NyRMKIiFSJmIPdq7FxkNMJkQ7ZEtVblOQ38VtKaA0zZMW1Eo6Q6W8oDKEflr1kNNTItSnk4JMCO1deeSgbLLg==
+ dependencies:
+ "@babel/runtime" "^7.7.6"
+
hmac-drbg@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1"
@@ -23548,14 +23520,7 @@ semver@7.0.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e"
integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==
-semver@^7.2.1, semver@^7.3.2, semver@^7.3.4:
- version "7.3.4"
- resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.4.tgz#27aaa7d2e4ca76452f98d3add093a72c943edc97"
- integrity sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==
- dependencies:
- lru-cache "^6.0.0"
-
-semver@^7.3.5:
+semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5:
version "7.3.5"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7"
integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==
@@ -25592,9 +25557,9 @@ trezor-link@1.7.3:
whatwg-fetch "^3.5.0"
trim-newlines@^3.0.0:
- version "3.0.0"
- resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.0.tgz#79726304a6a898aa8373427298d54c2ee8b1cb30"
- integrity sha512-C4+gOpvmxaSMKuEf9Qc134F1ZuOHVXKRbtEflf4NTtuuJDEIJ9p5PXsalL8SkeRw+qit1Mo+yuvMPAKwWg/1hA==
+ version "3.0.1"
+ resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.1.tgz#260a5d962d8b752425b32f3a7db0dcacd176c144"
+ integrity sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw==
trim-repeated@^1.0.0:
version "1.0.0"
@@ -26328,12 +26293,7 @@ uuid@^3.1.0, uuid@^3.2.1, uuid@^3.2.2, uuid@^3.3.2, uuid@^3.3.3:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.3.tgz#4568f0216e78760ee1dbf3a4d2cf53e224112866"
integrity sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==
-uuid@^8.0.0:
- version "8.3.1"
- resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.1.tgz#2ba2e6ca000da60fce5a196954ab241131e05a31"
- integrity sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==
-
-uuid@^8.3.0, uuid@^8.3.2:
+uuid@^8.0.0, uuid@^8.3.0, uuid@^8.3.2:
version "8.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==