Skip to content

Commit

Permalink
fix: price in usd (DimensionDev#4470)
Browse files Browse the repository at this point in the history
* fix: fix grammar

* fix: price in usd

* fixup! fix: price in usd
  • Loading branch information
UncleBill authored Sep 26, 2021
1 parent aabb1e9 commit 16dde4b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/maskbook/src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,10 @@
"wallet_transfer_error_gasLimit_absence": "Enter a gas limit",
"wallet_transfer_error_maxFee_absence": "Enter a max fee",
"wallet_transfer_error_maxPriority_fee_absence": "Enter a max priority fee",
"wallet_transfer_error_max_fee_too_low": "Max fee too low for network conditions.",
"wallet_transfer_error_max_fee_too_low": "Max fee is too low for network conditions.",
"wallet_transfer_error_max_fee_too_high": "Max fee is higher than necessary",
"wallet_transfer_error_max_priority_gas_fee_positive": "Max priority fee must be greater than 0 GWEI",
"wallet_transfer_error_max_priority_gas_fee_too_low": "Max priority fee is low for current network conditions",
"wallet_transfer_error_max_priority_gas_fee_too_low": "Max priority fee is too low for network conditions",
"wallet_transfer_error_max_priority_gas_fee_too_high": "Max priority fee is higher than necessary. You may pay more than needed.",
"wallet_transfer_error_max_priority_gas_fee_imbalance": "Max fee cannot be lower than max priority fee",
"wallet_transfer_gwei": "GWEI",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ export const GasSetting1559: FC<GasSettingProps> = memo(

const onSubmit = handleSubmit(handleConfirm)

const [maxPriorityFeePerGas, maxFeePerGas] = watch(['maxPriorityFeePerGas', 'maxFeePerGas'])
const [maxPriorityFeePerGas, maxFeePerGas, inputGasLimit] = watch([
'maxPriorityFeePerGas',
'maxFeePerGas',
'gasLimit',
])

//#region These are additional form rules that need to be prompted for but do not affect the validation of the form
const maxPriorFeeHelperText = useMemo(() => {
Expand Down Expand Up @@ -189,6 +193,7 @@ export const GasSetting1559: FC<GasSettingProps> = memo(
{t('popups_wallet_gas_fee_settings_usd', {
usd: formatGweiToEther(content?.suggestedMaxFeePerGas ?? 0)
.times(nativeTokenPrice)
.times(21000)
.toPrecision(3),
})}
</Typography>
Expand Down Expand Up @@ -226,6 +231,7 @@ export const GasSetting1559: FC<GasSettingProps> = memo(
{t('popups_wallet_gas_fee_settings_usd', {
usd: formatGweiToEther(Number(maxPriorityFeePerGas) ?? 0)
.times(nativeTokenPrice)
.times(inputGasLimit || 1)
.toPrecision(3),
})}
</Typography>
Expand Down Expand Up @@ -257,6 +263,7 @@ export const GasSetting1559: FC<GasSettingProps> = memo(
{t('popups_wallet_gas_fee_settings_usd', {
usd: formatGweiToEther(Number(maxFeePerGas) ?? 0)
.times(nativeTokenPrice)
.times(inputGasLimit || 1)
.toPrecision(3),
})}
</Typography>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const Prior1559GasSetting: FC<GasSettingProps> = memo(
control,
handleSubmit,
setValue,
watch,
formState: { errors },
} = useForm<zod.infer<typeof schema>>({
mode: 'onChange',
Expand All @@ -91,6 +92,8 @@ export const Prior1559GasSetting: FC<GasSettingProps> = memo(
},
})

const [inputGasLimit] = watch(['gasLimit'])

useUpdateEffect(() => {
if (gasLimit) setValue('gasLimit', new BigNumber(gasLimit).toString())
}, [gasLimit, setValue])
Expand Down Expand Up @@ -122,7 +125,7 @@ export const Prior1559GasSetting: FC<GasSettingProps> = memo(
<Typography>{formatWeiToGwei(gasPrice ?? 0).toString()} Gwei</Typography>
<Typography className={classes.gasUSD}>
{t('popups_wallet_gas_fee_settings_usd', {
usd: formatWeiToEther(gasPrice).times(nativeTokenPrice).toPrecision(3),
usd: formatWeiToEther(gasPrice).times(nativeTokenPrice).times(21000).toPrecision(3),
})}
</Typography>
</div>
Expand Down

0 comments on commit 16dde4b

Please sign in to comment.