forked from coinbase/mesh-geth-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
185 lines (155 loc) · 5.9 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
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
// Copyright 2022 Coinbase, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package client
import (
"encoding/json"
"math/big"
"time"
"github.com/ethereum/go-ethereum/common/hexutil"
RosettaTypes "github.com/coinbase/rosetta-sdk-go/types"
EthTypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/common"
)
const (
gethHTTPTimeout = 120 * time.Second
maxTraceConcurrency = int64(16) // nolint:gomnd
semaphoreTraceWeight = int64(1) // nolint:gomnd
// ERC20 Standard Definition for the Transfer Event Logs Topics
Erc20TransferEventLogTopics = "Transfer(address,address,uint256)"
// While parsing ERC20 ops, we will ignore any event logs that we think are an ERC20 transfer
// that do not contain 3 topics and who's `data` field is not a single 32 byte hex string
// representing the amount of the transfer
NumTopicsERC20Transfer = 3
UnknownERC20Symbol = "ERC20_UNKNOWN"
UnknownERC20Decimals = 0
UnknownERC721Symbol = "ERC721_UNKNOWN"
UnknownERC721Decimals = 0
// eip1559TxType is the EthTypes.Transaction.Type() value that indicates this Transaction
// follows EIP-1559.
eip1559TxType = 2
ContractAddressMetadata = "contractAddress"
)
type ContractCurrency struct {
Symbol string `json:"symbol"`
Decimals int32 `json:"decimals"`
}
type RPCBlock struct {
Hash common.Hash `json:"hash"`
Transactions []RPCTransaction `json:"transactions"`
UncleHashes []common.Hash `json:"uncles"`
}
type TxExtraInfo struct {
BlockNumber *string `json:"blockNumber,omitempty"`
BlockHash *common.Hash `json:"blockHash,omitempty"`
From *common.Address `json:"from,omitempty"`
TxHash *common.Hash `json:"hash,omitempty"`
}
type Metadata struct {
Nonce uint64 `json:"nonce"`
GasPrice *big.Int `json:"gas_price"`
GasLimit uint64 `json:"gas_limit"`
ContractData string `json:"data,omitempty"`
MethodSignature string `json:"method_signature,omitempty"`
MethodArgs []string `json:"method_args,omitempty"`
}
type ParseMetadata struct {
Nonce uint64 `json:"nonce"`
GasPrice *big.Int `json:"gas_price"`
ChainID *big.Int `json:"chain_id"`
}
type Transaction struct {
From string `json:"from"`
To string `json:"to"`
Value *big.Int `json:"value"`
Data []byte `json:"data"`
// ContractData string `json:"contractData"`
Nonce uint64 `json:"nonce"`
GasPrice *big.Int `json:"gas_price"`
GasLimit uint64 `json:"gas"`
ChainID *big.Int `json:"chain_id"`
Currency *RosettaTypes.Currency `json:"currency,omitempty"`
}
type LoadedTransaction struct {
Transaction *EthTypes.Transaction
From *common.Address
BlockNumber *string
BlockHash *common.Hash
TxHash *common.Hash // may not equal Transaction.Hash() due to state sync indicator
FeeAmount *big.Int
FeeBurned *big.Int // nil if no fees were burned
Miner string
Author string
Status bool
Trace []*FlatCall
RawTrace json.RawMessage
Receipt *RosettaTxReceipt
BaseFee *big.Int
IsBridgedTxn bool
}
type SignedTransactionWrapper struct {
SignedTransaction []byte `json:"signed_tx"`
Currency *RosettaTypes.Currency `json:"currency,omitempty"`
}
// EthTypes.Transaction contains TxData, which is DynamicFeeTx:
// https://github.com/ethereum/go-ethereum/blob/980b7682b474db61ecbd78171e7cacfec8214048
// /core/types/dynamic_fee_tx.go#L25
type RPCTransaction struct {
Tx *EthTypes.Transaction
TxExtraInfo
}
type RosettaTxReceipt struct {
GasPrice *big.Int
GasUsed *big.Int
TransactionFee *big.Int
Logs []*EthTypes.Log
RawMessage json.RawMessage
}
type FeeSetResult struct {
L1Transaction *hexutil.Big `json:"l1Transaction"`
L1Calldata *hexutil.Big `json:"l1Calldata"`
L2Storage *hexutil.Big `json:"l2Storage"`
L2Computation *hexutil.Big `json:"l2Computation"`
}
type FeeStatsResult struct {
Prices *FeeSetResult `json:"prices"`
UnitsUsed *FeeSetResult `json:"unitsUsed"`
Paid *FeeSetResult `json:"paid"`
}
type L1InboxBatchInfo struct {
Confirmations *hexutil.Big `json:"confirmations"`
BlockNumber *hexutil.Big `json:"blockNumber"`
LogAddress common.Address `json:"logAddress"`
LogTopics []common.Hash `json:"logTopics"`
LogData hexutil.Bytes `json:"logData"`
}
type PayloadsResponse struct {
TransferData []byte
Address common.Address
Amount *big.Int
}
type Options struct {
From string `json:"from"`
To string `json:"to"`
TokenAddress string `json:"token_address,omitempty"`
ContractAddress string `json:"contract_address,omitempty"`
Value *big.Int `json:"value"`
SuggestedFeeMultiplier *float64 `json:"suggested_fee_multiplier,omitempty"`
GasPrice *big.Int `json:"gas_price,omitempty"`
GasLimit *big.Int `json:"gas_limit,omitempty"`
Nonce *big.Int `json:"nonce,omitempty"`
Currency *RosettaTypes.Currency `json:"currency,omitempty"`
MethodSignature string `json:"method_signature,omitempty"`
MethodArgs []string `json:"method_args,omitempty"`
ContractData string `json:"data,omitempty"`
}