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 TokenID common.TokenID `meddler:"token_id"`
25 USD float64 `meddler:"amount_usd,zeroisnull"`
26 BatchNum common.BatchNum `meddler:"batch_num,zeroisnull"` // batchNum in which this tx was forged. If the tx is L2, this must be != 0
27 EthBlockNum int64 `meddler:"eth_block_num"` // Ethereum Block Number in which this L1Tx was added to the queue
28 // L1
29 ToForgeL1TxsNum int64 `meddler:"to_forge_l1_txs_num"` // toForgeL1TxsNum in which the tx was forged / will be forged
30 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
31 FromEthAddr ethCommon.Address `meddler:"from_eth_addr"`
32 FromBJJ *babyjub.PublicKey `meddler:"from_bjj"`
33 LoadAmount *big.Int `meddler:"load_amount,bigintnull"`
34 LoadAmountFloat float64 `meddler:"load_amount_f"`
35 LoadAmountUSD float64 `meddler:"load_amount_usd,zeroisnull"`
36 // L2
37 Fee common.FeeSelector `meddler:"fee,zeroisnull"`
38 FeeUSD float64 `meddler:"fee_usd,zeroisnull"`
39 Nonce common.Nonce `meddler:"nonce,zeroisnull"`
40 // API extras
41 Timestamp time.Time `meddler:"timestamp,utctime"`
42 TokenSymbol string `meddler:"symbol"`
43 CurrentUSD float64 `meddler:"current_usd"`
44 USDUpdate time.Time `meddler:"usd_update,utctime"`
45 TotalItems int `meddler:"total_items"`
46}