A lint error was accidentally introduced recently when two PRs changed
the same area of code (#9793 and #9795). They didn't conflict, and the
lint passed for both, but when combined they left an unused variable.
This page appears to serve the sole purpose of locking the extension
and redirecting back to the base route if the page is refreshed during
the onboarding flow. This ineffectual before the vault has been
initialized, and it's a barrier to resuming interrupted onboarding
flows when done after initialization.
This prop was being passed to the `CreatePassword` component, but that
component has no prop with this name. In fact, no component in this
entire project does.
Adds swaps-gas-customization-modal and utilize in swaps
Remove swaps specific code from gas-modal-page-container/
Remove slow estimate data from swaps-gas-customization-modal.container
Use average as lower safe price limit in swaps-gas-customization-modal
Lint fix
Fix up unit tests
Update ui/app/ducks/swaps/swaps.js
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Remove stale properties from gas-modal-page-container.component.js
Replace use of isCustomPrice safe with isCustomSwapsGasPriceSafe, in swaps-gas-customization-modal
Remove use of averageIsSafe in isCustomPriceSafe function
Stop calling resetCustomGasState in swaps
Refactor 'setter' type actions and creators to 'event based', for swaps slice custom gas logic
Replace use of advanced-tab-content.component with advanceGasInputs in swaps gas customization component
Add validation for the gasPrices endpoint
swaps custom gas price should be considered safe if >= to average
Update renderDataSummary unit test
Lint fix
Remove customOnHideOpts for swapsGasCustomizationModal in modal.js
Better handling for swaps gas price loading and failure states
Improve semantics: isCustomSwapsGasPriceSafe renamed to isCustomSwapsGasPriceUnSafe
Mutate state directly in swaps gas slice reducer
Remove unused params
More reliable tracking of speed setting for Gas Fees Changed metrics event
Lint fix
Throw error when fetchSwapsGasPrices response is invalid
add disableSave and customTotalSupplement to swaps-gas-customization container return
Update ui/app/ducks/swaps/swaps.js
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Improve error handling in fetchMetaSwapsGasPriceEstimates
Remove metricsEvent from swaps-gas-customization-modal context
Base check of gas speed type in swaps-gas-customization-modal on gasEstimateType
Improve naming of variable and functions use to set customPriceIsSafe prop of AdvancedGasInputs in swaps-gas-customization-modal
Simplify sinon spy/stub code in gas-price-button-group-component.test.js
Remove unnecessary getSwapsFallbackGasPrice call in swaps-gas-customization-modal
Remove use of getSwapsTradeTxParams and clean up related gas price logic in swaps
Improve validator of SWAP_GAS_PRICE_VALIDATOR
Ensure default tradeValue
* Display network form chain ID in decimal
* Hide chainId tooltip in view mode
* Display chain ID error message in entered format
* Update locale messages
* Rename on change chain ID validator
There were a few lint errors introduced in #9768 due to the recently
merged prettier PR. They have now been fixed.
Additionally, one line using the property `eth_accounts` was
intermittently failing for me locally. I've been seeing this lint
failure off-and-on for a few days now - I'm not sure why I haven't seen
it on CI. Either way though, it's now ignored.
This will allow usage in areas where getting the line-height, etc
of the typography settings will introduce issues. The mixins have been
updated to references these variables so that they can be changed in
one place in the future
* Check if swapTokenValue is negative and set prefix accordingly
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
* Ensure that trade.value fees are included in displayed network fees
* Remove unused getTotalEthCost function
* Remove unused getTotalEthCost function
* Update ui/app/pages/swaps/swaps.util.js
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
* Lint fix
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
If the attempt to fetch quotes fails, an error message is now logged to
the console explaining why it failed. This makes it dramatically easier
to understand what's happening when quotes fail.
At some point later on we should also look specifically for errors we
expect to occur, and report to Sentry in unexpected cases. I've added a
TODO comment about this.
* Update main-quote-summary designs/styles
* Clean up css: use className instead of element types
* Style fixes to symbol elements in main-quote-view
* Use correct source for token iconUrls passed to main-quote-view
* Improve vertical spacing on view-quote screen and with new main-quote-view designs
* Remove unused classes
* Tweak space around large quote amount text in main-quote-summary
These two stories showcased components that used React context and
Redux state that was not made available in the stories themselves. They
both crashed with an error when rendered in Storybook.
Instead of going through a great deal of effort to setup mocks for the
global Redux state and context, they have been removed. They are
perhaps the wrong layer for us to showcase in Storybook. Storybook is
more well suited for individual components that contain just UI logic.
A PropType error was shown in the console when on the Awaiting Swap
page in certain error scenarios. The `symbol` property was sometimes
not set if `destinationTokenInfo` was missing.
The `symbol` prop has been removed, as the `AwaitingSwap` component
already selected the `fetchParams`, and the `destinationTokenInfo`
object within. The prop was effectively a duplicate.
Refs #9663
See [`node/no-deprecated-api`][1] for more information.
This change enables `node/no-deprecated-api` and fixes the issues raised by the rule.
[1]:https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/no-deprecated-api.md
The change to the way that `punycode` is imported is to address the fact that
third-party module is hidden by the built-in. This is a silly hack but it works.
Consolidates the background and UI segment implementations into a shared solution.
This results in the introduction of our first shared module.
Co-authored-by: Erik Marks <25517051+rekmarks@users.noreply.github.com>
`@metamask/eslint-config` has been updated to v4.1.0. This update
requires that we update `eslint` to v7 as well, which in turn requires
updating most `eslint`-related packages.
Most notably, `babel-eslint` was replaced with `@babel/eslint-parser`,
and `babel-eslint-plugin` was replaced by `@babel/eslint-plugin`. This
required renaming all the `babel/*` rules to `@babel/*`.
Most new or updated rules that resulted in lint errors have been
temporarily disabled. They will be fixed and re-enabled in subsequent
PRs.
Sorting was broken for the "Quote Source" column of the quote sort
list. Attempting to sort by this column would arrange the quotes in a
seemingly random order.
It appears that this was due to this column being programmed to sort by
a property called `liquiditySource`, which does not exist in the quote
data. I'm unsure what the difference between `liquiditySource` and
`quoteSource` was supposed to be; the values in the mocks are all
identical.
All references to `liquiditySource` have been updated to refer to
`quoteSource` instead, and the sorting now works correctly.
The `conversionRate` prop of `GasModalPageContainer` was updated
recently in PR #9623 to have a PropType of `string` instead of
`number`. This resulted in a PropType error whenever this modal was
rendered, as `conversionRate` is always a `number`.
The PropType has been reverted to the correct type, `number`.
The `InfoTooltip` component had a `contentText` prop with a PropType of
`string` that was being passed a `node` as of #9614. This resulted in a
PropType error.
The `contentText` prop was being passed directly to `Tooltip` component
as the prop `html`, which has a PropType of `node`. A string is a valid
`node` type, which is why this worked before.
The `contentText` prop is now of type `node`, and the error no longer
appears.
The `message` prop of `ActionableMessage` had a PropType of `string`,
but it was being passed a `node`. This was resulting in a PropType
error in the console on the view quote page.
The PropType has been changed to `node`, and the error is now gone.
The `AwaitingSwap` component was emitting a React warning when rendered
because a component was being rendered in an array without having a
`key` prop set.
A key has been added to the `CountdownTimer` component, which is passed
into the translation helper in an array. The warning no longer appears.
The `metaMaskFee` property on the "quote data" PropType was not used,
and it never existed in practice. This resulted in PropType errors.
The non-existent property has been removed.
The MetaMask fee is shown with two percent signs on the view quote page, because the percent sign is embedded in the fee amount as well as in the localized message.
The fee amount used now comes from the API, and does not have a percent sign. The percent sign is now only in the localized message. This allows for different locales to display the percentage differently. The old hard-coded value with a percent sign embedded has been removed, as it is no longer used anywhere.
* Only format timeRemaining if in useTransactionTimeRemaining if it is truthy
* Only setTimeRemaining in useTransactionTimeRemaining if submitted time is a number
* Use isSubmitted as a check, instead of isPending and submittedTime, before calculating timeRemaining
* Add a minimumGasLimit to the gas customization modal in swaps
* Update app/_locales/en/messages.json
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
* Set default for minimum gas limit in gas-modal-page-container.container and make required in sub components
* Update unit tests
* Default value for minimumGasLimit in advanced-gas-inputs.component.js
* Preserve existing gasLimitTooLow message key by creating new gasLimitTooLowWithDynamicFee
* Fix failing unit test
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Co-authored-by: Erik Marks <rekmarks@protonmail.com>
* Don't show average (slowest) button in custom gas modal while in swaps
* In swaps, show warning in custom gas modal if price set below average price
* Update ui/app/selectors/custom-gas.js
Co-authored-by: Erik Marks <25517051+rekmarks@users.noreply.github.com>
* Fix typo
Co-authored-by: Erik Marks <25517051+rekmarks@users.noreply.github.com>
* Explicitly set balance and string on the swaps from token in token-overview
* Set swapsFromToken balance to a decimal instead of a hex on eth balance change in build-quote
We were unable to deliver this public dashboard as we had originally
anticipated, and this is no longer a priority for the team. We may
revisit this idea in the future, but for now it has been removed from
our list of commitments.
* Add data point to 'Swaps Completed' segment event: estimated vs used gas
* Linted
* Correct property name for estimated gas on swapMetaData in _trackSwapsMetrics()
* Set estimated_gas property on swapMetaData to a hex string
* Correct base when dividing by estimated_gas
Co-authored-by: Dan Finlay <dan@danfinlay.com>
* Delete CachedBalancesController.cachedBalances
* Migrate provider to Rinkeby instead of deleting it
* Convert hex transaction metamaskNetworkId values to decimal
* Don't migrate provider state in e2e tests
* Don't kick custom RPC users to Rinkeby unnecessarily
* Use provider.chainId for address book chainId values
* Add address book migration
* Fix failing unit test
* fixup! Merge branch 'develop' into address-book-use-chainId
* Select address book entries for display by chainId
* Merge all address book entry keys
* fixup! Merge all address book entry keys
* Delete localhost provider type
* Use ganache-cli default chain ID for tests
* Delete unused test firstTimeState variable
* Migrate default ganache-cli network to frequentRpcListDetail
* Add default test provider state
* Add test functionality to createJsonRpcClient
* Lint locales
* Update test middleware creation
* fixup! Update test middleware creation
* Update txMeta after postTxBalance has been retrieved
* Use gas used from txReceipt to calculate eth received
* Return null from getSwapsTokensReceivedFromTxMeta in tokenSymbol is ETH and txReceipt is missing
* Get latest txMeta before updating it with postTxBalance in case of a swaps tx in confirmTransaction
* Lint fix
* Use initial transaction for settings swap transaction title params, and remove addition of swap properties to cancel transcations
* Update unit test data
* Use token symbol properties from initial transaction for filitering in transaction list
* Set result of calcTokenAmount to base 10 string in useTokenDisplayValue
* Use primaryCurrency for amount in transaction breakdownd details
* Hidden overflow and text overflow ellipsis on long primary currency in transaction-list-item
* Empty prefix for token approvals
* Conditional render primaryCurrency title in tx breakdown to `Spend limit amount` when tx is a token approve.
* Add title to primaryCurrency in tx list item to show full amount on hover
* Update ui/app/components/app/transaction-breakdown/transaction-breakdown.component.js
DRY title conditional rendering.
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
* Add useSwapsEthToken hook and utilize wherever we need the ETH 'token' for swaps
* Remove rawEthTokens param from useTokensToSearch calls
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Co-authored-by: Erik Marks <rekmarks@protonmail.com>
The quote list columns have been adjusted to add more space in between
the columns. Additionally, the third column cells are now better
aligned under the header. A few unnecessary `<div>`s and CSS classes
have been removed as well.
This updated error message shows the key of the message instead of the
message text itself, followed by the locale code.
This will make it easier to filter messages we want to ignore in
Sentry. Currently it's difficult to filter because the message is
radically different for each locale. With this change, we can add a
filter and use a glob for the last part to filter it for all locales.
It's still important to include the locale code in the message, so that
we can catch cases where the message has the wrong number of
substitutions for a specific locale.
* Only shows the swaps intro popup on mainnet
* Remove code that closes swaps popup from e2e tests
* correct casing on isMainnet prop in home component
The tooltip for the Retry Transaction button would be erroneously set
to display a custom block explorer, if one was set for the current
network. It now displays the intended retry transaction text in all
cases.
On-chain failed transactions have a transaction status of `confirmed`,
and should not be retried. Our retry function doesn't handle on-chain
failures yet, so it would inevitably fail due to the transaction having
the same nonce as a confirmed on-chain transaction.
When determining whether to show the retry button in the UI, we had
mistakenly been using a `status` variable that determined whether we
should show "Failed" on that transaction in the activity log. That
display status includes both network and on-chain failures, unlike
the `txMeta.status` property.
The `showRetry` logic has been updated to ensure it's only shown when
`txMeta.status` is `failed`, meaning on-chain failures will no longer
show the retry button. Additionally, the display-specific `status`
variable has been renamed to `displayedStatusKey`, to indicate that it
is a string that corresponds to a localized message, and that it's the
status meant for display purposes.
* Stop passing a gas param to the estimateGas call initiated in the swaps controller timedoutGasReturn
* Stop passing gas params to timedoutGasReturn
* Lint fix
* Stop passing no longer used param to setInitialGasEstimate
The app header would sometimes mistakenly not get rendered while on the
Home screen. This could happen when a permission request was made while
the UI was open, to either the browser action popup or the fullscreen
UI.
This was caused by faulty logic in the top-level router component. It
would hide the app header if there was a pending permission request,
presumably because the author assumed that a redirect to the permission
flow would shortly follow. This redirect only happens on mount though,
not if the UI was already open when the permission request was
submitted.
The intent of this logic was to hide a brief flash of the app header
prior to rendering the permission flow. This brief flash has now been
restored, which is unfortunate, but is better than the missing app
header bug. We can revisit a solution to removing this flash in the
future, hopefully in a manner that avoids this bug and works for all
notification UI cases.
If a notification popup was opened while the user was partway through
the swaps flow, the notification would display the swaps flow instead
of whatever action triggered the popup (e.g. a connect request or a
confirmation). This is confusing and potentially dangerous, as the
user might mistakenly think the swap was triggered by a dapp.
The swap redirects are now prevented in the notification UI. The user
will still be redirected to an in-progress swap flow if they open the
browser action popup or the fullscreen UI, but not on the notification
popup that is triggered by dapp actions.
* Remove network config store
* Remove inline networks variable in network controller
* Re-key network controller 'rpcTarget' to 'rpcUrl'
* Require chainId in lookupNetwork, implement eth_chainId
* Require chain ID in network form
* Add alert, migrations, and tests
* Add chainId validation to addToFrequentRpcList
* Update public config state selector to match new network controller
state
* Use network enums in networks-tab.constants
* Ensure chainId in provider config is current
* Update tests
* Fix dismiss button on unconnected alert modal
Set button type to primary, rounded, and set `!important` on css class width
* Update ui/app/components/app/alerts/unconnected-account-alert/unconnected-account-alert.scss
* Add unconnected-account-alert to popover component classname to simplify css selector.
Co-authored-by: Brad Decker <git@braddecker.dev>
Add a prop to the `ButtonGroup` component to make it act as a group of
radio buttons, rather than a group of regular buttons. These commits
were written by @danjm - I just pulled them into this branch.
* Show token symbol when token amount string is long
Fixes#9318
This essentially separates the token cell list item title/token amount and the token symbol.
I do request advice/recomendations on how to better handle the new `subTtitle` which I set the token symbol to and the `subtitle` https://github.com/MetaMask/metamask-extension/blob/develop/ui/app/components/app/asset-list-item/asset-list-item.js#L99.
* Individually test token balance and token symbol and their associated css element
* Feedback commit
* Classname and css overflow for title with string.
This change moves warning message from `add-recipient` component to `send-content`. Currently
whenever provided address is a valid eth address `send-content` is rendered instead of `add-recipient`
this is why warnings never popped up.
* Use verifyPassword instead of submitPassword when exporting priv key
Fixes#9287 which was when submitPassword is called will fully clear the keyring state
https://github.com/MetaMask/KeyringController/blob/master/index.js#L155ad823d0ac1/index.js (L562)ad823d0ac1/index.js (L726)
Also, pass hideWarning action prop so it will clear the appState.warning if a correct password is never provided on componentWillUnmount
* Hide Warning on componentWillUnmount
* Update exportAccount tests to verifyPassword
* Update ui/app/store/actions.js
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
* MetaMask mascot support for provided directions targets and toggling followMouse
* Fixes for mascot.component.js
* Update metamask-logo version to 2.4.0
* Lint fix
* Fix mouse follow updating
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
* Improve mascot story name
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
* Update package.json
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
* Lint fix
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
* Add react-testing-library
Adds react-testing-library as a dependency, creates a wrapper function with Provider store/I18n context support, and implements it in unconnected-account-alert.
* Refactor renderWithProvider store to extra param, instead of component prop store
this moves very little code around, to enable deleting files that are
no longer used or necessary. There are a few more things to move and
delete that will be handled in a seperate PR after this one.
Follows the previously set pattern of colocating styles along side the
consuming components. This one was really straight forward and just a
reorganization of files and imports. No code changes occurred.
The old tooltip component was only used in two places. Removing those usages
was simple and straight forward. So, instead of colocating the old tooltip
styles with the deprecated tooltip component, I removed all old styles and
made tooltip-v2 now simply 'tooltip' and removed the deprecated component.
Follows the previously set pattern of colocating styles along side the
consuming components. This one was really straight forward and just a
reorganization of files and imports. No code changes occurred.
The only place that these .menu styles were being used was the account-menu by way of components/app/dropdowns/menu. Because account-menu is the only place that used these styles I moved them to exist with the account-menu
Follows previous patterns of moving styles to exist alongside the components that use them. I would like these styles to be updated to use BEM syntax as well but I am holding off for a future PR to improve these styles.
* Clear Account Details in AppState
We store sensitive information in the AppState under accountDetail for when the modal is active and present. This adds a new action/reducer and componentWillUnmount to clean up the persisted data left after leaving the modal.
* Remove reduntant clearAccountDetails call when clicking done button
This change tidies up the implementation of `ConnectHardwareForm#checkIfUnlocked`—passing
an `async` function to `forEach` doesn't ensure that the one is run before the other.
* Fix require-unicode-regexp issues
See [`require-unicode-regexp`](https://eslint.org/docs/rules/require-unicode-regexp) for more information.
This change enables `require-unicode-regexp` and fixes the issues raised by the rule.
* Remove case-insensitive flag from regexps