-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds toggle for primary currency #5421
Conversation
looks awesome @alextsg! @cjeria @danfinlay on the confirm screen, are you cool with the diamond? or would you prefer |
Conceptually, I like the idea of using a diamond to represent the ETH symbol, however, what I keep on getting caught up with is the fact that it's not exactly the Ethereum symbol - it's generic diamond alt code. I know some folks in the community have proposed using Ξ to represent Eth. https://www.reddit.com/r/ethereum/comments/6ldlgi/making_%CE%BE_ether_symbol_more_known/ I think if we decide to go with an ETH symbol, we should use the actual version of the logo in SVG format to reuse in different contexts. Here's a link to an svg version of the eth symbol |
That makes sense, and I'm open to either one. Should we also make the representation, whether it be the ETH logo or Ξ, be consistent across the whole app? This would include the transactions list, wallet view, etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure introducing a preferences
property to the PreferencesController state is the best option here—something about preferencesController.store.getState().preferences
seems redundant to me. Shouldn't the entire state of the PreferencesController keep be considered the "preferences"?
Also the generic setPreference
method taking a string argument is a bit lax. I could live with it if we introduced constants for each of the available preferences (e.g. setPreference(PreferencesController.USE_ETH_AS_PRIMARY, value)
) but I think we're better off having a method to set each of the preferences directly. With this implementation we can easily mistype preference names e.g. setPreference('useETHAsPriamryCurrency', value)
.
@whymarrh From changes in the PR, I agree with the second point - I was following what we were doing with modals and feature flags. Creating specific methods for each preference will probably work better. |
Ah, yes—I had forgotten that we flatten the state. 😔 |
Yeah, I guess. For now let's use the ethereum diamond here and we can get to the rest shortly. Filed here: #5477 |
Is this just about Eth vs Fiat or does this also affect displaying token values vs fiat values? what happens when we're missing fiat values (e.g. ether price api is down)? |
@kumavis This is about ETH vs Fiat. For tokens this would affect whether an ETH or Fiat value is displayed as the conversion underneath. By missing Fiat values/price API being down are you referring to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! I left a few minor comments.
import PropTypes from 'prop-types' | ||
import TokenInput from '../token-input' | ||
|
||
export default class UserPreferencedCurrencyInput extends PureComponent { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UserPreferencedCurrencyInput
-> UserPreferencedTokenInput
const { decimalValue } = this.state | ||
|
||
return ( | ||
<UnitInput |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracting the UnitInput component was a great idea 👍
import UserPreferencedCurrencyDisplay from '../user-preferenced-currency-display.component' | ||
import CurrencyDisplay from '../../currency-display' | ||
|
||
describe('UserPreferencedCurrencyInput Component', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UserPreferencedCurrencyInput
-> UserPreferencedCurrencyDisplay
@@ -0,0 +1,13 @@ | |||
import { connect } from 'react-redux' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if either user-preferenced-currency-input.container.js
or currency-input.container.js
can be eliminated?
They both only get a small amount of data from state, and the currency-input.container.js
is only ever imported in the user-preferenced-currency-input.component.js
.
It seems like CurrencyInput
could be an unconnected component that just receives its props from its parent. I think this would make it easier to understand the relation between the UserPreferencedCurrencyInput
and the CurrencyInput
. Also could make CurrencyInput
more flexible for future use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way I look at this is that UserPreferencedCurrencyInput
builds on top of CurrencyInput
, which builds on top of UnitInput
, the unconnected component. Everything that UserPreferencedCurrencyInput
and CurrencyInput
does can be done with UnitInput
itself, but they're just added layers of convenience and do require being connected to the redux store. It's a much easier API to use for the developer when the component requires just a few props to use and reduces duplication of managing these props.
09f7f17
to
91879c4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a quick QA pass and this LGTM 👍
91879c4
to
55d7fb5
Compare
Fixes #4510
Fixes #5477
Screenshots