-
Notifications
You must be signed in to change notification settings - Fork 0
/
event.go
46 lines (40 loc) · 1.17 KB
/
event.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) 2020 The Meter.io developers
// Distributed under the GNU Lesser General Public License v3.0 software license, see the accompanying
// file LICENSE or <https://www.gnu.org/licenses/lgpl-3.0.html>
package tx
import (
"fmt"
"encoding/hex"
"strings"
"github.com/saolacoincom/saolacoin/meter"
)
// Event represents a contract event log. These events are generated by the LOG opcode and
// stored/indexed by the node.
type Event struct {
// address of the contract that generated the event
Address meter.Address
// list of topics provided by the contract.
Topics []meter.Bytes32
// supplied by the contract, usually ABI-encoded
Data []byte
}
// Events slice of event logs.
type Events []*Event
func (es Events) String() string{
if es == nil{
return "nil"
}
lines := make([]string, 0)
for _, e:=range es {
hexData := ""
if (e.Data!=nil){
hexData = hex.EncodeToString(e.Data)
}
topics := make([]string, 0)
for _, tps :=range e.Topics{
topics = append(topics, tps.String())
}
lines = append(lines, fmt.Sprintf("Event(addr:%v, topics:%v, data:%v)", e.Address.String(), strings.Join(topics, ","), hexData))
}
return "["+strings.Join(lines, "\n")+"]"
}