From d651ed462548b11441a26097f1df401441f43c04 Mon Sep 17 00:00:00 2001 From: Tien Nam Dao Date: Wed, 23 Nov 2022 13:52:18 +0700 Subject: [PATCH] fix: display amount transfer with NFT + add sentry captureException --- components/Card/CardInfo/Components/RawInput.tsx | 5 ++++- components/Card/CardInfo/Components/Transfers.tsx | 4 ++-- components/VerifyContract/ContractFlattenedVerify.tsx | 2 ++ components/VerifyContract/ContractStandardVerify.tsx | 2 ++ pages/address/[address].tsx | 2 ++ pages/blocks/[block].tsx | 2 ++ pages/token/[token].tsx | 2 ++ pages/token/[token]/instance/[index].tsx | 2 ++ pages/tx/[tx].tsx | 3 ++- utils/evm.ts | 5 ++++- views/transactions/utils.ts | 1 + 11 files changed, 25 insertions(+), 5 deletions(-) diff --git a/components/Card/CardInfo/Components/RawInput.tsx b/components/Card/CardInfo/Components/RawInput.tsx index bcf517c9..818ab511 100644 --- a/components/Card/CardInfo/Components/RawInput.tsx +++ b/components/Card/CardInfo/Components/RawInput.tsx @@ -1,3 +1,4 @@ +import * as Sentry from '@sentry/nextjs' import CopyButton from 'components/Button/CopyButton' import Tabs from 'components/Tabs/Tabs' import web3 from 'web3' @@ -24,7 +25,9 @@ export default function RawInput({ text }: RawInputProps) { let utf8Text = text try { utf8Text = web3.utils.toAscii(text) - } catch (e) {} + } catch (e) { + Sentry.captureException(e) + } return (
{ const data = content?.transfer || {} - const isNFT = data.tokenType === 'ERC-721' + const isNFT = isERC721(data.tokenType) return (
{ } }) .catch(function (error) { + Sentry.captureException(error) setLoading(false) console.log(error) }) diff --git a/components/VerifyContract/ContractStandardVerify.tsx b/components/VerifyContract/ContractStandardVerify.tsx index feb11308..266f598d 100644 --- a/components/VerifyContract/ContractStandardVerify.tsx +++ b/components/VerifyContract/ContractStandardVerify.tsx @@ -1,5 +1,6 @@ import { NormalButton } from '@astraprotocol/astra-ui' import { InputProps } from '@astraprotocol/astra-ui/lib/es/components/Form/Input' +import * as Sentry from '@sentry/nextjs' import axios from 'axios' import clsx from 'clsx' import FormItem, { FormRadioButtonData, FormSelectData, InputData } from 'components/FormItem' @@ -68,6 +69,7 @@ const ContractStandardVerify = ({ address, onClose, onSuccess }: Props) => { } }) .catch(function (error) { + Sentry.captureException(error) console.log(error) }) } diff --git a/pages/address/[address].tsx b/pages/address/[address].tsx index 51db54ee..c69f54f1 100644 --- a/pages/address/[address].tsx +++ b/pages/address/[address].tsx @@ -1,4 +1,5 @@ import { Breadcumbs, useMobileLayout } from '@astraprotocol/astra-ui' +import * as Sentry from '@sentry/nextjs' import { evmApi } from 'api' import API_LIST from 'api/api_list' import { AxiosError } from 'axios' @@ -75,6 +76,7 @@ export async function getServerSideProps({ params }) { } } catch (e) { // console.log(e.message) + Sentry.captureException(e) let errorMessage = e.message if (e instanceof AxiosError) { console.log('error api', e.message, e.code, e?.config?.baseURL, e?.config?.url) diff --git a/pages/blocks/[block].tsx b/pages/blocks/[block].tsx index 6ca05c4b..bc85b84d 100644 --- a/pages/blocks/[block].tsx +++ b/pages/blocks/[block].tsx @@ -1,5 +1,6 @@ import { astraToEth } from '@astradefi/address-converter' import { Breadcumbs } from '@astraprotocol/astra-ui' +import * as Sentry from '@sentry/nextjs' import { cosmosApi } from 'api' import API_LIST from 'api/api_list' import { AxiosError } from 'axios' @@ -146,6 +147,7 @@ export async function getServerSideProps({ params }) { } } } catch (e) { + Sentry.captureException(e) let errorMessage = e.message if (e instanceof AxiosError) { console.log('error api', e.message, e.code, e?.config?.baseURL, e?.config?.url) diff --git a/pages/token/[token].tsx b/pages/token/[token].tsx index 7e26a601..26568fd5 100644 --- a/pages/token/[token].tsx +++ b/pages/token/[token].tsx @@ -1,4 +1,5 @@ import { Breadcumbs, useMobileLayout } from '@astraprotocol/astra-ui' +import * as Sentry from '@sentry/nextjs' import { evmApi } from 'api' import API_LIST from 'api/api_list' import { AxiosError } from 'axios' @@ -72,6 +73,7 @@ export async function getServerSideProps({ params }) { } } } catch (err) { + Sentry.captureException(err) let errorMessage = err.message if (err instanceof AxiosError) { console.log('error api', err.message, err.code, err?.config?.baseURL, err?.config?.url) diff --git a/pages/token/[token]/instance/[index].tsx b/pages/token/[token]/instance/[index].tsx index c936c5e7..e51c1837 100644 --- a/pages/token/[token]/instance/[index].tsx +++ b/pages/token/[token]/instance/[index].tsx @@ -1,4 +1,5 @@ import { Breadcumbs, useMobileLayout } from '@astraprotocol/astra-ui' +import * as Sentry from '@sentry/nextjs' import { evmApi } from 'api' import API_LIST from 'api/api_list' import { AxiosError } from 'axios' @@ -99,6 +100,7 @@ export async function getServerSideProps({ params }) { } } } catch (err) { + Sentry.captureException(err) let errorMessage = err.message if (err instanceof AxiosError) { console.log('error api', err.message, err.code, err?.config?.baseURL, err?.config?.url) diff --git a/pages/tx/[tx].tsx b/pages/tx/[tx].tsx index 28b15fef..5bbfb786 100644 --- a/pages/tx/[tx].tsx +++ b/pages/tx/[tx].tsx @@ -1,4 +1,5 @@ import { Breadcumbs, useMobileLayout } from '@astraprotocol/astra-ui' +import * as Sentry from '@sentry/nextjs' import { cosmosApi } from 'api' import API_LIST from 'api/api_list' import { AxiosError } from 'axios' @@ -113,12 +114,12 @@ export async function getServerSideProps({ query }) { data = pickBy(data, item => item !== undefined && item !== '') return { props: { data, evmHash, cosmosHash } } } catch (e: any) { + Sentry.captureException(e) let errorMessage = e.message if (e instanceof AxiosError) { console.log('error api', e.message, e.code, e?.config?.baseURL, e?.config?.url) if (e.code !== '200') errorMessage = '404 Not Found' } - return { props: { errorMessage, data: null, evmHash: tx, cosmosHash } } } } diff --git a/utils/evm.ts b/utils/evm.ts index b9aee3e5..48feb025 100644 --- a/utils/evm.ts +++ b/utils/evm.ts @@ -3,6 +3,7 @@ import { isEmpty } from 'lodash' import { TransactionRowProps } from 'views/transactions/TransactionRow' import { ZERO_ADDRESS } from './constants' import { TransacionTypeEnum } from './enum' +import { isERC721 } from './helper' export const evmTransactionType = (type: number): string => { if (type === 2) { @@ -26,11 +27,13 @@ export const evmConvertTokenTransferToTransactionRow = ( const isMint = item.fromAddress === ZERO_ADDRESS const isBurn = item.toAddress === ZERO_ADDRESS const labelStatus = (isMint && 'Mint') || (isBurn && 'Burn') + + const isNft = isERC721(item.tokenType) rows.push({ style: 'inject', blockNumber: blockHeight, updatedAt: blockTime, - value: formatUnits(item.amount || '0', item.decimals), + value: isNft ? '1' : formatUnits(item.amount || '0', item.decimals), valueCurrency: item.tokenSymbol, hash: hash, status, diff --git a/views/transactions/utils.ts b/views/transactions/utils.ts index a754a0d9..9034e858 100644 --- a/views/transactions/utils.ts +++ b/views/transactions/utils.ts @@ -81,6 +81,7 @@ export const evmTransactionDetail = async (evmHash?: string, cosmosHash?: string `${API_LIST.TRANSACTIONS}/${evmHash || cosmosHash}?type=evm` ) const result = res.data.result + console.log(result) if (!result) return data.evmHash = isUndefined(evmHash) ? result.messages && result.messages.length > 0