fix: token swap event parser (#428)

This commit is contained in:
Yusuf Seyrek 2023-09-06 10:08:16 +03:00 committed by GitHub
parent 4cc0fddada
commit a3737ce584
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,7 @@ export default function getTokenOutFromSwapResponse(
denom: string, denom: string,
): Coin { ): Coin {
try { try {
if (response.result) { if (response.result?.response.code === 0) {
const rawLogs = JSON.parse(response.result.rawLogs) const rawLogs = JSON.parse(response.result.rawLogs)
const events = rawLogs[0].events const events = rawLogs[0].events
const tokenSwappedEvent = events.find((e: { type: string }) => e.type === 'token_swapped') const tokenSwappedEvent = events.find((e: { type: string }) => e.type === 'token_swapped')