Skip to content

Commit

Permalink
fix: update From/To from cosmos msg
Browse files Browse the repository at this point in the history
  • Loading branch information
vien.nguyen2-tiki committed Feb 14, 2023
1 parent f7012d3 commit 527732b
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions views/transactions/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export const evmTransactionDetail = async (evmHash?: string, cosmosHash?: string
)
const result = res.data.result
if (!result) return

const [from, to] = _getFromAndToEvmFromCosmosMsg(res.data)
data.evmHash = isUndefined(evmHash)
? result.messages && result.messages.length > 0
? getEvmTxhash(result.messages)
Expand All @@ -46,9 +48,9 @@ export const evmTransactionDetail = async (evmHash?: string, cosmosHash?: string
data.confirmations = result.confirmations ? result.confirmations.toString() : ''
data.blockHeight = `${result.blockHeight}`
data.time = result.blockTime
data.from = result.from
data.from = from
data.fromAddressName = result.fromAddressName
data.to = result.to
data.to = to
data.toAddressName = result.toAddressName
data.createdContractAddressHash = result.createdContractAddressHash
data.createdContractAddressName = result.createdContractAddressName
Expand Down Expand Up @@ -249,3 +251,25 @@ const _convertTransfer = (
) => {
data.tabTokenTransfers = convertMessageToTransfer(messages, blockTime, success)
}

const _getFromAndToEvmFromCosmosMsg = (res: EvmTransactionDetailResponse): [string, string] => {
const { result } = res
const { messages } = result

let from = ''
let to = ''
if (!isEmpty(result) && !isEmpty(result.from) && !isEmpty(result.to)) {
// server parsed
from = result.from
to = result.to
} else {
// server is parsing data
const message = messages[0]
try {
from = message.content.params.from
to = message.content.params.data.to
} catch (e) {}
}

return [from, to]
}

0 comments on commit 527732b

Please sign in to comment.