Skip to content

Commit 8f756ec

Browse files
s1najwasinger
authored andcommitted
Pass pointer to log for unpack
1 parent bb63ef3 commit 8f756ec

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

accounts/abi/bind/lib.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func Transfer2(instance ContractInstance, opts *TransactOpts) (*types.Transactio
7272
return c.Transfer(opts)
7373
}
7474

75-
func FilterLogs[T any](instance ContractInstance, opts *FilterOpts, eventID common.Hash, unpack func(types.Log) (*T, error), topics ...[]any) (*EventIterator[T], error) {
75+
func FilterLogs[T any](instance ContractInstance, opts *FilterOpts, eventID common.Hash, unpack func(*types.Log) (*T, error), topics ...[]any) (*EventIterator[T], error) {
7676
backend := instance.Backend()
7777
c := NewBoundContract(instance.Address(), abi.ABI{}, backend, backend, backend)
7878
logs, sub, err := c.filterLogs(opts, eventID, topics...)
@@ -82,7 +82,7 @@ func FilterLogs[T any](instance ContractInstance, opts *FilterOpts, eventID comm
8282
return &EventIterator[T]{unpack: unpack, logs: logs, sub: sub}, nil
8383
}
8484

85-
func WatchLogs[T any](instance ContractInstance, opts *WatchOpts, eventID common.Hash, unpack func(types.Log) (*T, error), sink chan<- *T, topics ...[]any) (event.Subscription, error) {
85+
func WatchLogs[T any](instance ContractInstance, opts *WatchOpts, eventID common.Hash, unpack func(*types.Log) (*T, error), sink chan<- *T, topics ...[]any) (event.Subscription, error) {
8686
backend := instance.Backend()
8787
c := NewBoundContract(instance.Address(), abi.ABI{}, backend, backend, backend)
8888
logs, sub, err := c.watchLogs(opts, eventID, topics...)
@@ -95,7 +95,7 @@ func WatchLogs[T any](instance ContractInstance, opts *WatchOpts, eventID common
9595
select {
9696
case log := <-logs:
9797
// New log arrived, parse the event and forward to the user
98-
ev, err := unpack(log)
98+
ev, err := unpack(&log)
9999
if err != nil {
100100
return err
101101
}
@@ -120,7 +120,7 @@ func WatchLogs[T any](instance ContractInstance, opts *WatchOpts, eventID common
120120
type EventIterator[T any] struct {
121121
Event *T // Event containing the contract specifics and raw log
122122

123-
unpack func(types.Log) (*T, error) // Unpack function for the event
123+
unpack func(*types.Log) (*T, error) // Unpack function for the event
124124

125125
logs chan types.Log // Log channel receiving the found contract events
126126
sub ethereum.Subscription // Subscription for errors, completion and termination
@@ -140,7 +140,7 @@ func (it *EventIterator[T]) Next() bool {
140140
if it.done {
141141
select {
142142
case log := <-it.logs:
143-
res, err := it.unpack(log)
143+
res, err := it.unpack(&log)
144144
if err != nil {
145145
it.fail = err
146146
return false
@@ -155,7 +155,7 @@ func (it *EventIterator[T]) Next() bool {
155155
// Iterator still in progress, wait for either a data or an error event
156156
select {
157157
case log := <-it.logs:
158-
res, err := it.unpack(log)
158+
res, err := it.unpack(&log)
159159
if err != nil {
160160
it.fail = err
161161
return false

accounts/abi/bind/template2.go

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)