diff --git a/types/message.d.ts b/types/message.d.ts index 84ec479e..bef1b790 100644 --- a/types/message.d.ts +++ b/types/message.d.ts @@ -10,6 +10,7 @@ enum TransacionTypeEnum { } interface MsgCreateValidator { + evmType?: string type: '/cosmos.staking.v1beta1.MsgCreateValidator' content: { height: number @@ -40,6 +41,7 @@ interface MsgCreateValidator { } interface MsgUnjail { + evmType?: string type: '/cosmos.slashing.v1beta1.MsgUnjail' content: { txHash: string @@ -54,11 +56,13 @@ interface MsgUnjail { } interface MsgEthereumTx { + evmType?: string type: '/ethermint.evm.v1.MsgEthereumTx' content: MsgEthereumTxContent } interface MsgBeginRedelegate { + evmType?: string type: string content: MsgBeginRedelegateContent } diff --git a/types/transactions.d.ts b/types/transactions.d.ts index 699e6dc6..2a940ead 100644 --- a/types/transactions.d.ts +++ b/types/transactions.d.ts @@ -187,10 +187,7 @@ interface EvmTransactionDetailResponse { type: number v: string value: string - messages?: { - type: TransacionTypeEnum - content: MsgEthereumTxContent - }[] + messages?: MsgEthereumTx[] } status: string } diff --git a/views/accounts/hook/useAddressTransaction.ts b/views/accounts/hook/useAddressTransaction.ts index 6f102195..b844664f 100644 --- a/views/accounts/hook/useAddressTransaction.ts +++ b/views/accounts/hook/useAddressTransaction.ts @@ -3,7 +3,7 @@ import API_LIST from 'api/api_list' import { formatEther } from 'ethers/lib/utils' import { useEffect, useState } from 'react' import useSWR from 'swr' -import { caculateCosmosTxAmount, caculateEthereumTxAmount } from 'views/transactions/utils' +import { caculateCosmosTxAmount, caculateEthereumTxAmount, getEvmTxhash } from 'views/transactions/utils' export default function useAddressTransactions(address: string, page: number) { const [hookData, setState] = useState({ @@ -35,7 +35,7 @@ export default function useAddressTransactions(address: string, page: number) { // if (numberOfMsgTypes >= 2) type = `${msgTypeShort} (+${numberOfMsgTypes - 1})` // else type = msgTypeShort type = msgTypeShort - + const evmHash = getEvmTxhash(d.messages) return { value: (d.value @@ -48,7 +48,7 @@ export default function useAddressTransactions(address: string, page: number) { blockHeight: d.blockHeight, blockTime: d.blockTime, fee: d.fee.length > 0 ? d.fee[0]?.amount : 0, - hash: d.hash, + hash: evmHash || d.hash, messageTypes: d.messageTypes, messages: d.messages, success: d.success, diff --git a/views/transactions/utils.ts b/views/transactions/utils.ts index 593bf970..a754a0d9 100644 --- a/views/transactions/utils.ts +++ b/views/transactions/utils.ts @@ -84,10 +84,10 @@ export const evmTransactionDetail = async (evmHash?: string, cosmosHash?: string if (!result) return data.evmHash = isUndefined(evmHash) ? result.messages && result.messages.length > 0 - ? result.messages?.[0].content.params.hash + ? getEvmTxhash(result.messages) : result.hash : evmHash - data.pageTitle = result.messages ? getTransactionType(result.messages[0]?.type) : '' + // data.pageTitle = result.messages ? getTransactionType(result.messages[0]?.type) : '' data.cosmosHash = cosmosHash || result.cosmosHash data.result = result.success ? 'Success' : 'Error' data.confirmations = result.confirmations ? result.confirmations.toString() : '' @@ -199,7 +199,7 @@ export const getAstraTokenAmount = (amounts: TokenAmount[]): string => { * @param tx messages * @returns amount in string */ -export const caculateEthereumTxAmount = (messages: TransactionMessage[]): string => { +export const caculateEthereumTxAmount = (messages: MsgEthereumTx[] | TransactionMessage[]): string => { if (messages && messages.length > 0) { let totalAmount = BigNumber.from('0') for (let message of messages) { @@ -246,6 +246,15 @@ export const caculateAmount = (amounts: TokenAmount[]): TokenAmount => { } } +/** + * Get Evm TxHash from messages + * @param messages: MsgEthereumTx[] + * @returns + */ +export const getEvmTxhash = (messages: MsgEthereumTx[] | TransactionMessage[]): string | undefined => { + return messages?.[0]?.content?.params?.hash || undefined +} + export const getSignerEthAddress = (signers: Signer[]) => { const addresses = [] signers.forEach((s: Signer) => {