forked from Fantom-foundation/go-evm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
40 lines (32 loc) · 725 Bytes
/
types.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
package state
import (
"bytes"
"encoding/json"
ethTypes "github.com/ethereum/go-ethereum/core/types"
)
type TxError struct {
Tx ethTypes.Transaction `json:"tx"`
Error string `json:"error"`
}
func (te *TxError) Marshal() ([]byte, error) {
bf := bytes.NewBuffer([]byte{})
enc := json.NewEncoder(bf)
if err := enc.Encode(te); err != nil {
return nil, err
}
return bf.Bytes(), nil
}
func (te *TxError) Unmarshal(data []byte) error {
bf := bytes.NewBuffer(data)
dec := json.NewDecoder(bf)
if err := dec.Decode(te); err != nil {
return err
}
return nil
}
func (te *TxError) GetTx() *ethTypes.Transaction {
return &te.Tx
}
func (te *TxError) GetError() string {
return te.Error
}