Skip to content

Commit a009d55

Browse files
committed
fix all ethers versioning issues
1 parent dc35d46 commit a009d55

3 files changed

Lines changed: 11 additions & 15 deletions

File tree

src/frontend/account/AccountDetail/useAccountDetailHook.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useCallback, useEffect, useState } from 'react'
22
import { api, PATHS } from '../../api'
33
import { Account, AccountType, ContractType, Token, Transaction, TransactionSearchType } from '../../../types'
4-
import { BigNumberish, utils } from 'ethers'
4+
import { BigNumberish, formatUnits } from 'ethers'
55

66
interface detailProps {
77
id: string
@@ -88,7 +88,7 @@ export const useAccountDetailHook = ({ id, txType }: detailProps): AccountDetail
8888
(item: { contractType: ContractType; contractInfo: { decimals: string } | null; balance: BigNumberish }) => {
8989
if (item.contractType === ContractType.ERC_20) {
9090
const decimalsValue = item.contractInfo?.decimals ? parseInt(item.contractInfo.decimals) : 18
91-
item.balance = utils.formatUnits(item.balance, decimalsValue)
91+
item.balance = formatUnits(item.balance, decimalsValue)
9292
}
9393
}
9494
)

src/frontend/token/Token.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import { useRouter } from 'next/router'
3-
import { utils } from 'ethers'
3+
import { formatUnits } from 'ethers'
44

55
import { AnchorLink, Button, ContentLayout, CopyButton, Spacer, Tab, Table, Pagination } from '../components'
66
import { DetailCard } from '../account/DetailCard'
@@ -59,8 +59,7 @@ export const Token: React.FC = () => {
5959
{val
6060
? transactionType === TransactionSearchType.ERC_721
6161
? val
62-
: utils
63-
.formatUnits(
62+
: formatUnits(
6463
val as number,
6564
account?.contractInfo?.decimals ? parseInt(account?.contractInfo?.decimals) : 18
6665
)
@@ -157,8 +156,7 @@ export const Token: React.FC = () => {
157156
{
158157
key: 'Max Total Supply :',
159158
value: account?.contractInfo?.totalSupply
160-
? utils
161-
.formatUnits(
159+
? formatUnits(
162160
account?.contractInfo?.totalSupply,
163161
account?.contractInfo?.decimals ? parseInt(account?.contractInfo?.decimals) : 18
164162
)
@@ -178,8 +176,7 @@ export const Token: React.FC = () => {
178176
{
179177
key: 'Max Total Supply :',
180178
value: account?.contractInfo?.totalSupply
181-
? utils
182-
.formatUnits(
179+
? formatUnits(
183180
account?.contractInfo?.totalSupply,
184181
account?.contractInfo?.decimals ? parseInt(account?.contractInfo?.decimals) : 18
185182
)
@@ -220,8 +217,7 @@ export const Token: React.FC = () => {
220217
{tokenBalance
221218
? transactionType === TransactionSearchType.ERC_721
222219
? tokenBalance
223-
: utils
224-
.formatUnits(
220+
: formatUnits(
225221
tokenBalance,
226222
account?.contractInfo?.decimals ? parseInt(account?.contractInfo?.decimals) : 18
227223
)

src/frontend/utils/calculateValue.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import web3 from 'web3'
2-
import { utils } from 'ethers'
2+
import { formatUnits } from 'ethers'
33
import { TokenTx, TokenType, TransactionType } from '../../types'
44
import BN from 'bn.js'
55
import { fromWeiNoTrailingComma } from './fromWeiNoTrailingComma'
@@ -28,13 +28,13 @@ export const calculateTokenValue = (
2828
): string => {
2929
try {
3030
if (txType === TokenType.ERC_20 || txType === TokenType.EVM_Internal) {
31-
const decimalsValue = tokenTx.contractInfo.decimals ? parseInt(tokenTx.contractInfo.decimals) : 18
31+
const decimalsValue = tokenTx.contractInfo?.decimals ? parseInt(tokenTx.contractInfo.decimals) : 18
3232

3333
return tokenTx.tokenValue === '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
3434
? 'unlimited'
3535
: fullValue
36-
? utils.formatUnits(tokenTx.tokenValue, decimalsValue)
37-
: roundTokenValue(utils.formatUnits(tokenTx.tokenValue, decimalsValue))
36+
? formatUnits(tokenTx.tokenValue, decimalsValue)
37+
: roundTokenValue(formatUnits(tokenTx.tokenValue, decimalsValue))
3838

3939
// : round(web3.utils.fromWei(tokenTx.tokenValue, "ether"));
4040
} else if (txType === TokenType.ERC_721) {

0 commit comments

Comments
 (0)