This repository has been archived by the owner on Oct 9, 2022. It is now read-only.
/
types.go
106 lines (96 loc) · 3.48 KB
/
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
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
96
97
98
99
100
101
102
103
104
105
106
package eth
import (
"encoding/json"
"github.com/ethereum/go-ethereum/core/types"
)
// The response of etherscan api
type InfuraResponse struct {
JsonRPC string `json:"jsonrpc"`
Id uint32 `json:"id"`
Result types.Header `json:"result"`
}
// Darwinia block
type DarwiniaEthHeader struct {
ParentHash string `json:"parent_hash"`
TimeStamp uint64 `json:"timestamp"`
Number uint64 `json:"number"`
Author string `json:"author"`
TransactionsRoot string `json:"transactions_root"`
UnclesHash string `json:"uncles_hash"`
ExtraData string `json:"extra_data"`
StateRoot string `json:"state_root"`
ReceiptsRoot string `json:"receipts_root"`
LogBloom string `json:"log_bloom"`
GasUsed uint64 `json:"gas_used"`
GasLimited uint64 `json:"gas_limit"`
Difficulty uint64 `json:"difficulty"`
Seal []string `json:"seal"`
Hash string `json:"hash"`
}
func (d *DarwiniaEthHeader) ToString() (string, error) {
bytes, err := json.Marshal(d)
if err != nil {
return "", err
}
return string(bytes), nil
}
type DarwiniaEthHeaderHexFormat struct {
ParentHash string `json:"parent_hash"`
TimeStamp string `json:"timestamp"`
Number string `json:"number"`
Author string `json:"author"`
TransactionsRoot string `json:"transactions_root"`
UnclesHash string `json:"uncles_hash"`
ExtraData string `json:"extra_data"`
StateRoot string `json:"state_root"`
ReceiptsRoot string `json:"receipts_root"`
LogBloom string `json:"log_bloom"`
GasUsed string `json:"gas_used"`
GasLimited string `json:"gas_limit"`
Difficulty string `json:"difficulty"`
Seal []string `json:"seal"`
Hash string `json:"hash"`
}
type Receipts struct {
BlockNumber string `json:"block_number"`
Logs []Log `json:"logs"`
Status string `json:"status"`
ChainSource string `json:"chainSource"`
GasUsed string `json:"gasUsed"`
LogsBloom string `json:"logsBloom"`
Solidity bool `json:"solidity"`
TransactionIndex string `json:"transactionIndex"`
BlockHash string `json:"blockHash"`
}
type Log struct {
Topics []string `json:"topics"`
Data string `json:"data"`
Address string `json:"address"`
}
type BlockResult struct {
Difficulty string `json:"difficulty"`
ExtraData string `json:"extraData"`
GasLimit string `json:"gasLimit"`
GasUsed string `json:"gasUsed"`
Hash string `json:"hash"`
LogsBloom string `json:"logs_bloom"`
Miner string `json:"miner"`
MixHash string `json:"mixHash"`
Nonce string `json:"nonce"`
Number string `json:"number"`
ParentHash string `json:"parentHash"`
ReceiptsRoot string `json:"receiptsRoot"`
Sha3Uncles string `json:"sha3Uncles"`
StateRoot string `json:"stateRoot"`
Timestamp string `json:"timestamp"`
TotalDifficulty string `json:"totalDifficulty"`
Transactions []Transaction `json:"transactions"`
TransactionsRoot string `json:"transactionsRoot"`
}
type Transaction struct {
Hash string `json:"hash"`
From string `json:"from"`
Input string `json:"input"`
To string `json:"to"`
Value string `json:"value"`
}