This repository was archived by the owner on May 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
feat - Fixes #293. Shows tx fee estimate and total tx amount. See issues in commit details #307
Merged
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
6eaa9e3
WIP - Fixes #293. Shows tx fee estimate and total tx amount. See issu…
ltfschoen f4d6784
Merge branch 'master' into luke-293-show-tx-fee
ltfschoen b0ce528
review-fix: Swap order that Amount and Gas Price are shown
ltfschoen 9f3b3c6
review-fix: Rename Gas Price back to Transaction Speed
ltfschoen ba122f2
review-fix: Combine Tx Fees and Total Amount into a Tx Details component
ltfschoen c491cba
review-fix: Squeeze calculation into details section and refactor code
ltfschoen 0be070d
refactor: Rename Calculation to Calcs so fits in better
ltfschoen 48136d1
review-fix: Gas Price of 21000 is measured in Wei not Gwei
ltfschoen eebf01d
review-fix: Remove the division by 10**18 since makes it look too com…
ltfschoen aa689f4
review-fix: Darken the colour of the Details section placeholder text
ltfschoen 6964453
review-fix: Toggling the Details/Hide buttons no longer makes Send bu…
ltfschoen 18dab6e
merge latest from master and fix merge conflict
ltfschoen d053f7d
merge latest from master
ltfschoen d9e6a0a
refactor: Make it gas limit clearer in calcs. Round to 9 decimals to …
ltfschoen 0e86a7a
refactor: Simplify syntax of call to function
ltfschoen 13fd9f6
fix: Fix unresolved promise bug when enter valid amount and recipient…
ltfschoen 2ef7659
review-fix: Reorder tx details and make clearer
ltfschoen 5a631b2
review-fix: Tweak tx details. Convert functions into instance methods.
ltfschoen 6ac70de
review-fix: Refactor into TxDetails component and make text selectable
ltfschoen 7f45a5a
fix: Remvoe useless else
ltfschoen 96b7109
review-fix: Use fromWei to convert to ether values
ltfschoen 01887a3
review-fix: Fix indentation
ltfschoen e576126
review-fix: Add try/catch and throw error if estimateGas throws. See …
ltfschoen b3fc6e2
review-fix: Move logic so TxDetails not unnecessarily mounted
ltfschoen 2e4ef04
refactor: Move TxDetails in TxForm folder since only used by that com…
ltfschoen 86d6e19
Merge branch 'master' into luke-293-show-tx-fee
ltfschoen d370246
review-fix: Replace concat with interpolated strings on new lines
ltfschoen 44fa269
fix: Fix typo
ltfschoen 7a53f64
review-fix: Pass down estimatedTxFee value instead of the function as…
ltfschoen e7af4eb
review-fix: Remove useless prop that is no longer used
ltfschoen c331736
review-fix: Change TxDetails text to be full opacity to match normal …
ltfschoen 7af4838
review-fix: Show values that have Wei decimal places. Need remove tra…
ltfschoen 7b79b80
review-fix: Remove trailing zeros from big number decimal values for …
ltfschoen b73ecab
fix: Do not process removing trailing zeros when more than one decima…
ltfschoen 063215b
merge latest from master
ltfschoen e5e3a76
refactor: Move autofocus from the Amount to the To input field on TxForm
ltfschoen 2a9403b
review-fix: Hide vertical overflow on body element so scrollbar not f…
ltfschoen a684de2
review-fix: Remove toFixed(18) so do not need script to remove traili…
ltfschoen bd56db6
review-fix: TxDetails floats above footer. TxDetails toggle buttons m…
ltfschoen 2d96f28
review-fix: Restore TxDetails between inputs and footer. Move toggle …
ltfschoen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
packages/fether-react/src/Send/TxForm/TxDetails/TxDetails.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright 2015-2018 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity. | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
import React, { Component } from 'react'; | ||
import BigNumber from 'bignumber.js'; | ||
import { fromWei, toWei } from '@parity/api/lib/util/wei'; | ||
|
||
class TxDetails extends Component { | ||
renderCalculation = () => { | ||
const { estimatedTxFee, values } = this.props; | ||
|
||
const gasPriceBn = new BigNumber(values.gasPrice.toString()); | ||
const gasLimitBn = estimatedTxFee | ||
.div(gasPriceBn) | ||
.div(10 ** 9) | ||
.toFixed(0) | ||
.toString(); | ||
|
||
return `Estimate amount of gas: ${gasLimitBn}`; | ||
}; | ||
|
||
renderDetails = () => { | ||
return `${this.renderCalculation()} | ||
${this.renderFee()} | ||
${this.renderTotalAmount()}`; | ||
}; | ||
|
||
renderFee = () => { | ||
const { estimatedTxFee } = this.props; | ||
|
||
return `Fee: ${fromWei(estimatedTxFee, 'ether') | ||
.toFixed(9) | ||
.toString()} ETH (estimate * gas price)`; | ||
}; | ||
|
||
renderTotalAmount = () => { | ||
const { estimatedTxFee, token, values } = this.props; | ||
|
||
return `Total Amount: ${fromWei( | ||
estimatedTxFee.plus( | ||
token.address === 'ETH' ? toWei(values.amount.toString()) : 0 | ||
), | ||
'ether' | ||
).toString()} ETH`; | ||
}; | ||
|
||
render () { | ||
const { showDetails } = this.props; | ||
|
||
return ( | ||
<div> | ||
<div className='form_field'> | ||
<div hidden={!showDetails}> | ||
<label htmlFor='txDetails'>Transaction Details (Estimate):</label> | ||
<textarea | ||
className='-sm-details' | ||
id='txDetails' | ||
readOnly | ||
value={this.renderDetails()} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default TxDetails; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright 2015-2018 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity. | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
import TxDetails from './TxDetails'; | ||
|
||
export default TxDetails; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ body { | |
font-weight: 400; | ||
font-size: ms(0); | ||
line-height: ms(0) * 1.3; | ||
overflow-y: hidden; | ||
} | ||
|
||
.hidden { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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. Not sure this vulnerability concerns us since we're not a website, but anyways, it's a good habit to have. 👍