You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
2.5 KiB

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