forked from trezor/blockbook
/
types_ethereum_type.go
148 lines (128 loc) · 4.55 KB
/
types_ethereum_type.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package bchain
import (
"math/big"
"github.com/ethereum/go-ethereum/accounts/abi"
)
// EthereumInternalTransfer contains data about internal transfer
type EthereumInternalTransfer struct {
Type EthereumInternalTransactionType `json:"type"`
From string `json:"from"`
To string `json:"to"`
Value big.Int `json:"value"`
}
// FourByteSignature contains data about about a contract function signature
type FourByteSignature struct {
// stored in DB
Name string
Parameters []string
// processed from DB data and stored only in cache
DecamelName string
Function string
ParsedParameters []abi.Type
}
// EthereumParsedInputParam contains data about a contract function parameter
type EthereumParsedInputParam struct {
Type string `json:"type"`
Values []string `json:"values,omitempty"`
}
// EthereumParsedInputData contains the parsed data for an input data hex payload
type EthereumParsedInputData struct {
MethodId string `json:"methodId"`
Name string `json:"name"`
Function string `json:"function,omitempty"`
Params []EthereumParsedInputParam `json:"params,omitempty"`
}
// EthereumInternalTransactionType - type of ethereum transaction from internal data
type EthereumInternalTransactionType int
// EthereumInternalTransactionType enumeration
const (
CALL = EthereumInternalTransactionType(iota)
CREATE
SELFDESTRUCT
)
// EthereumInternalTransaction contains internal transfers
type EthereumInternalData struct {
Type EthereumInternalTransactionType `json:"type"`
Contract string `json:"contract,omitempty"`
Transfers []EthereumInternalTransfer `json:"transfers,omitempty"`
Error string
}
// ContractInfo contains info about a contract
type ContractInfo struct {
Type TokenTypeName `json:"type"`
Contract string `json:"contract"`
Name string `json:"name"`
Symbol string `json:"symbol"`
Decimals int `json:"decimals"`
CreatedInBlock uint32 `json:"createdInBlock,omitempty"`
DestructedInBlock uint32 `json:"destructedInBlock,omitempty"`
}
// Ethereum token type names
const (
ERC20TokenType TokenTypeName = "ERC20"
ERC771TokenType TokenTypeName = "ERC721"
ERC1155TokenType TokenTypeName = "ERC1155"
)
// EthereumTokenTypeMap maps bchain.TokenType to TokenTypeName
// the map must match all bchain.TokenType to avoid index out of range panic
var EthereumTokenTypeMap = []TokenTypeName{ERC20TokenType, ERC771TokenType, ERC1155TokenType}
type MultiTokenValue struct {
Id big.Int
Value big.Int
}
// TokenTransfer contains a single token transfer
type TokenTransfer struct {
Type TokenType
Contract string
From string
To string
Value big.Int
MultiTokenValues []MultiTokenValue
}
// RpcTransaction is returned by eth_getTransactionByHash
type RpcTransaction struct {
AccountNonce string `json:"nonce"`
GasPrice string `json:"gasPrice"`
GasLimit string `json:"gas"`
To string `json:"to"` // nil means contract creation
Value string `json:"value"`
Payload string `json:"input"`
Hash string `json:"hash"`
BlockNumber string `json:"blockNumber"`
BlockHash string `json:"blockHash,omitempty"`
From string `json:"from"`
TransactionIndex string `json:"transactionIndex"`
// Signature values - ignored
// V string `json:"v"`
// R string `json:"r"`
// S string `json:"s"`
}
// RpcLog is returned by eth_getLogs
type RpcLog struct {
Address string `json:"address"`
Topics []string `json:"topics"`
Data string `json:"data"`
}
// RpcLog is returned by eth_getTransactionReceipt
type RpcReceipt struct {
GasUsed string `json:"gasUsed"`
Status string `json:"status"`
Logs []*RpcLog `json:"logs"`
}
// EthereumSpecificData contains data specific to Ethereum transactions
type EthereumSpecificData struct {
Tx *RpcTransaction `json:"tx"`
InternalData *EthereumInternalData `json:"internalData,omitempty"`
Receipt *RpcReceipt `json:"receipt,omitempty"`
}
// AddressAliasRecord maps address to ENS name
type AddressAliasRecord struct {
Address string
Name string
}
// EthereumBlockSpecificData contain data specific for Ethereum block
type EthereumBlockSpecificData struct {
InternalDataError string
AddressAliasRecords []AddressAliasRecord
Contracts []ContractInfo
}