-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add gas estimate and add more explanation (#1063)
* fix-faq-background * Add second text on step1 * Add gas estimate * Add translation * Separete into Price and GasPrice * Do not show gas price estimate for renewal * Get rid of gas detail * Change to show gas price range and simpify the UI * Remove gasDescription * Remove the mention of the buffer
- Loading branch information
Showing
16 changed files
with
202 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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
94 changes: 94 additions & 0 deletions
94
src/components/SingleName/NameRegister/EthRegistrationGasPrice.js
This file contains 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,94 @@ | ||
import React, { useState } from 'react' | ||
import styled from '@emotion/styled/macro' | ||
import { useTranslation, Trans } from 'react-i18next' | ||
import mq from 'mediaQuery' | ||
import EthVal from 'ethval' | ||
import DefaultInput from '../../Forms/Input' | ||
const GWEI = 1000000000 | ||
const COMMIT_GAS_WEI = 42000 | ||
const REGISTER_GAS_WEI = 240000 | ||
const TOGAL_GAS_WEI = COMMIT_GAS_WEI + REGISTER_GAS_WEI | ||
|
||
const PriceContainer = styled('div')` | ||
width: 100%; | ||
${mq.medium` | ||
width: auto | ||
`} | ||
margin:5px 0; | ||
` | ||
|
||
const Value = styled('div')` | ||
font-family: Overpass; | ||
font-weight: 100; | ||
font-size: 22px; | ||
color: #2b2b2b; | ||
border-bottom: 1px solid #dbdbdb; | ||
${mq.small` | ||
font-size: 28px; | ||
`} | ||
` | ||
|
||
const TotalValue = styled(Value)` | ||
font-weight: 300; | ||
` | ||
|
||
const Description = styled('div')` | ||
font-family: Overpass; | ||
font-weight: 300; | ||
font-size: 14px; | ||
color: #adbbcd; | ||
margin-top: 10px; | ||
` | ||
|
||
const USD = styled('span')` | ||
font-size: 22px; | ||
color: #adbbcd; | ||
margin-left: 20px; | ||
${mq.small` | ||
font-size: 28px; | ||
`} | ||
` | ||
|
||
const Input = styled(DefaultInput)` | ||
display: inline-block; | ||
width: 4em; | ||
margin: 5px 0; | ||
` | ||
|
||
const EthRegistrationGasPrice = ({ price, ethUsdPrice, gasPrice }) => { | ||
const { t } = useTranslation() | ||
console.log('***gasPrice', gasPrice) | ||
const ethVal = new EthVal(`${price}`).toEth() | ||
const registerGasSlow = new EthVal(`${TOGAL_GAS_WEI * gasPrice.slow}`).toEth() | ||
const registerGasFast = new EthVal(`${TOGAL_GAS_WEI * gasPrice.fast}`).toEth() | ||
const gasPriceToGweiSlow = new EthVal(`${gasPrice.slow}`).toGwei() | ||
const gasPriceToGweiFast = new EthVal(`${gasPrice.fast}`).toGwei() | ||
const totalSlow = ethVal.add(registerGasSlow) | ||
const totalFast = ethVal.add(registerGasFast) | ||
const totalInUsdSlow = totalSlow.mul(ethUsdPrice) | ||
const totalInUsdFast = totalFast.mul(ethUsdPrice) | ||
return ( | ||
<PriceContainer> | ||
<TotalValue> | ||
{ethVal.toFixed(3)} ETH + {registerGasSlow.toFixed(3)}- | ||
{registerGasFast.toFixed(3)} ETH = {totalSlow.toFixed(3)}- | ||
{totalFast.toFixed(3)} ETH | ||
{ethVal && ethUsdPrice && ( | ||
<USD> | ||
{' '} | ||
${totalInUsdSlow.toFixed(2)}-${totalInUsdFast.toFixed(2)} | ||
USD | ||
</USD> | ||
)} | ||
</TotalValue> | ||
<Description> | ||
{t('pricer.totalDescription', { | ||
gasPriceToGweiSlow: gasPriceToGweiSlow.toFixed(0), | ||
gasPriceToGweiFast: gasPriceToGweiFast.toFixed(0) | ||
})} | ||
</Description> | ||
</PriceContainer> | ||
) | ||
} | ||
|
||
export default EthRegistrationGasPrice |
This file contains 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 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 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
Oops, something went wrong.