-
Notifications
You must be signed in to change notification settings - Fork 47
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
Send Page amount USD. #152
Conversation
The amount-usd feature doesn't work. The currency conversion feature isn't just to show a user DCR equivalent in dollars but to also allow the user input an amount in dollars and have its DCR equivalent sent. Currently, it doesn't do that. |
ui/send_page.go
Outdated
pg.activeTotalAmount = dcrutil.Amount(amountAtoms).String() | ||
pg.inactiveTotalAmount = totalAmountUSDTostring | ||
pg.activeTransactionFeeValue = dcrutil.Amount(txFee).String() | ||
pg.inactiveTransactionFeeValue = fmt.Sprintf("(%f USD)", txFeeValueUSD) | ||
pg.activeTotalCostValue = dcrutil.Amount(totalCostDCR).String() | ||
pg.inactiveTotalCostValue = fmt.Sprintf("(%s USD)", strconv.FormatFloat(totalAmountUSD+txFeeValueUSD, 'f', 7, 64)) |
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 looks repeated. To make it cleaner, you can create a data type for it. For each case, assign the respective data properties their respective methods and pass that to a single method that initiates those values to the SendPage properties.
Also, all that would be cleaner if they were in a separate method.
ui/send_page.go
Outdated
return amountAtoms | ||
} | ||
|
||
func (pg *SendPage) setUSDValues(usdExchangeRate, inputAmount float64, totalCostDCR, txFee, amountAtoms int64) { |
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.
make this a data type and pass a single argument to the Set method.
ui/send_page.go
Outdated
pg.activeTotalAmount = totalAmountUSDTostring | ||
pg.inactiveTotalAmount = dcrutil.Amount(amountAtoms).String() | ||
pg.activeTransactionFeeValue = fmt.Sprintf("%f USD", txFeeValueUSD) | ||
pg.inactiveTransactionFeeValue = fmt.Sprintf("(%s)", dcrutil.Amount(txFee).String()) | ||
pg.activeTotalCostValue = fmt.Sprintf("%s USD", strconv.FormatFloat(inputAmount+txFeeValueUSD, 'f', 7, 64)) | ||
pg.inactiveTotalCostValue = fmt.Sprintf("(%s )", dcrutil.Amount(totalCostDCR).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.
you only need one method to set these.
ui/send_page.go
Outdated
pg.activeTotalAmount = dcrutil.Amount(amountAtoms).String() | ||
pg.inactiveTotalAmount = totalAmountUSDTostring | ||
pg.activeTransactionFeeValue = dcrutil.Amount(txFee).String() | ||
pg.inactiveTransactionFeeValue = fmt.Sprintf("(%f USD)", txFeeValueUSD) | ||
pg.activeTotalCostValue = dcrutil.Amount(totalCostDCR).String() | ||
pg.inactiveTotalCostValue = fmt.Sprintf("(%s USD)", strconv.FormatFloat(totalAmountUSD+txFeeValueUSD, 'f', 7, 64)) |
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.
you only need one method to set these.
ui/send_page.go
Outdated
func (pg *SendPage) updateDefaultValues(totalCostDCR, txFee, amountAtoms int64, noExchangeText string) { | ||
pg.activeTotalAmount = dcrutil.Amount(amountAtoms).String() | ||
pg.inactiveTotalAmount = noExchangeText | ||
pg.activeTransactionFeeValue = dcrutil.Amount(txFee).String() | ||
pg.inactiveTransactionFeeValue = "" | ||
pg.activeTotalCostValue = dcrutil.Amount(totalCostDCR).String() | ||
pg.inactiveTotalCostValue = "" | ||
} |
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 the only method you need to set the data. And it only really needs to accept one argument.
remove data struct
initialize exchange call on send page load split switch code to multi func
fix issue with repeated print to terminal
* add default value without exchange * add currency change button * remove imported account * initialize exchange call on send page load
Resolves
Issue #142
What's new
This PR adds the send amount USD equivalence for all transactions fields to the send Page.
Relevant screenshots or logs