Skip to content

Commit

Permalink
fix: display amount transfer with NFT + add sentry captureException
Browse files Browse the repository at this point in the history
  • Loading branch information
Tien Nam Dao committed Nov 23, 2022
1 parent 009ee66 commit d651ed4
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 5 deletions.
5 changes: 4 additions & 1 deletion components/Card/CardInfo/Components/RawInput.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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 (
<div style={{ maxWidth: '885px', maxHeight: '200px', overflowY: 'scroll' }}>
<Tabs
Expand Down
4 changes: 2 additions & 2 deletions components/Card/CardInfo/Components/Transfers.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import clsx from 'clsx'
import CopyButton from 'components/Button/CopyButton'
import Typography from 'components/Typography'
import { LinkMaker } from 'utils/helper'
import { isERC721, LinkMaker } from 'utils/helper'
import { Content } from '../'
import styles from '../style.module.scss'

const Transfers = ({ content }: { content: Content }) => {
const data = content?.transfer || {}
const isNFT = data.tokenType === 'ERC-721'
const isNFT = isERC721(data.tokenType)
return (
<div className="block-center sm-wrap flex-justify-start">
<span
Expand Down
2 changes: 2 additions & 0 deletions components/VerifyContract/ContractFlattenedVerify.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NormalButton } from '@astraprotocol/astra-ui'
import { InputProps } from '@astraprotocol/astra-ui/lib/es/components/Form/Input'
import { InputProps as InputNumberProps } from '@astraprotocol/astra-ui/lib/es/components/Form/Input/NumberInput'
import * as Sentry from '@sentry/nextjs'
import API_LIST from 'api/api_list'
import axios from 'axios'
import clsx from 'clsx'
Expand Down Expand Up @@ -98,6 +99,7 @@ const ContractFlattenedVerify = ({ address, onClose, onSuccess }: Props) => {
}
})
.catch(function (error) {
Sentry.captureException(error)
setLoading(false)
console.log(error)
})
Expand Down
2 changes: 2 additions & 0 deletions components/VerifyContract/ContractStandardVerify.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -68,6 +69,7 @@ const ContractStandardVerify = ({ address, onClose, onSuccess }: Props) => {
}
})
.catch(function (error) {
Sentry.captureException(error)
console.log(error)
})
}
Expand Down
2 changes: 2 additions & 0 deletions pages/address/[address].tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions pages/blocks/[block].tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions pages/token/[token].tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions pages/token/[token]/instance/[index].tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion pages/tx/[tx].tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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 } }
}
}
Expand Down
5 changes: 4 additions & 1 deletion utils/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions views/transactions/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d651ed4

Please sign in to comment.