Skip to content

Commit

Permalink
feat: add withdrawals field to transaction events (#310)
Browse files Browse the repository at this point in the history
* feat: add withdrawals field to transaction events

Added support for staking withdrawals in transaction events.
Withdrawal data was already available from gouroboros and is now propagated through adder's events.

* fix: update check for withdrawals len

Somehow committed an earlier version 🤦 Fixed
  • Loading branch information
Javieracost authored Jan 22, 2025
1 parent 9bab858 commit 7e44524
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions input/chainsync/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type TransactionEvent struct {
Fee uint64 `json:"fee"`
TTL uint64 `json:"ttl,omitempty"`
ResolvedInputs []ledger.TransactionOutput `json:"resolvedInputs,omitempty"`
Withdrawals map[string]uint64 `json:"withdrawals,omitempty"`
}

func NewTransactionContext(
Expand Down Expand Up @@ -88,5 +89,11 @@ func NewTransactionEvent(
if len(resolvedInputs) > 0 {
evt.ResolvedInputs = resolvedInputs
}
if withdrawals := tx.Withdrawals(); len(withdrawals) > 0{
evt.Withdrawals = make(map[string]uint64)
for addr, amount := range withdrawals {
evt.Withdrawals[addr.String()] = amount
}
}
return evt
}

0 comments on commit 7e44524

Please sign in to comment.