Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

impr(events): Naming clarity and I don't trust the sussiness from before #15

Merged
merged 11 commits into from
Jan 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions types/abi/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi"
)

// `maxTopicsLen` is the maximum number of topics hashes allowed in an Eth log.
const maxTopicsLen = 4
// `maxIndexedEvents` is the maximum number of topics hashes allowed in an Eth log.
const maxIndexedEvents = 3

type (
Argument = abi.Argument
Expand Down Expand Up @@ -52,15 +52,15 @@ func ToMixedCase(input string) string {
// indexed arguments are provided by the inputs ABI.
func GetIndexed(args abi.Arguments) abi.Arguments {
var indexed abi.Arguments
numIndexed := 0
for i := range args {
if args[i].Indexed {
numIndexed++
if numIndexed == maxTopicsLen {
panic("number of indexed arguments is more than allowed by Eth event log")
}
indexed = append(indexed, args[i])
for _, arg := range args {
if arg.Indexed {
indexed = append(indexed, arg)
}
}

if len(indexed) > maxIndexedEvents {
panic("number of indexed arguments is more than allowed by Eth event log")
}

return indexed
}