Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions packages/mask/src/plugins/ITO/SNSAdaptor/ConfirmDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { FormattedAddress, FormattedBalance } from '@masknet/shared'
import {
formatAmountPrecision,
formatBalance,
formatEthereumAddress,
FungibleTokenDetailed,
Expand Down Expand Up @@ -316,12 +315,7 @@ export function ConfirmDialog(props: ConfirmDialogProps) {
<Grid item lg={6} xs={12} className={classes.button}>
<ActionButton className={classes.buttonText} fullWidth variant="contained" onClick={onDone}>
{t('plugin_ito_send_text', {
total: formatAmountPrecision(
poolSettings?.total,
poolSettings?.token?.decimals,
undefined,
poolSettings?.token?.decimals,
),
total: formatBalance(poolSettings?.total, poolSettings?.token?.decimals),
symbol: poolSettings?.token?.symbol,
})}
</ActionButton>
Expand Down
5 changes: 2 additions & 3 deletions packages/mask/src/plugins/ITO/SNSAdaptor/ITO.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
formatAmountPrecision,
formatBalance,
formatEthereumAddress,
FungibleTokenDetailed,
Expand Down Expand Up @@ -569,8 +568,8 @@ export function ITO(props: ITO_Props) {
</Box>
<Typography variant="body2" className={classes.totalText}>
{t('plugin_ito_swapped_status', {
remain: formatAmountPrecision(sold, token.decimals, undefined, token.decimals),
total: formatAmountPrecision(total, token.decimals, undefined, token.decimals),
remain: formatBalance(sold, token.decimals),
total: formatBalance(total, token.decimals),
token: token.symbol,
})}
<Link
Expand Down
28 changes: 0 additions & 28 deletions packages/web3-shared/evm/utils/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,34 +78,6 @@ export function formatNumberString(str: string, size = 0) {
return `${str.substr(0, size)}...${str.substr(-size)}`
}

export function formatAmountPrecision(
amount?: BigNumber.Value,
token_decimals?: number,
decimalPlaces = 6,
precision = 12,
): string {
const _amount = new BigNumber(formatBalance(amount, token_decimals))
const _decimalPlaces = decimalPlaces < 0 ? 6 : decimalPlaces
const _precision = precision < 0 ? 12 : precision

if (_amount.isZero()) {
return '0'
}

if (_amount.isLessThan(1)) {
return _amount.toFixed(_precision)
}

const len = _amount.precision() - _amount.decimalPlaces()
if (len <= _decimalPlaces) {
return _amount.toPrecision(len + _decimalPlaces)
} else if (len >= _precision) {
return _amount.toPrecision(len)
}

return _amount.toPrecision(_precision)
}

export function formatWeiToGwei(value: BigNumber.Value) {
return new BigNumber(value).shiftedBy(-9).integerValue()
}
Expand Down