github.com/neatio-net/neatio@v1.7.3-0.20231114194659-f4d7a2226baa/chain/accounts/abi/event.go (about) 1 package abi 2 3 import ( 4 "fmt" 5 "strings" 6 7 "github.com/neatio-net/neatio/utilities/common" 8 "github.com/neatio-net/neatio/utilities/crypto" 9 ) 10 11 type Event struct { 12 Name string 13 14 RawName string 15 Anonymous bool 16 Inputs Arguments 17 } 18 19 func (e Event) String() string { 20 inputs := make([]string, len(e.Inputs)) 21 for i, input := range e.Inputs { 22 inputs[i] = fmt.Sprintf("%v %v", input.Type, input.Name) 23 if input.Indexed { 24 inputs[i] = fmt.Sprintf("%v indexed %v", input.Type, input.Name) 25 } 26 } 27 return fmt.Sprintf("event %v(%v)", e.RawName, strings.Join(inputs, ", ")) 28 } 29 30 func (e Event) Sig() string { 31 types := make([]string, len(e.Inputs)) 32 for i, input := range e.Inputs { 33 types[i] = input.Type.String() 34 } 35 return fmt.Sprintf("%v(%v)", e.RawName, strings.Join(types, ",")) 36 } 37 38 func (e Event) ID() common.Hash { 39 return common.BytesToHash(crypto.Keccak256([]byte(e.Sig()))) 40 }