Skip to content

Commit

Permalink
fix: display contract name in tx detail To field
Browse files Browse the repository at this point in the history
  • Loading branch information
Tien Nam Dao committed Nov 30, 2022
1 parent 495ea51 commit 744c1a7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions types/transactions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ interface EvmTransactionDetailResponse {
success: boolean
to: string
toAddressName?: string
createdContractAddressName?: string
createdContractAddressHash?: string
tokenTransfers: EVMTransferItem[]
type: number
Expand Down
7 changes: 4 additions & 3 deletions views/transactions/hook/useConvertData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,16 @@ export default function useConvertData({ data }: { data: TransactionDetail }) {
})
break
case 'to': //to
const name = data['createdContractAddressHash']
? data['createdContractAddressName']
: data['toAddressName']
if (data[key] !== undefined && data[key] !== null)
items.push({
label: CardInfoLabels[key],
type: 'link-copy',
contents: [
{
value: data['toAddressName']
? `${data['toAddressName']} (${data[key]})`
: data[key],
value: name ? `${name} (${data[key]})` : data[key],
link: LinkMaker.address(data[key])
}
]
Expand Down
2 changes: 2 additions & 0 deletions views/transactions/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface TransactionDetail {
to?: string
toAddressName?: string
createdContractAddressHash?: string
createdContractAddressName?: string
value?: string
valueToken?: string
fee?: string
Expand Down Expand Up @@ -100,6 +101,7 @@ export const evmTransactionDetail = async (evmHash?: string, cosmosHash?: string
data.to = result.to
data.toAddressName = result.toAddressName
data.createdContractAddressHash = result.createdContractAddressHash
data.createdContractAddressName = result.createdContractAddressName
data.value = (result.value ? formatEther(result.value) : caculateEthereumTxAmount(result.messages)) || '0'
data.fee = result.fee && result.fee.length > 0 ? formatEther(result.fee[0].amount) : ''
data.gasPrice = result.gasPrice ? formatUnits(result.gasPrice, 9) + ' NanoAstra' : ''
Expand Down

0 comments on commit 744c1a7

Please sign in to comment.