Skip to content

Commit

Permalink
fix: parsing msg as string
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasRalee committed Feb 5, 2025
1 parent 6c64a39 commit 287a8b4
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ import { isJsonString } from '../../../utils/helpers.js'

const ZERO_IN_BASE = new BigNumberInBase(0)

const isValidJson = (value: string) => {
try {
JSON.parse(value)

return true
} catch (e) {
return false
}
}

const getContractTransactionAmount = (
ApiTransaction: ContractTransactionExplorerApiResponse,
): BigNumberInBase => {
Expand All @@ -43,6 +53,10 @@ const getContractTransactionAmount = (
return ZERO_IN_BASE
}

if (typeof msg === 'string' && !isValidJson(msg)) {
return ZERO_IN_BASE
}

const msgObj = typeof msg === 'string' ? JSON.parse(msg) : msg

if (!msgObj.transfer) {
Expand Down

0 comments on commit 287a8b4

Please sign in to comment.