/
receipt.go
95 lines (79 loc) · 2.41 KB
/
receipt.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package types
import (
"fmt"
"encoding/json"
"github.com/KasperLiu/gobcos/common"
)
// Receipt represents the results of a transaction.
type Receipt struct {
TransactionHash string `json:"transactionHash"`
TransactionIndex string `json:"transactionIndex"`
BlockHash string `json:"blockHash"`
BlockNumber string `json:"blockNumber"`
GasUsed string `json:"gasUsed"`
ContractAddress string `json:"contractAddress"`
Root string `json:"root"`
Status string `json:"status"`
From string `json:"from"`
To string `json:"to"`
Input string `json:"input"`
Output string `json:"output"`
Logs []*NewLog `json:"logs"`
LogsBloom string `json:"logsBloom"`
}
// GetTransactionHash returns the transaction hash string
func (r *Receipt) GetTransactionHash() string {
return r.TransactionHash
}
// GetTransactionIndex returns the transaction index string
func (r *Receipt) GetTransactionIndex() string {
return r.TransactionIndex
}
// GetBlockHash returns the block hash string
func (r *Receipt) GetBlockHash() string {
return r.BlockHash
}
// GetBlockNumber returns the block number string
func (r *Receipt) GetBlockNumber() string {
return r.BlockNumber
}
// GetGasUsed returns the used gas
func (r *Receipt) GetGasUsed() string {
return r.GasUsed
}
// GetContractAddress returns the contract address
func (r *Receipt) GetContractAddress() common.Address {
return common.HexToAddress(r.ContractAddress)
}
// GetRoot returns the transactions root
func (r *Receipt) GetRoot() string {
return r.Root
}
// GetStatus returns the transaction status
func (r *Receipt) GetStatus() string {
return r.Status
}
// GetFrom returns the transaction sender address
func (r *Receipt) GetFrom() string {
return r.From
}
// GetTo returns the transaction receiver address
func (r *Receipt) GetTo() string {
return r.To
}
// GetInput returns the transaction content
func (r *Receipt) GetInput() string {
return r.Input
}
// GetOutput returns the transaction output
func (r *Receipt) GetOutput() string {
return r.Output
}
// String returns the string representation of Receipt sturct.
func (r *Receipt) String() string {
out, err := json.MarshalIndent(r, "", "\t")
if err != nil {
return fmt.Sprintf("%v", err)
}
return fmt.Sprintf(string(out))
}