Skip to content

Commit

Permalink
Fix ts error for 0x interpreter (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasiarods authored Dec 7, 2024
1 parent e0dd9bf commit 335b860
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/clean-beans-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@3loop/transaction-interpreter': patch
---

Fix ts error for 0x interpreter
9 changes: 7 additions & 2 deletions packages/transaction-interpreter/interpreters/zeroEx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ export function transformEvent(event: DecodedTransaction): InterpretedTransactio

if (!swapEvent || newEvent.type !== 'unknown') return newEvent

const { recipient } = swapEvent.event?.params as { recipient: string }
const params = swapEvent.event?.params as { recipient?: string } | undefined
const recipient = params?.recipient || event.fromAddress

const buyToken = event.methodCall?.params?.[0]?.components?.find((c) => c.name === 'buyToken') as
| { value: string }
| undefined

const netSent = getNetTransfers({
transfers: event.transfers,
Expand All @@ -17,7 +22,7 @@ export function transformEvent(event: DecodedTransaction): InterpretedTransactio
})

const netReceived = getNetTransfers({
transfers: event.transfers,
transfers: buyToken ? event.transfers.filter((t) => t.address === buyToken.value) : event.transfers,
toAddresses: [recipient],
type: ['ERC20', 'native'],
})
Expand Down

0 comments on commit 335b860

Please sign in to comment.