hermez-node/db/historydb/views.go
db/historydb/views.goRaw
1package historydb
2
3import (
4 "math/big"
5 "time"
6
7 ethCommon "github.com/ethereum/go-ethereum/common"
8 "github.com/hermeznetwork/hermez-node/common"
9 "github.com/iden3/go-iden3-crypto/babyjub"
10)
11
12// HistoryTx is a representation of a generic Tx with additional information
13// required by the API, and extracted by joining block and token tables
14type HistoryTx struct {
15 // Generic
16 IsL1 bool `meddler:"is_l1"`
17 TxID common.TxID `meddler:"id"`
18 Type common.TxType `meddler:"type"`
19 Position int `meddler:"position"`
20 FromIdx common.Idx `meddler:"from_idx"`
21 ToIdx common.Idx `meddler:"to_idx"`
22 Amount *big.Int `meddler:"amount,bigint"`
23 AmountFloat float64 `meddler:"amount_f"`
24 HistoricUSD *float64 `meddler:"amount_usd"`
25 BatchNum *common.BatchNum `meddler:"batch_num"` // batchNum in which this tx was forged. If the tx is L2, this must be != 0
26 EthBlockNum int64 `meddler:"eth_block_num"` // Ethereum Block Number in which this L1Tx was added to the queue
27 // L1
28 ToForgeL1TxsNum int64 `meddler:"to_forge_l1_txs_num"` // toForgeL1TxsNum in which the tx was forged / will be forged
29 UserOrigin bool `meddler:"user_origin"` // true if the tx was originated by a user, false if it was aoriginated by a coordinator. Note that this differ from the spec for implementation simplification purpposes
30 FromEthAddr ethCommon.Address `meddler:"from_eth_addr"`
31 FromBJJ *babyjub.PublicKey `meddler:"from_bjj"`
32 LoadAmount *big.Int `meddler:"load_amount,bigintnull"`
33 LoadAmountFloat *float64 `meddler:"load_amount_f"`
34 HistoricLoadAmountUSD *float64 `meddler:"load_amount_usd"`
35 // L2
36 Fee *common.FeeSelector `meddler:"fee"`
37 HistoricFeeUSD *float64 `meddler:"fee_usd"`
38 Nonce *common.Nonce `meddler:"nonce"`
39 // API extras
40 Timestamp time.Time `meddler:"timestamp,utctime"`
41 TotalItems int `meddler:"total_items"`
42 TokenID common.TokenID `meddler:"token_id"`
43 TokenEthBlockNum int64 `meddler:"token_block"`
44 TokenEthAddr ethCommon.Address `meddler:"eth_addr"`
45 TokenName string `meddler:"name"`
46 TokenSymbol string `meddler:"symbol"`
47 TokenDecimals uint64 `meddler:"decimals"`
48 TokenUSD *float64 `meddler:"usd"`
49 TokenUSDUpdate *time.Time `meddler:"usd_update"`
50}