mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-24 08:49:29 +00:00
accounts/abi: checkout whether event exists
This commit is contained in:
parent
934a0091fa
commit
89a4e43b56
1 changed files with 10 additions and 2 deletions
|
|
@ -463,8 +463,12 @@ func (c *BoundContract) FilterLogs(opts *FilterOpts, name string, query ...[]any
|
||||||
if opts == nil {
|
if opts == nil {
|
||||||
opts = new(FilterOpts)
|
opts = new(FilterOpts)
|
||||||
}
|
}
|
||||||
|
ev, ok := c.abi.Events[name]
|
||||||
|
if !ok {
|
||||||
|
return nil, nil, fmt.Errorf("event %q not found in the ABI", name)
|
||||||
|
}
|
||||||
// Append the event selector to the query parameters and construct the topic set
|
// Append the event selector to the query parameters and construct the topic set
|
||||||
query = append([][]any{{c.abi.Events[name].ID}}, query...)
|
query = append([][]any{{ev.ID}}, query...)
|
||||||
topics, err := abi.MakeTopics(query...)
|
topics, err := abi.MakeTopics(query...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
|
@ -508,8 +512,12 @@ func (c *BoundContract) WatchLogs(opts *WatchOpts, name string, query ...[]any)
|
||||||
if opts == nil {
|
if opts == nil {
|
||||||
opts = new(WatchOpts)
|
opts = new(WatchOpts)
|
||||||
}
|
}
|
||||||
|
ev, ok := c.abi.Events[name]
|
||||||
|
if !ok {
|
||||||
|
return nil, nil, fmt.Errorf("event %q not found in the ABI", name)
|
||||||
|
}
|
||||||
// Append the event selector to the query parameters and construct the topic set
|
// Append the event selector to the query parameters and construct the topic set
|
||||||
query = append([][]any{{c.abi.Events[name].ID}}, query...)
|
query = append([][]any{{ev.ID}}, query...)
|
||||||
|
|
||||||
topics, err := abi.MakeTopics(query...)
|
topics, err := abi.MakeTopics(query...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue