-
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
Add token selection to the send screen #6445
Conversation
@chikeichan can we get this rebased on the latest |
0a8556a
to
1c129c9
Compare
this.setState({ | ||
isShowingDropdown: false, | ||
}, () => { | ||
this.context.metricsEvent({ |
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.
@danjm Added a metric event - can you verify that I have used the right category and things?
Note: I am tracking whether or not the user selected a Token or Ether, instead of tracking the exact token address. Erring on the side of privacy.
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.
@chikeichan this is correct
In addition, when we first add a custom variable, we need to map it to a specific id in metamask-extension/ui/app/helpers/utils/metametrics.util.js
However there are some limitations on how we do that and before we add anymore custom variables I want to reorganize the code and provide clear inline documentation.
Your code can stay in this PR. But let's not do the additional changes to the metrics util in this PR. I will do them as part of #6453 which I've added to next sprint. I have made a not that references your comment/code.
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.
Looks good overall. Left a few comments. The one about selecting between multiple tokens while editing is the only really important one.
selectedTokenAddress: action.value, | ||
}) | ||
const newSend = extend(metamaskState.send) | ||
|
||
if (metamaskState.send.editingTransactionId && !action.value) { |
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.
This is meant to handle the specific case of when we are editing a transaction and ETH is selected, correct?
I see in send-asset-row.component
that we pass an empty string when ETH is selected. Perhaps instead of just !action.value
, we could explicitly check action.value === ''
. That way the reader of the code here knows that the value passed to the action was intentionally an empty string, and not just defaulting to undefined.
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.
changed it to this.setSelectedToken()
to invoke with no params, keeping it consistent with how it is call everywhere else in the app.
selectedTokenAddress: action.value, | ||
}) | ||
const newSend = extend(metamaskState.send) | ||
|
||
if (metamaskState.send.editingTransactionId && !action.value) { |
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.
What about the case when a user has ETH + two or more tokens in the dropdown. Do we need to modify unapprovedTxs
in state if, while editing a token transaction, a user switches it to a different token?
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.
This part is handled in ui/app/pages/send/send.component.js:L169
. Would love a manual test from you to see if it works. I tested it with multiple tokens locally many times.
ui/app/pages/send/send.component.js
Outdated
const selectedTokenAddress = selectedToken && selectedToken.address | ||
|
||
if (selectedTokenAddress && prevTokenAddress !== selectedTokenAddress) { | ||
updateSendTokenBalance({ |
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.
Can we use this.updateSendToken()
here?
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 catch! Updated
ui/app/pages/send/send.component.js
Outdated
@@ -209,6 +225,7 @@ export default class SendTransactionScreen extends PersistentForm { | |||
updateGas={(updateData) => this.updateGas(updateData)} | |||
scanQrCode={_ => this.props.scanQrCode()} | |||
showHexData={showHexData} | |||
editingTransactionId={editingTransactionId} |
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 don't think we need to pass editingTransactionId
here
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 catch!
|
||
export default class SendContent extends Component { | ||
|
||
static propTypes = { | ||
updateGas: PropTypes.func, | ||
scanQrCode: PropTypes.func, | ||
showHexData: PropTypes.bool, | ||
editingTransactionId: PropTypes.string, |
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 don't think we need to include editingTransactionId
in prop types here
@chikeichan I notice that the spacing between each form element is inconsistent. As per the design system, we have spacing variables defined starting with 0, 4px, 8px, 16px, 24px. and so on. I'm aware that we'll want this to display nicely in the extension viewport as well, so I'd suggest we go with an 8px spacing between form elements (form rows). Adding token selection will push down the transaction fee form element (not ideal) and will end up looking like this, but I think reducing the spacing (to 8px) will help here. |
Two other thoughts:
|
3eb299d
to
a8efcd8
Compare
Going to address @cjeria comment regarding padding tomorrow. For the comment on changing send screen, I think that's too big of a UX change, and it would affect send flow initiated from a Dapp. |
@chikeichan I believe the suggestion about the send screen is to just open the extension in a browser tab when the user goes to the send screen. This is done, for example, in the |
hmm.... I'm still not a big fan of introducing this change to the users. I think opening a new tab is a drastic UX change that we don't know if it's good or bad. Also, if it changes again in the near future when Address Book is shipped, we would be resetting users expectation when it comes to "what happen when I click on send" too many times within a short period of time. A few suggestions, with a couple wild ones:
@cjeria - what do you think 😃 ? |
Nice catch @bdresser! Approved! |
wait @danjm
|
fixed @bdresser |
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.
Let's hold off on merging... I am seeing something weird while QAing on testnet
A couple UX adjustments i've made @cjeria @bdresser